LagoonFlowManager

Documentation for eth_defi.lagoon.vault.LagoonFlowManager Python class.

class LagoonFlowManager[source]

Manage deposit/redemption queue for Lagoon.

  • Lagoon uses ERC-7540 Asynchronous ERC-4626 Tokenized Vaults for deposits and redemptions flow

On the Lagoon flow:

Ok so for settlement you dont have to worry about this metric, the only thing you have to value is the assets inside the safe (what you currently have under management) and update the NAV of the vault by calling updateNewTotalAssets (ex: if you have 1M inside the vault and 500K pending deposit you only need to call updateTotalAssets with the 1M that are currently inside the safe). Then, to settle you just call settleDeposit and the vault calculate everything for you.

To monitor the pending deposits it’s a bit more complicated. You have to check the balanceOf the pendingSilo contract (0xAD1241Ba37ab07fFc5d38e006747F8b92BB217D5) in term of underlying (here USDC) for pending deposit and in term of shares (so the vault itself) for pending withdraw requests

Methods summary

__init__(vault)

calculate_underlying_neeeded_for_redemptions(...)

How much underlying token (USDC) we are going to need on the next redemption cycle.

fetch_pending_deposit(block_identifier)

Get how much users want to redeem from the vault.

fetch_pending_deposit_events(range)

Read incoming pending deposits.

fetch_pending_redemption(block_identifier)

Get how much users want to redeem from the vault.

fetch_pending_redemption_event(range)

Read outgoing pending withdraws.

fetch_processed_deposit_event(range)

Read incoming pending deposits.

fetch_processed_redemption_event(vault, range)

Read outgoing pending withdraws.

__init__(vault)[source]
Parameters

vault (eth_defi.lagoon.vault.LagoonVault) –

Return type

None

fetch_pending_redemption(block_identifier)[source]

Get how much users want to redeem from the vault.

Parameters

block_identifier (Union[Literal['latest', 'earliest', 'pending', 'safe', 'finalized'], eth_typing.evm.BlockNumber, eth_typing.evm.Hash32, eth_typing.encoding.HexStr, int]) – Block number

Returns

Number of share tokens the users want to redeem from the vault.

Shares must be valued separately.

Return type

decimal.Decimal

fetch_pending_deposit(block_identifier)[source]

Get how much users want to redeem from the vault.

Parameters

block_identifier (Union[Literal['latest', 'earliest', 'pending', 'safe', 'finalized'], eth_typing.evm.BlockNumber, eth_typing.evm.Hash32, eth_typing.encoding.HexStr, int]) – Block number

Returns

Number of underlying tokens the users want to redeem from the vault.

Return type

decimal.Decimal

fetch_pending_deposit_events(range)[source]

Read incoming pending deposits.

Parameters

range (Tuple[eth_typing.evm.BlockNumber, eth_typing.evm.BlockNumber]) –

Return type

None

fetch_pending_redemption_event(range)[source]

Read outgoing pending withdraws.

Parameters

range (Tuple[eth_typing.evm.BlockNumber, eth_typing.evm.BlockNumber]) –

Return type

None

fetch_processed_deposit_event(range)[source]

Read incoming pending deposits.

Parameters

range (Tuple[eth_typing.evm.BlockNumber, eth_typing.evm.BlockNumber]) –

Return type

None

fetch_processed_redemption_event(vault, range)[source]

Read outgoing pending withdraws.

Parameters
Return type

None

calculate_underlying_neeeded_for_redemptions(block_identifier)[source]

How much underlying token (USDC) we are going to need on the next redemption cycle.

Returns

Raw token amount

Parameters

block_identifier (Union[Literal['latest', 'earliest', 'pending', 'safe', 'finalized'], eth_typing.evm.BlockNumber, eth_typing.evm.Hash32, eth_typing.encoding.HexStr, int]) –

Return type

decimal.Decimal