UniswapV3LivePricing#

API documentation for tradeexecutor.ethereum.uniswap_v3.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'), epsilon=0.001)[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)

Outdated: 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.

set_trading_fee_override(trading_fee_override)

Set the trading fee override.

validate_mid_price_for_buy(lp_fee, price, ...)

Validate the mid price calculation for a buy trade.

validate_mid_price_for_sell(lp_fee, ...)

Validate the mid price calculation for a sell trade.

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

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

Now, all pairs are already in multiplier format, so no changes necessary.

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:

TradePricing

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:

TradePricing