UniswapV2Router02Quoter

Documentation for eth_defi.vault.valuation.UniswapV2Router02Quoter Python class.

class UniswapV2Router02Quoter[source]

Handle Uniswap v2 quoters using Router02 contract.

Attributes summary

dex_hint

signature_string

Quoter signature string for Multicall lib.

Methods summary

__init__(swap_router_v2[, debug])

create_multicall_wrapper(route, amount_in)

format_path(route)

Get human-readable route path line.

generate_routes(source_token, target_token, ...)

Create routes we need to test on Uniswap v2

get_path_combinations(source_token, ...)

Generate Uniswap v2 swap paths with all supported intermediate tokens

handle_onchain_return_value(wrapper, ...)

Convert getAmountsOut() return value to tokens we receive

signature_string = 'getAmountsOut(uint256,address[])(uint256[])'

Quoter signature string for Multicall lib.

Not the standard string signature format, because Multicall lib wants it special output format suffix here

__init__(swap_router_v2, debug=False)[source]
Parameters
  • swap_router_v2 (web3.contract.contract.Contract) –

  • debug (bool) –

generate_routes(source_token, target_token, intermediate_tokens, amount, debug)[source]

Create routes we need to test on Uniswap v2

Parameters
Return type

Iterable[eth_defi.vault.valuation.Route]

handle_onchain_return_value(wrapper, raw_return_value)[source]

Convert getAmountsOut() return value to tokens we receive

Parameters
Return type

decimal.Decimal | None

get_path_combinations(source_token, target_token, intermediate_tokens)[source]

Generate Uniswap v2 swap paths with all supported intermediate tokens

Parameters
Return type

Iterable[list[eth_defi.token.TokenDetails]]

format_path(route)[source]

Get human-readable route path line.

Return type

str