y package
Subpackages
- y.classes package
- Submodules
- y.classes.common module
- y.classes.singleton module
ChecksumASyncSingletonMetaChecksumASyncSingletonMeta.__base__ChecksumASyncSingletonMeta.__prepare__()ChecksumASyncSingletonMeta.__call__()ChecksumASyncSingletonMeta.__dir__()ChecksumASyncSingletonMeta.__getattribute__()ChecksumASyncSingletonMeta.__init__()ChecksumASyncSingletonMeta.__instancecheck__()ChecksumASyncSingletonMeta.__or__()ChecksumASyncSingletonMeta.__ror__()ChecksumASyncSingletonMeta.__sizeof__()ChecksumASyncSingletonMeta.__subclasscheck__()ChecksumASyncSingletonMeta.__subclasses__()ChecksumASyncSingletonMeta.mro()ChecksumASyncSingletonMeta.register()ChecksumASyncSingletonMeta.__bases__ChecksumASyncSingletonMeta.__basicsize__ChecksumASyncSingletonMeta.__dictoffset__ChecksumASyncSingletonMeta.__flags__ChecksumASyncSingletonMeta.__itemsize__ChecksumASyncSingletonMeta.__mro__ChecksumASyncSingletonMeta.__name__ChecksumASyncSingletonMeta.__qualname__ChecksumASyncSingletonMeta.__text_signature__ChecksumASyncSingletonMeta.__type_params__ChecksumASyncSingletonMeta.__weakrefoffset__
- Module contents
- y.interfaces package
- y.prices package
- Subpackages
- Submodules
- y.prices.band module
- y.prices.chainlink module
- y.prices.convex module
- y.prices.gearbox module
- y.prices.magic module
- y.prices.one_to_one module
- y.prices.pendle module
- y.prices.popsicle module
- y.prices.rkp3r module
- y.prices.solidex module
- y.prices.synthetix module
- y.prices.yearn module
- Module contents
- y.utils package
- Submodules
- y.utils.cache module
- y.utils.checks module
- y.utils.client module
- y.utils.events module
- y.utils.fakes module
- y.utils.gather module
- y.utils.logging module
PriceLoggerPriceLogger.__init__()PriceLogger.addFilter()PriceLogger.addHandler()PriceLogger.callHandlers()PriceLogger.close()PriceLogger.critical()PriceLogger.debug()PriceLogger.error()PriceLogger.exception()PriceLogger.fatal()PriceLogger.filter()PriceLogger.findCaller()PriceLogger.getChild()PriceLogger.getChildren()PriceLogger.getEffectiveLevel()PriceLogger.handle()PriceLogger.hasHandlers()PriceLogger.info()PriceLogger.isEnabledFor()PriceLogger.log()PriceLogger.makeRecord()PriceLogger.removeFilter()PriceLogger.removeHandler()PriceLogger.setLevel()PriceLogger.warn()PriceLogger.warning()PriceLogger.__final__PriceLogger.addressPriceLogger.blockPriceLogger.debug_taskPriceLogger.enabledPriceLogger.keyPriceLogger.managerPriceLogger.root
enable_debug_logging()get_price_logger()
- y.utils.middleware module
- y.utils.multicall module
- y.utils.raw_calls module
- Module contents
Submodules
y.ENVIRONMENT_VARIABLES module
y.cli module
y.constants module
y.contracts module
y.convert module
- y.convert.checksum(address)
- y.convert.to_address(address)
- async y.convert.to_address_async()
y.datatypes module
- class y.datatypes.UsdPrice[source]
Bases:
UsdValueRepresents a USD price.
Examples
>>> price = UsdPrice(1234.5678) >>> str(price) '$1234.56780000'
- classmethod fromhex(string, /)
Create a floating-point number from a hexadecimal string.
>>> float.fromhex('0x1.ffffp10') 2047.984375 >>> float.fromhex('-0x1p-1074') -5e-324
- __add__(value, /)
Return self+value.
- __bool__()
True if self else False
- __eq__(value, /)
Return self==value.
- __floordiv__(value, /)
Return self//value.
- __ge__(value, /)
Return self>=value.
- __gt__(value, /)
Return self>value.
- __le__(value, /)
Return self<=value.
- __lt__(value, /)
Return self<value.
- __mul__(value, /)
Return self*value.
- __pow__(value, mod=None, /)
Return pow(self, value, mod).
- __radd__(value, /)
Return value+self.
- __str__()
Return a string representation of the USD value. The value is formatted as a USD value with 8 decimal places.
- Return type:
- __sub__(value, /)
Return self-value.
- __truediv__(value, /)
Return self/value.
- hex()
Return a hexadecimal representation of a floating-point number.
>>> (-0.1).hex() '-0x1.999999999999ap-4' >>> 3.14159.hex() '0x1.921f9f01b866ep+1'
- class y.datatypes.UsdValue[source]
Bases:
floatRepresents a USD value with custom string representation.
Examples
>>> value = UsdValue(1234.5678) >>> str(value) '$1234.56780000'
- classmethod fromhex(string, /)
Create a floating-point number from a hexadecimal string.
>>> float.fromhex('0x1.ffffp10') 2047.984375 >>> float.fromhex('-0x1p-1074') -5e-324
- __add__(value, /)
Return self+value.
- __bool__()
True if self else False
- __eq__(value, /)
Return self==value.
- __floordiv__(value, /)
Return self//value.
- __ge__(value, /)
Return self>=value.
- __gt__(value, /)
Return self>value.
- __le__(value, /)
Return self<=value.
- __lt__(value, /)
Return self<value.
- __mul__(value, /)
Return self*value.
- __pow__(value, mod=None, /)
Return pow(self, value, mod).
- __radd__(value, /)
Return value+self.
- __str__()[source]
Return a string representation of the USD value. The value is formatted as a USD value with 8 decimal places.
- Return type:
- __sub__(value, /)
Return self-value.
- __truediv__(value, /)
Return self/value.
- hex()
Return a hexadecimal representation of a floating-point number.
>>> (-0.1).hex() '-0x1.999999999999ap-4' >>> 3.14159.hex() '0x1.921f9f01b866ep+1'
- y.datatypes.Address
A union of types used to represent Ethereum addresses.
Examples
>>> address_str = "0x1234567890abcdef1234567890abcdef12345678" >>> address_hex = HexBytes("0x1234567890abcdef1234567890abcdef12345678") >>> address_any = AnyAddress("0x1234567890abcdef1234567890abcdef12345678") >>> address_eth = EthAddress("0x1234567890abcdef1234567890abcdef12345678")
alias of
str|HexBytes|AnyAddress|Address|EthAddress
- y.datatypes.AddressOrContract
A type alias representing either an Ethereum address or a contract object. This can be an
Address, aContract, or its subclasses such asContractandContract.Examples
>>> address = "0x1234567890abcdef1234567890abcdef12345678" >>> contract = Contract.from_abi("MyContract", address, abi)
alias of
str|HexBytes|AnyAddress|Address|EthAddress|Contract
- y.datatypes.AnyAddressType
A type alias representing any valid representation of an Ethereum address. This can be an
Address, aContract, or an integer.Examples
>>> any_address_str = "0x1234567890abcdef1234567890abcdef12345678" >>> any_address_contract = Contract.from_abi("MyContract", any_address_str, abi) >>> any_address_int = 12345678
alias of
str|HexBytes|AnyAddress|Address|EthAddress|Contract|int
- y.datatypes.Block
A union of types used to represent block numbers as integers.
Examples
>>> block_int = 12345678 >>> block_number = BlockNumber(12345678)
alias of
int|BlockNumber
- y.datatypes.Pool
A union of types representing liquidity pools.
Examples
>>> uniswap_pool = UniswapV2Pool("0xUniswapPoolAddress") >>> curve_pool = CurvePool("0xCurvePoolAddress")
See also
UniswapV2PoolCurvePool
alias of
UniswapV2Pool|CurvePool|BalancerV2Pool
y.exceptions module
- exception y.exceptions.CallReverted
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.CalldataPreparationError
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.CantFetchParam
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.CantFindSwapPath
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.ContractNotVerified
Bases:
_ExplorerError- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.InvalidAPIKeyError
Bases:
_ExplorerError- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.MessedUpBrownieContract
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.NoProxyImplementation
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.NodeNotSynced
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.NonStandardERC20
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.NotABalancerV2Pool
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.NotAUniswapV2Pool
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.PriceError
Bases:
Exception- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.TokenError
Bases:
ValueError- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.TokenNotFound
Bases:
ValueError- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.UnsupportedNetwork
Bases:
ValueError- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- exception y.exceptions.yPriceMagicError
Bases:
ValueError- __getstate__()
Helper for pickle.
- add_note()
Exception.add_note(note) – add a note to the exception
- __mypyc_attrs__ = ('__dict__',)
- y.exceptions.call_reverted(e)
- y.exceptions.continue_if_call_reverted(e)
- y.exceptions.contract_not_verified(e)
- y.exceptions.out_of_gas(e)
- y.exceptions.reraise_excs_with_extra_context(*extra_context, after=True)
y.monkey_patches module
- y.monkey_patches.monkey_patch_checksum_cache()[source]
Monkey patch dependency checksums with faster versions.
This function replaces the default checksumming functions in various libraries with a faster implementation using to_address. This improves performance by utilizing caching and optimized checksumming.
See also
to_address()for the checksumming process.
y.networks module
- class y.networks.Network
Bases:
IntEnummypyc filler docstring
- classmethod __contains__(value)
Return True if value is in cls.
value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members. 3) value is a pseudo-member (flags)
- classmethod __getitem__(name)
Return the member matching name.
- classmethod __iter__()
Return members in definition order.
- classmethod __len__()
Return the number of members (no aliases)
- classmethod from_bytes(bytes, byteorder='big', *, signed=False)
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- __add__(value, /)
Return self+value.
- __and__(value, /)
Return self&value.
- __bool__()
True if self else False
- __dir__()
Returns public methods and other interesting attributes.
- __eq__(value, /)
Return self==value.
- __floordiv__(value, /)
Return self//value.
- __ge__(value, /)
Return self>=value.
- __getattribute__(name, /)
Return getattr(self, name).
- __gt__(value, /)
Return self>value.
- __index__()
Return self converted to an integer, if self is suitable for use as an index into a list.
- __init__(*args, **kwds)
- __invert__()
~self
- __le__(value, /)
Return self<=value.
- __lshift__(value, /)
Return self<<value.
- __lt__(value, /)
Return self<value.
- __mul__(value, /)
Return self*value.
- __or__(value, /)
Return self|value.
- __pow__(value, mod=None, /)
Return pow(self, value, mod).
- __radd__(value, /)
Return value+self.
- __rand__(value, /)
Return value&self.
- __reduce_ex__(proto)
Helper for pickle.
- __rlshift__(value, /)
Return value<<self.
- __ror__(value, /)
Return value|self.
- __rrshift__(value, /)
Return value>>self.
- __rshift__(value, /)
Return self>>value.
- __rxor__(value, /)
Return value^self.
- __sizeof__()
Returns size in memory, in bytes.
- __str__()
Return repr(self).
- __sub__(value, /)
Return self-value.
- __truediv__(value, /)
Return self/value.
- __xor__(value, /)
Return self^value.
- to_bytes(length=1, byteorder='big', *, signed=False)
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- __final__ = True
- __members__ = mappingproxy({'Mainnet': <Network.Mainnet: 1>, 'Optimism': <Network.Optimism: 10>, 'Cronos': <Network.Cronos: 25>, 'BinanceSmartChain': <Network.BinanceSmartChain: 56>, 'OKEx': <Network.OKEx: 66>, 'Gnosis': <Network.Gnosis: 100>, 'xDai': <Network.Gnosis: 100>, 'Heco': <Network.Heco: 128>, 'Polygon': <Network.Polygon: 137>, 'Fantom': <Network.Fantom: 250>, 'Moonriver': <Network.Moonriver: 1285>, 'Base': <Network.Base: 8453>, 'Arbitrum': <Network.Arbitrum: 42161>, 'Avalanche': <Network.Avalanche: 43114>, 'Harmony': <Network.Harmony: 1666600000>, 'Aurora': <Network.Aurora: 1313161554>, 'Katana': <Network.Katana: 747474>, 'Berachain': <Network.Berachain: 80094>})
- __name__ = 'Network'
- __qualname__ = 'Network'
- denominator
the denominator of a rational number in lowest terms
- label
- name
- numerator
the numerator of a rational number in lowest terms
- printable
y.time module
- final exception y.time.NoBlockFound[source]
Bases:
ExceptionRaised when no block is found for a specified timestamp because the timestamp is in the future.
- Parameters:
timestamp – The timestamp for which no block was found.
- add_note()
Exception.add_note(note) – add a note to the exception
- __final__ = True
- y.time.check_node()[source]
Check if the Ethereum node is synced.
- Raises:
y.exceptions.NodeNotSynced – If the node is not synced.
- Return type:
None
Examples
>>> check_node()
- y.time.closest_block_after_timestamp(timestamp, wait_for_block_if_needed=False)[source]
Get the closest block after a given timestamp.
- Parameters:
- Returns:
The block number closest after the given timestamp.
- Raises:
NoBlockFound – If no block is found after the timestamp.
- Return type:
Example
>>> closest_block_after_timestamp(1672531199) 12345678
See also
get_block_at_timestamp()get_block_timestamp()