erc_4626.vault_protocol.lagoon.analysis

Documentation for eth_defi.erc_4626.vault_protocol.lagoon.analysis Python module.

Analyse Lagoon protocol deposits and redemptions.

Functions

analyse_vault_flow_in_settlement(vault, tx_hash)

Extract deposit and redeem events from a settlement transaction.

Classes

LagoonSettlementEvent

Capture Lagoon vault flow when it is settled.

class LagoonSettlementEvent

Bases: object

Capture Lagoon vault flow when it is settled.

  • Use to adjust vault treasury balances for internal accounting

  • Shows the Lagoon vault status after the settlement at a certain block height

  • We do not capture individual users

The cycle is - Value vault - Settle deposits (USD in) and redeemds (USDC out, shares in) - Because valuation is done before the settle, you need to be careful what the values reflect here - We pull some values from receipt, some values at the end of the block

chain_id: int

Chain we checked

tx_hash: hexbytes.main.HexBytes

settleDeposit() transaction by the asset managre

block_number: int

When the settlement was done

timestamp: datetime.datetime

When the settlement was done

vault: eth_defi.erc_4626.vault_protocol.lagoon.vault.LagoonVault

Vault address

deposit_events: int

Number of deposit event processed (0..1)

redeem_events: int

Number of deposit event processed (0..1)

deposited: decimal.Decimal

How much new underlying was added to the vault

redeemed: decimal.Decimal

How much was redeemed successfully

shares_minted: decimal.Decimal

Shares added for new investor

shares_burned: decimal.Decimal

Shares burned for redemptions

total_assets: decimal.Decimal

Vault latest settled valuation.

This does not include the newly settled deposits, as they were not part of the previous share valuation cycle.

total_supply: decimal.Decimal

Outstanding shares.

Vault latest issued share count

share_price: decimal.Decimal

Share price in the underlying token, after the settlement

pending_redemptions_underlying: decimal.Decimal

Amount of redemptions we could not settle (USD), because the lack of cash in the previous cycle.

This much of cash needs to be made available for the next settlement cycle.

pending_redemptions_shares: decimal.Decimal

Amount of redemptions we could not settle (share count), because the lack of cash in the previous cycle.

underlying_balance: decimal.Decimal

Balance of the underlying token (treasuty/reserve) at the end of the block

property underlying: eth_defi.token.TokenDetails

Get USDC.

property share_token: eth_defi.token.TokenDetails

Get USDC.

get_serialiable_diagnostics_data()

JSON serialisable diagnostics data for logging

Return type

dict

get_underlying_diff()

How much the underlying asset changed in the vault treasury

Return type

decimal.Decimal

get_underlying_balance()

How much of treasury we are holding after this update

Return type

decimal.Decimal

__init__(chain_id, tx_hash, block_number, timestamp, vault, deposit_events, redeem_events, deposited, redeemed, shares_minted, shares_burned, total_assets, total_supply, share_price, pending_redemptions_underlying, pending_redemptions_shares, underlying_balance)
Parameters
Return type

None

analyse_vault_flow_in_settlement(vault, tx_hash)

Extract deposit and redeem events from a settlement transaction.

  • Analyse vault asset flow based on the settlement tx logs in the receipt

  • May need to call vault contract if no deposist or redeem events were prevent. This needs an archive node for historical lookback.

  • Gnosis Safe error list.

Raises

AssertionError – If the Lagoon settlement transaction reverted.

Parameters
Return type

eth_defi.erc_4626.vault_protocol.lagoon.analysis.LagoonSettlementEvent