UniswapV2Router02Quoter
Documentation for eth_defi.vault.valuation.UniswapV2Router02Quoter Python class.
- class UniswapV2Router02Quoter[source]
Handle Uniswap v2 quoters using Router02 contract.
https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#getamountsout
https://basescan.org/address/0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24#readContract
Attributes summary
dex_hint
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
source_token (eth_defi.token.TokenDetails) –
target_token (eth_defi.token.TokenDetails) –
intermediate_tokens (set[eth_defi.token.TokenDetails]) –
amount (decimal.Decimal) –
debug (bool) –
- Return type
- handle_onchain_return_value(wrapper, raw_return_value)[source]
Convert getAmountsOut() return value to tokens we receive
- Parameters
wrapper (eth_defi.vault.valuation.ValuationMulticallWrapper) –
raw_return_value (bytes) –
- 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
source_token (eth_defi.token.TokenDetails) –
target_token (eth_defi.token.TokenDetails) –
intermediate_tokens (set[eth_defi.token.TokenDetails]) –
- Return type