Skip to content

Commit

Permalink
Merge pull request #16 from kilnfi/feat/restaking
Browse files Browse the repository at this point in the history
Add Liquid Restaking flows
  • Loading branch information
apaillier-ledger authored Feb 7, 2024
2 parents 0cfd3ab + ca391d9 commit 49f35d5
Show file tree
Hide file tree
Showing 91 changed files with 1,026 additions and 30 deletions.
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ SortIncludes: false
SpaceAfterCStyleCast: true
AllowShortCaseLabelsOnASingleLine: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: None
BinPackArguments: false
Expand Down
58 changes: 41 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,33 @@ The flow processed in [GitHub Actions](https://github.com/features/actions) is t

![](/tests/snapshots/nanos_requestValidatorsExit/00000.png) ![](/tests/snapshots/nanos_requestValidatorsExit/00001.png) ![](/tests/snapshots/nanos_requestValidatorsExit/00002.png) ![](/tests/snapshots/nanos_requestValidatorsExit/00003.png) ![](/tests/snapshots/nanos_requestValidatorsExit/00004.png) ![](/tests/snapshots/nanos_requestValidatorsExit/00005.png)

## Stake v2
### Stake v2

![](/tests/snapshots/nanos_stakeV2/00000.png) ![](/tests/snapshots/nanos_stakeV2/00001.png) ![](/tests/snapshots/nanos_stakeV2/00002.png) ![](/tests/snapshots/nanos_stakeV2/00003.png) ![](/tests/snapshots/nanos_stakeV2/00004.png) ![](/tests/snapshots/nanos_stakeV2/00005.png)
![](/tests/snapshots/nanos_stakev2/00000.png) ![](/tests/snapshots/nanos_stakev2/00001.png) ![](/tests/snapshots/nanos_stakev2/00002.png) ![](/tests/snapshots/nanos_stakev2/00003.png) ![](/tests/snapshots/nanos_stakev2/00004.png) ![](/tests/snapshots/nanos_stakev2/00005.png)

## RequestExit v2
### RequestExit V2

![](/tests/snapshots/nanos_requestExitV2/00000.png) ![](/tests/snapshots/nanos_requestExitV2/00001.png) ![](/tests/snapshots/nanos_requestExitV2/00002.png) ![](/tests/snapshots/nanos_requestExitV2/00003.png) ![](/tests/snapshots/nanos_requestExitV2/00004.png) ![](/tests/snapshots/nanos_requestExitV2/00005.png)
![](/tests/snapshots/nanos_requestExitv2/00000.png) ![](/tests/snapshots/nanos_requestExitv2/00001.png) ![](/tests/snapshots/nanos_requestExitv2/00002.png) ![](/tests/snapshots/nanos_requestExitv2/00003.png) ![](/tests/snapshots/nanos_requestExitv2/00004.png) ![](/tests/snapshots/nanos_requestExitv2/00005.png)

## MultiClaim v2
### MultiClaim V2

![](/tests/snapshots/nanos_multiClaimV2/00000.png) ![](/tests/snapshots/nanos_multiClaimV2/00001.png) ![](/tests/snapshots/nanos_multiClaimV2/00002.png) ![](/tests/snapshots/nanos_multiClaimV2/00003.png) ![](/tests/snapshots/nanos_multiClaimV2/00004.png) ![](/tests/snapshots/nanos_multiClaimV2/00005.png)
![](/tests/snapshots/nanos_multiClaimv2/00000.png) ![](/tests/snapshots/nanos_multiClaimv2/00001.png) ![](/tests/snapshots/nanos_multiClaimv2/00002.png) ![](/tests/snapshots/nanos_multiClaimv2/00003.png) ![](/tests/snapshots/nanos_multiClaimv2/00004.png) ![](/tests/snapshots/nanos_multiClaimv2/00005.png)

## Claim v2
### Claim V2

![](/tests/snapshots/nanos_claimV2/00000.png) ![](/tests/snapshots/nanos_claimV2/00001.png) ![](/tests/snapshots/nanos_claimV2/00002.png) ![](/tests/snapshots/nanos_claimV2/00003.png) ![](/tests/snapshots/nanos_claimV2/00004.png) ![](/tests/snapshots/nanos_claimV2/00005.png)
![](/tests/snapshots/nanos_claimv2/00000.png) ![](/tests/snapshots/nanos_claimv2/00001.png) ![](/tests/snapshots/nanos_claimv2/00002.png) ![](/tests/snapshots/nanos_claimv2/00003.png) ![](/tests/snapshots/nanos_claimv2/00004.png) ![](/tests/snapshots/nanos_claimv2/00005.png)

### LR Deposit Into Strategy

![](/tests/snapshots/nanos_lrDepositIntoStrategyNormal/00000.png) ![](/tests/snapshots/nanos_lrDepositIntoStrategyNormal/00001.png) ![](/tests/snapshots/nanos_lrDepositIntoStrategyNormal/00002.png) ![](/tests/snapshots/nanos_lrDepositIntoStrategyNormal/00003.png) ![](/tests/snapshots/nanos_lrDepositIntoStrategyNormal/00004.png) ![](/tests/snapshots/nanos_lrDepositIntoStrategyNormal/00005.png) ![](/tests/snapshots/nanos_lrDepositIntoStrategyNormal/00006.png) ![](/tests/snapshots/nanos_lrDepositIntoStrategyNormal/00007.png)

### LR Queue Withdrawal

![](/tests/snapshots/nanos_lrQueueWithdrawal/00000.png) ![](/tests/snapshots/nanos_lrQueueWithdrawal/00001.png) ![](/tests/snapshots/nanos_lrQueueWithdrawal/00002.png) ![](/tests/snapshots/nanos_lrQueueWithdrawal/00003.png) ![](/tests/snapshots/nanos_lrQueueWithdrawal/00004.png) ![](/tests/snapshots/nanos_lrQueueWithdrawal/00005.png) ![](/tests/snapshots/nanos_lrQueueWithdrawal/00006.png) ![](/tests/snapshots/nanos_lrQueueWithdrawal/00007.png)

### LR Complete Queued Withdrawal

![](/tests/snapshots/nanos_lrCompleteQueuedWithdrawal/00000.png) ![](/tests/snapshots/nanos_lrCompleteQueuedWithdrawal/00001.png) ![](/tests/snapshots/nanos_lrCompleteQueuedWithdrawal/00002.png) ![](/tests/snapshots/nanos_lrCompleteQueuedWithdrawal/00003.png) ![](/tests/snapshots/nanos_lrCompleteQueuedWithdrawal/00004.png) ![](/tests/snapshots/nanos_lrCompleteQueuedWithdrawal/00005.png)

## NANO X

Expand Down Expand Up @@ -154,22 +166,34 @@ The flow processed in [GitHub Actions](https://github.com/features/actions) is t

![](/tests/snapshots/nanox_batchWithdrawCL/00000.png) ![](/tests/snapshots/nanox_batchWithdrawCL/00001.png) ![](/tests/snapshots/nanox_batchWithdrawCL/00002.png) ![](/tests/snapshots/nanox_batchWithdrawCL/00003.png) ![](/tests/snapshots/nanox_batchWithdrawCL/00004.png) ![](/tests/snapshots/nanox_batchWithdrawCL/00005.png)

## Request Exits
### Request Exits

![](/tests/snapshots/nanox_requestValidatorsExit/00000.png) ![](/tests/snapshots/nanox_requestValidatorsExit/00001.png) ![](/tests/snapshots/nanox_requestValidatorsExit/00002.png) ![](/tests/snapshots/nanox_requestValidatorsExit/00003.png) ![](/tests/snapshots/nanox_requestValidatorsExit/00004.png) ![](/tests/snapshots/nanox_requestValidatorsExit/00005.png)

## Stake V2
### Stake V2

![](/tests/snapshots/nanox_stakev2/00000.png) ![](/tests/snapshots/nanox_stakev2/00001.png) ![](/tests/snapshots/nanox_stakev2/00002.png) ![](/tests/snapshots/nanox_stakev2/00003.png) ![](/tests/snapshots/nanox_stakev2/00004.png) ![](/tests/snapshots/nanox_stakev2/00005.png)

### RequestExit V2

![](/tests/snapshots/nanox_requestExitv2/00000.png) ![](/tests/snapshots/nanox_requestExitv2/00001.png) ![](/tests/snapshots/nanox_requestExitv2/00002.png) ![](/tests/snapshots/nanox_requestExitv2/00003.png) ![](/tests/snapshots/nanox_requestExitv2/00004.png) ![](/tests/snapshots/nanox_requestExitv2/00005.png)

### MultiClaim V2

![](/tests/snapshots/nanox_multiClaimv2/00000.png) ![](/tests/snapshots/nanox_multiClaimv2/00001.png) ![](/tests/snapshots/nanox_multiClaimv2/00002.png) ![](/tests/snapshots/nanox_multiClaimv2/00003.png) ![](/tests/snapshots/nanox_multiClaimv2/00004.png) ![](/tests/snapshots/nanox_multiClaimv2/00005.png)

### Claim V2

![](/tests/snapshots/nanox_stakeV2/00000.png) ![](/tests/snapshots/nanox_stakeV2/00001.png) ![](/tests/snapshots/nanox_stakeV2/00002.png) ![](/tests/snapshots/nanox_stakeV2/00003.png) ![](/tests/snapshots/nanox_stakeV2/00004.png) ![](/tests/snapshots/nanox_stakeV2/00005.png)
![](/tests/snapshots/nanox_claimv2/00000.png) ![](/tests/snapshots/nanox_claimv2/00001.png) ![](/tests/snapshots/nanox_claimv2/00002.png) ![](/tests/snapshots/nanox_claimv2/00003.png) ![](/tests/snapshots/nanox_claimv2/00004.png) ![](/tests/snapshots/nanox_claimv2/00005.png)

## RequestExit V2
### LR Deposit Into Strategy

![](/tests/snapshots/nanox_requestExitV2/00000.png) ![](/tests/snapshots/nanox_requestExitV2/00001.png) ![](/tests/snapshots/nanox_requestExitV2/00002.png) ![](/tests/snapshots/nanox_requestExitV2/00003.png) ![](/tests/snapshots/nanox_requestExitV2/00004.png) ![](/tests/snapshots/nanox_requestExitV2/00005.png)
![](/tests/snapshots/nanox_lrDepositIntoStrategyNormal/00000.png) ![](/tests/snapshots/nanox_lrDepositIntoStrategyNormal/00001.png) ![](/tests/snapshots/nanox_lrDepositIntoStrategyNormal/00002.png) ![](/tests/snapshots/nanox_lrDepositIntoStrategyNormal/00003.png) ![](/tests/snapshots/nanox_lrDepositIntoStrategyNormal/00004.png) ![](/tests/snapshots/nanox_lrDepositIntoStrategyNormal/00005.png)

## MultiClaim V2
### LR Queue Withdrawal

![](/tests/snapshots/nanox_multiClaimV2/00000.png) ![](/tests/snapshots/nanox_multiClaimV2/00001.png) ![](/tests/snapshots/nanox_multiClaimV2/00002.png) ![](/tests/snapshots/nanox_multiClaimV2/00003.png) ![](/tests/snapshots/nanox_multiClaimV2/00004.png) ![](/tests/snapshots/nanox_multiClaimV2/00005.png)
![](/tests/snapshots/nanox_lrQueueWithdrawal/00000.png) ![](/tests/snapshots/nanox_lrQueueWithdrawal/00001.png) ![](/tests/snapshots/nanox_lrQueueWithdrawal/00002.png) ![](/tests/snapshots/nanox_lrQueueWithdrawal/00003.png) ![](/tests/snapshots/nanox_lrQueueWithdrawal/00004.png) ![](/tests/snapshots/nanox_lrQueueWithdrawal/00005.png) ![](/tests/snapshots/nanox_lrQueueWithdrawal/00006.png)

## Claim V2
### LR Complete Queued Withdrawal

![](/tests/snapshots/nanox_claimV2/00000.png) ![](/tests/snapshots/nanox_claimV2/00001.png) ![](/tests/snapshots/nanox_claimV2/00002.png) ![](/tests/snapshots/nanox_claimV2/00003.png) ![](/tests/snapshots/nanox_claimV2/00004.png) ![](/tests/snapshots/nanox_claimV2/00005.png)
![](/tests/snapshots/nanox_lrCompleteQueuedWithdrawal/00000.png) ![](/tests/snapshots/nanox_lrCompleteQueuedWithdrawal/00001.png) ![](/tests/snapshots/nanox_lrCompleteQueuedWithdrawal/00002.png) ![](/tests/snapshots/nanox_lrCompleteQueuedWithdrawal/00003.png) ![](/tests/snapshots/nanox_lrCompleteQueuedWithdrawal/00004.png) ![](/tests/snapshots/nanox_lrCompleteQueuedWithdrawal/00005.png)
7 changes: 7 additions & 0 deletions ledger_app.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[app]
build_directory = "./"
sdk = "C"
devices = ["nanos", "nanox", "nanos+"]

[tests]
pytest_directory = "./tests/"
57 changes: 55 additions & 2 deletions src/contract.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "kiln_plugin.h"

// V1 - Solo Staking
// ONCHAIN V1 - Solo Staking
// --- cast sig "deposit()"
static const uint32_t KILN_V1_DEPOSIT_SELECTOR = 0xd0e30db0;
// --- cast sig "withdraw(bytes)"
Expand All @@ -18,7 +18,7 @@ static const uint32_t KILN_V1_BATCH_WITHDRAW_CL_SELECTOR = 0x0ffab6c2;
// --- cast sig "requestValidatorsExit(bytes)"
static const uint32_t KILN_V1_REQUEST_EXIT_SELECTOR = 0xb6b06dec;

// V2 - Pooled Staking
// ONCHAIN V2 - Pooled Staking
// --- cast sig "stake()"
static const uint32_t KILN_V2_STAKE_SELECTOR = 0x3a4b66f1;
// --- cast sig "requestExit(uint256)"
Expand All @@ -28,6 +28,15 @@ static const uint32_t KILN_V2_MULTICLAIM_SELECTOR = 0xb7ba18c7;
// --- cast sig "claim(uint256[],uint32[],uint16)"
static const uint32_t KILN_V2_CLAIM_SELECTOR = 0xadcf1163;

// RESTAKING - Liquid Restaking
// --- cast sig "depositIntoStrategy(address,address,uint256)"
static const uint32_t KILN_LR_DEPOSIT_INTO_STRATEGY_SELECTOR = 0xe7a050aa;
// --- cast sig "queueWithdrawal(uint256[],address[],uint256[],address,bool)"
static const uint32_t KILN_LR_QUEUE_WITHDRAWAL_SELECTOR = 0xf123991e;
// --- cast sig
// "completeQueuedWithdrawal((address[],uint256[],address,(address,uint96),uint32,address),address[],uint256,bool)"
static const uint32_t KILN_LR_COMPLETE_QUEUED_WITHDRAWAL_SELECTOR = 0xf3be65d3;

const uint32_t KILN_SELECTORS[NUM_SELECTORS] = {
// V1
KILN_V1_DEPOSIT_SELECTOR,
Expand All @@ -43,4 +52,48 @@ const uint32_t KILN_SELECTORS[NUM_SELECTORS] = {
KILN_V2_REQUEST_EXIT_SELECTOR,
KILN_V2_MULTICLAIM_SELECTOR,
KILN_V2_CLAIM_SELECTOR,
// LR
KILN_LR_DEPOSIT_INTO_STRATEGY_SELECTOR,
KILN_LR_QUEUE_WITHDRAWAL_SELECTOR,
KILN_LR_COMPLETE_QUEUED_WITHDRAWAL_SELECTOR,
};

const char lr_strategy_addresses[LR_STRATEGIES_COUNT][ADDRESS_STR_LEN] = {
"0x54945180dB7943c0ed0FEE7EdaB2Bd24620256bc", // cbETH
"0x93c4b944D05dfe6df7645A86cd2206016c51564D", // stETH
"0x1BeE69b7dFFfA4E2d53C2a2Df135C388AD25dCD2", // rETH
"0x9d7eD45EE2E8FC5482fa2428f15C971e6369011d", // ETHx
"0x13760F50a9d7377e4F20CB8CF9e4c26586c658ff", // ankrETH
"0xa4C637e0F704745D182e4D38cAb7E7485321d059", // OETH
"0x57ba429517c3473B6d34CA9aCd56c0e735b94c02", // osETH
"0x0Fe4F44beE93503346A3Ac9EE5A26b130a5796d6", // swETH
"0x7CA911E83dabf90C90dD3De5411a10F1A6112184", // wBETH
"0x8CA7A5d6f3acd3A7A8bC468a8CD0FB14B6BD28b6", // sfrxETH
"0x298aFB19A105D59E74658C4C334Ff360BadE6dd2" // mETH
};

const char lr_erc20_addresses[LR_STRATEGIES_COUNT][ADDRESS_STR_LEN] = {
"0xBe9895146f7AF43049ca1c1AE358B0541Ea49704", // cbETH
"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", // stETH
"0xae78736Cd615f374D3085123A210448E74Fc6393", // rETH
"0xA35b1B31Ce002FBF2058D22F30f95D405200A15b", // ETHx
"0xE95A203B1a91a908F9B9CE46459d101078c2c3cb", // ankrETH
"0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3", // OETH
"0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38", // osETH
"0xf951E335afb289353dc249e82926178EaC7DEd78", // swETH
"0xa2E3356610840701BDf5611a53974510Ae27E2e1", // wBETH
"0xac3E018457B222d93114458476f3E3416Abbe38F", // sfrxETH
"0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa", // mETH
};

const char lr_tickers[LR_STRATEGIES_COUNT][MAX_TICKER_LEN] = {"cbETH",
"stETH",
"rETH",
"ETHx",
"ankrETH",
"OETH",
"osETH",
"swETH",
"wBETH",
"sfrxETH",
"mETH"};
12 changes: 12 additions & 0 deletions src/handle_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ void handle_finalize(ethPluginFinalize_t *msg) {
msg->numScreens = 1;
msg->result = ETH_PLUGIN_RESULT_OK;
break;
case KILN_LR_DEPOSIT_INTO_STRATEGY:
msg->numScreens = 3;
msg->result = ETH_PLUGIN_RESULT_OK;
break;
case KILN_LR_QUEUE_WITHDRAWAL:
msg->numScreens = 2;
msg->result = ETH_PLUGIN_RESULT_OK;
break;
case KILN_LR_COMPLETE_QUEUED_WITHDRAWAL:
msg->numScreens = 1;
msg->result = ETH_PLUGIN_RESULT_OK;
break;
default:
PRINTF("Selector Index not supported: %d\n", context->selectorIndex);
msg->result = ETH_PLUGIN_RESULT_ERROR;
Expand Down
11 changes: 10 additions & 1 deletion src/handle_init_contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ void handle_init_contract(ethPluginInitContract_t *msg) {
case KILN_V1_WITHDRAW:
case KILN_V1_WITHDRAW_EL:
case KILN_V1_WITHDRAW_CL:
context->next_param = WITHDRAW_VALIDATION_OFFSET;
break;

case KILN_V1_BATCH_WITHDRAW:
Expand All @@ -58,6 +57,16 @@ void handle_init_contract(ethPluginInitContract_t *msg) {
case KILN_V2_CLAIM:
break;

case KILN_LR_DEPOSIT_INTO_STRATEGY:
context->next_param = LR_DEPOSIT_INTO_STRATEGY_STRATEGY;
break;
case KILN_LR_QUEUE_WITHDRAWAL:
context->next_param = LR_QUEUE_WITHDRAWAL_STRATEGY_INDEXES_OFFSET;
break;
case KILN_LR_COMPLETE_QUEUED_WITHDRAWAL:
context->next_param = LR_COMPLETE_QUEUED_WITHDRAWAL_QUEUEDWITHDRAWAL_OFFSET;
break;

default:
PRINTF("Missing selectorIndex: %d\n", context->selectorIndex);
msg->result = ETH_PLUGIN_RESULT_ERROR;
Expand Down
Loading

0 comments on commit 49f35d5

Please sign in to comment.