UniswapV3LivePricing#

tradeexecutor.ethereum.uniswap_v3_live_pricing.UniswapV3LivePricing Python class in Trading Strategy framework.

class UniswapV3LivePricing[source]#

Bases: EthereumPricingModel

Always pull the latest dollar price for an asset from Uniswap v3 deployment.

Supports

  • Two-way BUSD -> Cake

  • Three-way trades BUSD -> BNB -> Cake

… within a single, uniswap v3 like exchange.

Note

If a trade quantity/currency amount is not given uses a “default small value” that is 0.1. Depending on the token, this value might be too much/too little, as Uniswap fixed point math starts to break for very small amounts. For example, for USDC trade 10 cents is already quite low.

More information

__init__(web3, pair_universe, routing_model, very_small_amount=Decimal('0.10'))[source]#
Parameters:

Methods

__init__(web3, pair_universe, routing_model)

check_supported_quote_token(pair)

get_buy_price(ts, pair, reserve)

Get live price on Uniswap.

get_mid_price(ts, pair)

Get the mid price from Uniswap pool.

get_pair_fee(ts, pair)

Estimate the trading/LP fees for a trading pair.

get_pair_fee_multiplier(ts, pair)

Uniswap V3 pairs get fees in raw format e.g.

get_pair_for_id(internal_id)

Look up a trading pair.

get_price_helper(target_pair)

get_sell_price(ts, pair, quantity)

Get live price on Uniswap.

get_uniswap(target_pair)

Helper function to speed up Uniswap v3 deployment resolution.

quantize_base_quantity(pair, quantity[, ...])

Convert any base token quantity to the native token units by its ERC-20 decimals.

__init__(web3, pair_universe, routing_model, very_small_amount=Decimal('0.10'))[source]#
Parameters:
get_pair_fee_multiplier(ts, pair)[source]#

Uniswap V3 pairs get fees in raw format e.g. 3000 instead of 0.3%

get_uniswap(target_pair)[source]#

Helper function to speed up Uniswap v3 deployment resolution.

Parameters:

target_pair (TradingPairIdentifier) –

Return type:

UniswapV3Deployment

get_sell_price(ts, pair, quantity)[source]#

Get live price on Uniswap.

Parameters:
Return type:

float

get_buy_price(ts, pair, reserve)[source]#

Get live price on Uniswap.

Parameters:
Returns:

Price for one reserve unit e.g. a dollar

Return type:

float