How to test token-to-token swap flows in the sandbox environment
Prerequisite: Your organization must be approved before it can quote. Swaps do not need a bank account. For onboarding your customers, see KYC Overview.
A swap exchanges one asset for another on the same chain. In v2 a swap is a quote and an order between two wallet payment accounts, the same way an onramp or offramp is. The destination can be the same wallet as the source, or another wallet on the same chain.Every call below runs for one organization, set as $ORGANIZATION_ID in the examples. Use your own organization’s id from GET /me, or a customer organization’s id when you swap for that customer. Register the wallets, quote and order under the same id. See Organizations in the route.
export ORGANIZATION_ID=<organization_id>
Swaps run on Stellar, Solana and Monad. The source and destination wallets must be on the same chain. To move the same token to a wallet on another chain, quote a cross-chain transfer instead. A quote between different tokens on different chains returns 400invalid-request. Base, Polygon and Avalanche support onramps and offramps, not swaps.
Stellar swaps need a funded, trustlined wallet. The wallet must hold XLM for the network fee and a trustline for the asset it receives. An embedded wallet does not need this setup: its first onramp pays for its reserves, we pay its network fees and bill them at cost, and a token it has no trustline for arrives as a claim. See the Stellar, Solana and Monad chain guides for per-chain setup.
Swap flow
1
Discover assets
Show Details
Either of these endpoints gives you the asset identifiers for a quote:
GET /supported_assets requires auth. Pass paymentAccountId with a wallet’s id to list the tokens on that wallet’s chain.
GET /lookup/stablebonds is public. It returns every stablebond on every chain, with pricing and supply data.
Use a token’s asset from the first, or the identifier from the second, as sourceAsset and destinationAsset.Swap rules:
At least one side must be a stablebond. The other side can be a stablecoin such as USDC, so USDC → CETES and CETES → USDC both work.
Both assets must be stablebonds or supported stablecoins. Non-stable tokens (SOL, XLM) return 400invalid-request.
Register the wallets: POST /organization/{organizationId}/payment_account
Show Details
Register the wallet that sends the source asset. To deliver to a different wallet, register that one too. The source can also be an embedded wallet you registered with kindembeddedWallet. See Register payment account for the full schema.
Create a quote: POST /organization/{organizationId}/quote
Show Details
Quote between the two wallet accounts. Each account must belong to the organization in the route or to your API key’s organization. Quotes expire 2 minutes after they are created (expiresAt). The response includes rateBeforeFees, rateAfterFees and midMarketRate. See Create quote for the full schema.
Partner fees: We charge your partner fee only on quotes for your customer organizations, so this quote for your own organization has none. To see it, quote with a customer organization’s id in the path. To set it for one quote, add "partnerFeeBpsOverride": 100. We cap values above 500. See Partner fees.
4
Create the order: POST /organization/{organizationId}/order
Show Details
Send the quoteId. The response is 201 with the full order, and the order’s id equals the quoteId. See Create order for the full schema.
As on an offramp, fundingInstructions.rail is the chain, and fundingInstructions.destination gives the address to send to, a memo when one is needed, and a preparedTransaction when we built one. When the source is an embedded wallet, destination holds an authorizationId in place of an address.
5
Send the source asset
Show Details
The swap does not start until the customer’s wallet sends the source asset. Fund the order before fundingDeadline in one of three ways:
Sign the prepared transaction. When preparedTransaction is present, sign transaction with the customer’s wallet and submit it to the network.
Send a transfer yourself. Send the order’s source.amount of source.asset to address, with memo when it is present.
Prepared transactions go stale. A Solana or Stellar transaction goes stale after refreshAfter. A Stellar or EVM transaction also goes stale when the wallet sends another transaction first. In either case, call POST /organization/{organizationId}/order/{id}/funding_instructions/refresh. The new funding instructions arrive a moment later in an orderUpdated webhook and on GET.
6
Track the order: GET /organization/{organizationId}/order/{id}
Show Details
We receive the source asset, run the swap on the chain’s venue, and deliver the result to the destination wallet. The status moves created → funded → completed. A completed swap usually holds the hash of the delivery transaction in deliveryTransactionId. It can be null on a delivered swap. Read the order with Get order, or subscribe to orderUpdated with POST /webhook_subscription.
Swaps are orders, so List orders returns them with your onramps and offramps.When the destination is an embedded wallet that has no trustline for the destination token yet, the order ends claimable. Claim it the same way as an onramp: see Claims.
Sandbox tester
Sandbox API keys only. The tester sends requests from your browser with the API key you paste. Production keys do not work in it. In production, call these endpoints from your server.
The tester lists the organization’s wallet payment accounts and runs a swap between two of them: quote, order, funding, and the order’s progress. Each step shows its request and response, with a curl command to copy.
Embedded wallet source: paste the PKCS#8 PEM private key of the wallet’s signer key. Your organization needs embedded wallets turned on, and the wallet must already hold the source token. The tester signs the order’s funding authorization in your browser and, when the destination is the same wallet and ends claimable, prepares and signs the claim authorization too. The key never leaves the page.
Self-held wallet source: the tester shows fundingInstructions.destination. Send the funds or sign preparedTransaction with your own wallet, and refresh the funding instructions when the prepared transaction goes stale.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Etherfuse API","colors":{"primary":"#141414","light":"#E4FF3F","dark":"#141414"},"logo":{"light":"https://mintcdn.com/etherfuse/XRSchVFGUgreQatD/img/logo-black.svg?fit=max\u0026auto=format\u0026n=XRSchVFGUgreQatD\u0026q=85\u0026s=92cf84eca27df4a19f7b032da398d110","dark":"https://mintcdn.com/etherfuse/XRSchVFGUgreQatD/img/logo-white.svg?fit=max\u0026auto=format\u0026n=XRSchVFGUgreQatD\u0026q=85\u0026s=7c87780c9a248347ffe6357ccf6762ed","href":"https://etherfuse.com"},"favicon":"https://mintcdn.com/etherfuse/pF4txuzXWQE790kS/img/favicon.png?fit=max\u0026auto=format\u0026n=pF4txuzXWQE790kS\u0026q=85\u0026s=ac74be5f7f4605e75bc961be0c6e5ff9","api":{"openapi":["openapi.json","https://api.etherfuse.com/openapi-v2.json"],"playground":{"display":"interactive"},"examples":{"languages":["curl","javascript","python"],"autogenerate":true}},"navbar":{"links":[{"href":"https://cal.com/team/etherfuse/api-overview?overlayCalendar=true","label":"Book a demo"},{"href":"https://app.etherfuse.com","label":"App"}],"primary":{"type":"button","label":"Get sandbox keys","href":"https://sandbox.etherfuse.com/sign-in?returnTo=%2Faccount%2Fmanage"}},"footer":{"links":[{"items":[{"label":"Website","href":"https://etherfuse.com"},{"label":"App","href":"https://app.etherfuse.com"},{"label":"Book a demo","href":"https://cal.com/team/etherfuse/api-overview?overlayCalendar=true"}]}]},"fonts":{"family":"Figtree"},"integrations":{"posthog":{"apiKey":"phc_vJEpZk4aZr9PxdPqapjg8ZKWFybTTmDvAxZNg88LTuPu","apiHost":"https://us.i.posthog.com"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"etherfuse","hasAudioNarration":false,"actualSubdomain":"etherfuse","customDomains":["docs.etherfuse.com"],"gitSource":{"type":"github","owner":"etherfuse","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6b04f977268f4c77be388fb9","clientVersion":"0.0.4286","searchFilterCounts":[{"language":"default","tag":"API Reference","count":155},{"language":"default","tag":"Ramp API","count":72},{"language":"default","tag":"Guides","count":65},{"language":"default","tag":"Endpoints","count":60},{"language":"default","tag":"KYC","count":20},{"language":"default","tag":"Orders","count":17},{"language":"default","tag":"Organizations","count":17},{"language":"default","tag":"Blockchains","count":12},{"language":"default","tag":"Integration Guides","count":12},{"language":"default","tag":"Lookup API","count":10}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[{"filePath":"global.css","content":"body{scrollbar-gutter:stable}.sandbox-playground-cta{display:block;margin:1rem 0 1.25rem;padding:1rem 1.25rem;border-radius:0.75rem;border:1px solid #141414;background-color:#e4ff3f;color:#141414!important;text-decoration:none;transition:background-color 0.15s ease, box-shadow 0.15s ease}.sandbox-playground-cta:hover{background-color:#d8f32f;box-shadow:0 2px 8px rgba(20, 20, 20, 0.12);color:#141414!important}.sandbox-playground-cta__title,.sandbox-playground-cta__body,.sandbox-playground-cta__detail{color:inherit!important}.dark .sandbox-playground-cta{border-color:#e4ff3f;background-color:#e4ff3f;color:#141414!important}.dark .sandbox-playground-cta:hover{background-color:#d8f32f;color:#141414!important}.sandbox-playground-cta__title{display:block;font-size:1rem;font-weight:600;margin-bottom:0.35rem}.sandbox-playground-cta__body{display:block;font-size:0.95rem;line-height:1.45;font-weight:500}.sandbox-playground-cta__detail{display:block;margin-top:0.35rem;font-size:0.85rem;line-height:1.45;opacity:0.85}"}]}
{"page":{"pagePath":"v2/guides/testing-swaps","slug":"/v2/guides/testing-swaps","pageMetadata":{"title":"Swaps","description":"How to test token-to-token swap flows in the sandbox environment","href":"/v2/guides/testing-swaps"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"How to test token-to-token swap flows in the sandbox environment\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];const SwapTutorialV2=()=>{const{useState,useEffect,useCallback,useRef}=React;const _palette={border:`#e5e7eb`,panel:`#f8fafc`,panelAlt:`#f9fafb`,blue:`#3b82f6`,greenBg:`#dcfce7`,greenText:`#166534`,redText:`#dc2626`,redBg:`#fef2f2`,muted:`#6b7280`,mono:`ui-monospace, SFMono-Regular, \"SF Mono\", Menlo, Consolas, monospace`};const _stepBadgeColor=status=>{if(status===`done`)return{bg:`#dcfce7`,color:`#166534`};if(status===`active`)return{bg:`#dbeafe`,color:`#1e40af`};if(status===`error`)return{bg:`#fef2f2`,color:`#dc2626`};return{bg:`#f3f4f6`,color:`#6b7280`}};const _stepDotStyle=status=>{const base={width:24,height:24,borderRadius:`50%`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:12,fontWeight:600,flexShrink:0};if(status===`done`)return{...base,backgroundColor:`#22c55e`,color:`#fff`};if(status===`active`)return{...base,backgroundColor:_palette.blue,color:`#fff`};if(status===`error`)return{...base,backgroundColor:_palette.redText,color:`#fff`};return{...base,backgroundColor:`#e5e7eb`,color:_palette.muted}};const _codeStyle={width:`100%`,maxHeight:260,overflow:`auto`,padding:12,fontFamily:_palette.mono,fontSize:12,lineHeight:1.5,borderRadius:6,backgroundColor:_palette.panel,color:`#334155`,border:`1px solid #e2e8f0`,margin:0,whiteSpace:`pre-wrap`,wordBreak:`break-word`,boxSizing:`border-box`};const _btnSecondary={padding:`6px 12px`,borderRadius:6,border:`1px solid #d1d5db`,cursor:`pointer`,backgroundColor:`transparent`,color:_palette.muted,fontSize:12};const _btnPrimary=(enabled,busy)=>({padding:`8px 16px`,borderRadius:6,border:`none`,cursor:enabled?`pointer`:`not-allowed`,backgroundColor:enabled?_palette.blue:`#9ca3af`,color:`#fff`,fontSize:13,fontWeight:500,opacity:busy?.7:1});const StepCard=({name,num,title,subtitle,children,action,actionLabel,actionDisabled,showRefresh,onRefresh,steps,busy})=>{const status=steps[name];const colors=_stepBadgeColor(status);return _jsxs(`div`,{style:{marginBottom:16,border:`1px solid ${_palette.border}`,borderRadius:8,overflow:`hidden`,opacity:status===`idle`?.6:1},children:[_jsxs(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`10px 14px`,backgroundColor:_palette.panel,borderBottom:`1px solid ${_palette.border}`},children:[_jsxs(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`},children:[_jsx(`span`,{style:_stepDotStyle(status),children:status===`done`?`✓`:num}),_jsx(`span`,{style:{fontSize:14,fontWeight:500},children:title}),subtitle\u0026\u0026_jsx(`span`,{style:{fontSize:12,color:_palette.muted},children:subtitle}),status!==`idle`\u0026\u0026_jsx(`span`,{style:{fontSize:11,padding:`2px 8px`,borderRadius:10,backgroundColor:colors.bg,color:colors.color,fontWeight:500},children:status})]}),_jsxs(`div`,{style:{display:`flex`,gap:6},children:[showRefresh\u0026\u0026_jsx(`button`,{onClick:onRefresh,style:_btnSecondary,title:`Read the order again`,children:`Refresh`}),action\u0026\u0026_jsx(`button`,{onClick:action,disabled:actionDisabled||busy,style:_btnPrimary(!actionDisabled\u0026\u0026!busy,busy),children:actionLabel||`Run`})]})]}),_jsx(`div`,{style:{padding:14},children})]})};const[copied,setCopied]=useState(``);const LogPanel=({stepName,log})=>{const entry=log[stepName];if(!entry)return null;return _jsxs(`div`,{style:{marginTop:10},children:[entry.req!==null\u0026\u0026entry.req!==undefined\u0026\u0026_jsxs(`div`,{style:{marginBottom:6},children:[_jsxs(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:3},children:[_jsx(`span`,{style:{fontSize:11,color:_palette.muted},children:`Request`}),entry.curl\u0026\u0026_jsx(`button`,{onClick:()=>copyText(entry.curl,stepName),style:{..._btnSecondary,padding:`2px 8px`,fontSize:11},children:copied===stepName?`Copied`:`Copy curl`})]}),_jsx(`pre`,{style:_codeStyle,children:typeof entry.req===`string`?entry.req:JSON.stringify(entry.req,null,2)})]}),entry.res\u0026\u0026_jsxs(`div`,{style:{marginBottom:6},children:[_jsxs(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,marginBottom:3},children:[entry.status\u0026\u0026_jsx(`span`,{style:{fontSize:11,padding:`2px 6px`,borderRadius:4,backgroundColor:_palette.greenBg,color:_palette.greenText,fontWeight:500},children:entry.status}),_jsx(`span`,{style:{fontSize:11,color:_palette.muted},children:`Response`})]}),_jsx(`pre`,{style:_codeStyle,children:JSON.stringify(entry.res,null,2)})]}),entry.error\u0026\u0026_jsxs(`div`,{style:{padding:10,backgroundColor:_palette.redBg,color:_palette.redText,borderRadius:6,fontSize:13,border:`1px solid #fecaca`,wordBreak:`break-word`},children:[_jsx(`strong`,{children:`Error:`}),` `,entry.error]})]})};const baseUrl=`https://api.sand.etherfuse.com`;const[apiKey,setApiKey]=useState(``);const prodKeyBlocked=apiKey.startsWith(`api_prod`);useEffect(()=>{try{const stored=sessionStorage.getItem(`etherfuse_api_key`);if(stored)setApiKey(stored)}catch{}},[]);const handleApiKeyChange=value=>{setApiKey(value);try{if(value)sessionStorage.setItem(`etherfuse_api_key`,value);else sessionStorage.removeItem(`etherfuse_api_key`)}catch{}};const copyText=(text,id)=>{try{navigator.clipboard.writeText(text)}catch{}setCopied(id);setTimeout(()=>setCopied(``),2e3)};const curlFor=(method,path,body,headers={})=>{let cmd=`curl`;if(method!==`GET`)cmd+=` -X `+method;cmd+=` \"`+baseUrl+path+`\" \\\\\n -H \"Authorization: \u003capi_key>\"`;Object.entries(headers).forEach(([k,v])=>{cmd+=` \\\\\n -H \"`+k+`: `+v+`\"`});if(body!==undefined)cmd+=` \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '`+JSON.stringify(body)+`'`;return cmd};const[organizationId,setOrganizationId]=useState(``);const org=`/organization/${organizationId}`;const[walletAccounts,setWalletAccounts]=useState([]);const[sourceKind,setSourceKind]=useState(`embedded`);const[sourceId,setSourceId]=useState(``);const[destinationId,setDestinationId]=useState(``);const[privateKeyPem,setPrivateKeyPem]=useState(``);const[keyError,setKeyError]=useState(``);const[keyReady,setKeyReady]=useState(false);const signKeyRef=useRef(null);const submittedAuthorizationIdsRef=useRef(new Set);const[tokens,setTokens]=useState([]);const[sourceAsset,setSourceAsset]=useState(``);const[destinationAsset,setDestinationAsset]=useState(``);const[amount,setAmount]=useState(`10`);const[quote,setQuote]=useState(null);const[order,setOrder]=useState(null);const[authorization,setAuthorization]=useState(null);const[finalOrder,setFinalOrder]=useState(null);const[steps,setSteps]=useState({quote:`idle`,order:`idle`,fund:`idle`,watch:`idle`});const setStep=(name,status)=>setSteps(prev=>({...prev,[name]:status}));const[log,setLog]=useState({});const setStepLog=(name,entry)=>setLog(prev=>({...prev,[name]:entry}));const[busy,setBusy]=useState(false);const pollRunRef=useRef(0);const[polling,setPolling]=useState(false);const sleep=ms=>new Promise(r=>setTimeout(r,ms));const apiFetch=useCallback(async(method,path,body)=>{if(prodKeyBlocked){throw new Error(`Production API keys are not allowed in this sandbox tester. Use a sandbox key.`)}const opts={method,headers:{Authorization:apiKey,\"Content-Type\":`application/json`}};if(body!==undefined)opts.body=JSON.stringify(body);const res=await fetch(baseUrl+path,opts);const text=await res.text();let json;try{json=text?JSON.parse(text):{}}catch{json={raw:text}}if(!res.ok){const slug=typeof json.type===`string`?json.type.split(`/`).pop():``;throw Object.assign(new Error(`${res.status} ${slug}: ${json.detail||text.slice(0,300)}`),{status:res.status,slug,body:json})}return{status:res.status,json}},[apiKey,prodKeyBlocked]);useEffect(()=>{if(!apiKey||prodKeyBlocked)return;apiFetch(`GET`,`/me`).then(({json})=>{if(json.id)setOrganizationId(prev=>prev||json.id)}).catch(()=>{})},[apiKey,prodKeyBlocked,apiFetch]);useEffect(()=>{if(!apiKey||prodKeyBlocked||!organizationId){setWalletAccounts([]);return}apiFetch(`GET`,`${org}/payment_accounts?pageSize=100`).then(({json})=>{const wallets=(json.items||[]).filter(a=>{const rails=Object.values(a.rails||{});return rails.length>0\u0026\u0026rails.every(r=>r\u0026\u0026!r.currency)});setWalletAccounts(wallets);setSourceId(prev=>wallets.some(w=>w.id===prev)?prev:(wallets[0]||{}).id||``)}).catch(()=>setWalletAccounts([]))},[apiKey,prodKeyBlocked,organizationId,apiFetch]);useEffect(()=>{setDestinationId(prev=>walletAccounts.some(w=>w.id===prev)?prev:sourceId)},[sourceId,walletAccounts]);useEffect(()=>{if(!apiKey||prodKeyBlocked||!sourceId){setTokens([]);return}apiFetch(`GET`,`/supported_assets?paymentAccountId=${sourceId}`).then(({json})=>{const list=json.tokens||[];setTokens(list);const usdc=list.find(t=>t.symbol===`USDC`);const bond=list.find(t=>t.symbol!==`USDC`);setSourceAsset(prev=>list.some(t=>t.asset===prev)?prev:(usdc||list[0]||{}).asset||``);setDestinationAsset(prev=>list.some(t=>t.asset===prev)?prev:(bond||list[1]||{}).asset||``)}).catch(()=>setTokens([]))},[apiKey,prodKeyBlocked,sourceId,apiFetch]);const pemToPkcs8=pem=>{const b64=pem.replace(/-----(BEGIN|END) PRIVATE KEY-----/g,``).replace(/\\s+/g,``);return Uint8Array.from(atob(b64),c=>c.charCodeAt(0))};useEffect(()=>{signKeyRef.current=null;setKeyReady(false);if(!privateKeyPem.trim()){setKeyError(``);return}Promise.resolve().then(()=>crypto.subtle.importKey(`pkcs8`,pemToPkcs8(privateKeyPem),{name:`ECDSA`,namedCurve:`P-256`},false,[`sign`])).then(key=>{signKeyRef.current=key;setKeyReady(true);setKeyError(``)}).catch(()=>setKeyError(`This is not a P-256 private key in PKCS#8 PEM.`))},[privateKeyPem]);const hexEncode=bytes=>[...bytes].map(b=>b.toString(16).padStart(2,`0`)).join(``);const signMessage=async(message,key)=>{const sig=await crypto.subtle.sign({name:`ECDSA`,hash:`SHA-256`},key,new TextEncoder().encode(message));return hexEncode(new Uint8Array(sig))};const resetFrom=stepName=>{const stepNames=[`quote`,`order`,`fund`,`watch`];const idx=stepNames.indexOf(stepName);pollRunRef.current+=1;setPolling(false);if(idx\u003c=0)setQuote(null);if(idx\u003c=1){setOrder(null);setAuthorization(null);setFinalOrder(null)}setSteps(prev=>{const next={...prev};stepNames.slice(idx).forEach(s=>{next[s]=`idle`});return next})};const isEmbedded=sourceKind===`embedded`;const sameWallet=sourceId\u0026\u0026sourceId===destinationId;const handleQuote=async()=>{setBusy(true);resetFrom(`quote`);setStep(`quote`,`active`);const path=`${org}/quote`;const reqBody={source:{type:`stored`,id:sourceId},destination:{type:`stored`,id:destinationId},sourceAmount:amount,sourceAsset,destinationAsset};try{const{status,json}=await apiFetch(`POST`,path,reqBody);setQuote(json);setStepLog(`quote`,{req:reqBody,res:json,status,curl:curlFor(`POST`,path,reqBody)});setStep(`quote`,`done`);setStep(`order`,`active`)}catch(e){setStepLog(`quote`,{req:reqBody,error:e.message,curl:curlFor(`POST`,path,reqBody)});setStep(`quote`,`error`)}finally{setBusy(false)}};const applyOrder=json=>{setOrder(json);const pendingAuthorization=json.authorization\u0026\u0026!submittedAuthorizationIdsRef.current.has(json.authorization.id)?json.authorization:null;setAuthorization(pendingAuthorization)};const readOrder=useCallback(async orderId=>{const{json}=await apiFetch(`GET`,`${org}/order/${orderId}`);applyOrder(json);setStepLog(`watch`,{req:`GET ${org}/order/${orderId}`,res:json});if(json.status!==`created`)setStep(`fund`,`done`);if([`completed`,`failed`,`canceled`,`refunded`].includes(json.status)){setFinalOrder(json);setStep(`watch`,json.status===`completed`?`done`:`error`);return true}return false},[apiFetch,org]);const startPolling=useCallback(orderId=>{pollRunRef.current+=1;const run=pollRunRef.current;setPolling(true);setStep(`watch`,`active`);(async()=>{for(let i=0;i\u003c180\u0026\u0026pollRunRef.current===run;i++){await sleep(2500);if(pollRunRef.current!==run)return;try{if(await readOrder(orderId))break}catch{}}if(pollRunRef.current===run)setPolling(false)})()},[readOrder]);const handleOrder=async()=>{setBusy(true);resetFrom(`order`);setStep(`order`,`active`);const path=`${org}/order`;const reqBody={quoteId:quote.quoteId};try{const{status,json}=await apiFetch(`POST`,path,reqBody);applyOrder(json);setStepLog(`order`,{req:reqBody,res:json,status,curl:curlFor(`POST`,path,reqBody)});setStep(`order`,`done`);setStep(`fund`,`active`);startPolling(json.id)}catch(e){setStepLog(`order`,{req:reqBody,error:e.message,curl:curlFor(`POST`,path,reqBody)});setStep(`order`,`error`)}finally{setBusy(false)}};const handleSign=async()=>{setBusy(true);const stepName=order\u0026\u0026order.status===`claimable`?`watch`:`fund`;try{const{json:fresh}=await apiFetch(`GET`,`${org}/order/${order.id}`);applyOrder(fresh);if(!fresh.authorization)throw new Error(`The order has no pending authorization. Refresh to read it again.`);const signature=await signMessage(fresh.authorization.method.message,signKeyRef.current);const path=`${org}/order/${order.id}/authorization`;const reqBody={id:fresh.authorization.id,signature};const{status,json}=await apiFetch(`POST`,path,reqBody);setStepLog(stepName,{req:reqBody,res:json,status,curl:curlFor(`POST`,path,reqBody)});submittedAuthorizationIdsRef.current.add(reqBody.id);setAuthorization(null);if(stepName===`fund`)setStep(`fund`,`done`);if(!polling)startPolling(order.id)}catch(e){const isClaim=order\u0026\u0026order.status===`claimable`;const expiredHint=isClaim?` We do not replace an expired claim authorization. Prepare the claim again to get a new one.`:` We replaced the authorization. Press Sign and submit again to sign the new one.`;const hint=e.slug===`authorization-expired`?expiredHint:``;setStepLog(stepName,{error:e.message+hint});if(stepName===`fund`)setStep(`fund`,`error`)}finally{setBusy(false)}};const handleRefreshFunding=async()=>{setBusy(true);const path=`${org}/order/${order.id}/funding_instructions/refresh`;try{const{status,json}=await apiFetch(`POST`,path);setStepLog(`fund`,{req:`POST ${path}`,res:Object.keys(json).length?json:{note:`New funding instructions arrive on the order in a moment.`},status,curl:curlFor(`POST`,path)})}catch(e){setStepLog(`fund`,{req:`POST ${path}`,error:e.message})}finally{setBusy(false)}};const waitForClaimAuthorization=async(orderPath,previousAuthorizationId)=>{for(let attempt=0;attempt\u003c15;attempt+=1){const{json:fresh}=await apiFetch(`GET`,orderPath);if(fresh.authorization\u0026\u0026fresh.authorization.reason===`claim`\u0026\u0026fresh.authorization.id!==previousAuthorizationId)return;await new Promise(resolve=>setTimeout(resolve,2e3))}throw new Error(`The claim authorization has not appeared yet. Refresh the order in a moment.`)};const handleClaim=async()=>{setBusy(true);const path=`${org}/order/${order.id}/claim`;try{const previousAuthorizationId=order.authorization?order.authorization.id:null;const{status,json}=await apiFetch(`POST`,path);setStepLog(`watch`,{req:`POST ${path}`,res:json,status,curl:curlFor(`POST`,path)});await waitForClaimAuthorization(`${org}/order/${order.id}`,previousAuthorizationId);await readOrder(order.id)}catch(e){setStepLog(`watch`,{req:`POST ${path}`,error:e.message})}finally{setBusy(false)}};const handleRefresh=async()=>{if(!order)return;try{const done=await readOrder(order.id);if(!done\u0026\u0026!polling)startPolling(order.id)}catch{}};const inputStyle={width:`100%`,padding:`8px 10px`,borderRadius:4,border:`1px solid #d1d5db`,fontSize:13,fontFamily:_palette.mono,boxSizing:`border-box`};const selectStyle={...inputStyle,backgroundColor:`white`,cursor:`pointer`,appearance:`auto`,WebkitAppearance:`menulist`,MozAppearance:`menulist`};const labelStyle={display:`block`,fontSize:12,fontWeight:600,color:`#374151`,marginBottom:4};const noteStyle={padding:`8px 12px`,marginBottom:10,backgroundColor:`#eff6ff`,borderRadius:4,border:`1px solid #bfdbfe`,fontSize:12,color:`#1e40af`};const cardProps={steps,busy,onRefresh:handleRefresh};const canSign=isEmbedded\u0026\u0026keyReady;const destination=order\u0026\u0026order.fundingInstructions\u0026\u0026order.fundingInstructions.destination;const claimable=order\u0026\u0026order.status===`claimable`;const canClaim=claimable\u0026\u0026isEmbedded\u0026\u0026sameWallet\u0026\u0026canSign;const quoteReady=sourceId\u0026\u0026destinationId\u0026\u0026sourceAsset\u0026\u0026destinationAsset\u0026\u0026sourceAsset!==destinationAsset\u0026\u0026(!isEmbedded||canSign);const changeInput=setter=>e=>{setter(e.target.value);if(quote)resetFrom(`quote`)};const walletLabel=w=>`${w.label} (${Object.keys(w.rails||{}).join(`, `)}, ${w.status})`;return _jsxs(`div`,{style:{padding:20,border:`1px solid ${_palette.border}`,borderRadius:8,marginTop:20},children:[_jsxs(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:20,gap:8,flexWrap:`wrap`},children:[_jsx(`h3`,{style:{margin:0},children:`Swap tester`}),_jsx(`span`,{style:{fontSize:12,fontWeight:600,color:_palette.greenText,padding:`4px 10px`,backgroundColor:`#f0fdf4`,borderRadius:999,border:`1px solid #bbf7d0`},children:`Sandbox only`})]}),_jsxs(`div`,{style:{marginBottom:20,padding:16,backgroundColor:`#f3f4f6`,borderRadius:6},children:[_jsxs(`div`,{style:{marginBottom:12},children:[_jsx(`span`,{style:{fontSize:12,color:_palette.muted},children:`Host: `}),_jsx(`code`,{style:{fontSize:12},children:baseUrl})]}),_jsxs(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:8,marginBottom:8,flexWrap:`wrap`},children:[_jsx(`label`,{style:{fontWeight:600},children:`API key`}),_jsxs(`span`,{style:{fontSize:12,color:_palette.muted},children:[`Find it under API Keys at`,` `,_jsx(`a`,{href:`https://sandbox.etherfuse.com/ramp?view=manage`,target:`_blank`,rel:`noopener noreferrer`,style:{color:_palette.blue},children:`sandbox.etherfuse.com/ramp`})]})]}),_jsx(`input`,{type:`text`,value:apiKey,onChange:e=>handleApiKeyChange(e.target.value),placeholder:`Paste your sandbox API key`,style:{...inputStyle,padding:10,fontSize:14,border:`1px solid ${prodKeyBlocked?`#fca5a5`:`#d1d5db`}`}}),prodKeyBlocked\u0026\u0026_jsx(`div`,{style:{marginTop:8,padding:`8px 12px`,backgroundColor:_palette.redBg,borderRadius:4,border:`1px solid #fecaca`,fontSize:12,color:_palette.redText},children:`Production keys do not work here. Use a sandbox key.`}),_jsxs(`div`,{style:{marginTop:12},children:[_jsx(`label`,{style:labelStyle,children:`Organization id`}),_jsx(`input`,{type:`text`,value:organizationId,onChange:e=>setOrganizationId(e.target.value.trim()),placeholder:`Filled from GET /me; replace it with a customer organization's id to act for that customer`,style:inputStyle})]}),_jsx(`p`,{style:{fontSize:12,color:_palette.muted,marginTop:12,marginBottom:0},children:`We keep your API key in session storage and clear it when you close the tab.`})]}),_jsxs(`div`,{style:{marginBottom:20,padding:14,backgroundColor:_palette.panelAlt,borderRadius:8,border:`1px solid ${_palette.border}`},children:[_jsxs(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(200px, 1fr))`,gap:12},children:[_jsxs(`div`,{children:[_jsx(`label`,{style:labelStyle,children:`Source wallet holds its key`}),_jsxs(`select`,{value:sourceKind,onChange:changeInput(setSourceKind),style:selectStyle,children:[_jsx(`option`,{value:`embedded`,children:`Embedded wallet (you sign an authorization)`}),_jsx(`option`,{value:`wallet`,children:`Self-held wallet (you send the funds)`})]})]}),_jsxs(`div`,{children:[_jsx(`label`,{style:labelStyle,children:`Source wallet`}),_jsxs(`select`,{value:sourceId,onChange:changeInput(setSourceId),style:selectStyle,children:[walletAccounts.map(w=>_jsx(`option`,{value:w.id,children:walletLabel(w)},w.id)),walletAccounts.length===0\u0026\u0026_jsx(`option`,{value:``,children:apiKey?`No wallets found`:`Enter your API key`})]})]}),_jsxs(`div`,{children:[_jsx(`label`,{style:labelStyle,children:`Destination wallet`}),_jsx(`select`,{value:destinationId,onChange:changeInput(setDestinationId),style:selectStyle,children:walletAccounts.map(w=>_jsxs(`option`,{value:w.id,children:[walletLabel(w),w.id===sourceId?` (same as source)`:``]},w.id))})]}),_jsxs(`div`,{children:[_jsx(`label`,{style:labelStyle,children:`Source token`}),_jsxs(`select`,{value:sourceAsset,onChange:changeInput(setSourceAsset),style:selectStyle,children:[tokens.map(t=>_jsxs(`option`,{value:t.asset,children:[t.symbol,` (`,t.chain,`)`]},t.asset)),tokens.length===0\u0026\u0026_jsx(`option`,{value:``,children:`Pick a source wallet`})]})]}),_jsxs(`div`,{children:[_jsx(`label`,{style:labelStyle,children:`Destination token`}),_jsx(`select`,{value:destinationAsset,onChange:changeInput(setDestinationAsset),style:selectStyle,children:tokens.map(t=>_jsxs(`option`,{value:t.asset,children:[t.symbol,` (`,t.chain,`)`]},t.asset))})]}),_jsxs(`div`,{children:[_jsx(`label`,{style:labelStyle,children:`Amount of the source token`}),_jsx(`input`,{type:`text`,value:amount,onChange:changeInput(setAmount),style:inputStyle})]})]}),isEmbedded\u0026\u0026_jsxs(`div`,{style:{marginTop:12},children:[_jsx(`label`,{style:labelStyle,children:`Signer private key (PKCS#8 PEM)`}),_jsx(`textarea`,{spellCheck:false,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,value:privateKeyPem,onChange:e=>setPrivateKeyPem(e.target.value),placeholder:`-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----`,rows:4,style:{...inputStyle,resize:`vertical`}}),_jsx(`p`,{style:{margin:`6px 0 0`,fontSize:12,color:keyError?_palette.redText:_palette.muted},children:keyError||`We sign in your browser and never send this key. Use the key you registered as an embeddedWallet payment account with POST .../payment_account, after an onramp into that wallet so it holds the source token.`})]}),sourceAsset\u0026\u0026sourceAsset===destinationAsset\u0026\u0026_jsx(`p`,{style:{margin:`10px 0 0`,fontSize:12,color:`#92400e`},children:`Pick two different tokens. One of them must be a stablebond.`})]}),StepCard({...cardProps,name:`quote`,num:1,title:`Get a quote`,subtitle:`POST /organization/{organizationId}/quote`,action:handleQuote,actionLabel:`Quote`,actionDisabled:!quoteReady,children:_jsxs(_Fragment,{children:[_jsx(`p`,{style:{color:_palette.muted,margin:`0 0 10px`},children:`We quote between the two wallets by their payment account ids. Both must be on the same chain. A quote expires after 2 minutes.`}),LogPanel({stepName:`quote`,log})]})}),StepCard({...cardProps,name:`order`,num:2,title:`Create the order`,subtitle:`POST /organization/{organizationId}/order`,action:handleOrder,actionLabel:`Create order`,actionDisabled:!quote,children:_jsxs(_Fragment,{children:[_jsxs(`p`,{style:{color:_palette.muted,margin:`0 0 10px`},children:[`We send the `,_jsx(`code`,{children:`quoteId`}),`. The order's `,_jsx(`code`,{children:`id`}),` is the `,_jsx(`code`,{children:`quoteId`}),`, and `,_jsx(`code`,{children:`fundingInstructions`}),` tells you how to send the source token.`]}),LogPanel({stepName:`order`,log})]})}),StepCard({...cardProps,name:`fund`,num:3,title:`Fund the order`,subtitle:isEmbedded?`POST /organization/{organizationId}/order/{id}/authorization`:`Send from your wallet`,action:isEmbedded?handleSign:handleRefreshFunding,actionLabel:isEmbedded?`Sign and submit`:`Refresh funding instructions`,actionDisabled:!order||order.status!==`created`||isEmbedded\u0026\u0026(!authorization||!canSign),children:_jsxs(_Fragment,{children:[isEmbedded?_jsxs(_Fragment,{children:[_jsxs(`p`,{style:{color:_palette.muted,margin:`0 0 10px`},children:[`An embedded wallet has no address to send from. `,_jsx(`code`,{children:`fundingInstructions.destination`}),` holds an `,_jsx(`code`,{children:`authorizationId`}),`, and the order shows a `,_jsx(`code`,{children:`funding`}),` authorization. We read the order, sign the UTF-8 bytes of `,_jsx(`code`,{children:`authorization.method.message`}),` with ECDSA P-256 and SHA-256, and send the hex signature with the authorization `,_jsx(`code`,{children:`id`}),`. Then we move the funds.`]}),order\u0026\u0026!authorization\u0026\u0026order.status===`created`\u0026\u0026_jsx(`div`,{style:noteStyle,children:`Waiting for the funding authorization to appear on the order.`}),authorization\u0026\u0026_jsxs(`div`,{style:{marginBottom:10},children:[_jsxs(`div`,{style:{fontSize:12,color:_palette.muted,marginBottom:3},children:[`Pending authorization (`,authorization.reason,`, expires `,authorization.expiresAt,`)`]}),_jsx(`pre`,{style:_codeStyle,children:JSON.stringify(authorization,null,2)})]})]}):_jsxs(_Fragment,{children:[_jsxs(`p`,{style:{color:_palette.muted,margin:`0 0 10px`},children:[`Send the order's `,_jsx(`code`,{children:`source.amount`}),` of the source token to `,_jsx(`code`,{children:`address`}),`, with `,_jsx(`code`,{children:`memo`}),` when there is one, or sign and submit `,_jsx(`code`,{children:`preparedTransaction.transaction`}),` with your wallet. A prepared transaction goes stale after `,_jsx(`code`,{children:`refreshAfter`}),` or when the wallet sends another transaction first; refresh it to get a new one.`]}),destination\u0026\u0026_jsx(`pre`,{style:{..._codeStyle,marginBottom:10},children:JSON.stringify(destination,null,2)})]}),LogPanel({stepName:`fund`,log})]})}),StepCard({...cardProps,name:`watch`,num:4,title:`Watch the order`,subtitle:`GET /organization/{organizationId}/order/{id}`,showRefresh:!!order,action:canClaim?authorization?handleSign:handleClaim:undefined,actionLabel:authorization?`Sign and submit`:`Prepare claim`,children:_jsxs(_Fragment,{children:[_jsxs(`p`,{style:{color:_palette.muted,margin:`0 0 10px`},children:[`We read the order every 2.5 seconds until it finishes. The status moves `,_jsx(`code`,{children:`created`}),`, `,_jsx(`code`,{children:`funded`}),`, `,_jsx(`code`,{children:`completed`}),`. In production, subscribe to `,_jsx(`code`,{children:`orderUpdated`}),`.`]}),claimable\u0026\u0026_jsxs(`div`,{style:noteStyle,children:[`The destination wallet has no trustline for the token yet, so the order is `,_jsx(`code`,{children:`claimable`}),`.`,` `,canClaim?_jsxs(_Fragment,{children:[`Press `,_jsx(`strong`,{children:`Prepare claim`}),`: `,_jsx(`code`,{children:`POST .../claim`}),` returns `,_jsx(`code`,{children:`202`}),`, and a few seconds later the order shows a `,_jsx(`code`,{children:`claim`}),` authorization. Then sign it.`]}):_jsxs(_Fragment,{children:[`Claim it with the destination wallet. See the order's `,_jsx(`code`,{children:`claimInstructions`}),`.`]})]}),polling\u0026\u0026!finalOrder\u0026\u0026!claimable\u0026\u0026_jsx(`div`,{style:{padding:10,backgroundColor:`#fefce8`,borderRadius:4,border:`1px solid #fde68a`,fontSize:12,color:`#92400e`,marginBottom:10},children:`Waiting for the order to change.`}),finalOrder\u0026\u0026_jsxs(`div`,{style:{marginBottom:8,fontSize:13},children:[`Final status: `,_jsx(`strong`,{children:finalOrder.status})]}),LogPanel({stepName:`watch`,log})]})})]})};function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Expandable,Heading,Info,Step,Steps,Table,Tip,Warning,_MdxComponentBoundary}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Info)_missingMdxReference(`Info`,true);if(!Step)_missingMdxReference(`Step`,true);if(!Steps)_missingMdxReference(`Steps`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);if(!_MdxComponentBoundary)_missingMdxReference(`_MdxComponentBoundary`,true);return _jsxs(_Fragment,{children:[_jsx(Info,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Prerequisite:`}),` Your organization must be approved before it can quote. Swaps do not need a bank account. For onboarding your customers, see `,_jsx(_components.a,{href:`/v2/guides/onboarding`,children:`KYC Overview`}),`.`]})}),`\n`,_jsx(_components.p,{children:`A swap exchanges one asset for another on the same chain. In v2 a swap is a quote and an order between two wallet payment accounts, the same way an onramp or offramp is. The destination can be the same wallet as the source, or another wallet on the same chain.`}),`\n`,_jsxs(_components.p,{children:[`Every call below runs for one organization, set as `,_jsx(_components.code,{children:`$ORGANIZATION_ID`}),` in the examples. Use your own organization’s id from `,_jsx(_components.code,{children:`GET /me`}),`, or a customer organization’s id when you swap for that customer. Register the wallets, quote and order under the same id. See `,_jsx(_components.a,{href:`/v2/overview#organizations-in-the-route`,children:`Organizations in the route`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ORGANIZATION_ID`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=\u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`organization_id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`})]}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Swaps run on `,_jsx(_components.strong,{children:`Stellar`}),`, `,_jsx(_components.strong,{children:`Solana`}),` and `,_jsx(_components.strong,{children:`Monad`}),`. The source and destination wallets must be on the `,_jsx(_components.strong,{children:`same chain`}),`. To move the same token to a wallet on another chain, quote a `,_jsx(_components.a,{href:`/v2/overview`,children:`cross-chain transfer`}),` instead. A quote between different tokens on different chains returns `,_jsx(_components.code,{children:`400`}),` `,_jsx(_components.code,{children:`invalid-request`}),`. Base, Polygon and Avalanche support onramps and offramps, not swaps.`]})}),`\n`,_jsx(Info,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Stellar swaps need a funded, trustlined wallet.`}),` The wallet must hold XLM for the network fee and a trustline for the asset it receives. An `,_jsx(_components.a,{href:`/v2/guides/embedded-wallets`,children:`embedded wallet`}),` does not need this setup: its first onramp pays for its reserves, we pay its network fees and bill them at cost, and a token it has no trustline for arrives as a claim. See the `,_jsx(_components.a,{href:`/v2/guides/chains/stellar#offramps-and-swaps-fund-the-wallet-first`,children:`Stellar`}),`, `,_jsx(_components.a,{href:`/v2/guides/chains/solana`,children:`Solana`}),` and `,_jsx(_components.a,{href:`/v2/guides/chains/monad`,children:`Monad`}),` chain guides for per-chain setup.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`swap-flow`,children:`Swap flow`}),`\n`,_jsxs(Steps,{children:[_jsx(Step,{title:`Discover assets`,children:_jsxs(Expandable,{title:`Details`,children:[_jsx(_components.p,{children:`Either of these endpoints gives you the asset identifiers for a quote:`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/v2/api-reference/assets/list-supported-assets`,children:`GET /supported_assets`}),` requires auth. Pass `,_jsx(_components.code,{children:`paymentAccountId`}),` with a wallet’s id to list the tokens on that wallet’s chain.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/v2/api-reference/lookup/list-stablebonds`,children:`GET /lookup/stablebonds`}),` is public. It returns every stablebond on every chain, with pricing and supply data.`]}),`\n`]}),_jsxs(_components.p,{children:[`Use a token’s `,_jsx(_components.code,{children:`asset`}),` from the first, or the `,_jsx(_components.code,{children:`identifier`}),` from the second, as `,_jsx(_components.code,{children:`sourceAsset`}),` and `,_jsx(_components.code,{children:`destinationAsset`}),`.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Swap rules:`})}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`At least one side must be a stablebond. The other side can be a stablecoin such as USDC, so `,_jsx(_components.code,{children:`USDC → CETES`}),` and `,_jsx(_components.code,{children:`CETES → USDC`}),` both work.`]}),`\n`,_jsxs(_components.li,{children:[`Both assets must be stablebonds or supported stablecoins. Non-stable tokens (SOL, XLM) return `,_jsx(_components.code,{children:`400`}),` `,_jsx(_components.code,{children:`invalid-request`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Stablecoin-to-stablecoin swaps (`,_jsx(_components.code,{children:`USDC → USDT`}),`) return `,_jsx(_components.code,{children:`400`}),` `,_jsx(_components.code,{children:`invalid-request`}),`.`]}),`\n`,_jsx(_components.li,{children:`The two assets must differ.`}),`\n`]}),_jsxs(Warning,{children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`Asset identifier format differs by chain:`})}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Solana:`}),` Base58 mint address (for example `,_jsx(_components.code,{children:`AvvetPGuuB5FD5m86fpw3LtDKyQoUFT1mG9WarNQLW4q`}),`)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Stellar:`}),` `,_jsx(_components.code,{children:`CODE:ISSUER`}),` (for example `,_jsx(_components.code,{children:`CETES:GC3CW7...`}),`)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Monad:`}),` the raw token contract address only (for example `,_jsx(_components.code,{children:`0xcC77c598d42f2f78Beb42C91d12B9d4041a5cE29`}),`)`]}),`\n`]})]}),_jsxs(Tip,{children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`USDC identifiers:`})}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Stellar sandbox:`}),` `,_jsx(_components.code,{children:`USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5`})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Stellar production:`}),` `,_jsx(_components.code,{children:`USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN`})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Solana sandbox:`}),` `,_jsx(_components.code,{children:`BXTou3CvPxpFVAJvzvEZcAnRLGCHqT1LHKsFTSQft7s`})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Solana production:`}),` `,_jsx(_components.code,{children:`EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`})]}),`\n`]})]})]})}),_jsx(Step,{title:`Register the wallets: POST /organization/{organizationId}/payment_account`,children:_jsxs(Expandable,{title:`Details`,children:[_jsxs(_components.p,{children:[`Register the wallet that sends the source asset. To deliver to a different wallet, register that one too. The source can also be an `,_jsx(_components.a,{href:`/v2/guides/embedded-wallets`,children:`embedded wallet`}),` you registered with `,_jsx(_components.code,{children:`kind`}),` `,_jsx(_components.code,{children:`embeddedWallet`}),`. See `,_jsx(_components.a,{href:`/v2/api-reference/payment-accounts/register-payment-account`,children:`Register payment account`}),` for the full schema.`]}),_jsx(CodeBlock,{filename:`Sandbox`,numberOfLines:`12`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.sand.etherfuse.com/organization/`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$ORGANIZATION_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`/payment_account`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: \u003capi_key>\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"kind\": \"wallet\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"label\": \"Treasury wallet\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"accountDetails\": {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"kind\": \"address\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"address\": \"GDUKMGUGD3V6VXTU2RLAUM7A2FABLMHCPWTMDHKP7HHJ6FCZKEY4PVWL\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"chain\": \"stellar\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),_jsxs(_components.p,{children:[`The source wallet needs `,_jsx(_components.code,{children:`source`}),` ready on its chain rail, and the destination wallet needs `,_jsx(_components.code,{children:`destination`}),` ready. Read the account again with `,_jsx(_components.a,{href:`/v2/api-reference/payment-accounts/get-payment-account`,children:`GET /organization/{organizationId}/payment_account/{id}`}),` to check.`]})]})}),_jsx(Step,{title:`Create a quote: POST /organization/{organizationId}/quote`,children:_jsxs(Expandable,{title:`Details`,children:[_jsxs(_components.p,{children:[`Quote between the two wallet accounts. Each account must belong to the organization in the route or to your API key’s organization. Quotes expire `,_jsx(_components.strong,{children:`2 minutes`}),` after they are created (`,_jsx(_components.code,{children:`expiresAt`}),`). The response includes `,_jsx(_components.code,{children:`rateBeforeFees`}),`, `,_jsx(_components.code,{children:`rateAfterFees`}),` and `,_jsx(_components.code,{children:`midMarketRate`}),`. See `,_jsx(_components.a,{href:`/v2/api-reference/quotes/create-quote`,children:`Create quote`}),` for the full schema.`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Sandbox`,numberOfLines:`10`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.sand.etherfuse.com/organization/`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$ORGANIZATION_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`/quote`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: \u003capi_key>\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"source\": { \"type\": \"stored\", \"id\": \"\u003cwallet_payment_account_id>\" },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"destination\": { \"type\": \"stored\", \"id\": \"\u003cwallet_payment_account_id>\" },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"sourceAmount\": \"10\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"sourceAsset\": \"USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"destinationAsset\": \"CETES:GC3CW7EDYRTWQ635VDIGY6S4ZUF5L6TQ7AA4MWS7LEQDBLUSZXV7UPS4\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`Production`,numberOfLines:`10`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.etherfuse.com/organization/`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$ORGANIZATION_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`/quote`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: \u003capi_key>\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"source\": { \"type\": \"stored\", \"id\": \"\u003cwallet_payment_account_id>\" },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"destination\": { \"type\": \"stored\", \"id\": \"\u003cwallet_payment_account_id>\" },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"sourceAmount\": \"10\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"sourceAsset\": \"USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"destinationAsset\": \"CETES:GC3CW7EDYRTWQ635VDIGY6S4ZUF5L6TQ7AA4MWS7LEQDBLUSZXV7UPS4\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})})]}),_jsx(Tip,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Partner fees:`}),` We charge your partner fee only on quotes for your customer organizations, so this quote for your own organization has none. To see it, quote with a customer organization’s id in the path. To set it for one quote, add `,_jsx(_components.code,{children:`\"partnerFeeBpsOverride\": 100`}),`. We cap values above 500. See `,_jsx(_components.a,{href:`/v2/fees#partner-fees`,children:`Partner fees`}),`.`]})})]})}),_jsx(Step,{title:`Create the order: POST /organization/{organizationId}/order`,children:_jsxs(Expandable,{title:`Details`,children:[_jsxs(_components.p,{children:[`Send the `,_jsx(_components.code,{children:`quoteId`}),`. The response is `,_jsx(_components.code,{children:`201`}),` with the full order, and the order’s `,_jsx(_components.code,{children:`id`}),` equals the `,_jsx(_components.code,{children:`quoteId`}),`. See `,_jsx(_components.a,{href:`/v2/api-reference/orders/create-order`,children:`Create order`}),` for the full schema.`]}),_jsx(CodeBlock,{filename:`Sandbox`,numberOfLines:`4`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.sand.etherfuse.com/organization/`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$ORGANIZATION_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`/order`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: \u003capi_key>\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{ \"quoteId\": \"\u003cquote_id>\" }'`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`As on an offramp, `,_jsx(_components.code,{children:`fundingInstructions.rail`}),` is the chain, and `,_jsx(_components.code,{children:`fundingInstructions.destination`}),` gives the `,_jsx(_components.code,{children:`address`}),` to send to, a `,_jsx(_components.code,{children:`memo`}),` when one is needed, and a `,_jsx(_components.code,{children:`preparedTransaction`}),` when we built one. When the source is an embedded wallet, `,_jsx(_components.code,{children:`destination`}),` holds an `,_jsx(_components.code,{children:`authorizationId`}),` in place of an address.`]})]})}),_jsx(Step,{title:`Send the source asset`,children:_jsxs(Expandable,{title:`Details`,children:[_jsxs(_components.p,{children:[`The swap does not start until the customer’s wallet sends the source asset. Fund the order before `,_jsx(_components.code,{children:`fundingDeadline`}),` in one of three ways:`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Sign the prepared transaction.`}),` When `,_jsx(_components.code,{children:`preparedTransaction`}),` is present, sign `,_jsx(_components.code,{children:`transaction`}),` with the customer’s wallet and submit it to the network.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Send a transfer yourself.`}),` Send the order’s `,_jsx(_components.code,{children:`source.amount`}),` of `,_jsx(_components.code,{children:`source.asset`}),` to `,_jsx(_components.code,{children:`address`}),`, with `,_jsx(_components.code,{children:`memo`}),` when it is present.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Sign the authorization (embedded wallet).`}),` The order’s `,_jsx(_components.code,{children:`authorization`}),` has `,_jsx(_components.code,{children:`reason`}),` `,_jsx(_components.code,{children:`funding`}),`. The key holder signs `,_jsx(_components.code,{children:`method.message`}),` and you send the signature to `,_jsx(_components.a,{href:`/v2/api-reference/orders/submit-authorization`,children:`POST /organization/{organizationId}/order/{id}/authorization`}),`. We then move the funds out of the wallet. See `,_jsx(_components.a,{href:`/v2/guides/embedded-wallets#3-approve-the-authorization`,children:`Order authorization`}),`.`]}),`\n`]}),_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Prepared transactions go stale.`}),` A Solana or Stellar transaction goes stale after `,_jsx(_components.code,{children:`refreshAfter`}),`. A Stellar or EVM transaction also goes stale when the wallet sends another transaction first. In either case, call `,_jsx(_components.a,{href:`/v2/api-reference/orders/refresh-funding-instructions`,children:`POST /organization/{organizationId}/order/{id}/funding_instructions/refresh`}),`. The new funding instructions arrive a moment later in an `,_jsx(_components.code,{children:`orderUpdated`}),` webhook and on GET.`]})})]})}),_jsx(Step,{title:`Track the order: GET /organization/{organizationId}/order/{id}`,children:_jsxs(Expandable,{title:`Details`,children:[_jsxs(_components.p,{children:[`We receive the source asset, run the swap on the chain’s venue, and deliver the result to the destination wallet. The status moves `,_jsx(_components.code,{children:`created`}),` → `,_jsx(_components.code,{children:`funded`}),` → `,_jsx(_components.code,{children:`completed`}),`. A `,_jsx(_components.code,{children:`completed`}),` swap usually holds the hash of the delivery transaction in `,_jsx(_components.code,{children:`deliveryTransactionId`}),`. It can be null on a delivered swap. Read the order with `,_jsx(_components.a,{href:`/v2/api-reference/orders/get-order`,children:`Get order`}),`, or subscribe to `,_jsx(_components.a,{href:`/v2/api-reference/webhook-events/orderupdated`,children:_jsx(_components.code,{children:`orderUpdated`})}),` with `,_jsx(_components.a,{href:`/v2/api-reference/webhook-subscriptions/create-webhook-subscription`,children:`POST /webhook_subscription`}),`.`]}),_jsx(CodeBlock,{filename:`Sandbox`,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: \u003capi_key>\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.sand.etherfuse.com/organization/`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$ORGANIZATION_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`/order/`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`order_i`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`d`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Swaps are orders, so `,_jsx(_components.a,{href:`/v2/api-reference/orders/list-orders`,children:`List orders`}),` returns them with your onramps and offramps.`]}),_jsxs(_components.p,{children:[`When the destination is an embedded wallet that has no trustline for the destination token yet, the order ends `,_jsx(_components.code,{children:`claimable`}),`. Claim it the same way as an onramp: see `,_jsx(_components.a,{href:`/v2/guides/embedded-wallets#claims`,children:`Claims`}),`.`]})]})})]}),`\n`,_jsx(Heading,{level:`2`,id:`sandbox-tester`,children:`Sandbox tester`}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Sandbox API keys only.`}),` The tester sends requests from your browser with the API key you paste. Production keys do not work in it. In production, call these endpoints from your server.`]})}),`\n`,_jsx(_components.p,{children:`The tester lists the organization’s wallet payment accounts and runs a swap between two of them: quote, order, funding, and the order’s progress. Each step shows its request and response, with a curl command to copy.`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Embedded wallet source:`}),` paste the PKCS#8 PEM private key of the wallet’s signer key. Your organization needs `,_jsx(_components.a,{href:`/v2/guides/embedded-wallets`,children:`embedded wallets`}),` turned on, and the wallet must already hold the source token. The tester signs the order’s `,_jsx(_components.code,{children:`funding`}),` authorization in your browser and, when the destination is the same wallet and ends `,_jsx(_components.code,{children:`claimable`}),`, prepares and signs the `,_jsx(_components.code,{children:`claim`}),` authorization too. The key never leaves the page.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Self-held wallet source:`}),` the tester shows `,_jsx(_components.code,{children:`fundingInstructions.destination`}),`. Send the funds or sign `,_jsx(_components.code,{children:`preparedTransaction`}),` with your own wallet, and refresh the funding instructions when the prepared transaction goes stale.`]}),`\n`]}),`\n`,_jsx(_MdxComponentBoundary,{name:`SwapTutorialV2`,children:_jsx(SwapTutorialV2,{})}),`\n`,_jsxs(Expandable,{title:`Chain-specific swap examples`,children:[_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Stellar:`}),` USDC to CETES:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"source\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stored\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cstellar_wallet_payment_account_id>\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"destination\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stored\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cstellar_wallet_payment_account_id>\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"sourceAmount\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"10\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"sourceAsset\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"destinationAsset\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CETES:GC3CW7EDYRTWQ635VDIGY6S4ZUF5L6TQ7AA4MWS7LEQDBLUSZXV7UPS4\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Solana:`}),` USDC to CETES:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"source\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stored\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003csolana_wallet_payment_account_id>\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"destination\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stored\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003csolana_wallet_payment_account_id>\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"sourceAmount\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"10\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"sourceAsset\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"BXTou3CvPxpFVAJvzvEZcAnRLGCHqT1LHKsFTSQft7s\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"destinationAsset\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"AvvetPGuuB5FD5m86fpw3LtDKyQoUFT1mG9WarNQLW4q\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})]}),`\n`,_jsxs(Expandable,{title:`Common errors`,children:[_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Error`}),_jsx(_components.th,{children:`Cause`}),_jsx(_components.th,{children:`Fix`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`400`}),` `,_jsx(_components.code,{children:`invalid-request`}),`, no stablebond`]}),_jsx(_components.td,{children:`Neither side is a stablebond (for example a stablecoin-to-stablecoin swap)`}),_jsxs(_components.td,{children:[`Make one side a stablebond. Use identifiers from `,_jsx(_components.code,{children:`/lookup/stablebonds`})]})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`400`}),` `,_jsx(_components.code,{children:`invalid-request`}),`, non-stable asset`]}),_jsx(_components.td,{children:`A side is a non-stable token (SOL, XLM, ETH)`}),_jsx(_components.td,{children:`Use a stablebond or a supported stablecoin on both sides`})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`400`}),` `,_jsx(_components.code,{children:`invalid-request`}),`, cross-chain`]}),_jsx(_components.td,{children:`The two wallets are on different chains and hold different tokens`}),_jsx(_components.td,{children:`Swap on one chain, or send the same token across chains`})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`400`}),` `,_jsx(_components.code,{children:`invalid-request`}),`, same asset`]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`sourceAsset`}),` equals `,_jsx(_components.code,{children:`destinationAsset`})]}),_jsx(_components.td,{children:`Pick two different assets`})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`400`}),` `,_jsx(_components.code,{children:`quote-expired`})]}),_jsx(_components.td,{children:`The quote is older than 2 minutes, or does not exist`}),_jsx(_components.td,{children:`Create a new quote`})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`409`}),` `,_jsx(_components.code,{children:`payment-account-not-ready`})]}),_jsxs(_components.td,{children:[`A wallet is not `,_jsx(_components.code,{children:`ready`}),` in the needed direction`]}),_jsxs(_components.td,{children:[`Check the wallet’s `,_jsx(_components.code,{children:`rails`})]})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`422`}),` `,_jsx(_components.code,{children:`quote-unavailable`})]}),_jsx(_components.td,{children:`We cannot quote this path right now, for example thin sandbox liquidity, or the chain has no swap venue`}),_jsx(_components.td,{children:`Retry with backoff. Swaps run only on Stellar, Solana and Monad`})]})]})]}),_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/v2/errors`,children:`Errors`}),` for every problem type.`]})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{SwapTutorialV2,default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Swaps","description":"How to test token-to-token swap flows in the sandbox environment","href":"/v2/guides/testing-swaps"}}},"mdxSourceWithNoJs":null,"noJsSplices":[[153,26238,"null;function _creat"]]},"mdxExtracts":{"tableOfContents":[{"title":"Swap flow","slug":"swap-flow","depth":2,"children":[]},{"title":"Sandbox tester","slug":"sandbox-tester","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"etherfuse","siteName":"Etherfuse API","title":"Swaps - Etherfuse API","navMaps":{"firstHrefInVersion":{"v2":{"href":"/v2/guides/testing-swaps","matchLevel":0},"v1 (deprecated)":{"href":"/guides/testing-swaps","matchLevel":1}},"firstHrefInLanguage":{}},"lastModified":"2026-11-23T21:37:59.561Z","originalFileLocation":"v2/guides/testing-swaps.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"How to test token-to-token swap flows in the sandbox environment\">\u003cmeta data-mint-head name=\"application-name\" content=\"Etherfuse API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Swaps - Etherfuse API\">\u003cmeta data-mint-head property=\"og:description\" content=\"How to test token-to-token swap flows in the sandbox environment\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Etherfuse API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.etherfuse.com/v2/guides/testing-swaps\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://etherfuse.mintlify.site/_mintlify/api/og/v2?division=Integration+Guides\u0026amp;title=Swaps\u0026amp;description=How+to+test+token-to-token+swap+flows+in+the+sandbox+environment\u0026amp;theme=7e3bc6313a40e5ac9e5925e8\u0026amp;signature=214cff59c5a3af08758dc8bf476242f3905907773559a60e9df52c7aaeabdff5\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Swaps - Etherfuse API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"How to test token-to-token swap flows in the sandbox environment\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://etherfuse.mintlify.site/_mintlify/api/og/v2?division=Integration+Guides\u0026amp;title=Swaps\u0026amp;description=How+to+test+token-to-token+swap+flows+in+the+sandbox+environment\u0026amp;theme=7e3bc6313a40e5ac9e5925e8\u0026amp;signature=214cff59c5a3af08758dc8bf476242f3905907773559a60e9df52c7aaeabdff5\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/etherfuse/2PYR-_ECBzhTGa_z/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Etherfuse API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#141414\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.etherfuse.com/v2/guides/testing-swaps\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/v2/guides/testing-swaps.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.etherfuse.com/#organization\",\"name\":\"Etherfuse API\",\"url\":\"https://docs.etherfuse.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/etherfuse/XRSchVFGUgreQatD/img/logo-black.svg?fit=max\u0026auto=format\u0026n=XRSchVFGUgreQatD\u0026q=85\u0026s=92cf84eca27df4a19f7b032da398d110\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.etherfuse.com#website\",\"name\":\"Etherfuse API\",\"url\":\"https://docs.etherfuse.com\",\"publisher\":{\"@id\":\"https://docs.etherfuse.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.etherfuse.com/v2/guides/testing-swaps#webpage\",\"url\":\"https://docs.etherfuse.com/v2/guides/testing-swaps\",\"name\":\"Swaps\",\"description\":\"How to test token-to-token swap flows in the sandbox environment\",\"dateModified\":\"2026-11-23T21:37:59.561Z\",\"isPartOf\":{\"@id\":\"https://docs.etherfuse.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.etherfuse.com/v2/guides/testing-swaps#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.etherfuse.com/v2/guides/testing-swaps#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Integration Guides\",\"item\":\"https://docs.etherfuse.com/v2/guides/payment-accounts\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Swaps\",\"item\":\"https://docs.etherfuse.com/v2/guides/testing-swaps\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.etherfuse.com/v2/guides/testing-swaps#article\",\"headline\":\"Swaps\",\"name\":\"Swaps\",\"description\":\"How to test token-to-token swap flows in the sandbox environment\",\"url\":\"https://docs.etherfuse.com/v2/guides/testing-swaps\",\"mainEntityOfPage\":{\"@id\":\"https://docs.etherfuse.com/v2/guides/testing-swaps#webpage\"},\"dateModified\":\"2026-11-23T21:37:59.561Z\",\"publisher\":{\"@id\":\"https://docs.etherfuse.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.etherfuse.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Etherfuse API\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Etherfuse API\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/v2/guides/testing-swaps.md","siteName":"Etherfuse API","nav":{"global":null,"versions":[{"version":"v2","default":true,"tabs":[{"tab":"Guides","groups":[{"group":"Get Started","icon":"rocket","pages":[{"title":"Introduction","href":"/v2"},{"title":"Quickstart","href":"/v2/quickstart"},{"title":"Initial Setup","href":"/v2/initial-setup"},{"title":"Sandbox Reference","href":"/v2/test-environment"}]},{"group":"Migration","icon":"arrow-right-arrow-left","pages":[{"title":"V1 → V2","href":"/v2/migration-guide"}]},{"group":"Concepts","icon":"lightbulb","pages":[{"title":"How it works","href":"/v2/overview"},{"title":"Webhooks","href":"/v2/webhooks"}]},{"group":"User Authentication","icon":"key","pages":[{"title":"JWT User Authentication","href":"/v2/guides/jwt-authentication"},{"title":"User Launch Flows","href":"/v2/guides/user-launch-flows"},{"title":"Authentication errors","href":"/v2/guides/authentication-errors"}]},{"group":"Integration Guides","icon":"code","pages":[{"title":"Payment Accounts","href":"/v2/guides/payment-accounts"},{"title":"Embedded Wallets","href":"/v2/guides/embedded-wallets"},{"title":"Verifying Webhooks","description":"How to verify webhook signatures to ensure payloads are authentic","href":"/v2/guides/verifying-webhooks"},{"title":"Swaps","href":"/v2/guides/testing-swaps"},{"title":"Onramps","description":"How to test onramp flows in the sandbox environment","href":"/v2/guides/testing-onramps"},{"title":"Offramps","href":"/v2/guides/testing-offramps"}]},{"group":"KYC","icon":"id-card","pages":[{"title":"KYC Overview","sidebarTitle":"Overview","href":"/v2/guides/onboarding"},{"title":"KYC WebSDK","href":"/v2/guides/kyc-websdk"},{"title":"KYC API","href":"/v2/guides/kyc-api"},{"title":"KYC Sumsub Shared Token","href":"/v2/guides/kyc-sumsub-shared-token"}]},{"group":"KYB","icon":"building","pages":[{"title":"KYB Overview","sidebarTitle":"Overview","href":"/v2/guides/kyb"},{"title":"KYB WebSDK","href":"/v2/guides/kyb-websdk"}]},{"group":"Blockchains","icon":"cubes","pages":[{"title":"Stellar","href":"/v2/guides/chains/stellar"},{"title":"Solana","href":"/v2/guides/chains/solana"},{"title":"Monad","href":"/v2/guides/chains/monad"},{"title":"Base","href":"/v2/guides/chains/base"},{"title":"Polygon","href":"/v2/guides/chains/polygon"},{"title":"Avalanche","href":"/v2/guides/chains/avalanche"}]},{"group":"Resources","icon":"book-open","pages":[{"title":"Transaction Fees","href":"/v2/fees"},{"title":"Price Feeds","href":"/v2/price-feeds"},{"title":"Glossary","href":"/v2/glossary"},{"title":"SDKs","href":"/v2/sdks"},{"title":"MCP Server","href":"/v2/mcp-overview"}]}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/v2/api-reference/introduction"}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog"}]}]},{"version":"v1 (deprecated)","pages":[{"title":"v1 (deprecated)","href":"/guides/testing-swaps"}]}]},"basePath":"","title":"Swaps - Etherfuse API","deploymentId":"dpl_G6E2ur2Zjq51xGTVZPSFXsWoTxCu","buildId":"dpl_G6E2ur2Zjq51xGTVZPSFXsWoTxCu","dynamics":[],"chunks":[]}