In deposit mode, funds route to a destination you configure in
routes. In swap mode, funds settle to the user’s own connected wallet. The routing engine and the quote, route, sign, broadcast, receipt, and status lifecycle are identical; only the configuration and where funds settle change.Enable swap mode
SetswapMode: true under features. With no destination flags set, the user selects the output token themselves. This is the open, Uniswap-style configuration.
TrustwareProvider:
swapMode defaults to false, which keeps the widget in deposit mode. Inputs are never restricted: users can always pay in from any supported asset on any supported chain. Only the output can be restricted, using the fields below.
Lock the destination token
To settle every swap into one token, setswapDefaultDestToken and lock it with swapLockDestToken: true. For example, a client on Base can lock the output so users only ever receive USDC on Base, paying in from any asset on any chain.
Restrict outputs to an allowlist
To allow a small set of output tokens, list them inswapAllowedDestTokens. The destination-token picker is limited to this list; everything else is locked out. This restricts outputs only. Users can still pay in with any supported asset on any chain.
Config reference
| Field | Type | Description |
|---|---|---|
swapMode | boolean | Enables swap mode. Defaults to false. |
swapDefaultDestToken | { address: string; chainId: number } | Pre-selects the destination token shown when the widget opens. |
swapLockDestToken | boolean | Locks the destination so the user cannot change it. Use with swapDefaultDestToken. |
swapAllowedDestTokens | Array<{ address: string; chainId: number }> | Restricts the destination-token picker to this list. Everything else is locked out. |
features in TrustwareConfigOptions. See the configuration overview for the full config reference.
React to route changes
In swap mode, the SDK emits aswap_route_changed event whenever the resolved route updates, for example when the user changes the source or destination chain, token, or amount. Subscribe with onEvent to keep your own UI in sync.
fromChain, fromToken, toChain, toToken, and an optional amount. See lifecycle events for the full event reference.
Works with every integration style
Swap mode is a configuration flag, so it works with all four integration paths without code changes.Drop-in widget
The fastest path: render
TrustwareWidget with swap mode enabled in your config.Host wallet bridge
Pass your app’s existing Wagmi or viem wallet and run it in swap mode.
Controlled widget
Open and close the swap widget programmatically from your own UI.
Headless core
Build a custom swap interface on top of the routing and transaction APIs.
