y.prices.lending package

Submodules

y.prices.lending.aave module

class y.prices.lending.aave.AaveMarketBase[source]

Bases: ContractBase

Base class for Aave markets.

__contains__(token)[source]

Check if token is an aToken from this market.

Parameters:
  • atoken – The item to check.

  • token (object)

Returns:

True if the token is an aToken from the market, False otherwise.

Return type:

bool

__eq__(_ContractBase__o)

Return self==value.

Parameters:

_ContractBase__o (object)

Return type:

bool

__init__(address, asynchronous=False, _deploy_block=None)
Parameters:
Return type:

None

__str__()

Return str(self).

Return type:

str

__atokens__: HiddenMethodDescriptor[Self, List[ERC20]]
__build_name__: HiddenMethodDescriptor[Self, str]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

address
asynchronous: bool = False
abstract property atokens: Awaitable[List[ERC20]]

Get the aTokens of the market.

Returns:

A list of aTokens as ERC20 objects.

build_name
contains[source]

Check if token is an aToken from this market.

Parameters:

token (object) – The item to check.

Returns:

True if the token is an aToken from the market, False otherwise.

Return type:

bool

property contract: Contract
deploy_block: ASyncBoundMethod[Self, Any, int]
Parameters:

when_no_history_return_0 (bool)

Return type:

int

get_reserve_data[source]
Parameters:

reserve (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

tuple

get_reserves[source]
Return type:

List[str | HexBytes | AnyAddress | EthAddress]

has_method
Parameters:
  • method (str)

  • return_response (bool)

Return type:

bool | Any

underlying[source]

Get the underlying asset of the given aToken address.

Parameters:

atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract) – The address of the aToken.

Returns:

The underlying asset.

Return type:

ERC20

class y.prices.lending.aave.AaveMarketV1[source]

Bases: AaveMarketBase

__contains__(token)

Check if token is an aToken from this market.

Parameters:
  • atoken – The item to check.

  • token (object)

Returns:

True if the token is an aToken from the market, False otherwise.

Return type:

bool

__eq__(_ContractBase__o)

Return self==value.

Parameters:

_ContractBase__o (object)

Return type:

bool

__init__(address, asynchronous=False, _deploy_block=None)
Parameters:
Return type:

None

__str__()

Return str(self).

Return type:

str

__atokens__: HiddenMethodDescriptor[Self, List[ERC20]]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__build_name__: HiddenMethodDescriptor[Self, str]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

address
asynchronous: bool = False
atokens[source]
build_name
contains

Check if token is an aToken from this market.

Parameters:

token (object) – The item to check.

Returns:

True if the token is an aToken from the market, False otherwise.

Return type:

bool

property contract: Contract
deploy_block: ASyncBoundMethod[Self, Any, int]
Parameters:

when_no_history_return_0 (bool)

Return type:

int

get_reserve_data
Parameters:

reserve (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

tuple

get_reserves
Return type:

List[str | HexBytes | AnyAddress | EthAddress]

has_method
Parameters:
  • method (str)

  • return_response (bool)

Return type:

bool | Any

underlying[source]

Since underlying is an ASyncFunctionAsyncDefault, you can optionally pass sync=True or asynchronous=False to force it to run synchronously and return a value. Without either kwarg, it will return a coroutine for you to await.

Parameters:

atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract)

Return type:

ERC20

class y.prices.lending.aave.AaveMarketV2[source]

Bases: AaveMarketBase

__contains__(token)

Check if token is an aToken from this market.

Parameters:
  • atoken – The item to check.

  • token (object)

Returns:

True if the token is an aToken from the market, False otherwise.

Return type:

bool

__eq__(_ContractBase__o)

Return self==value.

Parameters:

_ContractBase__o (object)

Return type:

bool

__init__(address, asynchronous=False, _deploy_block=None)
Parameters:
Return type:

None

__str__()

Return str(self).

Return type:

str

__atokens__: HiddenMethodDescriptor[Self, List[ERC20]]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__build_name__: HiddenMethodDescriptor[Self, str]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

address
asynchronous: bool = False
atokens[source]
build_name
contains

Check if token is an aToken from this market.

Parameters:

token (object) – The item to check.

Returns:

True if the token is an aToken from the market, False otherwise.

Return type:

bool

property contract: Contract
deploy_block: ASyncBoundMethod[Self, Any, int]
Parameters:

when_no_history_return_0 (bool)

Return type:

int

get_reserve_data[source]
Parameters:

reserve (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

tuple

get_reserves
Return type:

List[str | HexBytes | AnyAddress | EthAddress]

has_method
Parameters:
  • method (str)

  • return_response (bool)

Return type:

bool | Any

underlying[source]

Since underlying is an ASyncFunctionAsyncDefault, you can optionally pass sync=True or asynchronous=False to force it to run synchronously and return a value. Without either kwarg, it will return a coroutine for you to await.

Parameters:

atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract)

Return type:

ERC20

class y.prices.lending.aave.AaveMarketV3[source]

Bases: AaveMarketBase

__contains__(token)

Check if token is an aToken from this market.

Parameters:
  • atoken – The item to check.

  • token (object)

Returns:

True if the token is an aToken from the market, False otherwise.

Return type:

bool

__eq__(_ContractBase__o)

Return self==value.

Parameters:

_ContractBase__o (object)

Return type:

bool

__init__(address, asynchronous=False, _deploy_block=None)
Parameters:
Return type:

None

__str__()

Return str(self).

Return type:

str

__atokens__: HiddenMethodDescriptor[Self, List[ERC20]]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__build_name__: HiddenMethodDescriptor[Self, str]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

address
asynchronous: bool = False
atokens[source]
build_name
contains

Check if token is an aToken from this market.

Parameters:

token (object) – The item to check.

Returns:

True if the token is an aToken from the market, False otherwise.

Return type:

bool

property contract: Contract
deploy_block: ASyncBoundMethod[Self, Any, int]
Parameters:

when_no_history_return_0 (bool)

Return type:

int

get_reserve_data
Parameters:

reserve (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

tuple

get_reserves
Return type:

List[str | HexBytes | AnyAddress | EthAddress]

has_method
Parameters:
  • method (str)

  • return_response (bool)

Return type:

bool | Any

underlying[source]

Since underlying is an ASyncFunctionAsyncDefault, you can optionally pass sync=True or asynchronous=False to force it to run synchronously and return a value. Without either kwarg, it will return a coroutine for you to await.

Parameters:

atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract)

Return type:

ERC20

class y.prices.lending.aave.AaveRegistry[source]

Bases: ASyncGenericSingleton

__contains__(_AaveRegistry__o)[source]
Parameters:

_AaveRegistry__o (object)

Return type:

bool

__init__(asynchronous=False)[source]
Parameters:

asynchronous (bool)

Return type:

None

__pools__: HiddenMethodDescriptor[Self, List[AaveMarketV1 | AaveMarketV2 | AaveMarketV3]]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__pools_v1__: HiddenMethodDescriptor[Self, List[AaveMarketV1]]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__pools_v2__: HiddenMethodDescriptor[Self, List[AaveMarketV2]]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__pools_v3__: HiddenMethodDescriptor[Self, List[AaveMarketV3]]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

get_price[source]
Parameters:
Return type:

UsdPrice

get_price_wrapped_v2[source]
Parameters:
Return type:

UsdPrice | None

get_price_wrapped_v3[source]
Parameters:
Return type:

UsdPrice | None

is_atoken[source]

Since is_atoken is an ASyncFunctionAsyncDefault, you can optionally pass sync=True or asynchronous=False to force it to run synchronously and return a value. Without either kwarg, it will return a coroutine for you to await.

Parameters:

atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

bool

is_wrapped_atoken_v2[source]
Parameters:

atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

bool

is_wrapped_atoken_v3[source]
Parameters:

atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

bool

pool_for_atoken[source]
Parameters:

atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

AaveMarketV1 | AaveMarketV2 | AaveMarketV3 | None

pools[source]
pools_v1[source]
pools_v2[source]
pools_v3[source]
underlying[source]

Since underlying is an ASyncFunctionAsyncDefault, you can optionally pass sync=True or asynchronous=False to force it to run synchronously and return a value. Without either kwarg, it will return a coroutine for you to await.

Parameters:

atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract)

Return type:

ERC20

y.prices.lending.compound module

class y.prices.lending.compound.CToken[source]

Bases: ERC20

ASyncFunction_decimals(block: int | eth_typing.evm.BlockNumber | NoneType = None) int

used to fetch decimals at specific block

Since _decimals is an ASyncFunctionAsyncDefault, you can optionally pass sync=True or asynchronous=False to force it to run synchronously and return a value. Without either kwarg, it will return a coroutine for you to await.

Parameters:

block (int | BlockNumber | None)

Return type:

int

ASyncFunction_scale(block: int | eth_typing.evm.BlockNumber | NoneType = None) int

Since _scale is an ASyncFunctionAsyncDefault, you can optionally pass sync=True or asynchronous=False to force it to run synchronously and return a value. Without either kwarg, it will return a coroutine for you to await.

Parameters:

block (int | BlockNumber | None)

Return type:

int

__eq__(_ContractBase__o)

Return self==value.

Parameters:

_ContractBase__o (object)

Return type:

bool

__init__(address, comptroller=None, asynchronous=False)[source]
Parameters:
Return type:

None

__str__()

Return str(self).

Return type:

str

__build_name__: HiddenMethodDescriptor[Self, str]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__decimals__: HiddenMethodDescriptor[Self, int]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__name__: HiddenMethodDescriptor[Self, str] = 'CToken'
__scale__: HiddenMethodDescriptor[Self, int]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__symbol__: HiddenMethodDescriptor[Self, str]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__underlying__: HiddenMethodDescriptor[Self, ERC20]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

address
asynchronous: bool = False
balance_of
Parameters:
Return type:

int

balance_of_readable
Parameters:
Return type:

float

build_name
property contract: Contract
decimals
deploy_block: ASyncBoundMethod[Self, Any, int]
Parameters:

when_no_history_return_0 (bool)

Return type:

int

exchange_rate[source]
Parameters:

block (int | BlockNumber | None)

Return type:

float

get_price[source]
Parameters:
Return type:

UsdPrice

get_underlying_price[source]
Parameters:
Return type:

float | None

has_method
Parameters:
  • method (str)

  • return_response (bool)

Return type:

bool | Any

name
price
Parameters:
Return type:

UsdPrice | None

scale
symbol
total_supply
Parameters:

block (int | BlockNumber | None)

Return type:

int

total_supply_readable
Parameters:

block (int | BlockNumber | None)

Return type:

float

underlying[source]
underlying_per_ctoken[source]
Parameters:

block (int | BlockNumber | None)

Return type:

float

class y.prices.lending.compound.Compound[source]

Bases: ASyncGenericSingleton

__contains__(token_address)[source]
Parameters:

token_address (str | HexBytes | AnyAddress | EthAddress | Contract)

Return type:

bool

__init__(asynchronous=False)[source]
Parameters:

asynchronous (bool)

Return type:

None

get_price[source]
Parameters:
Return type:

UsdPrice | None

get_troller[source]
Parameters:

token_address (str | HexBytes | AnyAddress | EthAddress | Contract)

Return type:

Comptroller | None

is_compound_market[source]

Since is_compound_market is an ASyncFunctionAsyncDefault, you can optionally pass sync=True or asynchronous=False to force it to run synchronously and return a value. Without either kwarg, it will return a coroutine for you to await.

Parameters:

token_address (str | HexBytes | AnyAddress | EthAddress | Contract)

Return type:

bool

class y.prices.lending.compound.Comptroller[source]

Bases: ContractBase

__contains__(token_address)[source]
Parameters:

token_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

bool

__eq__(_ContractBase__o)

Return self==value.

Parameters:

_ContractBase__o (object)

Return type:

bool

__init__(address=None, key=None, asynchronous=False)[source]
Parameters:
Return type:

None

__str__()

Return str(self).

Return type:

str

__build_name__: HiddenMethodDescriptor[Self, str]

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__markets__

A HiddenMethodDescriptor for _ASyncPropertyDescriptorBase.get().

Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

address
asynchronous: bool = False
build_name
property contract: Contract
deploy_block: ASyncBoundMethod[Self, Any, int]
Parameters:

when_no_history_return_0 (bool)

Return type:

int

has_method
Parameters:
  • method (str)

  • return_response (bool)

Return type:

bool | Any

markets[source]
oracle[source]
Parameters:

block (int | BlockNumber | None)

Return type:

Contract

y.prices.lending.ib module

ASyncFunctiony.prices.lending.ib.get_price(token: Union[str, hexbytes.main.HexBytes, ~AnyAddress, brownie.convert.datatypes.EthAddress, brownie.network.contract.Contract, int], block: Union[int, eth_typing.evm.BlockNumber, NoneType] = None, skip_cache: bool = <EnvironmentVariable[name=`YPRICEMAGIC_SKIP_CACHE`, type=bool, default_value=False, current_value=False, using_default=True]>) y.datatypes.UsdPrice[source]

Calculates the price of an Iron Bank token.

Args:

token: The address of the Iron Bank token. block (optional): The block number to query. Defaults to the latest block. skip_cache (optional): Whether to skip the cache when fetching prices. Defaults to :obbj:`ENVS.SKIP_CACHE`.

Returns:

The price of the Iron Bank token in USD.

Example:
>>> price = get_price("0x41c84c0e2EE0b740Cf0d31F63f3B6F627DC6b393", block=14_000_000)
>>> print(f"{price:.6f}")
1.234567  # The price of the Iron Bank token in USD
Note:

This function calculates the price by determining the share price of the Iron Bank token relative to its underlying asset, and then multiplying by the price of the underlying asset.

Since get_price is an ASyncFunctionSyncDefault, you can optionally pass sync=False or asynchronous=True to force it to return a coroutine. Without either kwarg, it will run synchronously.

Parameters:
Return type:

UsdPrice

ASyncFunctiony.prices.lending.ib.is_ib_token(token: str | hexbytes.main.HexBytes | AnyAddress | brownie.convert.datatypes.EthAddress | brownie.network.contract.Contract | int) bool[source]

Determines if the given token address is an Iron Bank token.

Args:

token: The address of the token to check.

Returns:

True if the token is an Iron Bank token, False otherwise.

Example:
>>> is_ib = is_ib_token("0x41c84c0e2EE0b740Cf0d31F63f3B6F627DC6b393")
>>> print(is_ib)
True

Since is_ib_token is an ASyncFunctionSyncDefault, you can optionally pass sync=False or asynchronous=True to force it to return a coroutine. Without either kwarg, it will run synchronously.

Parameters:

token (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

bool

Module contents