y package

Subpackages

Submodules

y.ENVIRONMENT_VARIABLES module

y.constants module

y.contracts module

y.convert module

y.convert.to_address(address)[source]
Parameters:

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

Return type:

str

y.datatypes module

class y.datatypes.UsdPrice[source]

Bases: UsdValue

__abs__()

abs(self)

__add__(value, /)

Return self+value.

__bool__()

True if self else False

__ceil__()

Return the ceiling as an Integral.

__divmod__(value, /)

Return divmod(self, value).

__eq__(value, /)

Return self==value.

__float__()

float(self)

__floor__()

Return the floor as an Integral.

__floordiv__(value, /)

Return self//value.

__format__(format_spec, /)

Formats the float according to format_spec.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getformat__()

You probably don’t want to use this function.

typestr

Must be ‘double’ or ‘float’.

It exists mainly to be used in Python’s test suite.

This function returns whichever of ‘unknown’, ‘IEEE, big-endian’ or ‘IEEE, little-endian’ best describes the format of floating point numbers used by the C type named by typestr.

__getnewargs__()
__gt__(value, /)

Return self>value.

__init__(v)[source]
Return type:

None

__int__()

int(self)

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__mod__(value, /)

Return self%value.

__mul__(value, /)

Return self*value.

__ne__(value, /)

Return self!=value.

__neg__()

-self

__new__(**kwargs)
__pos__()

+self

__pow__(value, mod=None, /)

Return pow(self, value, mod).

__radd__(value, /)

Return value+self.

__rdivmod__(value, /)

Return divmod(value, self).

__rfloordiv__(value, /)

Return value//self.

__rmod__(value, /)

Return value%self.

__rmul__(value, /)

Return value*self.

__round__(ndigits=None, /)

Return the Integral closest to x, rounding half toward even.

When an argument is passed, work like built-in round(x, ndigits).

__rpow__(value, mod=None, /)

Return pow(value, self, mod).

__rsub__(value, /)

Return value-self.

__rtruediv__(value, /)

Return value/self.

__setformat__(fmt, /)

You probably don’t want to use this function.

typestr

Must be ‘double’ or ‘float’.

fmt

Must be one of ‘unknown’, ‘IEEE, big-endian’ or ‘IEEE, little-endian’, and in addition can only be one of the latter two if it appears to match the underlying C reality.

It exists mainly to be used in Python’s test suite.

Override the automatic determination of C-level floating point type. This affects how floats are converted to and from binary strings.

__str__()

Return str(self).

Return type:

str

__sub__(value, /)

Return self-value.

__truediv__(value, /)

Return self/value.

__trunc__()

Return the Integral closest to x between 0 and x.

as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original float and with a positive denominator.

Raise OverflowError on infinities and a ValueError on NaNs.

>>> (10.0).as_integer_ratio()
(10, 1)
>>> (0.0).as_integer_ratio()
(0, 1)
>>> (-.25).as_integer_ratio()
(-1, 4)
conjugate()

Return self, the complex conjugate of any float.

fromhex()

Create a floating-point number from a hexadecimal string.

>>> float.fromhex('0x1.ffffp10')
2047.984375
>>> float.fromhex('-0x1p-1074')
-5e-324
hex()

Return a hexadecimal representation of a floating-point number.

>>> (-0.1).hex()
'-0x1.999999999999ap-4'
>>> 3.14159.hex()
'0x1.921f9f01b866ep+1'
is_integer()

Return True if the float is an integer.

imag

the imaginary part of a complex number

real

the real part of a complex number

class y.datatypes.UsdValue[source]

Bases: float

__abs__()

abs(self)

__add__(value, /)

Return self+value.

__bool__()

True if self else False

__ceil__()

Return the ceiling as an Integral.

__divmod__(value, /)

Return divmod(self, value).

__eq__(value, /)

Return self==value.

__float__()

float(self)

__floor__()

Return the floor as an Integral.

__floordiv__(value, /)

Return self//value.

__format__(format_spec, /)

Formats the float according to format_spec.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getformat__()

You probably don’t want to use this function.

typestr

Must be ‘double’ or ‘float’.

It exists mainly to be used in Python’s test suite.

This function returns whichever of ‘unknown’, ‘IEEE, big-endian’ or ‘IEEE, little-endian’ best describes the format of floating point numbers used by the C type named by typestr.

__getnewargs__()
__gt__(value, /)

Return self>value.

__init__(v)[source]
Return type:

None

__int__()

int(self)

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__mod__(value, /)

Return self%value.

__mul__(value, /)

Return self*value.

__ne__(value, /)

Return self!=value.

__neg__()

-self

__new__(**kwargs)
__pos__()

+self

__pow__(value, mod=None, /)

Return pow(self, value, mod).

__radd__(value, /)

Return value+self.

__rdivmod__(value, /)

Return divmod(value, self).

__rfloordiv__(value, /)

Return value//self.

__rmod__(value, /)

Return value%self.

__rmul__(value, /)

Return value*self.

__round__(ndigits=None, /)

Return the Integral closest to x, rounding half toward even.

When an argument is passed, work like built-in round(x, ndigits).

__rpow__(value, mod=None, /)

Return pow(value, self, mod).

__rsub__(value, /)

Return value-self.

__rtruediv__(value, /)

Return value/self.

__setformat__(fmt, /)

You probably don’t want to use this function.

typestr

Must be ‘double’ or ‘float’.

fmt

Must be one of ‘unknown’, ‘IEEE, big-endian’ or ‘IEEE, little-endian’, and in addition can only be one of the latter two if it appears to match the underlying C reality.

It exists mainly to be used in Python’s test suite.

Override the automatic determination of C-level floating point type. This affects how floats are converted to and from binary strings.

__str__()[source]

Return str(self).

Return type:

str

__sub__(value, /)

Return self-value.

__truediv__(value, /)

Return self/value.

__trunc__()

Return the Integral closest to x between 0 and x.

as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original float and with a positive denominator.

Raise OverflowError on infinities and a ValueError on NaNs.

>>> (10.0).as_integer_ratio()
(10, 1)
>>> (0.0).as_integer_ratio()
(0, 1)
>>> (-.25).as_integer_ratio()
(-1, 4)
conjugate()

Return self, the complex conjugate of any float.

fromhex()

Create a floating-point number from a hexadecimal string.

>>> float.fromhex('0x1.ffffp10')
2047.984375
>>> float.fromhex('-0x1p-1074')
-5e-324
hex()

Return a hexadecimal representation of a floating-point number.

>>> (-0.1).hex()
'-0x1.999999999999ap-4'
>>> 3.14159.hex()
'0x1.921f9f01b866ep+1'
is_integer()

Return True if the float is an integer.

imag

the imaginary part of a complex number

real

the real part of a complex number

y.erc20 module

y.exceptions module

exception y.exceptions.CallReverted[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.CalldataPreparationError[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.CantFetchParam[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.CantFindSwapPath[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.ContractNotVerified[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.MessedUpBrownieContract[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(address, *args)[source]
Parameters:

args (object)

Return type:

None

__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.NoBlockFound[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.NoProxyImplementation[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.NodeNotSynced[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.NonStandardERC20[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.NotABalancerV2Pool[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.NotAUniswapV2Pool[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(non_pool)[source]
Parameters:

non_pool (UniswapV2Pool)

__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.PriceError[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(logger, symbol)[source]
Parameters:
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.TokenNotFound[source]

Bases: ValueError

__getattribute__(name, /)

Return getattr(self, name).

__init__(token, container)[source]
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.UnsupportedNetwork[source]

Bases: Exception

__getattribute__(name, /)

Return getattr(self, name).

__init__(*args, **kwargs)
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception y.exceptions.yPriceMagicError[source]

Bases: ValueError

__getattribute__(name, /)

Return getattr(self, name).

__init__(exc, address, block, symbol)[source]
Parameters:
__new__(**kwargs)
__str__()

Return str(self).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
y.exceptions.call_reverted(e)[source]
Parameters:

e (Exception)

Return type:

bool

y.exceptions.continue_if_call_reverted(e)[source]
Parameters:

e (Exception)

Return type:

None

y.exceptions.contract_not_verified(e)[source]
Parameters:

e (Exception)

Return type:

bool

y.exceptions.out_of_gas(e)[source]
Parameters:

e (Exception)

Return type:

bool

y.networks module

class y.networks.Network[source]

Bases: IntEnum

A lightweight enum that enables lookup of popular chainids.

__abs__()

abs(self)

__add__(value, /)

Return self+value.

__and__(value, /)

Return self&value.

__bool__()

True if self else False

__ceil__()

Ceiling of an Integral returns itself.

__divmod__(value, /)

Return divmod(self, value).

__eq__(value, /)

Return self==value.

__float__()

float(self)

__floor__()

Flooring an Integral returns itself.

__floordiv__(value, /)

Return self//value.

__format__(format_spec)

Returns format using actual value type unless __str__ has been overridden.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getnewargs__()
__gt__(value, /)

Return self>value.

__index__()

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()

int(self)

__invert__()

~self

__le__(value, /)

Return self<=value.

__lshift__(value, /)

Return self<<value.

__lt__(value, /)

Return self<value.

__mod__(value, /)

Return self%value.

__mul__(value, /)

Return self*value.

__ne__(value, /)

Return self!=value.

__neg__()

-self

__new__(value)
__or__(value, /)

Return self|value.

__pos__()

+self

__pow__(value, mod=None, /)

Return pow(self, value, mod).

__radd__(value, /)

Return value+self.

__rand__(value, /)

Return value&self.

__rdivmod__(value, /)

Return divmod(value, self).

__rfloordiv__(value, /)

Return value//self.

__rlshift__(value, /)

Return value<<self.

__rmod__(value, /)

Return value%self.

__rmul__(value, /)

Return value*self.

__ror__(value, /)

Return value|self.

__round__()

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)

Return pow(value, self, mod).

__rrshift__(value, /)

Return value>>self.

__rshift__(value, /)

Return self>>value.

__rsub__(value, /)

Return value-self.

__rtruediv__(value, /)

Return value/self.

__rxor__(value, /)

Return value^self.

__sizeof__()

Returns size in memory, in bytes.

__sub__(value, /)

Return self-value.

__truediv__(value, /)

Return self/value.

__trunc__()

Truncating an Integral returns itself.

__xor__(value, /)

Return self^value.

as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

from_bytes(byteorder, *, 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.

signed

Indicates whether two’s complement is used to represent the integer.

static label(chain_id=None)[source]
Parameters:

chain_id (int | None)

Return type:

str

static name(chain_id=None)[source]
Parameters:

chain_id (int | None)

Return type:

str

static printable(chain_id=None)[source]
Parameters:

chain_id (int | None)

Return type:

str

to_bytes(length, byteorder, *, 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.

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.

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.

Arbitrum = 42161
Aurora = 1313161554
Avalanche = 43114
Base = 8453
BinanceSmartChain = 56
Cronos = 25
Fantom = 250
Gnosis = 100
Harmony = 1666600000
Heco = 128
Mainnet = 1
Moonriver = 1285
OKEx = 66
Optimism = 10
Polygon = 137
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

xDai = 100

y.time module

class y.time.UnixTimestamp[source]

Bases: int

__abs__()

abs(self)

__add__(value, /)

Return self+value.

__and__(value, /)

Return self&value.

__bool__()

True if self else False

__ceil__()

Ceiling of an Integral returns itself.

__divmod__(value, /)

Return divmod(self, value).

__eq__(value, /)

Return self==value.

__float__()

float(self)

__floor__()

Flooring an Integral returns itself.

__floordiv__(value, /)

Return self//value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getnewargs__()
__gt__(value, /)

Return self>value.

__index__()

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()

int(self)

__invert__()

~self

__le__(value, /)

Return self<=value.

__lshift__(value, /)

Return self<<value.

__lt__(value, /)

Return self<value.

__mod__(value, /)

Return self%value.

__mul__(value, /)

Return self*value.

__ne__(value, /)

Return self!=value.

__neg__()

-self

__new__(**kwargs)
__or__(value, /)

Return self|value.

__pos__()

+self

__pow__(value, mod=None, /)

Return pow(self, value, mod).

__radd__(value, /)

Return value+self.

__rand__(value, /)

Return value&self.

__rdivmod__(value, /)

Return divmod(value, self).

__rfloordiv__(value, /)

Return value//self.

__rlshift__(value, /)

Return value<<self.

__rmod__(value, /)

Return value%self.

__rmul__(value, /)

Return value*self.

__ror__(value, /)

Return value|self.

__round__()

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)

Return pow(value, self, mod).

__rrshift__(value, /)

Return value>>self.

__rshift__(value, /)

Return self>>value.

__rsub__(value, /)

Return value-self.

__rtruediv__(value, /)

Return value/self.

__rxor__(value, /)

Return value^self.

__sizeof__()

Returns size in memory, in bytes.

__sub__(value, /)

Return self-value.

__truediv__(value, /)

Return self/value.

__trunc__()

Truncating an Integral returns itself.

__xor__(value, /)

Return self^value.

as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

from_bytes(byteorder, *, 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.

signed

Indicates whether two’s complement is used to represent the integer.

to_bytes(length, byteorder, *, 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.

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.

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.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

y.time.check_node()[source]
Return type:

None

y.time.check_node_async()[source]
Return type:

None

y.time.closest_block_after_timestamp(timestamp, wait_for_block_if_needed=False)[source]
Parameters:
Return type:

int

ASyncFunctiony.time.closest_block_after_timestamp_async(timestamp: y.time.UnixTimestamp | datetime.datetime, wait_for_block_if_needed: bool = False) int[source]
Parameters:
Return type:

int

ASyncFunctiony.time.get_block_at_timestamp(timestamp: datetime.datetime) int[source]
Parameters:

timestamp (datetime)

Return type:

int

ASyncFunctiony.time.get_block_timestamp_async(height: int) int[source]
Parameters:

height (int)

Return type:

int

Module contents