Skip to content

fix(swap): report relay's real minimumamount as minimumoutput (false zero-slippage signal)#598

Draft
gomesalexandre wants to merge 1 commit into
mainfrom
fix_relay_minimum_output_slippage
Draft

fix(swap): report relay's real minimumamount as minimumoutput (false zero-slippage signal)#598
gomesalexandre wants to merge 1 commit into
mainfrom
fix_relay_minimum_output_slippage

Conversation

@gomesalexandre

Copy link
Copy Markdown
Contributor

what — Relay reports a false zero-slippage floor

RelayProvider.GetQuote (sdk/swap/relay.go) set:

MinimumOutput: expectedOutput, // Relay is solver-based: no AMM slippage

That comment is false. A live POST api.relay.link/quote for ETH->USDC returns isFixedRate: false with a genuine gap between currencyOut.amount and currencyOut.minimumAmount:

amount        = 1758580426
minimumAmount = 1740994621   → ~1.000% gap

Copying expectedOutput into MinimumOutput hands every caller a permanently false zero-slippage floor. Any pre-sign card, slippage-risk warning, or downstream check that reads Quote.MinimumOutput shows "no downside" for a swap that can actually settle ~1% lower than expected.

how

Add minimumAmount to the relayCurrencyOut response struct and use it as MinimumOutput, falling back to expectedOutput only when the API omits the field. Regression test (httptest with distinct amount/minimumAmount) asserts MinimumOutput tracks minimumAmount and falls back safely when absent.

risk

Low, strictly corrective — MinimumOutput now reflects the API's real floor instead of an optimistic copy. go build ./sdk/swap/ + go vet clean; 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 pinned bytedance/sonic/go:linkname issue, 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: 0 opt-out; 1inch/Jupiter/LiFi/Uniswap not forwarding req.ToleranceBps) are being triaged separately.

…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>
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 488d59bb-fd19-4982-b4ec-f35ab89b2f90

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix_relay_minimum_output_slippage

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

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