ERC4626Profitability

Documentation for eth_defi.erc_4626.profit_and_loss.ERC4626Profitability Python class.

class ERC4626Profitability

Bases: object

Capture the data needed for the vault profitability calculation.

Attributes summary

vault

start_block

end_block

share_prices

timestamps

Methods summary

__init__(vault, start_block, end_block, ...)

calculate_profitability([annualise, ...])

Get profitability for the whole duration of the sampling period.

get_block_range()

Get the block range of the profitability data.

get_share_price_range()

Get the share price range of the profitability data.

get_time_range()

Get the time range of the profitability data.

calculate_profitability(annualise=True, year_in_seconds=31536000)

Get profitability for the whole duration of the sampling period.

This is the same as APY <https://tradingstrategy.ai/glossary/annual-percentage-yield-apy>__. But it’s incorrect to use term APY was some vaults may incur losses as well.

Parameters
  • annualise – If True, calculate profit % if we can maintain this profitability for a year.

  • year_in_seconds – Allow custom year durations.

Returns

Profitability as a percentage, either annualised or not.

0.07 means 7% APY.

Return type

float

get_time_range()

Get the time range of the profitability data.

Returns

Tuple of start and end timestamps.

Return type

tuple[datetime.datetime, datetime.datetime]

get_block_range()

Get the block range of the profitability data.

Returns

Tuple of start and end block numbers.

Return type

tuple[int, int]

get_share_price_range()

Get the share price range of the profitability data.

Returns

Tuple of start and end share prices.

Return type

tuple[decimal.Decimal, decimal.Decimal]

__init__(vault, start_block, end_block, share_prices, timestamps)
Parameters
Return type

None