TradeSuccess
Documentation for eth_defi.trade.TradeSuccess Python class.
- class TradeSuccess
Bases:
eth_defi.trade.TradeResultDescribe the result of a successful Uniswap swap.
See
eth_defi.uniswap_v2.analysis.analyse_trade_by_receipt()Attributes summary
Did we use a third party intent service for this swap.
Did we generate some excessive transfer events during the swap.
For Uniswap v2 swaps were token tax applies.
Routing path that was used for this trade.
How much token swas swapped from
What was the expected minimum output with slippage tolerance
What was the actual output
The price of the trade in some order.
Token information bookkeeping
Token information bookkeeping
Uniswap v3 pool token 0
Uniswap v3 pool token 1
How much was the LP fee
Methods summary
__init__(gas_used, effective_gas_price, ...)This will return the gas cost of the transaction in blockchain's native currency e.g.
get_effective_gas_price_gwei()get_human_price([reverse_token_order])Get the executed price of this trade in a human-readable form.
get_tax()Get Uniswap v2 style token tax.
- path: Optional[List[eth_typing.evm.HexAddress]]
Routing path that was used for this trade.
Should be lowercased.
- amount_in: int
How much token swas swapped from
- amount_out: int
What was the actual output
- price: decimal.Decimal
The price of the trade in some order.
Uniswap v2: Overall price paid as in token (first in the path) to out token (last in the path).
Uniswap v3: depends on ticks and order of token0 and token1 in the underlying pool smart contract
Price includes any fees paid during the order routing path.
Note that you get inverse price, if you route ETH-USD or USD-ETH e.g. are you doing buy or sell.
See also
get_human_price()
- amount_in_decimals: int
Token information bookkeeping
- amount_out_decimals: int
Token information bookkeeping
- token0: eth_defi.token.TokenDetails | None
Uniswap v3 pool token 0
Needed to calculate reverse token order.
- token1: eth_defi.token.TokenDetails | None
Uniswap v3 pool token 1
Needed to calculate reverse token order.
- lp_fee_paid: float | None
How much was the LP fee
Note: this is the raw amount in terms of the amount in token
- intent_based: bool | None = None
Did we use a third party intent service for this swap.
E.g. Enso.
We might not be analyse fees and path directly.
- untaxed_amount_out: int | None = None
For Uniswap v2 swaps were token tax applies.
Set to
Noneif could not be determined.
- transfer_event_count: int = 0
Did we generate some excessive transfer events during the swap.
Usually a sign of some rigging mechanism.
- get_human_price(reverse_token_order=False)
Get the executed price of this trade in a human-readable form.
This depends on:
If we are on Uniswap v2 or v3
If we do buy or sell
If quote token is token0 or token1 in Uniswap v3 pool
Example:
# TODO pass
- Parameters
reverse_token_order –
Base and quote token order.
Quote token should be natural quote token like USD or ETH based token of the trade. If reverse_token_order is set quote token is token0 of the pool, otherwise token1.
- Return type
- get_tax()
Get Uniswap v2 style token tax.
- Returns
Tax in bps. Always negative.
0 if no tax.
None if could not determined.
- Return type
float | None
- __init__(gas_used, effective_gas_price, path, amount_in, amount_out_min, amount_out, price, amount_in_decimals, amount_out_decimals, token0, token1, lp_fee_paid, intent_based=None, untaxed_amount_out=None, transfer_event_count=0)
- Parameters
gas_used (int) –
effective_gas_price (int) –
path (Optional[List[eth_typing.evm.HexAddress]]) –
amount_in (int) –
amount_out_min (int | None) –
amount_out (int) –
price (decimal.Decimal) –
amount_in_decimals (int) –
amount_out_decimals (int) –
token0 (eth_defi.token.TokenDetails | None) –
token1 (eth_defi.token.TokenDetails | None) –
lp_fee_paid (float | None) –
intent_based (bool | None) –
untaxed_amount_out (int | None) –
transfer_event_count (int) –
- Return type
None
- get_cost_of_gas()
This will return the gas cost of the transaction in blockchain’s native currency e.g. in ETH on Ethereum.
- Return type