Repository navigation
#599 Fixed-Point-Math | Constant Product Invariants via U256 High-Precision Engine - #3
Merged
Merged
Conversation
…igh-precision engine Core AMM swap math maintaining x*y=k without precision loss: - U256 struct for 256-bit intermediate products of two u128 values - mul_div with full precision, always rounding down (favors pool reserves) - compute_swap_out, compute_lp_shares, compute_remove_liquidity - assert_invariant_stable checks k is non-decreasing - Unit tests covering basic ops, max bounds, high volume scenarios
oraimoitel
pushed a commit
that referenced
this pull request
Oct 18, 2026
…or-warning-monitor feat: add dynamic vault health warning monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Core AMM swap module maintaining constant product (x * y = k) invariants without precision loss or rounding vulnerabilities.
Changes
src/amm/invariant.rswithU256struct (two u128 words) for 256-bit intermediate productscompute_swap_out:out = reserve_out * amount_in / (reserve_in + amount_in)with floor roundingcompute_lp_shares:min(a * total / reserve_a, b * total / reserve_b)with floor roundingcompute_remove_liquidity: proportional withdrawals with floor roundingassert_invariant_stable: verifies k is non-decreasing after swapsCloses StellarFlow-Network#599