Install
Get a trader key
A OneSwap administrator enables Trader SDK access and issues a key for the approved account and wallet. A trader cannot enable access, create a key, change its wallet binding, or enable three-token fees through the SDK. Contact OneSwap when you need a new or replacement key. The key, account, bound wallet, and requested pool must all remain approved. OneSwap can revoke access immediately.Create the client
walletId. Self-custody wallets also require an active OneSwap user mandate; the trader key
never contains or replaces the self-custody key.
Discover pools, tokens, and balances
xToY: true spends assetX and receives assetY;
false reverses the direction.
Quote and swap
Quote immediately before a swap and use the quote to set the output floor:idempotencyKey for each intended swap. Reuse it only when retrying that exact
swap, so a timeout or process restart cannot execute the order twice.
Three-token network fees
When a OneSwap administrator has enabled the trader and configured a distinct fee instrument for a synchronous atomic pool, select it explicitly on both calls:tokenFee.amount is derived from the live Canton traffic cost,
including the extra fee-token allocation. OneSwap subtracts measured reward recovery,
applies the best applicable global, pool, account, or wallet network-fee promotion, and then
converts CC → USDCx → the configured fee token at live prices.
The quote reports the final amount and authoritative fee-token balance checks. A trader with
a 100% promotion receives amount: 0 and promotionalWaiver: true; settlement omits the fee
allocation. A trader without that promotion pays the converted amount shown in the final
quote. When charged, the swap input, output, and fee-token allocation settle atomically.
History and asynchronous intents
Trade launchpad coins
The same key trades launchpad coins on its bound wallet throughtrader.launchpad. Buys spend
CC and sells spend the coin’s token. Graduated coins trade on their pool through the
same calls.
side: 'sell' and pass quote.ccOut as the floor:
idempotencyKeyis required: 8–200 letters, digits,.,_,:, or-. Reuse it only to retry the same order.slippageBpsdefaults to100and accepts0–5000.networkFee.ccis billed to the wallet’s prepaid CC balance when the order settles.- A buy quote can name the exact tokens to receive with
tokensOutinstead ofamount. trader.launchpad.positions()lists the wallet’s launchpad holdings, andtrader.launchpad.intent(id)reads one order.- Self-custody wallets need an active mandate, as for pool swaps.
What a trader key can see
A trader key trades its own wallet, so it sees only what it needs to trade:
It never shows other holders, holder counts, or other people’s trades. Version 0.4.0 removed the
trade feed and holder data from the trader SDK. For market data such as holder counts and the trade feed, use the
Launchpad SDK.