PairDetails

Documentation for eth_defi.uniswap_v2.pair.PairDetails Python class.

class PairDetails[source]

Uniswap v2 trading pair info.

Attributes summary

contract

Pool contract

token0

One pair of tokens

token1

One pair of tokens

reverse_token_order

Store the human readable token order on this data.

address

Get pair contract address

checksum_free_address

Get pair contract address, all lowercase.

Methods summary

__init__(contract, token0, token1[, ...])

convert_price_to_human(reserve0, reserve1[, ...])

Convert the price obtained through Sync event

get_base_token()

Get human-ordered base token.

get_current_mid_price()

Return the price in this pool.

get_quote_token()

Get human-ordered quote token.

contract: web3.contract.contract.Contract

Pool contract

https://docs.uniswap.org/contracts/v2/reference/smart-contracts/pair#getreserves

token0: eth_defi.token.TokenDetails

One pair of tokens

token1: eth_defi.token.TokenDetails

One pair of tokens

reverse_token_order: Optional[bool]

Store the human readable token order on this data.

If false then pair reads as token0 symbol (WETH) - token1 symbol (USDC).

If true then pair reads as token1 symbol (USDC) - token0 symbol (WETH).

property address: eth_typing.evm.HexAddress

Get pair contract address

property checksum_free_address: str

Get pair contract address, all lowercase.

get_base_token()[source]

Get human-ordered base token.

get_quote_token()[source]

Get human-ordered quote token.

convert_price_to_human(reserve0, reserve1, reverse_token_order=None)[source]

Convert the price obtained through Sync event

Parameters
  • reverse_token_order

    Decide token order for human (base, quote token) order. If set, assume quote token is token0.

    IF set to None, use value from the data.

  • reserve0 (int) –

  • reserve1 (int) –

get_current_mid_price()[source]

Return the price in this pool.

Calls getReserves() over JSON-RPC and calculate the current price basede on the pair reserves.

See https://docs.uniswap.org/contracts/v2/reference/smart-contracts/pair#getreserves

Returns

Quote token / base token price in human digestible form

Return type

decimal.Decimal

__init__(contract, token0, token1, reverse_token_order=None)
Parameters
Return type

None