fix(swap): forward caller slippage to jupiter instead of hardcoded 1%#599
Draft
gomesalexandre wants to merge 1 commit into
Draft
fix(swap): forward caller slippage to jupiter instead of hardcoded 1%#599gomesalexandre wants to merge 1 commit into
gomesalexandre wants to merge 1 commit into
Conversation
JupiterProvider.GetQuote always sent slippageBps=100 (the 1% default) and ignored QuoteRequest.ToleranceBps entirely, so a caller could neither tighten nor loosen the swap's slippage. Jupiter bakes the resulting min-out into the quote's otherAmountThreshold (carried to BuildTx via ProviderData), so forwarding a positive tolerance at the quote call is sufficient. Honor req.ToleranceBps (same bps units) when positive; fall back to the 1% default when omitted or 0 (0 would demand exact-out and revert on any movement). Regression test asserts the outgoing slippageBps tracks the requested tolerance and defaults correctly. 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
JupiterProvider.GetQuotealways sentslippageBps=100(the 1% default) and ignoredQuoteRequest.ToleranceBpsentirely — a caller could neither tighten (e.g. 0.3% for a deep pool) nor loosen (e.g. 3% for a volatile one) the swap's slippage. Not a fund-loss (1% is a sane floor), but the requested tolerance was silently dropped.how
Jupiter bakes the resulting min-out into the quote's
otherAmountThreshold, which is cached inProviderDataand reused byBuildTx— so forwarding a positive tolerance at the quote call is sufficient (single-site fix). Honorreq.ToleranceBps(same basis-point units) when positive; fall back to the 1% default when omitted or 0 (0 would demand exact-out and revert on any price movement). Regression test asserts the outgoingslippageBpstracks the requested tolerance, defaults to 100 when omitted, and falls back on 0.risk
Low — default behavior is unchanged; only an explicit positive tolerance now takes effect.
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
Found by the recipes swap-providers fund-safety audit (the MayaChain-CRITICAL / Relay-min-out vein — recipes#597, #598). Sibling finding: 1inch (
oneinch.go) has the same hardcoded-1% ignore-tolerance behavior but threads slippage at two sites (quote + BuildTx) and needs the tolerance carried throughSwapRequest/Quote, so it's left for a follow-up. LiFi's omitted-slippage default was live-verified conservative (0.5%).