y.prices package

Subpackages

Submodules

y.prices.band module

class y.prices.band.Band[source]

Bases: ASyncGenericSingleton

__contains__(asset)[source]
Parameters:

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

Return type:

bool

__init__(asynchronous=False)[source]
Parameters:

asynchronous (bool)

Return type:

None

__oracle__: HiddenMethodDescriptor[Self, Contract]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

get_price[source]
Parameters:
Return type:

float | None

oracle[source]

y.prices.convex module

ASyncFunctiony.prices.convex.get_price(token_address: brownie.convert.datatypes.EthAddress, 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]

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

y.prices.convex.is_convex_lp(token_address)[source]
Parameters:

token_address (EthAddress)

Return type:

bool

y.prices.gearbox module

class y.prices.gearbox.DieselPool[source]

Bases: ContractBase

__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

__build_name__: HiddenMethodDescriptor[Self, str]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__contract__: HiddenMethodDescriptor[Self, Contract]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__diesel_token__: HiddenMethodDescriptor[Self, ERC20]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__underlying__: HiddenMethodDescriptor[Self, ERC20]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

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

when_no_history_return_0 (bool)

Return type:

int

diesel_token[source]
exchange_rate[source]
Parameters:

block (int | BlockNumber)

Return type:

Decimal

get_price[source]
Parameters:
Return type:

Decimal

has_method
Parameters:
  • method (str)

  • return_response (bool)

Return type:

bool | Any

underlying[source]
class y.prices.gearbox.Gearbox[source]

Bases: ASyncGenericBase

__init__(asynchronous=False)[source]
Parameters:

asynchronous (bool)

__registry__
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

diesel_tokens[source]
Return type:

Dict[ERC20, DieselPool]

get_price[source]
Parameters:
Return type:

Decimal

is_diesel_token[source]
Parameters:

token (str | HexBytes | AnyAddress | EthAddress)

Return type:

bool

pools[source]

Since pools 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.

Return type:

List[DieselPool]

registry[source]

y.prices.magic module

ASyncFunctiony.prices.magic.get_price(token_address: AnyAddressType, block: Block | None = None, *, fail_to_None: Literal[True], skip_cache: bool = ENVS.SKIP_CACHE, ignore_pools: Tuple[Pool, ...] = (), silent: bool = False) UsdPrice | None[source]
ASyncFunctiony.prices.magic.get_price(token_address: AnyAddressType, block: Block | None = None, *, fail_to_None: bool = False, skip_cache: bool = ENVS.SKIP_CACHE, ignore_pools: Tuple[Pool, ...] = (), silent: bool = False) UsdPrice

Don’t pass an int like 123 into token_address please, that’s just silly. - ypricemagic accepts ints to allow you to pass y.get_price(0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e)

so you can save yourself some keystrokes while testing in a console

  • (as opposed to y.get_price(“0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e”))

When get_price is unable to find a price: - If silent == True, ypricemagic will print an error message using standard python logging - If silent == False, ypricemagic will not log any error - If fail_to_None == True, ypricemagic will return None - If fail_to_None == False, ypricemagic will raise a PriceError

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.

ASyncFunctiony.prices.magic.get_prices(token_addresses: Iterable[AnyAddressType], block: Block | None = None, *, fail_to_None: Literal[True], skip_cache: bool = ENVS.SKIP_CACHE, silent: bool = False) List[UsdPrice | None][source]
ASyncFunctiony.prices.magic.get_prices(token_addresses: Iterable[AnyAddressType], block: Block | None = None, *, fail_to_None: bool = False, skip_cache: bool = ENVS.SKIP_CACHE, silent: bool = False) List[UsdPrice]

A more optimized way to fetch prices for multiple assets at the same block.

# NOTE silent kwarg is currently disabled. In every case: - if silent == True, tqdm will not be used - if silent == False, tqdm will be used

When get_prices is unable to find a price: - if fail_to_None == True, ypricemagic will return None for that token - if fail_to_None == False, ypricemagic will raise a yPriceMagicError

Since get_prices 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.

y.prices.magic.map_prices(token_addresses: Iterable[str | HexBytes | AnyAddress | EthAddress | Contract | int], block: int | BlockNumber, *, fail_to_None: Literal[True], skip_cache: bool = ENVS.SKIP_CACHE, silent: bool = False) TaskMapping[str | HexBytes | AnyAddress | EthAddress | Contract | int, UsdPrice | None][source]
y.prices.magic.map_prices(token_addresses: Iterable[str | HexBytes | AnyAddress | EthAddress | Contract | int], block: int | BlockNumber, *, fail_to_None: bool = False, skip_cache: bool = ENVS.SKIP_CACHE, silent: bool = False) TaskMapping[str | HexBytes | AnyAddress | EthAddress | Contract | int, UsdPrice]

y.prices.one_to_one module

ASyncFunctiony.prices.one_to_one.get_price(token_address: brownie.convert.datatypes.EthAddress, 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]

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

y.prices.one_to_one.is_one_to_one_token(token_address)[source]
Parameters:

token_address (EthAddress)

Return type:

bool

y.prices.pendle module

ASyncFunctiony.prices.pendle.get_lp_price(token: Union[str, hexbytes.main.HexBytes, ~AnyAddress, brownie.convert.datatypes.EthAddress], block: Union[int, eth_typing.evm.BlockNumber] = None, skip_cache: bool = <EnvironmentVariable[name=`YPRICEMAGIC_SKIP_CACHE`, type=bool, default_value=False, current_value=False, using_default=True]>) decimal.Decimal[source]

Since get_lp_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:

Decimal

y.prices.pendle.get_tokens(lp_token)[source]
Parameters:

lp_token (str | HexBytes | AnyAddress | EthAddress)

Return type:

Tuple[str, str, str]

ASyncFunctiony.prices.pendle.is_pendle_lp(token: str | hexbytes.main.HexBytes | AnyAddress | brownie.convert.datatypes.EthAddress) bool[source]

Since is_pendle_lp 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)

Return type:

bool

y.prices.popsicle module

ASyncFunctiony.prices.popsicle.get_balances(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]>, _async_balance_objects: bool = False) Tuple[y.classes.common.WeiBalance, y.classes.common.WeiBalance] | None[source]

Since get_balances 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:

Tuple[WeiBalance, WeiBalance] | None

ASyncFunctiony.prices.popsicle.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 | None[source]

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 | None

ASyncFunctiony.prices.popsicle.get_tvl(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.UsdValue | None[source]

Since get_tvl 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:

UsdValue | None

ASyncFunctiony.prices.popsicle.is_popsicle_lp(token_address: str | hexbytes.main.HexBytes | AnyAddress | brownie.convert.datatypes.EthAddress | brownie.network.contract.Contract | int) bool[source]

Since is_popsicle_lp 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_address (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

bool

y.prices.rkp3r module

async y.prices.rkp3r.get_discount(block=None)[source]
Parameters:

block (int | BlockNumber | None)

Return type:

Decimal

ASyncFunctiony.prices.rkp3r.get_price(address: Union[str, hexbytes.main.HexBytes, ~AnyAddress, brownie.convert.datatypes.EthAddress], 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]>) decimal.Decimal[source]

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:

Decimal

y.prices.rkp3r.is_rkp3r(address)[source]
Parameters:

address (str | HexBytes | AnyAddress | EthAddress)

Return type:

bool

y.prices.solidex module

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

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:
ASyncFunctiony.prices.solidex.is_solidex_deposit(token: str | hexbytes.main.HexBytes | AnyAddress | brownie.convert.datatypes.EthAddress | brownie.network.contract.Contract | int) bool[source]

Since is_solidex_deposit 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

y.prices.synthetix module

class y.prices.synthetix.Synthetix[source]

Bases: ASyncGenericSingleton

__init__(asynchronous=False)[source]
Parameters:

asynchronous (bool)

Return type:

None

__address_resolver__: HiddenMethodDescriptor[Self, Contract]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__synths__
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

address_resolver[source]
get_address[source]
Get contract from Synthetix registry.

See also https://docs.synthetix.io/addresses/

Since get_address 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:
Return type:

Contract

get_currency_key[source]

Since get_currency_key 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 (str | HexBytes | AnyAddress | EthAddress | Contract | int)

Return type:

HexString | None

get_price[source]

Get a price of a synth in dollars.

Parameters:
Return type:

UsdPrice | None

is_synth[source]

returns True if a token is a synth, False if not

Parameters:

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

Return type:

bool

synths[source]

Get target addresses of all synths.

y.prices.synthetix.encode_bytes(s)

y.prices.yearn module

class y.prices.yearn.YearnInspiredVault[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, asynchronous=False, _deploy_block=None)
Parameters:
Return type:

None

__str__()

Return str(self).

Return type:

str

__build_name__: HiddenMethodDescriptor[Self, str]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__decimals__: HiddenMethodDescriptor[Self, int]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__name__: HiddenMethodDescriptor[Self, str] = 'YearnInspiredVault'
__scale__: HiddenMethodDescriptor[Self, int]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__symbol__: HiddenMethodDescriptor[Self, str]
Parameters:
  • instance (I)

  • owner (Type[I] | None)

Return type:

T

__underlying__: HiddenMethodDescriptor[Self, ERC20]
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

has_method
Parameters:
  • method (str)

  • return_response (bool)

Return type:

bool | Any

name
price[source]
Parameters:
Return type:

UsdPrice

scale
share_price[source]
Parameters:

block (int | BlockNumber | None)

Return type:

Decimal | None

symbol
total_supply
Parameters:

block (int | BlockNumber | None)

Return type:

int

total_supply_readable
Parameters:

block (int | BlockNumber | None)

Return type:

float

underlying[source]
ASyncFunctiony.prices.yearn.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]>, ignore_pools: Tuple[Union[ForwardRef('UniswapV2Pool'), ForwardRef('CurvePool')], ...] = ()) y.datatypes.UsdPrice[source]

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.yearn.is_yearn_vault(token: str | hexbytes.main.HexBytes | AnyAddress | brownie.convert.datatypes.EthAddress | brownie.network.contract.Contract | int) bool[source]

Since is_yearn_vault 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