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

Add fixAMMv1_3 amendment #5203

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

gregtatcam
Copy link
Collaborator

High Level Overview of Change

  • Add AMM bid/create/deposit/swap/withdraw/vote invariants:
    • Deposit, Withdrawal invariants: sqrt(asset1Balance * asset2Balance) >= LPTokens.
    • Bid: sqrt(asset1Balance * asset2Balance) > LPTokens and the pool balances don't change.
    • Create: sqrt(asset1Balance * assetBalance2) == LPTokens.
    • Swap: asset1BalanceAfter * asset2BalanceAfter >= asset1BalanceBefore * asset2BalanceBefore
      and LPTokens don't change.
    • Vote: LPTokens and pool balances don't change.
    • All AMM and swap transactions: amounts and tokens are greater than zero, except on withdrawal if all tokens
      are withdrawn.
  • Add AMM deposit and withdraw rounding to ensure AMM invariant:
    • On deposit, tokens out are rounded downward and deposit amount is rounded upward.
    • On withdrawal, tokens in are rounded upward and withdrawal amount is rounded downward.
  • Add Order Book Offer invariant to verify consumed amounts. Consumed amounts are less than the offer.
  • Fix Bid validation. AuthAccount can't have duplicate accounts or the submitter account.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

Test Plan

AMM, AMMExtended, AMMClawback, AMMInfo unit-tests are updated

* Add AMM deposit and withdraw rounding to ensure AMM invariant
* Add AMM bid/create/deposit/swap/withdraw/vote invariants
* Add Offer invariant to verify consumed amounts
* Fix Bid validation
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.

1 participant