Functionality

Deposit

The deposit() function allows users to restake a supported asset on EigenLayer.

Users are allowed to deposit a supported asset to the corresponding vault in any amount that is greater than minAmount.

Copy

function deposit(uint256 amount, address receiver) public returns (uint256);

// returns the min deposit amount (100 wei in the current version)
function minAmount() public returns(uint256);

Before sending a deposit transaction, ensure that the vault has sufficient allowances for spending your assets (utilizing the transferFrom() function). A successful deposit transaction results in minting an appropriate amount of the corresponding LRT and a Deposit event:

Copy

event Deposit(
      address indexed sender,
      address indexed receiver,
      uint256 amount,
      uint256 iShares
);

To determine the minted amount of LRT, use the following formula (amount – deposited amount of LST):

Copy

const mintedAmount = amount * ratio / 1e18;

Code Sample

Let’s say the user wants to restake and decided on a specific amount of the LST and receiverAddress that will be issued the mintedAmount of LRT.

Copy

await iVault.connect(staker).deposit(amount, receiverAddress);

Workflow

  1. User deposits into InceptionVault.

  2. Vault deposits the user amount directly to EigenLayer via strategyManager::delegateIntoStrategy().

  3. InceptionVault mints a corresponding amount of the LRT (instETH or inrETH respectively) for the user’s wallet.

See the example transaction on Ethereum Mainnet.

Withdraw

The withdraw() function allows users to unstake from the corresponding vault on EigenLayer, burning the user LRTs to get back the original asset.

During the withdrawal process, the corresponding vault instance stores the pending withdrawal amounts. Let us make the withdrawal process grandma-clear. It may be divided into the following steps:

  1. The vault burns the input amount of an appropriate LRT at the user’s address (no approval needed).

  2. The vault updates the global pending withdrawal state and the user’s pending withdrawal state with the corresponding receiverAddress and asset amount. The amount will be received to the receiverAddress upon the redeeming process.

  3. The vault emits a withdrawal event with the pending amount:

    Copy

    event Withdraw(
          address indexed sender,
          address indexed receiver,
          address indexed owner,
          uint256 amount,
          uint256 iShares
    );

    In order to get the pending withdraw amount use the following function in iVault:

    Copy

    function withdraw(uint256 iShares, address receiver) external;
    
    /// returns the amount of assets to be claimed and the receiver
    function getPendingWithdrawalOf(address claimer) public view returns (uint256, address)

See the example transaction on Ethereum Mainnet.

Redeem

The redeem() functions is applied at the final step, in which the user receives the pending asset amount that becomes available after the next rebalancing procedure.

Workflow

  1. The user (anyone) calls iVault::redeem() with a proper receiverAddress (that persists in the global state).

  2. The Inception vault calls iVault::isAbleToRedeem() to ensure that the user is able to claim at least one pending withdrawal.

    Copy

    // returns whether the user is able to redeem their assets (true/false)
    // returns an array of index positions of the withdrawal queue (claimerWithdrawalsQueue)
    function isAbleToRedeem(address receiverAddress) public view returns (bool able, uint256[] memory);
  3. If able to redeem, the vault adds up all the available corresponding withdrawals, transfers the resulting amount to receiverAddress, and updates the global withdrawal state.

See the example transaction on Ethereum Mainnet.

Flash Unstake

FlashWithdrawal feature.

It generally allows users to withdraw their underlying assets from a vault immediately by paying an extra fee.

The following functions facilitate the process:

  • flashWithdraw()

  • calculateFlashWithdrawFee()

  • flashWithdrawCapacity()

The FlashWithdrawal feature is available only when the flashPool capacity is sufficient. In particular, if a user wants to withdraw sharesToWithdraw shares of a corresponding Inception token, they should ensure that the flashWithdrawCapacity() is greater than or equal to the amount. Then, they should calculate the flash withdrawal fee that will be charged for processing the flash withdrawal. The resulting amount that the user will receive can be calculated as:

expectAmount = vault.convertToAssets(sharesToWithdraw)

receiveAmount = expectAmount - vault.calculateFlashWithdrawFee(expectAmount)

Known Issues

  • On each transfer, stEth loses 1–2 wei.

Last updated