Step1 - Calculate σx FT according to σLx lpFT and σy XT according to σLy lpXT
σx=σLx×SLxRx
σy=σLy×SLyRy
Step2 - Calculate σu UT to withdraw according to σx FT and σy XT
According to Eq.C2, εσu FT and σu XT can be combined into σu UT.
If εσy>σx,
Step2 - Calculate new price
The liquidity impact of withdrawing FT from the pool (Fig.2) is equivalent to the liquidity impact of following two operations (Fig.3).
Sell −σx FT to the pool and get −σy XT
Combine (Δx−σx) FT and σy XT into σy UT and withdraw
The new price impact of withdrawing FT from the pool will be equivalent to the price impact of the two operations as well. In addition, the price of pool remains the same when UT is provided or withdrawn from the pool by definition. Therefore, the price impact of withdrawing FT from the pool will be equivalent to the price impact of Sell −σx FT to the pool and get −σy XT.
LO2 - Withdraw XT
Withdraw δLy lpXT to Δy XT
Step1 - Calculate Δy XT according to δLy lpXT and contract state
Δy=δLy×SLyRy
Step2 - Calculate new price
The liquidity impact of withdrawing XT from the pool is equivalent to the liquidity impact of following two operations.
Sell −σy XT to the pool and get −σx FT
Combine (Δy−σy) XT and σx FT into (Δy−σy) UT and withdraw
The new price impact of withdrawing FT from the pool will be equivalent to the price impact of the two operations as well. In addition, the price of pool remains the same when UT is provided or withdrawn from the pool by definition. Therefore, the price impact of withdrawing FT from the pool will be equivalent to the price impact of Sell −σy XT to the pool and get −σx FT.