fix(swap): report relay's real minimumamount as minimumoutput (false zero-slippage signal)#598
Draft
gomesalexandre wants to merge 1 commit into
Draft
fix(swap): report relay's real minimumamount as minimumoutput (false zero-slippage signal)#598gomesalexandre wants to merge 1 commit into
gomesalexandre wants to merge 1 commit into
Conversation
…zero-slippage signal) RelayProvider.GetQuote set MinimumOutput = expectedOutput with the comment "Relay is solver-based: no AMM slippage". That claim is false: live POST api.relay.link/quote for ETH->USDC returns isFixedRate:false with a genuine ~1% gap between currencyOut.amount (1758580426) and currencyOut.minimumAmount (1740994621). Copying expectedOutput into MinimumOutput hands every caller a permanently FALSE zero-slippage floor — any pre-sign card or slippage-risk check that reads Quote.MinimumOutput shows 'no downside' for a swap that can actually settle ~1% lower. Add the minimumAmount field to the response struct and use it as MinimumOutput, falling back to expectedOutput only when the API omits it. Regression test (httptest) asserts MinimumOutput tracks minimumAmount and falls back safely when absent. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
what — Relay reports a false zero-slippage floor
RelayProvider.GetQuote(sdk/swap/relay.go) set:That comment is false. A live
POST api.relay.link/quotefor ETH->USDC returnsisFixedRate: falsewith a genuine gap betweencurrencyOut.amountandcurrencyOut.minimumAmount:Copying
expectedOutputintoMinimumOutputhands every caller a permanently false zero-slippage floor. Any pre-sign card, slippage-risk warning, or downstream check that readsQuote.MinimumOutputshows "no downside" for a swap that can actually settle ~1% lower than expected.how
Add
minimumAmountto therelayCurrencyOutresponse struct and use it asMinimumOutput, falling back toexpectedOutputonly when the API omits the field. Regression test (httptest with distinctamount/minimumAmount) assertsMinimumOutputtracksminimumAmountand falls back safely when absent.risk
Low, strictly corrective —
MinimumOutputnow reflects the API's real floor instead of an optimistic copy.go build ./sdk/swap/+go vetclean; test passes under the go.mod toolchain (GOTOOLCHAIN=go1.24.2— the package test binary doesn't link on Go >=1.24 due to a pinnedbytedance/sonic/go:linknameissue, unrelated to this change).receipts
Field + gap live-verified against the production Relay API (curl above). Found by a fund-safety audit of the recipes swap providers (the same audit that surfaced the MayaChain zero-slippage CRITICAL, recipes#597). Related lower-severity findings from that audit (Relay ignoring an explicit
AffiliateBps: 0opt-out; 1inch/Jupiter/LiFi/Uniswap not forwardingreq.ToleranceBps) are being triaged separately.