analyse_trade_by_hash

Documentation for eth_defi.uniswap_v2.analysis.analyse_trade_by_hash function.

analyse_trade_by_hash(web3, uniswap, tx_hash)[source]

Analyse details of a Uniswap trade based on a transaction id.

Analyses trade fees, etc. based on the event signatures in the transaction. Works only simp;e trades.

Currently only supports simple analysis where there is one input token and one output token.

Example:

analysis = analyse_trade(web3, uniswap_v2, tx_hash)
assert isinstance(analysis, TradeSuccess)  # Trade was successful
assert analysis.price == pytest.approx(Decimal('1744.899124998896692270848706'))  # ETC/USDC price
assert analysis.get_effective_gas_price_gwei() == 1  # What gas was paid for this price

Note

This code is still much under development and unlikely to support any advanced use cases yet.

Parameters
Returns

TradeSuccess or TradeFail instance

Return type

Union[eth_defi.uniswap_v2.analysis.TradeSuccess, eth_defi.uniswap_v2.analysis.TradeFail]