UniswapV2FeeCalculator
Documentation for eth_defi.uniswap_v2.fees.UniswapV2FeeCalculator Python class.
- class UniswapV2FeeCalculator[source]
A helper class to estimate Uniswap fees.
Methods summary
__init__
(uniswap_v2)get_amount_in
(amount_out, path, *[, fee, ...])Get how much token we are going to spend.
get_amount_in_from_reserves
(amount_out, ...)Returns the minimum input asset amount required to buy the given output asset amount (accounting for fees) given reserves.
get_amount_out
(amount_in, path, *[, fee, ...])Get how much token we are going to receive.
get_amount_out_from_reserves
(amount_in, ...)Given an input asset amount, returns the maximum output amount of the other asset (accounting for fees) given reserves.
get_reserves
(token_a, token_b)Gets the reserves of token_0 and token_1 used to price trades and distribute liquidity as well as the timestamp of the last block during which an interaction occurred for the pair.
- __init__(uniswap_v2)[source]
- Parameters
uniswap_v2 (eth_defi.uniswap_v2.deployment.UniswapV2Deployment) –
- get_reserves(token_a, token_b)[source]
Gets the reserves of token_0 and token_1 used to price trades and distribute liquidity as well as the timestamp of the last block during which an interaction occurred for the pair.
- Parameters
pair – Address of the pair.
token_a (eth_typing.evm.HexAddress) –
token_b (eth_typing.evm.HexAddress) –
- Returns
reserve_0 - Amount of token_0 in the contract.
reserve_1 - Amount of token_1 in the contract.
liquidity - Unix timestamp of the block containing the last pair interaction.
- Return type
- get_amount_out(amount_in, path, *, fee=30, slippage=0)[source]
Get how much token we are going to receive.
- get_amount_in(amount_out, path, *, fee=30, slippage=0)[source]
Get how much token we are going to spend.
- static get_amount_in_from_reserves(amount_out, reserve_in, reserve_out, *, fee=30)[source]
Returns the minimum input asset amount required to buy the given output asset amount (accounting for fees) given reserves.
- Parameters
- Returns
Required amount of input asset.
- Return type