feat: [swap] unified Swap API V2 documentation#854
feat: [swap] unified Swap API V2 documentation#8540xYankee-Raccoons wants to merge 29 commits intomainfrom
Conversation
Move existing Metis swap pages, API reference, and OpenAPI spec into v1 subdirectories to make room for the new Swap API V2. - docs/swap/*.mdx -> docs/swap/v1/ - api-reference/swap/*.mdx -> api-reference/swap/v1/ - openapi-spec/swap/swap.yaml -> openapi-spec/swap/v1/swap.yaml - Update V1 API ref pages to point to new spec path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New OpenAPI 3.0.3 spec for the unified Swap API V2 at api.jup.ag/swap/v2. Three endpoints: GET /order, GET /build, POST /execute. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8 new pages for the unified Swap API V2: - Overview with comparison table and decision tree - Order & Execute (happy path with @solana/kit and @solana/web3.js examples) - Build Custom Transactions (advanced path with full code examples) - Swap Instructions (common instructions to compose with /build) - Parameters & Routing (per-param routing badges + full routing matrix) - Fees (fee models for both paths) - Advanced Techniques (CU simulation, fast mode, gasless, maxAccounts) - Migration Guide (Metis -> /build, Ultra -> /order, V1 -> V2 differences) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- api-reference/swap.mdx: Updated overview with V2 and V1 card groups - api-reference/swap/v2.mdx: V2 overview with endpoint cards - api-reference/swap/v2/order.mdx: GET /order endpoint (from OpenAPI) - api-reference/swap/v2/build.mdx: GET /build endpoint (from OpenAPI) - api-reference/swap/v2/execute.mdx: POST /execute endpoint (from OpenAPI) - api-reference/swap/v1.mdx: V1 (Metis) overview with endpoint cards Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New top-level "Swap" nav item replacing "Ultra Swap" - V2 as primary expanded section with all new pages - Ultra Swap collapsed under Swap - Metis V1 collapsed under Swap (pointing to v1/ paths) - API reference: Swap group with V2 and V1 (Metis) sub-groups - 12 redirects for old Metis docs and API reference paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Delete original files that were moved to v1/ subdirectories. api-reference/swap.mdx updated in an earlier commit but had unstaged changes from the linter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove Ultra, Swap V1, Tokens V1, and Price V2 from API Reference nav. Pages remain live but are hidden from discovery: - Add deprecated: true frontmatter to all 22 deprecated API ref pages - Add <Warning> deprecation callouts pointing to replacements - Update llmsDescription with DEPRECATED prefix on overview pages - Modify generate-llms-from-docs.js to skip pages with deprecated: true - Update llms.txt Quick Reference to recommend Swap API V2 - Clean up api-reference/swap.mdx overview (V2 only, no V1 cards) API Reference nav now shows only current versions: - Swap: overview + V2 endpoints - Tokens: overview + V2 endpoints - Price: overview + V3 endpoints Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add "Deprecating API Versions" workflow to CLAUDE.md (6-step process for phasing out old API versions without breaking links or AI agents) - Drop redundant version overview pages from nav (swap/v2, tokens/v2, price/v3) since top-level overviews cover them - Add llmsDescription to all 3 Swap V2 API reference pages - Add Swap API V2 changelog entry to updates/index.mdx - Regenerate llms.txt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Latest changes (deprecation workflow + API ref cleanup)Deprecation workflow added to CLAUDE.md
API Reference nav cleanup
Changelog + llms.txt
All pre-commit checks pass. |
…DE.md - Drop redundant version overview pages from nav (swap/v2, tokens/v2, price/v3) — top-level overviews now show endpoint cards directly - Update tokens.mdx and price.mdx overviews to show only current version endpoints (no links to deprecated versions) - Add llmsDescription to tokens and price overview pages - Add "Deprecating API Versions" workflow to CLAUDE.md with expanded context on human vs agentic reader handling - Regenerate llms.txt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…kflow Apply the deprecation pattern to docs pages (not just API reference): - Add deprecated: true + Warning callout to all 16 docs/ultra/ pages - Add deprecated: true + Warning callout to all 8 docs/swap/v1/ pages - Add llmsDescription with DEPRECATED prefix to both overview pages - All 24 docs pages now excluded from llms.txt Refine CLAUDE.md deprecation workflow: - Applies to both API reference and docs pages - "What to deprecate" decision table for human/Claude to determine scope - Covers collapsed nav sub-sections (keep if needed for hierarchy) - Expanded "When to apply" list including product doc rewrites Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Latest: deprecate Ultra + Metis V1 docs pagesApplied the same deprecation pattern to docs pages (not just API reference):
CLAUDE.md deprecation workflow refined:
All pre-commit checks pass. |
Drop hidden/undocumented params from V2 spec and docs: - closeAuthority, nozomiTipLamports, gasMint - Advanced integrator fees (feeBps, feeFlat, feeReducer, feeReceiver, feeMint, AdvancedFee schema) - useWsol - All ExactOut references (swapMode enum, routing matrix row, build comparison) Enrich parameter descriptions with bullet points (matching Ultra V1 style): - receiver: ATA behaviour, SOL handling, wSOL limitation - payer: gasless flow implications - excludeDexes: Iris-only caveat - slippageBps/priorityFeeLamports: auto-optimisation notes - referralFee: range 50-255 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r & execute - Rename docs/swap/v2/build/swap-instructions.mdx to other-instructions.mdx - Update order-and-execute page with improved descriptions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…cation - Add fee schedule table (0 bps for Jupiter tokens, 2 for SOL-Stable, etc.) - Add fee mint priority list (SOL > Stablecoins > LSTs > Bluechips > Others) - Add full referral account setup guide with code examples (SDK install, create referralAccount, create referralTokenAccount per mint) - Clarify /build feeAccount can be any SPL token account (no referral program account needed) - Add Jupiter 20% integrator fee share note Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace monolithic Advanced Techniques page with an index linking to 5 standalone pages: - Gasless Swaps: rewritten from Ultra docs, covers both /order (automatic gasless + integrator payer) and /build (payer changes fee payer accounts), no "Ultra" naming, includes scenario matrix - Priority Fees: /order priority fee and Jito tip parameters - Estimate Compute Units: CU simulation pattern for /build - Reduce Transaction Size: maxAccounts + removing no-op createIdempotent - Reduce Latency: fast mode on /build Also: - Add gasless row to overview comparison table - Update payer description in parameters page (Iris only, link to gasless) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Must fix: - Fix blockhash type mismatch in /build kit example (convert byte array to base58 string before passing to setTransactionMessageLifetimeUsingBlockhash) - Fix extra closing parenthesis in overview gasless row Should fix: - Fix V1 index recommending Ultra (now points to Swap API V2) - Fix undefined accountExists in reduce-transaction-size (replaced with concrete ATA existence check pattern) - Fix V1 index internal links to use canonical /docs/swap/v1/ paths - Deduplicate blockhash conversion in web3.js /build example Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Consistency: - Standardise router naming: "Metis" in prose, iris noted once in params - "JupiterZ" used consistently (not alternating with "RFQ") - Remove horizontal rules from order-and-execute - Convert Mode section to Note callout in parameters Editorial: - RTSE: inline explanation (adjusts slippage at execution time) - Jupiter Beam: inline explanation (accelerated sending across RPCs) - Grammar fix: "Parses both successful and failed transactions" - reduce-latency: "extracting" -> "optimising" Cuts: - v1/index: remove marketing paragraphs, Card components, blog links - overview: remove "Two paths" heading Fixes: - compute-units: add getTransactionEncoder import and base64 conversion Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Order & Execute: - Add wallet loading accordion (base58 .env, Solana CLI keyfile, raw bytes) - Split into prerequisites (imports, types, constants) + code example - Expand OrderResponse (outAmount, router, mode, feeBps, feeMint) - Expand ExecuteResponse (code, inputAmountResult, outputAmountResult, error) - Use partiallySignTransaction for kit (JupiterZ MM co-signer) - Standardise BS58_PRIVATE_KEY env var Build Custom Transactions: - Split into prerequisites (types + helpers per library) + code example - Add SOL transfer as custom instruction example (after swap, before cleanup) - Include CU simulation inline (steps 4-5 in kit) - Add CU simulation explanation with Solana fee structure link - Fix build/index.mdx TODO comments - Standardise BS58_PRIVATE_KEY env var Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Routing: - Rename parameters.mdx to routing.mdx (new file, no redirect needed) - Strip parameter tables (duplicates API ref), keep routing overview, impact matrix, and ultra vs manual mode - Update all internal links from parameters -> routing Code examples: - Rewrite order-and-execute with workbench code (kit + web3.js) - Rewrite build with workbench code including CU simulation - Add wallet loading accordion (3 methods: .env, CLI keyfile, raw bytes) - Add SOL transfer as custom instruction example in /build - Standardise BS58_PRIVATE_KEY env var across all pages - Prerequisites/code split structure CPI: - Add full CPI section to other-instructions.mdx from Ultra docs - CPI with jupiter-cpi crate (Rust example) - Flash Fill alternative with flow explanation - GitHub reference links Editorial (from review): - Standardise router naming (Metis everywhere, iris noted once) - RTSE/Jupiter Beam inline explanations - Cut marketing copy from v1/index.mdx - Remove horizontal rules, convert Mode to Note callout - Fix compute-units missing import - Remove "Two paths" heading from overview - Fix V1 internal links to canonical paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove priority-fees.mdx (not useful as standalone advanced guide) and all links to it - Compute units: rewrite as concise pattern guide, link to Solana fee structure, reference /build code example instead of duplicating code - Reduce transaction size: add Warning for maxAccounts too low (below 50 can cause no route found), add Note about RPC latency cost of ATA existence checks - Reduce latency: add technical details for fast mode (Bellman-Ford with no splitting, parallel getRecentPriorityFee), add Note about priority fee estimation trade-off, expand trade-offs section Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Question: Does
|
- Fix typo: expanadable -> expandable in build code block (broke Mintlify collapse) - Fix em dash in build code comment (style guide) - Fix inconsistent slippageBps: add to web3.js /build example to match kit example - Fix unescaped $ in gasless llmsDescription - Delete redundant api-reference/swap/v2.mdx (merged base URL + API key info into swap overview) - Remove api-reference/swap/v2 from docs.json nav
- Revert \$ -> $ in gasless.mdx llmsDescription (YAML doesn't support \$ escape sequences, causing Mintlify parse failure) - Update style guide: frontmatter is YAML, body is markdown, escaping rules differ. Don't use markdown escaping in YAML frontmatter. - Add .env and audit/ to .gitignore
Answer:
|
| Source | Current state | Fix |
|---|---|---|
compute-units.mdx |
"price but not limit" | Correct, no change needed |
build/index.mdx line 163 |
"handled automatically by the compute budget instructions (web3.js)" | Wrong — will fix. The web3.js example includes computeBudgetInstructions as-is (which only sets the price, not the limit). This means the web3.js example sends with no explicit CU limit, relying on the Solana runtime default. |
OpenAPI spec (computeBudgetInstructions description) |
"Compute unit price and limit instructions" | Wrong — will fix to "Compute unit price instruction" |
What happens without a CU limit?
If no SetComputeUnitLimit instruction is present, Solana uses a default of 200,000 CU per instruction × number of instructions. For a typical swap with 5-6 instructions, that's ~1M CU — which is usually enough but not optimal for fee calculation.
Action items:
- Fix OpenAPI spec description: "Compute unit price and limit instructions" → "Compute unit price instruction"
- Fix
build/index.mdxline 163: remove "handled automatically" claim - Optionally: add CU simulation to the web3.js example to match the kit example (separate commit since it's a larger change)
Source confirmed: computeBudgetInstructions contains only setComputeUnitPrice (build/index.ts line 296). - Fix OpenAPI spec: "Compute unit price and limit" -> "Compute unit price instruction (does not include compute unit limit)" - Fix build/index.mdx: remove "handled automatically" claim for web3.js, clarify web3.js needs manual CU simulation for production - Update response fields table description Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The web3.js example was using computeBudgetInstructions as-is (which only includes CU price, not limit). Now matches the kit example: - Step 4: simulate with ComputeBudgetProgram.setComputeUnitLimit at max - Step 5: rebuild with 1.2x simulated value + CU price from response - Add ComputeBudgetProgram and COMPUTE_UNIT_LIMIT_MAX to prerequisites - Update "How it works" section to reference both examples Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Unified Swap API V2 documentation. New top-level "Swap" section with
/order(happy path, managed execution) and/build(advanced path, raw instructions) atapi.jup.ag/swap/v2. Existing Ultra and Metis docs preserved as collapsed sub-sections.Changes
New pages (8)
docs/swap/index.mdx) — comparison table, decision tree, endpoint summarydocs/swap/v2/order-and-execute.mdx) — happy path with@solana/kitand@solana/web3.jsexamplesdocs/swap/v2/build/index.mdx) — advanced path with full code examples for both librariesdocs/swap/v2/build/swap-instructions.mdx) — common instructions to compose with/builddocs/swap/v2/parameters.mdx) — per-param routing badges + full routing impact matrixdocs/swap/v2/fees.mdx) — fee models for both paths (no swap fees on/build)docs/swap/v2/advanced.mdx) — CU simulation, fast mode, gasless, maxAccountsdocs/swap/v2/migration.mdx) — Metis →/build, Ultra →/order, V1 → V2 instruction differencesOpenAPI spec
openapi-spec/swap/v2/swap.yaml(GET /order, GET /build, POST /execute)openapi-spec/swap/swap.yaml→openapi-spec/swap/v1/swap.yamlAPI reference (5 new pages)
api-reference/swap.mdx— updated overview with V2 and V1 card groupsapi-reference/swap/v2.mdx— V2 overview with endpoint cardsapi-reference/swap/v2/order.mdx,build.mdx,execute.mdx— generated from OpenAPI specapi-reference/swap/v1.mdx— V1 (Metis) overview with endpoint cardsStructural
docs/swap/v1/api-reference/swap/v1/Linear Issues
Checklist
node generate-llms-from-docs.jsrunmint broken-linkspassestitle,description,llmsDescriptiondocs.jsonnavigation updatedupdates/index.mdx.claude/rules/updated with learnings and decisions