y.prices.lending package
Submodules
y.prices.lending.aave module
- class y.prices.lending.aave.AaveMarketBase[source]
Bases:
ContractBase
Base class for Aave markets.
- __eq__(_ContractBase__o)
Return self==value.
- __init__(address, asynchronous=False, _deploy_block=None)
- Parameters:
address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
asynchronous (bool)
_deploy_block (int | None)
- Return type:
None
- __atokens__: HiddenMethodDescriptor[Self, List[ERC20]]
- __build_name__: HiddenMethodDescriptor[Self, str]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- address
- abstract property atokens: Awaitable[List[ERC20]]
Get the aTokens of the market.
- Returns:
A list of aTokens as
ERC20
objects.
- build_name
- get_reserve_data[source]
- Parameters:
reserve (str | HexBytes | AnyAddress | EthAddress | Contract | int)
- Return type:
- get_reserves[source]
- Return type:
List[str | HexBytes | AnyAddress | EthAddress]
- 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:
- class y.prices.lending.aave.AaveMarketV1[source]
Bases:
AaveMarketBase
- __contains__(token)
Check if token is an aToken from this market.
- __eq__(_ContractBase__o)
Return self==value.
- __init__(address, asynchronous=False, _deploy_block=None)
- Parameters:
address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
asynchronous (bool)
_deploy_block (int | None)
- Return type:
None
- __atokens__: HiddenMethodDescriptor[Self, List[ERC20]]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __build_name__: HiddenMethodDescriptor[Self, str]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- address
- build_name
- contains
Check if token is an aToken from this market.
- get_reserve_data
- Parameters:
reserve (str | HexBytes | AnyAddress | EthAddress | Contract | int)
- Return type:
- get_reserves
- Return type:
List[str | HexBytes | AnyAddress | EthAddress]
- 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:
- class y.prices.lending.aave.AaveMarketV2[source]
Bases:
AaveMarketBase
- __contains__(token)
Check if token is an aToken from this market.
- __eq__(_ContractBase__o)
Return self==value.
- __init__(address, asynchronous=False, _deploy_block=None)
- Parameters:
address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
asynchronous (bool)
_deploy_block (int | None)
- Return type:
None
- __atokens__: HiddenMethodDescriptor[Self, List[ERC20]]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __build_name__: HiddenMethodDescriptor[Self, str]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- address
- build_name
- contains
Check if token is an aToken from this market.
- get_reserve_data[source]
- Parameters:
reserve (str | HexBytes | AnyAddress | EthAddress | Contract | int)
- Return type:
- get_reserves
- Return type:
List[str | HexBytes | AnyAddress | EthAddress]
- 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:
- class y.prices.lending.aave.AaveMarketV3[source]
Bases:
AaveMarketBase
- __contains__(token)
Check if token is an aToken from this market.
- __eq__(_ContractBase__o)
Return self==value.
- __init__(address, asynchronous=False, _deploy_block=None)
- Parameters:
address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
asynchronous (bool)
_deploy_block (int | None)
- Return type:
None
- __atokens__: HiddenMethodDescriptor[Self, List[ERC20]]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __build_name__: HiddenMethodDescriptor[Self, str]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- address
- build_name
- contains
Check if token is an aToken from this market.
- get_reserve_data
- Parameters:
reserve (str | HexBytes | AnyAddress | EthAddress | Contract | int)
- Return type:
- get_reserves
- Return type:
List[str | HexBytes | AnyAddress | EthAddress]
- 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:
- class y.prices.lending.aave.AaveRegistry[source]
Bases:
ASyncGenericSingleton
- __pools__: HiddenMethodDescriptor[Self, List[AaveMarketV1 | AaveMarketV2 | AaveMarketV3]]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __pools_v1__: HiddenMethodDescriptor[Self, List[AaveMarketV1]]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __pools_v2__: HiddenMethodDescriptor[Self, List[AaveMarketV2]]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __pools_v3__: HiddenMethodDescriptor[Self, List[AaveMarketV3]]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- get_price[source]
- Parameters:
atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract)
block (int | BlockNumber | None)
skip_cache (bool)
- Return type:
- get_price_wrapped_v2[source]
- Parameters:
atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract)
block (int | BlockNumber | None)
skip_cache (bool)
- Return type:
UsdPrice | None
- get_price_wrapped_v3[source]
- Parameters:
atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract)
block (int | BlockNumber | None)
skip_cache (bool)
- 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:
- is_wrapped_atoken_v2[source]
- Parameters:
atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
- Return type:
- is_wrapped_atoken_v3[source]
- Parameters:
atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
- Return type:
- pool_for_atoken[source]
- Parameters:
atoken_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
- Return type:
AaveMarketV1 | AaveMarketV2 | AaveMarketV3 | None
- 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:
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:
- 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:
- __eq__(_ContractBase__o)
Return self==value.
- __init__(address, comptroller=None, asynchronous=False)[source]
- Parameters:
address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
comptroller (Comptroller | None)
asynchronous (bool)
- Return type:
None
- __build_name__: HiddenMethodDescriptor[Self, str]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __decimals__: HiddenMethodDescriptor[Self, int]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __scale__: HiddenMethodDescriptor[Self, int]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __symbol__: HiddenMethodDescriptor[Self, str]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __underlying__: HiddenMethodDescriptor[Self, ERC20]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- address
- balance_of
- Parameters:
address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
block (int | BlockNumber | None)
- Return type:
- balance_of_readable
- Parameters:
address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
block (int | BlockNumber | None)
- Return type:
- build_name
- decimals
- exchange_rate[source]
- Parameters:
block (int | BlockNumber | None)
- Return type:
- get_price[source]
- Parameters:
block (int | BlockNumber | None)
skip_cache (bool)
- Return type:
- get_underlying_price[source]
- Parameters:
block (int | BlockNumber | None)
skip_cache (bool)
- Return type:
float | None
- name
- price
- Parameters:
block (int | BlockNumber | None)
return_None_on_failure (bool)
skip_cache (bool)
ignore_pools (Tuple[UniswapV2Pool | CurvePool, ...])
- Return type:
UsdPrice | None
- scale
- symbol
- total_supply
- Parameters:
block (int | BlockNumber | None)
- Return type:
- total_supply_readable
- Parameters:
block (int | BlockNumber | None)
- Return type:
- underlying_per_ctoken[source]
- Parameters:
block (int | BlockNumber | None)
- Return type:
- class y.prices.lending.compound.Compound[source]
Bases:
ASyncGenericSingleton
- __contains__(token_address)[source]
- Parameters:
token_address (str | HexBytes | AnyAddress | EthAddress | Contract)
- Return type:
- get_price[source]
- Parameters:
token_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
block (int | BlockNumber | None)
skip_cache (bool)
- 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:
- class y.prices.lending.compound.Comptroller[source]
Bases:
ContractBase
- __contains__(token_address)[source]
- Parameters:
token_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)
- Return type:
- __eq__(_ContractBase__o)
Return self==value.
- __init__(address=None, key=None, asynchronous=False)[source]
- Parameters:
address (str | HexBytes | AnyAddress | EthAddress | Contract | int | None)
key (str | None)
asynchronous (bool)
- Return type:
None
- __build_name__: HiddenMethodDescriptor[Self, str]
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- __markets__
A
HiddenMethodDescriptor
for_ASyncPropertyDescriptorBase.get()
.
- address
- build_name
- deploy_block: ASyncBoundMethod[Self, Any, int]
- oracle[source]
- Parameters:
block (int | BlockNumber | None)
- Return type:
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:
token (str | HexBytes | AnyAddress | EthAddress | Contract | int)
block (int | BlockNumber | None)
skip_cache (bool)
- Return type:
- 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: