API documentation for tradingstrategy.priceimpact.estimate_xyk_price_impact Python function.

estimate_xyk_price_impact(liquidity, trade_amount, lp_fee, protocol_fee)[source]#

Calculates XY liquidity model slippage.

Works for all Uniswap v2 style DEXes.

For us, price impacts are easier because we operate solely in the US dollar space.

Some price impact calculation examples to study:

TODO: Check that calculations are consistent with SushiSwap.

  • liquidity (float) – Liquidity expressed as USD XY liquidity model single side liquidity.

  • trade_amount (float) – How much buy/sell you are doing

  • lp_fee (float) – Liquidity provider fee set for the pool as %. E.g. 0.0035 for Sushi.

  • protocol_fee (float) – Fees paid to the protocol, e.g. xSushi stakers

Return type: