Liquidity Operations (L)

LO1 - Provide Liquidity

When users provide liquidity on TermMax, they will deposit Underlying Token (UT) into the pool and mint the Liquidity Provider (LP) tokens (lpFT and lpXT). There are three internal steps: (1) deposit UT, (2) mint FT and XT to the pool, and (3) mint lpFT and lpXT to users' wallet. The number of FT/XT and lpFT/lpXT can be derived based on the amount of UT and LTV ratio of the pool.

If a user provides δu\delta_u UT as liquidity and the LTV ratio of the pool is ε\varepsilon, the amount of FT (δx\delta_x), XT (δy\delta_y), lpFT (δLx\delta_{\mathscr{L_x}}), and lpXT (δLy\delta_{\mathscr{L_y}}) can be derived as

δx=εδu (Eq.L-1)\delta_{x} = \varepsilon\delta_u \text{ (Eq.L-1)}
δy=δu (Eq.L-2)\delta_{y}=\delta_u \text{ (Eq.L-2)}
δLx=δx×SLxRx (Eq.L-3)whereRx:=FT token reserve of the marketSLx:=total supploy of lpFT token \delta_{\mathscr{L_x}}=\delta_{x} \times \frac{S_{\mathscr{L_x}}}{R_{x}} \text{ (Eq.L-3)}\\ \text{where} \\ R_{x} := \text{FT token reserve of the market} \\ S_{\mathscr{L_x}} := \text{total supploy of lpFT token}
δLy=δy×SLyRy (Eq.L-4)whereRy:=XT token reserve of the marketSLy:=total supploy of lpXT token \delta_{\mathscr{L_y}}=\delta_{y} \times \frac{S_{\mathscr{L_y}}}{R_{y}} \text{ (Eq.L-4)}\\ \text{where} \\ R_{y} := \text{XT token reserve of the market} \\ S_{\mathscr{L_y}} := \text{total supploy of lpXT token}

LO2 - Withdraw Liquidity

Withdraw σLx\sigma_{\mathscr{L}_x} lpFT and σLy\sigma_{\mathscr{L_y}} lpXt to λu\lambda_u UT

Step1 - Calculate σx\sigma_x FT according to σLx\sigma_{\mathscr{L}_x} lpFT and σy\sigma_y XT according to σLy\sigma_{\mathscr{L_y}} lpXT

σx=σLx×RxSLx\sigma_x=\sigma_{\mathscr{L}_x} \times \frac{R_x}{S_{\mathscr{L}_x}}
σy=σLy×RySLy\sigma_y=\sigma_{\mathscr{L}_y} \times \frac{R_y}{S_{\mathscr{L}_y}}

Step2 - Withdraw σx\sigma_x FT and σy\sigma_y XT from the pool

According to Eq.C-2\text{Eq.C-2}, εσu\varepsilon \sigma_u FT and σu\sigma_u XT can be combined into σu\sigma_u UT.

When the withdrawal amount of FT and XT equals to ε:1\varepsilon:1, there will be no price impact to the pool. Therefore, to minimize the impermanent loss when withdrawing the liquidity, we first combine FT and XT with ratio ε:1\varepsilon:1 and withdraw the remaining FT or XT from the pool for UT.

Step3 - Withdraw remaining FT or XT from the pool for UT

The liquidity impact of withdrawing FT from the pool (Fig.F-1\text{Fig.F-1}) is equivalent to the liquidity impact of the following two operations (Fig.F-2\text{Fig.F-2}).

  1. Sell δx-\delta_x FT to the pool and get δy-\delta_y XT

  2. Combine (Δxδx)(\Delta_x-\delta_x) FT and δy\delta_y XT into δy\delta_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. By definition, the price of the pool remains the same when UT is provided or withdrawn from the pool. Therefore, the price impact of withdrawing FT from the pool will be equivalent to the price impact of Sell δx-\delta_x FT to the pool and get δy-\delta_y XT.

Last updated