Swap: quote through SwapPro (keyless, every venue at once) - #297
Open
sktbrd wants to merge 1 commit into
Open
Conversation
…e at once The /swap page keeps its UI and its two-step flow; behind /api/0x/price and /api/0x/quote a single SwapPro /quote now routes across 0x, CoW, LI.FI, Relay and more and answers with a firm quote and the transaction to sign. No API key: ZEROX_API_KEY is retired. src/lib/swappro.ts is the pure translation between SwapPro's answer (human decimals, approval, tx, provider) and the shape the widget already reads (liquidityAvailable, base-unit amounts, issues.allowance, transaction), with unit tests. The widget passes sellDecimals/buyDecimals so the proxy can convert both ways; nothing else in it changes. The affiliate fee is still opt-in per request and still set from config server-side, sent as SwapPro's partner + partnerFeeBps. How it is collected depends on the venue SwapPro picks — on-chain per swap on CoW, settled off-chain on 0x and LI.FI, not at all on Relay — and every quote reports it in a partnerFee block. docs/integrations/swap.md spells this out; it is the one thing the DAO should decide on before merging. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018aKwE1cu2NvM7Gj7ykdcgD
|
@sktbrd is attempting to deploy a commit to the r4to's projects Team on Vercel. A member of the Team first needs to authorize it. |
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
The
/swappage keeps its UI and its two-step flow (price while typing, firm quote on click). Behind/api/0x/priceand/api/0x/quote, a single SwapProGET /quotenow routes across 0x, CoW, LI.FI, Relay and more and returns one firm quote with the transaction to sign. No API key —ZEROX_API_KEYis retired.src/lib/swappro.ts— pure translation between SwapPro's answer and the shape the widget already reads, with unit tests (6 passing).src/lib/swapproRoute.ts— the one handler behind both routes; fee recipient still comes fromsrc/lib/config.ts, server-side.SwapWidget.tsx— two lines: it passessellDecimals/buyDecimalsso the proxy converts base units ⇄ human decimals. Nothing visual changes.docs/integrations/swap.mdrewritten.What the user gets
minBuyAmountis the floor the transaction enforces on chain.The one thing to decide before merging — the treasury fee
The "Support Gnars treasury (0.5%)" checkbox still works and is still opt-in per request. What changes is how the fee is collected, and it depends on the venue SwapPro picks:
Every quote reports this in a
partnerFeeblock (collected,paidToPartner), passed through verbatim. SwapPro also takes its own 30 bps on same-chain EVM routes. With direct 0x the fee landed in the split contract on every swap; with SwapPro it does on some venues and is settled off-chain on others. That is a policy call for the DAO, which is why this is a proposal.How to test on the preview
/swap, connect, pick ETH → USDC or ETH → GNARS, type an amount: the price should appear with the venue named in the response (route).minBuyAmount.UNSUPPORTED_CHAIN— SwapPro does not route it yet.Checks run locally:
vitest(6/6 on the new module),tsc --noEmit(no errors in touched files),eslintandprettierclean on touched files.Reference: https://www.swaps.pro/docs/api/quote
🤖 Generated with Claude Code
https://claude.ai/code/session_018aKwE1cu2NvM7Gj7ykdcgD