VaultBase

Documentation for eth_defi.vault.base.VaultBase Python class.

class VaultBase[source]

Base class for vault protocol adapters.

  • Allows automated interaction with different vault protocols.

  • Contains various abstract methods that the implementation class must override

Supported protocols include

Code exists, but does not confirm the interface yet:

Vault covered functionality

  • Fetching the current balances, deposits or redemptions

  • Get vault information with fetch_info()
    • No standardised data structures or functions yet

  • Build a swap through a vault
    • No standardised data structure yet

  • Update vault position valuations
    • No standardised data structure yet

Integration check list

Integration tests needed for:

  • ☑️ read vault core info

  • ☑️ read vault investors

  • ☑️ read vault share price

  • ☑️ read vault share token

  • ☑️ read all positions

  • ☑️ read NAV

  • ☑️ read pending redemptions to know how much USDC we will need for the next settlement cycles

  • ☑️ deposit integration test

  • ☑️ redemption integration

  • ☑️ swap integration test

  • ☑️ re-valuation integration test

  • ☑️ only asset manager allowed to swap negative test

  • ☑️ only valuation commitee allowed to update vault valuations (if applicable)

  • ☑️ can redeem if enough USDC to settle

  • ☑️ cannot redeem not enough USDC to settle

For code examples see tests/lagoon and tests/velvet on the Github repository.

Attributes summary

address

Vault contract address.

chain_id

Chain this vault is on

denomination_token

Get the token which denominates the vault valuation

info

Get info dictionary related to this vault deployment.

name

Vault name.

share_token

ERC-20 that presents vault shares.

symbol

Vault share token symbol

first_seen_at_block

Block number hint when this vault was deployed.

Methods summary

__init__([token_cache])

param token_cache

fetch_denomination_token()

Read denomination token from onchain.

fetch_denomination_token_address()

Get the address for the denomination token.

fetch_info()

Read vault parameters from the chain.

fetch_nav()

Fetch the most recent onchain NAV value.

fetch_portfolio(universe[, block_identifier])

Read the current token balances of a vault.

fetch_share_token()

Read share token details onchain.

get_flow_manager()

Get flow manager to read individial events.

get_historical_reader()

Get share price reader to fetch historical returns.

get_management_fee(block_identifier)

Get the current management fee as a percent.

get_performance_fee(block_identifier)

Get the current performancae fee as a percent.

has_block_range_event_support()

Does this vault support block range-based event queries for deposits and redemptions.

has_deposit_distribution_to_all_positions()

Deposits go automatically to all open positions.

__init__(token_cache=None)[source]
Parameters

token_cache (Optional[dict]) –

Token cache for vault tokens.

Allows to pass eth_defi.token.TokenDiskCache to speed up operations.

first_seen_at_block: int | None

Block number hint when this vault was deployed.

Must be set externally, as because of shitty Ethereum RPC we cannot query this. Allows us to avoid unnecessary work when scanning historical price data.

abstract property chain_id: int

Chain this vault is on

abstract property address: eth_typing.evm.HexAddress

Vault contract address.

  • Often vault protocols need multiple contracts per vault, so what this function returns depends on the protocol

abstract property name: str

Vault name.

abstract property symbol: str

Vault share token symbol

abstract has_block_range_event_support()[source]

Does this vault support block range-based event queries for deposits and redemptions.

  • If not we use chain balance polling-based approach

Return type

bool

abstract has_deposit_distribution_to_all_positions()[source]

Deposits go automatically to all open positions.

  • Deposits do not land into the vault as cash

  • Instead, smart contracts automatically increase all open positions

  • The behaviour of Velvet Capital

Return type

bool

abstract fetch_portfolio(universe, block_identifier=None)[source]

Read the current token balances of a vault.

  • SHould be supported by all implementations

Parameters
Return type

eth_defi.vault.base.VaultPortfolio

abstract fetch_info()[source]

Read vault parameters from the chain.

Use info() property for cached access.

Return type

eth_defi.vault.base.VaultInfo

abstract get_flow_manager()[source]

Get flow manager to read individial events.

Return type

eth_defi.vault.base.VaultFlowManager

abstract get_historical_reader()[source]

Get share price reader to fetch historical returns.

Returns

None if unsupported

Return type

eth_defi.vault.base.VaultHistoricalReader

fetch_denomination_token_address()[source]

Get the address for the denomination token.

Triggers RCP call

Return type

eth_typing.evm.HexAddress

abstract fetch_denomination_token()[source]

Read denomination token from onchain.

Use denomination_token() for cached access.

Return type

eth_defi.token.TokenDetails

abstract fetch_nav()[source]

Fetch the most recent onchain NAV value.

Returns

Vault NAV, denominated in denomination_token()

Return type

decimal.Decimal

property denomination_token: eth_defi.token.TokenDetails | None

Get the token which denominates the vault valuation

  • Used in deposits and redemptions

  • Used in NAV calculation

  • Used in profit benchmarks

  • Usually USDC

Returns

Token wrapper instance.

Maybe None for broken vaults like https://arbiscan.io/address/0x9d0fbc852deccb7dcdd6cb224fa7561efda74411#code

abstract fetch_share_token()[source]

Read share token details onchain.

Use share_token() for cached access.

Return type

eth_defi.token.TokenDetails

property share_token: eth_defi.token.TokenDetails

ERC-20 that presents vault shares.

  • User gets shares on deposit and burns them on redemption

property info: eth_defi.vault.base.VaultInfo

Get info dictionary related to this vault deployment.

  • Get cached data on the various vault parameters

Returns

Vault protocol specific information dictionary

get_management_fee(block_identifier)[source]

Get the current management fee as a percent.

Returns

0.1 = 10%

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

float

get_performance_fee(block_identifier)[source]

Get the current performancae fee as a percent.

Returns

0.1 = 10%

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

float