UnUniFi / chain

GNU General Public License v3.0
35 stars 14 forks source link

Support Earn Liquidity Pool #729

Open Senna46 opened 5 months ago

Senna46 commented 5 months ago

The current IRS backend is NOT able to support the Liquidity Pool of Earn

TODO implements the following logic

Deposit (Earn)

Estimate

The calculations are quite difficult and may not be realized.

  1. Calculate how many PTs should be swaped from inputUT (backend)
  2. Calculate and return the number of LPs that can be issued with the swaped PT and remaining UT (backend)

Tx

If the query is realized, it can be created.

  1. Calculate 1 in Estimate again to find the number of UTs to be converted.
  2. Execute SwapInPool and swap to PT.
  3. Use remaining UT & swapped PT to DepositToPool

Withdraw (Earn)

Estimate

not difficult

  1. Get LP => UT & PT (Existing querie)
  2. Get PT => UT (Existing querie)
  3. Display 1 + 2 UT value

Tx

With the current implementation, it needs two Tx's and the frontend cannot support it considering the waiting time for the first Tx. We should create a Msg that combines the two Tx.

  1. LP => UT & PT
  2. PT => UT