aave_v3.rates

Documentation for eth_defi.aave_v3.rates Python module.

Aave v3 rate calculation.

Functions

aave_v3_calculate_accrued_deposit_interest(df, ...)

aave_v3_calculate_accrued_interests(df, ...)

Calculate total interest accrued for a given time period.

aave_v3_calculate_accrued_stable_borrow_interest(df, ...)

aave_v3_calculate_accrued_variable_borrow_interest(df, ...)

aave_v3_calculate_apr_apy_rates(df)

Calculate APR and APY columns for Aave v3 DataFrame previously generated from the blockchain events.

aave_v3_calculate_mean(df, time_bucket, ...)

Calculate mean values for a given time bucket (e.g.

aave_v3_calculate_ohlc(df, time_bucket, ...)

Calculate OHLC (Open, High, Low, Close) values for a given time bucket (e.g.

aave_v3_filter_by_date_range(df, start_time)

Filter the DataFrame by date range suitable for interest calculation (loan start to loan end time) The DataFrame must be indexed by timestamp.

aave_v3_filter_by_token(df[, token])

Filter the DataFrame by token.

Classes

AaveAccruedInterest

AaveAccruedInterest(actual_start_time, actual_end_time, interest)

AaveAccruedInterests

AaveAccruedInterests(actual_start_time, actual_end_time, deposit_interest, variable_borrow_interest, stable_borrow_interest)

class AaveAccruedInterests

Bases: NamedTuple

AaveAccruedInterests(actual_start_time, actual_end_time, deposit_interest, variable_borrow_interest, stable_borrow_interest)

Create new instance of AaveAccruedInterests(actual_start_time, actual_end_time, deposit_interest, variable_borrow_interest, stable_borrow_interest)

actual_start_time: datetime.datetime

Alias for field number 0

actual_end_time: datetime.datetime

Alias for field number 1

deposit_interest: decimal.Decimal

Alias for field number 2

variable_borrow_interest: decimal.Decimal

Alias for field number 3

stable_borrow_interest: decimal.Decimal

Alias for field number 4

static __new__(_cls, actual_start_time, actual_end_time, deposit_interest, variable_borrow_interest, stable_borrow_interest)

Create new instance of AaveAccruedInterests(actual_start_time, actual_end_time, deposit_interest, variable_borrow_interest, stable_borrow_interest)

Parameters
count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

class AaveAccruedInterest

Bases: NamedTuple

AaveAccruedInterest(actual_start_time, actual_end_time, interest)

Create new instance of AaveAccruedInterest(actual_start_time, actual_end_time, interest)

actual_start_time: datetime.datetime

Alias for field number 0

actual_end_time: datetime.datetime

Alias for field number 1

interest: decimal.Decimal

Alias for field number 2

static __new__(_cls, actual_start_time, actual_end_time, interest)

Create new instance of AaveAccruedInterest(actual_start_time, actual_end_time, interest)

Parameters
count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

aave_v3_calculate_apr_apy_rates(df)

Calculate APR and APY columns for Aave v3 DataFrame previously generated from the blockchain events. Also add converted float versions of rate columns for easier calculation operations. https://docs.aave.com/developers/v/2.0/guides/apy-and-apr

Parameters

df (pandas.core.frame.DataFrame) –

Return type

pandas.core.frame.DataFrame

aave_v3_filter_by_token(df, token='')

Filter the DataFrame by token. If token is empty, return the entire DataFrame.

Parameters
  • df (pandas.core.frame.DataFrame) –

  • token (str) –

Return type

pandas.core.frame.DataFrame

aave_v3_calculate_ohlc(df, time_bucket, attribute, token='')

Calculate OHLC (Open, High, Low, Close) values for a given time bucket (e.g. 1 day) and given attribute. Attribute can be e.g. deposit_apr, variable_borrow_apr, stable_borrow_apr, deposit_apy, variable_borrow_apy, stable_borrow_apy. The dataframe must be indexed by timestamp. Returns a new DataFrame, or a tuple of DataFrames if a tuple of attributes was specified.

Parameters
  • df (pandas.core.frame.DataFrame) –

  • time_bucket (pandas._libs.tslibs.timedeltas.Timedelta) –

  • attribute (Union[str, Tuple]) –

  • token (str) –

Return type

Union[pandas.core.frame.DataFrame, Tuple]

aave_v3_calculate_mean(df, time_bucket, attribute, token='')

Calculate mean values for a given time bucket (e.g. 1 day) and given attribute. Attribute can be e.g. deposit_apr, variable_borrow_apr, stable_borrow_apr, deposit_apy, variable_borrow_apy, stable_borrow_apy. The dataframe must be indexed by timestamp. Returns a new DataFrame, or a tuple of DataFrames if a tuple of attributes was specified.

Parameters
  • df (pandas.core.frame.DataFrame) –

  • time_bucket (pandas._libs.tslibs.timedeltas.Timedelta) –

  • attribute (Union[str, Tuple]) –

  • token (str) –

Return type

Union[pandas.core.frame.DataFrame, Tuple]

aave_v3_filter_by_date_range(df, start_time, end_time=None, token='')

Filter the DataFrame by date range suitable for interest calculation (loan start to loan end time) The DataFrame must be indexed by timestamp. If token is specified, also filters by token.

Parameters
Return type

pandas.core.frame.DataFrame

aave_v3_calculate_accrued_interests(df, start_time, end_time, amount, token='')

Calculate total interest accrued for a given time period. The dataframe must be indexed by timestamp. Returns a tuple with actual start time, actual end time, and total interest accrued for a deposit, variable borrow debt, and stable borrow debt. Actual start time and actual end time are the first and last timestamp in the time period in the DataFrame.

Parameters
Return type

eth_defi.aave_v3.rates.AaveAccruedInterests