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

fix: AMM swap rounding #5002

Merged
merged 2 commits into from
Apr 26, 2024
Merged

fix: AMM swap rounding #5002

merged 2 commits into from
Apr 26, 2024

Commits on Apr 26, 2024

  1. Add global access to the current ledger rules:

    It can be difficult to make transaction breaking changes to low level
    code because the low level code does not have access to a ledger and the
    current activated amendments in that ledger (the "rules"). This patch
    adds global access to the current ledger rules as a `std::optional`. If
    the optional is not seated, then there is no active transaction.
    seelabs committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    1edc31a View commit details
    Browse the repository at this point in the history
  2. fix amendment: AMM swap should honor invariants: (XRPLF#5002)

    The AMM has an invariant for swaps where:
    new_balance_1*new_balance_2 >= old_balance_1*old_balance_2
    
    Due to rounding, this invariant could sometimes be violated (although by
    very small amounts).
    
    This patch introduces an amendment `fixAMMRounding` that changes the
    rounding to always favor the AMM. Doing this should maintain the
    invariant.
    
    Co-authored-by: Bronek Kozicki
    Co-authored-by: thejohnfreeman
    seelabs committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    b90f58d View commit details
    Browse the repository at this point in the history