Skip to main content
This page takes you from a quote to the funds received from a completed swap, in the Shield Swap app or with the TypeScript SDK, Python SDK, or CLI.

How a swap settles

Every swap finishes in two steps. The swap trades your input asset through the pool and leaves the output waiting to be collected. The claim then delivers the output to your wallet, along with any unused input. In the app, the claim runs on its own after the swap confirms, and the price is final as soon as the swap confirms. If anything interrupts the claim, the output waits for you. In the app, open Portfolio, then Pending Claims. With the SDKs or CLI, recover the existing swap and finish its claim. You do not need to start another trade, and a second swap opens a new trade instead of finishing the first one. The settled amounts can differ from the quote. A trade can stop before it spends the full input when the price reaches your limit, and the claim returns the unused amount alongside the output. On a route through two pools, any unused input comes back in the asset you sold, never in the intermediate asset. The assets traded, the amount, the route, the output, any refund, the price movement, and the timing of each swap are public. Your wallet address stays out of the public market data. See Public data.

Quote, submit, and claim

Prerequisites: Your authenticated mainnet client for TypeScript, dex for Python, or CLI profile from Setup. Your account needs one spendable token record covering 1 USDCx, plus funds for transaction fees. Fund your account or prepare a covering record if needed.For services, scripts, and agents, the optional storage setup saves the data needed to resume after a restart. Without it, your application must retain the swap handle returned on submission. A handle contains the identifiers and claim data needed to finish that trade.These examples trade 1 USDCx for ETH on mainnet. To practice with test assets, use the Quickstart.

1. Review a quote

Your quote gives you an estimated output and the minimum you’ll accept for 1 USDCx on mainnet. The examples allow 50 basis points (0.5%) below the estimate. Use your authenticated client from Setup; Quote explains the parameter types and defaults.
expectedOutput and minimumOutput are decimal strings in ETH units. Review both before submitting. If the time in quote.expiresAt has passed, request a fresh quote.

2. Submit the reviewed quote

Once you’re satisfied with the quote, you can submit the swap. The SDK examples use the mainnet quote from Review a quote and preserve its route and minimum output. The CLI requests a fresh quote when you execute the command.
Submit only when you’re ready to trade on mainnet. These calls spend the quoted input. Running them again starts another swap.
handle.transactionId identifies the submitted transaction, and handle.swapId identifies the swap to claim. Keep the handle until the claim finishes; a configured file store retains it for recovery.
If proving or confirmation times out, check the original transaction before retrying. A timeout leaves its outcome unknown. Your history and recovery data let you continue investigating the existing trade.

3. Claim the output

After the swap is accepted, its output becomes available to collect. The claim delivers the output and any unused input to your account. Continue with the mainnet account and handle from Submit the reviewed quote, or the saved CLI account and swap ID.If a claim attempt was interrupted, check its transaction status before submitting another claim.
The optional timeout is a polling limit in milliseconds; this example allows 60 seconds instead of the default 15 seconds. Waiting does not submit a transaction. Once the output is available, the claim call submits the transaction that delivers it.claim.transactionId identifies the claim. claim.amountOut and claim.amountRemaining are bigint amounts in output-token and input-token base units, respectively. The latter is zero when no input is refunded.

Check the result

Your swap and claim each have a transaction ID. Checking both confirms whether the ledger accepted the trade and its collection. Your account’s balance then shows whether record scanning has found the received funds.The SDK examples use the handle and claim from the mainnet steps above. They also use publicClient for TypeScript or aleo for Python, alongside the trading client from Setup. These checks read existing state and do not submit another transaction.
Both transaction results must have status: "accepted". balances[quote.to.id]?.private reports your ETH record balance as a base-unit bigint. Use formatUnits from the quote example with quote.to.decimals to display it in ETH units.
If a transaction lookup fails or remains unconfirmed, repeat the read before deciding whether to retry an operation. Record scanning can also lag behind an accepted claim; a delayed balance update does not mean you need to claim again.A total balance does not identify which trade produced it. Verify swap settlement shows how to match the claim to its exact output record and check that the pending output has been removed from the contract.

Handle partial fills and refunds

The settled amounts can differ from the quote. A price limit can stop a single-pool trade before it spends the full input; the claim returns the unused amount alongside your output. Record both received output and refunded input when accounting for the trade.For a route through several pools, later hops must spend their intermediate input or the route rejects. Output claims and refunds and multi-hop swaps explain these settlement rules.

Next Steps

Recover an interrupted swap

Swap History & Recovery shows how to check an existing trade and finish its claim after a timeout or restart.

Run packaged examples

The TypeScript examples and Python examples include setup, funding, and a complete 1.5 USDCx swap on testnet. Follow the Quickstart commands to run them. Each run starts a new trade.