Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 14 commits into from
Dec 11, 2023
Merged

Conversation

Senna46
Copy link
Contributor

@Senna46 Senna46 commented Dec 8, 2023

Change AMM code & Impl test

  • Added error when StartTime is less than block time
  • Added error handling for AMM functions
    k = x1^(1-t) + y1^(1-t)
    If x2 is too large x2^(1-t) > k, so y2^(1-t) become < 0.
    Then y2 = y2^(1-t)^(1/(1-t)) cannot be calculated.

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
Copy link
Contributor Author

Senna46 commented Dec 11, 2023

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)

@Senna46 Senna46 changed the title Add test & fix feat: AMM, Swap fix and test & impl SwapUtToYt Dec 11, 2023
@Senna46 Senna46 merged commit 637f9cf into irs_module Dec 11, 2023
1 of 2 checks passed
@Senna46 Senna46 deleted the types_test branch December 11, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants