Repository navigation
fix(safe-eth-flow): wrap slippage-adjusted sell amount for buy orders - #7727
fairlighteth merged 7 commits into
Conversation
For buy orders sold as ETH in a Safe bundle, the wrap step used the quoted input amount instead of the maximum sell amount (which includes the buy-order slippage threshold). When the order filled above the quoted sell amount, WETH balance was insufficient and the order became unfillable. Use `maximumSendSellAmount` from `useAmountsToSignFromQuote()` as the wrap amount so the bundled wrap covers the full settleable sell amount. Fixes cowprotocol#7293
|
@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Walkthrough
ChangesSafe Bundle ETH Wrap Amount Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Cloudflare Pages preview mirror Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7727 Source fork branch:
|
fairlighteth
left a comment
There was a problem hiding this comment.
✅ AI Review (Codex GPT-5, worked 4m 28s): no new findings
Review completed. I found no new non-duplicate comments worth posting.
Review scope and related context
- Checked current PR head
bd7ffd2c1036b2af7ef790cf0a45e69453186409againstdevelop. - The linked issue is specifically an under-wrapped Safe buy order with ETH as the sell token; the patch makes the Safe wrap tx use
maximumSendSellAmount, which is already slippage-adjusted for buy swap orders and converted to WETH in Safe ETH flow. - The approval path already derives
needsApproval/amountToApprovefrom the same maximum amount, so wrap and approval are aligned. - Existing review state: no review threads, no actionable bot comments, and a member approval on the current head.
- I did not do manual Safe/browser QA here; the PR body's Safe buy-order test note plus existing approval were enough that I would not raise a separate QA traceability comment.
Generated using the pr-review skill from the CoW Protocol skills repo.
🧪 Scoped automated QA passed: mocked Safe ETH buy-order bundle construction on PR head; real Safe/browser execution not checkedOutcome
Artifacts Summary:
Captured mocked Safe state:
Run details
How to retest
Not checked / follow-up
AI usage: Codex created the temporary local Jest harness, ran the targeted assertions, generated/uploaded the sanitized artifacts, and drafted this summary from the observed command result. |
✅ Security Review (Codex GPT-5 + DeepSec PR mode, worked ~15m): no verified security findingsReview completed. DeepSec PR mode produced no net-new findings, and follow-up code inspection found no verified security findings worth posting. Review scope and related context
Generated using the |


Closes #7293
Problem
When placing a buy order in a Safe with ETH in the sell field (no WETH balance), the bundled wrap step wraps a lower amount than the order may actually settle. The order then becomes unfillable because the Safe lacks WETH to cover the executed sell amount (see linked order in the issue).
Cause
safeBundleEthFlowwas wrappingcontext.inputAmount(the quoted sell amount). For buy orders, the signed order's sell amount can be up toquotedSell × (1 + slippageThreshold). Result: wrap amount < settle amount.Fix
Wrap
maximumSendSellAmountfromuseAmountsToSignFromQuote()instead. That value already accounts for the buy-order slippage threshold (and equals the input amount for sell orders), matching what the order may actually sell.Changes
useSafeBundleFlowContext: exposemaximumSendSellAmounton the bundle contextsafeBundleEthFlow: use it for the wrap tx weiAmountSafeBundleFlowContext: typed field addedTesting
Sell-order behaviour unchanged (
maximumSendSellAmount === inputAmount).Summary by CodeRabbit