test(math): add value-conservation proptests for slip-fee and swap-mirror paths - #1518
Open
chiliec wants to merge 1 commit into
Open
Conversation
…rror paths The omnipool slip-fee trade paths (introduced with the dynamic slip fee) are currently exercised only by fixed numeric unit tests — every proptest in omnipool/invariants.rs passes slip = None, so the randomized per-pool k-conservation check (new_reserve * new_hub >= old_reserve * old_hub) that the no-slip paths are held to never runs against a slip trade. This adds two proptest modules that close that coverage gap: - omnipool/slip_invariants.rs (5 tests): sell/buy with a non-zero slip fee preserve the per-asset invariant, and slip trades conserve the hub asset (hub_in == hub_out + protocol_fee) — the property that guards against LRNA mint/burn. - stableswap/tests/swap_mirror.rs (3 tests): a swap and its mirror do not net a profit (round-trip is non-positive for the trader), and add-then-withdraw of one asset does not net a profit — both asserting the rounding always favours the pool. All new tests pass at 4000 proptest cases. No production code is changed; this is test coverage only.
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.
What
Adds value-conservation proptests for two
hydra-dx-mathpaths that the existing randomized suite does not currently cover. Test-only — no production code is changed.Why
While reviewing the math crate I noticed the omnipool slip-fee trade paths are exercised only by fixed numeric unit tests: every proptest in
omnipool/invariants.rspassesslip = None, so the randomized per-pool k-conservation check that the no-slip paths are held to (new_reserve * new_hub_reserve >= old_reserve * old_hub_reserve) never runs against a slip trade. The hub-asset (LRNA) conservation of slip trades likewise had no property test.Changes
omnipool/slip_invariants.rs(5 proptests):sell/buywith a non-zero slip fee preserve the per-asset invariantnew_reserve * new_hub >= old_reserve * old_hub(the same checkomnipool/invariants.rsapplies to no-slip trades).hub_in == hub_out + protocol_fee— the property that guards against LRNA mint/burn across a slip trade.asset_state,assert_asset_invariant) is copied verbatim fromomnipool/invariants.rsso tolerance/rounding semantics match exactly.stableswap/tests/swap_mirror.rs(3 proptests):Verification
All new tests pass at 4000 proptest cases; the full
hydra-dx-mathsuite is green (399 passed) andcargo fmtis clean. Everything I found holds — these tests document and lock in the existing (correct) conservation behaviour, they do not fix a bug.First-time contributor here — happy to adjust scope, naming, or the harness placement to match your conventions. Also open to contract / full-time work if useful.