uniswap_v3.analysis

Documentation for eth_defi.uniswap_v3.analysis Python module.

Functions

analyse_trade_by_receipt(web3, uniswap, tx, ...)

Analyse a Uniswpa v3 trade.

get_input_args(params)

Names and decodes input arguments from router.decode_function_input()

get_input_args(params)

Names and decodes input arguments from router.decode_function_input()

Note there is no support yet for SwapRouter02, it does not accept a deadline parameter. See: https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISwapRouter#exactinputparams

Example struct:

struct ExactInputParams {
    bytes path;
    address recipient;
    uint256 amountIn;
    uint256 amountOutMinimum;
}
Parameters

params (tuple | dict) – params from router.decode_function_input

Returns

Dict of exactInputParams as specified in the link above

Return type

dict

analyse_trade_by_receipt(web3, uniswap, tx, tx_hash, tx_receipt, input_args=None)

Analyse a Uniswpa v3 trade.

Figure out

  • The success of the trade

  • Slippage, etc.

Warning

Do not use TradeSuccess.price directly, as this price depends on in which order token0 and token1 are in the pool smart contract. Use TradeSuccess.get_human_price() instead.

Parameters
  • tx_receipt (dict) – Transaction receipt

  • input_args (tuple | None) –

    The swap input arguments.

    If not given automatically decode from tx. You need to pass this for Enzyme transactions, because transaction payload is too complex to decode.

  • web3 (web3.main.Web3) –

  • uniswap (eth_defi.uniswap_v3.deployment.UniswapV3Deployment) –

  • tx (dict) –

  • tx_hash (str | bytes) –

Return type

eth_defi.trade.TradeSuccess | eth_defi.trade.TradeFail