Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Liquid Restaking flows #16

Merged
merged 26 commits into from
Feb 7, 2024
Merged

Conversation

loicttn
Copy link

@loicttn loicttn commented Feb 2, 2024

In order to support Eigenlayer Restaking flows, 3 functions of the EigenLayer StrategyManager contract have been added to the Kiln plugin (see detail below).

Interactions

Eigenlayer liquid restaking means you deposit ERC20 in Eigenlayer Strategy contracts (stETH to stETH strategy, cbETH to cbETH strategy...) through a contract called StrategyManager. You then have a shares amount in each strategy contract which is different from your ERC20 amounts in some cases (to manage ctokens and atokens on the contract side).
we have 3 functions for the flow we want to clear sign:

  1. depositIntoStrategy
depositIntoStrategy
function depositIntoStrategy(
  IStrategy strategy,    // -> clearsigned
  IERC20 token,          // -> clearsigned
  uint256 amount         // -> clearsigned
)
  1. queueWithdrawal - to initiate withdraw of part / all a position
function queueWithdrawal(
  uint256[] strategyIndexes,
  address[] strategies,
  uint256[] shares,
  address withdrawer,        // -> clearsigned
  bool undelegateIfPossible
)

we think the 3 first parameters are not relevant to clearsign as they showcase share amount, which would confuse the users as everything is expressed in ERC20 in the dapp for simplicity (like what we did with the ETH pooling flow). We could only showcase the strategies user interact with, but without the erc20 amounts it feels unrelevant.

withdrawer clearsigning has been added as it is an attack vector, as any address can be put there to claim the withdrawal once it is complete.

undelegateIfPossible is a cleanup feature in the case a user withdraw everything, which we always set to true like the eigenlayer dapp. Doing it or not does not change anything for the user position, and this will be removed in future eigenlayer versions, so we think there is no need to clearsign it.

  1. completeQueuedWithdrawals
struct WithdrawerAndNonce {
    address withdrawer;
    uint96 nonce;
}

struct QueuedWithdrawal {
    IStrategy[] strategies;
    uint256[] shares;
    address depositor;
    WithdrawerAndNonce withdrawerAndNonce;
    uint32 withdrawalStartBlock;
    address delegatedAddress;
}

function completeQueuedWithdrawal(
  QueuedWithdrawal calldata queuedWithdrawal,
  IERC20[] calldata tokens, 
  uint256 middlewareTimesIndex,
  bool receiveAsTokens
)

This functions takes a lot of pre-computed data for the smart contract to recompute the withdrawal position and complete it. Most of this data is not relevant to the user (like middlewareTimesIndex, withdrawalstartblocks etc)

Same issue as above, we could clear sign the shares amount but it does not seem relevant as it will confuse the user.
The msg.sender must be the withdrawer and the withdrawer must be the withdrawer set during the queueWithdrawal, so no need to clearsign it either.

Preview

image

@loicttn loicttn changed the title Add Liquid Restaking flows WIP: Add Liquid Restaking flows Feb 2, 2024
@loicttn loicttn changed the title WIP: Add Liquid Restaking flows Add Liquid Restaking flows Feb 2, 2024
@apaillier-ledger
Copy link

Don't forget to bump the version next time 👍

@apaillier-ledger apaillier-ledger merged commit 49f35d5 into LedgerHQ:develop Feb 7, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants