fix(stableswap): correct inverted admin/non-admin fee branch in swap-x-for-y and swap-y-for-x#15
Open
sonic-mast wants to merge 2 commits into
Open
Conversation
…x-for-y and swap-y-for-x Addresses finding F-01 from Sonic Mast audit (2026-06-07): All 6 fee conditionals in swap-x-for-y (lines 332-344) and swap-y-for-x (lines 454-466) had their branches inverted — admins paid configured fees while non-admins received admin-swap-fees (0 bps). Fix: swap true/false branches so: - Admin (is-some returns true) -> admin-swap-fees (0 bps as intended) - Non-admin (is-some returns false) -> buy-fees/sell-fees (configured rates) Audit: https://gist.github.com/sonic-mast/c3a352aa6b9b46dd42e36f163d9d9b2d
…x-for-y and swap-y-for-x Addresses finding F-01 from Sonic Mast audit (2026-06-07): All 6 fee conditionals in swap-x-for-y (lines 332-344) and swap-y-for-x (lines 454-466) had their branches inverted -- admins paid configured fees while non-admins received admin-swap-fees (0 bps). Fix: swap true/false branches so: - Admin (is-some returns true) -> admin-swap-fees (0 bps as intended) - Non-admin (is-some returns false) -> buy-fees/sell-fees (configured rates) Audit gist: https://gist.github.com/sonic-mast/c3a352aa6b9b46dd42e36f163d9d9b2d Finding: F-01 (High severity)
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
Fixes finding F-01 from Sonic Mast audit (2026-06-07) of
SPQC38PW542EQJ5M11CR25P7BS1CA6QT4TBXGB3M.stableswap-stx-ststx-v-1-2.Finding F-01 (High): Fee exemption inverted — non-admins pay 0 fees on all swaps.
Both
swap-x-for-yandswap-y-for-xhad the admin/non-admin branch order reversed in all 6 fee conditionals. When(is-some (index-of (var-get admins) tx-sender))evaluates totrue(admin), the code was entering the fee branch; when it evaluated tofalse(non-admin), it entered the zero-fee branch — opposite of intent. The comment says "Admins pay no fees on swaps" but the branch selection was inverted.Before:
After:
All 3 fee components (
swap-fee-lps,swap-fee-stacking-dao,swap-fee-bitflow) corrected in bothswap-x-for-yandswap-y-for-x(6 conditionals total, lines ~332–344 and ~454–466).Impact: Since deployment, all non-admin swap volume has collected zero LP, StackingDAO, and Bitflow protocol fees. This PR restores correct fee routing. No user principal is at risk — only fee revenue was affected.
Audit source: Sonic Mast audit 2026-06-07, bounty
mpwj216i51b1ad3c6731