Plan the route
In v0.12.1, you can request a quote withclient.quote({ from, to, amountIn: "1", slippageBps: 50 }) and submit it with client.swap({ quote }). See the Quickstart for a complete example. Use the manual steps below if you need to supply execution parameters yourself.
planSwap resolves token metadata, requests a route and quote, checks each pool against current chain controls, applies a slippage floor, and fetches the required program imports.
50 basis points means 0.5 percent slippage.
Submit the request
Useswap for one pool and swapMultiHop for a route with two or more pools.
fileBlindedIdentityStore records it before the action returns. If you do not use that store, save the handle in your own database before ending the request flow.
Do not submit another request because a confirmation wait timed out. Check the transaction and mapping state first. A second submission can spend another record and create another trade.
Claim the output
The pending output becomes readable after the request finalizes. Both route types useclaimSwapOutput.
amountOut is the received output. amountRemaining is the unused portion of the original input. Wrapped assets are paid out as records of the underlying asset.
For a multi-hop route, each later hop must consume its intermediate input. A partial fill in a later hop rejects the route. Only unused original input can appear as the final refund.
Verify settlement
UsepublicClient.getConfirmedTransaction({ id }) for both the request and claim transaction IDs. Both must report accepted. Then check that client.getSwapOutput({ swapId: handle.swapId }) returns null and that the account has the claim’s returned token records.
An absent pending output or an empty getUnclaimedSwaps() result does not establish settlement on its own. Match the accepted claim to the swap ID and its output commitments to the decrypted records. See Verify swap settlement for the complete quickstart verifier.
Recover pending claims
For long-running local clients, check the configured identity store at startup.getUnclaimedSwaps reads swap_outputs from chain. It returns per-token totals and handles that can be claimed from the store alone. In v0.12.1, claimSwapOutput resolves program imports from the output tokens automatically. Older records without a complete handle may require reconcileSwapHistory().