estimate_xyk_price_impact#

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:

https://help.sushidocs.com/products/sushiswap-exchange

https://ethereum.stackexchange.com/a/111334/620

https://dailydefi.org/articles/price-impact-and-how-to-calculate/

https://ethereum.stackexchange.com/a/111334/620

TODO: Check that calculations are consistent with SushiSwap.

Parameters
  • 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

PriceImpact