UnUniFi / chain

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

feat: AMM, Swap fix and test & impl SwapUtToYt #714

Closed Senna46 closed 9 months ago

Senna46 commented 9 months ago

Change AMM code & Impl test

Therefore, return value should be 0 or y1(all amount in pool). Current returns 0 (= error), but you may verify that you can give y1 and set y in the pool to 0.

I think error return is a safe now.

Senna46 commented 9 months ago

swap_advanced SwapUtToYt Spec

check if TokenIn is enough to cover to payback loan (Swap 4.)

  1. check deposit denom = pool strategy denom
  2. estimate Pt amount to mint
  3. estimate Ut amount to get by selling Pt
  4. estimated Ut + TokenIn is enough to payback loan

Swap

  1. Take loan (Ut) from IRS vault account (pool => sender)
  2. Mint Pt and Yt
  3. Sell minted PT amount for underlying token
  4. Payback loan (Ut)