Skip to content

fix(facade): report TradeHelperFacet sellAmount in token quanta - #1306

Merged
akshatmittal merged 1 commit into
masterfrom
fix/trade-helper-sell-amount-quanta
Oct 9, 2026
Merged

akshatmittal merged 1 commit into
masterfrom
fix/trade-helper-sell-amount-quanta

Conversation

@akshatmittal

@akshatmittal akshatmittal commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

TradeHelperFacet.getAllOpenTradesForRToken returns the two amounts of each SingleBid in different units:

  • sellAmount came from DutchTrade.sellAmount(), which is {sellTok}, an 18-decimal fixed-point value.
  • bidAmount comes from DutchTrade.bidAmount(), which is {qBuyTok}, buy-token quanta.

For a sell token with fewer than 18 decimals, sellAmount is too large by 10^(18 - decimals). The trusted fillers SDK uses this value as the CoW order sell amount, so CowSwapFiller rejects the order (OrderCheckFailed(9)). See reserve-protocol/reserve-fillers-monorepo#26 for the SDK-side workaround.

This change reports trade.lot(), which is {qSellTok}. It is the same amount DutchTrade.createTrustedFill gives the filler. The struct fields now have unit comments.

Compatibility

  • The ABI does not change. A new field would change the encoding of SingleBid[] and break existing decoders, so this PR changes the value only.
  • For 18-decimal sell tokens, lot() returns the same number as before.
  • Deployed Facades keep the old behavior until a new TradeHelperFacet is deployed and the Facade owner calls save(newFacet, [getAllOpenTradesForRToken.selector]) on each chain.

Verification

hardhat compile passes. prettier --check and solhint pass on the changed file. No tests were added.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the reported sell amount for Dutch trades in open-trade results.

getAllOpenTradesForRToken returned DutchTrade.sellAmount(), a {sellTok} D18 value, next to bidAmount in {qBuyTok}. Use lot() so both amounts are in token quanta, matching the amount createTrustedFill uses.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1218b-431d-74f9-94c8-a47fdaadb450
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-09T16:50:39.081497Z e2306ab PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fa45e06b-0299-4ef2-b5e3-f0489ac8d708

📥 Commits

Reviewing files that changed from the base of the PR and between 6a69bc0 and e2306ab.


📒 Files selected for processing (1)
  • contracts/facade/facets/TradeHelperFacet.sol

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.



📝 Walkthrough

Walkthrough

SingleBid amount fields now include quote-token unit annotations. getAllOpenTradesForRToken now reports trade.lot() as the sell amount for Dutch trades. The bid amount calculation is unchanged.

Changes

Trade helper updates

Layer / File(s) Summary
Trade sell amount fields and mapping
contracts/facade/facets/TradeHelperFacet.sol
SingleBid.sellAmount and SingleBid.bidAmount have quote-token unit annotations. getAllOpenTradesForRToken uses trade.lot() for the Dutch trade sell amount; the bid amount calculation is unchanged.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix


Merge Risk: ⚪ Minimal · up to e2306

The facade now reports the sell-token amount used by the in-repository fill paths. No merge-blocking regression is established.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: correcting TradeHelperFacet.sellAmount reporting to use token quanta.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.


✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@akshatmittal
akshatmittal requested a review from tbrent October 9, 2026 16:51
@akshatmittal
akshatmittal merged commit b4120ee into master Oct 9, 2026
17 checks passed
@akshatmittal
akshatmittal deleted the fix/trade-helper-sell-amount-quanta branch October 9, 2026 17:00
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.

2 participants