Basic swap
Amulet when you mean CC (Amulet).
This returns a SwapIntent with everything you need:
| Field | Description |
|---|---|
depositAddress | Pool swap party that should receive the deposit |
swapAddress | The same pool swap party, returned explicitly for clarity |
depositReference | Transfer reference to pass through when the wallet supports Canton reason/reference metadata |
expectedOutput | Estimated output amount |
minOutput | Minimum accepted after slippage |
outputAddress | Resolved destination party for the payout |
expiresAt | Intent expiration timestamp |
instructions | Step-by-step transfer instructions |
swap.expiresAt from the response instead of hard-coding a shorter timeout.
Direct-party flow
- Request a OneSwap wallet-auth challenge for the user’s
party ID - Have the user sign the challenge with the same wallet that will deposit
- Verify the signature and store the returned wallet token
- Create the intent with
client.swaps.create(...) - OneSwap returns the pool swap party as
depositAddressplus adepositReference - The user sends the input token directly from that same party to
depositAddressand passes through the reference when the wallet supports Canton reason/reference metadata - OneSwap detects the deposit and executes the swap
- Output returns directly to the same party that made the deposit
walletAddress is a consistency check, not the trust root. The verified wallet token is what authorizes the swap.
Slippage tolerance
Default is 1%. You can set it between 0.1% (0.001) and 50% (0.5):
minOutput, the swap is refunded.
Maximum price impact
OneSwap enforces a server-side price impact cap (currently 15%). If a quote or swap-intent creation request would move the pool price beyond this limit, the API returns400 and the SDK surfaces that as ValidationError. If an already-created intent later crosses the same cap during execution, it reaches terminal status price_impact_exceeded and swap.wait() throws PriceImpactError. The cap is returned in quote.maxPriceImpact. To execute large swaps, either split them into smaller amounts or add liquidity to the pool first.
Output routing
The current SDK flow always returns swap output to the same Canton party that sends the deposit.outputAddress remains in the type surface for backward compatibility, but the SDK ignores it and /api/v1/swaps resolves output back to the depositor party.
depositReference is recommended operational metadata. Pass it through to the wallet UX when the wallet supports Canton reason/reference fields so fallback matching and observability stay stronger.
Disambiguating duplicate symbols
If the same token symbol exists under multiple admins, use the token list plus admin fields to select the exact pool.409 ambiguous_pool_pair and the SDK throws AmbiguousPoolPairError.
Track swap status
Await completion
swap.wait() resolves on completed. It throws typed errors for terminal failures, including ExpiredError when the intent expires or when polling observes a cancelled intent.
Listen to events
Poll manually
Cancel a pending swap
Status lifecycle
no_output_holdings, failed, and refund_failed mean the swap reached a terminal state that may require manual investigation.
Quotes
quote.estimatedTrafficCost, quote.trafficFeeInInput, and quote.inputAmountAfterTrafficFee help you account for Canton execution costs before the swap executes.
inputTokenAdminandoutputTokenAdminidentify the exact instruments that were priced.maxPriceImpactis the server-enforced price impact cap. Swaps exceeding this are rejected.trafficFeeInInputis the amount deducted from the input token as traffic-cost recovery.outputAmountis quoted frominputAmountAfterTrafficFee, not from the gross deposit amount.receiverPartylets the quote include the same destination-party traffic assumptions used by the live execution path.- The traffic fee is separate from the 1% swap fee and is not shared with LPs or SDK developers.
Wallet auth
For browser-based SDK apps, keep the API key and wallet proof separate:- The API key identifies your app or developer account.
- The wallet token identifies the end user who signed the OneSwap challenge.
client.swaps.create(...),client.swaps.getStatus(...), andclient.track(partyId)require the wallet token.- If your app refreshes wallet auth in state, pass
walletTokenas a function so the SDK reads the current token on each request.