Skip to content

[codex] Fix StackingDAO get-dy scaled fees#17

Open
caydyan wants to merge 1 commit into
BitflowFinance:mainfrom
caydyan:codex/fix-stackingdao-get-dy-fees
Open

[codex] Fix StackingDAO get-dy scaled fees#17
caydyan wants to merge 1 commit into
BitflowFinance:mainfrom
caydyan:codex/fix-stackingdao-get-dy-fees

Conversation

@caydyan

@caydyan caydyan commented Jun 22, 2026

Copy link
Copy Markdown

Summary

  • Apply the total swap fee to x-amount-scaled inside stableswap-stackingDAO.get-dy.
  • Keep the read-only quote path aligned with swap-x-for-y, which already computes fees in scaled units before deriving dy.
  • Add a mixed-decimal regression case using 6-decimal STX input and 8-decimal sUSDT output so get-dy must match the actual swap return.

Audit context

This addresses ClankOS StackingDAO audit finding F-04 from https://gist.github.com/ClankOS/61003f54ed834fdbc9be72fe95a314fa. The finding notes that get-dy scales x-amount but then computes total fees from the unscaled x-amount, producing inaccurate quotes for pairs whose token decimals differ.

Validation

  • git diff --check
  • clarinet check with 12 contracts checked; remaining warnings are pre-existing project warnings
  • Clarinet console mixed-decimal scenario: get-dy returned (ok u999303143) and swap-x-for-y returned (ok u999303143) for the same 6-decimal STX -> 8-decimal sUSDT swap

BTC payout address if this is accepted for any related bounty: bc1qev5ant33v5y89qqjvcf4mh9hlax5svqf5xd7gc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant