fix(dex): reject same-token (base==quote) pools on create and remove (v1.1.9)#479
Open
AntonAndell wants to merge 3 commits into
Open
fix(dex): reject same-token (base==quote) pools on create and remove (v1.1.9)#479AntonAndell wants to merge 3 commits into
AntonAndell wants to merge 3 commits into
Conversation
addInternal used Java reference equality (!=) on freshly-deserialized score.Address params, so the base!=quote guard was a silent no-op and base==quote pools could be created. Switch to value equality (.equals). Add the same guard to _remove so any pre-existing same-token pool cannot be drained via the DictDB key-collision double-credit. Bump DEX to v1.1.9. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #479 +/- ##
============================================
- Coverage 72.98% 72.97% -0.01%
Complexity 1639 1639
============================================
Files 120 120
Lines 7839 7840 +1
Branches 944 945 +1
============================================
Hits 5721 5721
Misses 1708 1708
- Partials 410 411 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
58-action Governance execute() batch used alongside the DEX v1.1.9 fix: block bnUSD/BALN cross-chain transfers (setSpokeLimit 0) and lock down Loans (setRedemptionExemption true / setDebtCeiling 0) to neutralize the redemption decimals bug and new borrows config-side. See recovery/README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ArbitraryCallManager parses Boolean params via JsonValue.asBoolean, which
requires a JSON boolean literal. The value was a quoted string ("true"),
causing execute() to revert with UnknownFailure on the first exemption call
(atomic batch -> whole tx failed). Verified fixed via debug_estimateStep.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Reject AMM pools where
base == quote.The create-time guard in
addInternalused Java reference equality onscore.Address(_baseToken != _quoteToken), which is always true for freshly-deserialized parameters — so it never fired, and a same-token pool could be created. Whenbase == quote, the per-token storage keys (poolTotal,deposit) collide, and_remove's sequential read-modify-write double-credits the deposit ledger, letting a withdrawal exceed the pool's backing.Changes
DexImpl.addInternal:_baseToken != _quoteToken→!_baseToken.equals(_quoteToken)(value equality) — prevents creating same-token pools.DexImpl._remove: addrequire(!baseToken.equals(quoteToken), ...)— prevents removing from an already-created same-token pool (the create-time guard alone does not cover pre-existing pools).DEXversion v1.1.8 → v1.1.9.Test plan
add/xAddwithbase == quotereverts ("Pool must contain two token contracts").removeon a pre-existingbase == quotepool reverts ("Invalid same-token pool, removal blocked").base != quote) add/remove/swap unaffected (regression).Deployment
Deploy under governance shutdown, then re-enable.
🤖 Generated with Claude Code