Skip to content

[codex] Fix standard stableswap quote fee scaling#24

Open
caydyan wants to merge 1 commit into
BitflowFinance:mainfrom
caydyan:codex/fix-standard-get-dx-scaled-fees
Open

[codex] Fix standard stableswap quote fee scaling#24
caydyan wants to merge 1 commit into
BitflowFinance:mainfrom
caydyan:codex/fix-standard-get-dx-scaled-fees

Conversation

@caydyan

@caydyan caydyan commented Jun 22, 2026

Copy link
Copy Markdown

Summary

  • calculate get-dx and get-dy total swap fees from scaled token amounts
  • add a mixed-decimal regression test that checks get-dx against swap-y-for-x

Why

The read-only quote helpers compute AMM balances in scaled precision, but their total-fee inputs used the unscaled token amount. For mixed-decimal pairs this can make the quote path diverge from the executable swap path. In the USDA/sUSDT pool, get-dx overquoted u9999948020 before the fix while swap-y-for-x returned u9994998022 for the same u100000000 USDA input.

Validation

  • git diff --check
  • clarinet check
  • clarinet console confirmed get-dx and swap-y-for-x now both return u9994998022 for the mixed-decimal scenario above

Note: the local environment does not have deno, so the TypeScript Clarinet test was added but not executed here.

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