type: "superstate::swap" and settles directly onchain: the user pays with a stablecoin and receives the tokenized equity, an ERC-20, in the same flow.
Recommended: render
CheckoutContainer. It detects superstate::swap and renders this entire flow - wallet step, amount, review, confirmation - for you. This page covers what is specific to Superstate, and the rungs below the component.passage.superstate was the swap namespace before v0.11.0, and executeSwap is now execute. It is named after the provider now, because Ondo ships its own swap and swap could only ever mean one of them. See the changelog for the migration table.What Superstate needs from you
Nothing. The SDK looks up the swap contract for the chain you pass, and the funding assets and issuer are the provider’s own constants. EveryCheckoutConfig key is optional, and so is config itself. The "superstate::swap" entry takes one optional listener, onOrderConfirmed, which fires once the swap has mined. The confirmation dialog shows either way:
checkout blocked with the reason unsupported-chain once, at error, through your Config.logger.
The Superstate checkout ignores CheckoutContainer’s optionId prop, because a swap sends no option id. The prop is still required, as it is for every offer type, so pass the option your page showed: the SDK never picks one. useSuperstateSwapCheckoutViewModel takes no optionId at all.
Three things distinguish Superstate from the other providers:
- The wallet must be allowlisted. Superstate only settles to addresses the issuer has approved. The user signs an ownership challenge and the SDK allowlists the address on the swap contract, once per wallet per offer. The same allowlists are what make permissioned DeFi pools and RWA lending markets reachable. That is also why the Superstate checkout never skips its wallet step: a
wallets.preselectedwallet opens the step with its row already selected, rather than skipping it (see Wallets). - The fee comes out of the amount quoted. You quote the gross amount the user wants to spend, and the quote splits it into
inputTokenAmount(what buys shares) andfee. The wallet is debitedinputTokenAmount + fee, which never exceeds the amount quoted, so always show that sum as the total cost. - Quotes are read quotes, polled every 15 seconds. Nothing is committed until the swap itself, and slippage protection guards the on-chain minimum output. There is no expiring committed quote to race, as there is with Ondo.
Prerequisites
- Completed OAuth with a working
PassageProvider - A swap-enabled offer. CoinList provides the offer ID during onboarding - keep it in a constant (
SWAP_OFFER_ID).Offers expose atypefield, so you can detect Superstate swap offers from fetch offers data viaoffer.type === "superstate::swap"instead of hard-coding IDs. Ondo swap offers are'ondo::swap'and take a different flow. - A wallet integration. The partner demo uses wagmi + Reown AppKit; any stack that can sign messages and send transactions works. See Wallets.
Build your own UI with hooks (L2)
Build your own UI with hooks (L2)
useSuperstateSwapCheckoutViewModel wraps the whole flow and returns { state, onEvent }. Call it behind your own markup when you want the SDK’s logic, state and error handling but not its UI.state is either { type: "error", reason }, when the swap could not be loaded at all ("unsupported-chain": no contract on the chain, or "load-failed": the output token read failed, which { type: "ON_RETRY_LOAD" } retries), or { type: "content" } with one slice per region: wallet, amount, review, sidebar, and orderConfirmed. Each slice is a discriminated union of its own. switch on each exhaustively and assign the default to const exhaustive: never, so a new arm is a compile error rather than a blank screen.The data hooks it is built from are exported too, so you can assemble your own viewmodel instead:Each returns its result as a
state union with DISABLED, LOADING, ERROR (with a reason of "not-authenticated" or "generic-error"), and CONTENT arms, and each takes a required enabled flag. Switched off with no answer in hand, a hook reports DISABLED. useSwapQuote keeps a quote it already has; useErc20TokenBalances drops its balances and reports DISABLED whenever it is switched off or has no address. Like all React hooks they must be called unconditionally. See SDK structure for the conventions they share.The step viewmodels (useSuperstateAmountViewModel, useSuperstateWalletViewModel, useSuperstateReviewViewModel, useSuperstateSidebarViewModel) and the SlippagePicker component are no longer exported since v0.13.0. Use the god viewmodel above, or build the steps yourself from the data hooks and the L1 namespace below.Drive it yourself with the client (L1)
Drive it yourself with the client (L1)
passage.superstate is a plain namespace with no React. The walkthrough below builds the flow from scratch, trimmed to the minimum that still compiles and runs.Flow at a glance
- connect_wallet - your wallet UI; the SDK only needs the connected account.
- authorizing -
passage.superstate.authorizeWalletproves the user owns the wallet (a message signature) and allow-lists it for the offer, broadcasting an allow-list transaction if the contract requires one. One-time per wallet per offer. - quoting -
useSwapOutputToken+useSwapQuoteshow a live quote (input, fee, output), refreshed every 15s. - swapping -
passage.superstate.executeruns the ERC-20 approval and then the swap, reporting progress phases. - success / error - show the confirmed output amount and an explorer link, or a readable error.
The flow involves two identities: the CoinList session (from OAuth) identifies who is buying, and the external wallet is where the shares are delivered.
authorizeWallet is what links them - which is why the user signs a message before ever swapping.Step 1: Pin the swap parameters
Keep the offer, chain, contract, and input token in one place.superstateSwapContractAddress(chain) returns the swap contract the SDK knows for a chain, or null where none is deployed. TOKEN_REGISTRY knows the ERC-20 metadata and per-chain address for USDC, USDT, and USDZ. Superstate pays in USDC on every chain, Sepolia included. USDZ, CoinList’s test dollar on Ethereum Sepolia, pays Centrifuge vaults there, and token sales that list it.constants.ts
This page runs on Sepolia throughout. The SDK knows the Sepolia swap contract only, so
superstateSwapContractAddress("ethereum_mainnet") returns null today. CoinList provides the production mainnet address when swaps go live. To move to mainnet, set SWAP_CHAIN to "ethereum_mainnet" and point SWAP_CONTRACT_ADDRESS at that address - TOKEN_REGISTRY already knows the mainnet USDC/USDT addresses.Step 2: Bring your wallet
The swap flows never import wagmi. They drive any wallet through theEvmWallet interface, which you implement once for every flow in the SDK.Wallets: the EvmWallet seam
The five members, the wagmi + AppKit adapter, and how wallet errors are classified.
Step 3: Allowlist the wallet
Superstate only settles to wallets the issuer has allowlisted.passage.superstate.authorizeWallet does both halves in one call: it proves the user controls the wallet by having them sign a challenge, then registers the address against the offer, broadcasting an allowlist transaction if the contract requires one.success immediately without prompting, so it is safe to call at the start of every session. Failures come back as { type: "error" } rather than throwing.Parameters
Progress phases
Emitted in order. Two of them open a wallet popup. A wallet that is already authorized stops afterchecking-authorization:checking-authorization → requesting-challenge → signing-message (wallet popup) → submitting-signature → (broadcasting-transaction (wallet popup) → awaiting-confirmation, only when the contract needs an allowlist transaction) → verifying-authorizationError steps
WalletAuthorizationError is tagged by the step that failed, so you can tell a user rejection apart from an infrastructure problem.An allowlist transaction that reverts is not an error of its own: the flow goes on to the on-chain re-check, and reports
not-authorized only if the contract still says no.A cause of { type: "disconnected" } means the wallet is no longer connected, or no longer on the account its address names, so nothing was sent. Retrying through the same wallet fails the same way, so ask the user to reconnect or choose another wallet. Your EvmWallet reports this by throwing WalletDisconnectedError from @passage-cl/react/universal. An EIP-1193 4100 error and wagmi’s ConnectorNotConnectedError count the same, so a viem or wagmi adapter can let those propagate. See Wallets.Allowlisting needs a CoinList user: passage.wallets.createOwnershipChallenge and passage.superstate.allowWallet both throw NotAuthenticatedError on a wallet session, and authorizeWallet turns that into its challenge-request step. A wallet that is already authorized succeeds before reaching either call.authorizeWallet reads authorized(address) on the swap contract over JSON-RPC (through CoinList’s authenticated RPC proxy unless you set Config.rpc), and calls two Frontline endpoints. The first is also passage.wallets.createOwnershipChallenge, which the requirements checklist uses to bind a wallet to an offer option. For non-SDK integrations, Frontline also serves the authorization read as GET /v1/wallet/authorized.Step 4: Show a live quote
Read the output token to learn its decimals, parse the user’s input, then poll a quote.useSwapQuote waits while outputTokenDecimals is null; gate it on a valid amount yourself, through enabled.quoteState is DISABLED while switched off with no quote in hand, LOADING until the first quote lands (or while the output token’s decimals are unknown), ERROR with a reason when no quote could be read at all, and CONTENT with quote and isRefreshing otherwise.A SwapQuote has inputTokenAmount, fee, and outputTokenAmount, all BlockchainAmounts. Render them with formatAmount(amount, LOCALE), and derive the total and the slippage-protected minimum:The fee comes out of the amount you quote:
inputTokenAmount is what buys shares, and fee is charged on top of it. The wallet is debited inputTokenAmount + fee, so always show that sum as the total cost.pollIntervalMs to change that. isRefreshing flags a newer quote on the way. A failed poll behind a quote in hand keeps the last quote, stays CONTENT, and retries on the next tick, so ERROR means the hook never got a quote. A quote also stays in CONTENT after you switch the hook off, and after the amount changes until the new quote lands, which is why the sample checks it against the amount before using it, the way the SDK’s own review step does.Step 5: Execute the swap
passage.superstate.execute runs the whole on-chain sequence and returns a discriminated result. It never throws.swap-unconfirmed: the wallet sent the swap, but waiting for its receipt failed. It may still mine, so swapping again can fill the order twice. It carries thetxHashto look up first, and acauseof typeWalletError. The SDK’s own review step disables its button until the user leaves the step, with “Your swap was sent but has not confirmed yet. Check your wallet before placing another.”swapmeans the wallet never sent the swap (causesays why), so swapping again is safe, unlesscause.typeis"disconnected": then the user has to reconnect first.
swap-paused means the contract has suspended swaps and may resume, so “try again shortly” fits. swap-stopped is permanent.Phases (wallet popups marked):checking-status → checking-allowance → (resetting-allowance → confirming-allowance-reset, only for a non-zero allowance that does not cover input + fee) → approving (wallet popup) → confirming-approval → swapping (wallet popup) → confirming-swapWhen the standing allowance already covers input + fee, the approval phases are skipped.The user signs up to two transactions - an ERC-20
approve for input + fee when the allowance does not already cover it, then the swap itself. When the wallet holds a non-zero allowance that does not cover the amount, the SDK first resets it to zero in one extra transaction, whatever the coin, because USDT-style tokens reject a non-zero to non-zero approve. All read-only checks run before the first popup, so the user never signs a transaction that those checks could have stopped.slippageBps sets the on-chain minimum-output guard. DEFAULT_SLIPPAGE_BPS is 0.5% and is fine for a minimal integration; see Going further for a picker.Putting it together
A complete, minimal swap component. It compiles against the current SDK release and reusesconstants.ts (Step 1) and buildEvmWallet (Step 2).MinimalSwap.tsx
CheckoutContainer, which the partner demo renders in OfferCheckoutView.tsx.Going further
- Balances and a Max button -
useErc20TokenBalances({ address, chain, assets: [USDC_SYMBOL], enabled })returns{ state }. ItsCONTENTarm carriesbalances, aMapof raw per-asset balances (nullfor a read that failed), so you can show the user’s USDC and prefill the max amount. Balances refresh every 15s. It wasuseSwapTokenBalancesbefore v0.11.0. - A slippage picker -
SLIPPAGE_OPTIONS_BPS(0.25%-5%) withformatBpsAsPercent(bps, LOCALE)for labels; pass the selectedBpstopassage.superstate.execute. - A quote without React -
passage.superstate.getQuote({ contractAddress, chain, inputToken, amount, outputTokenDecimals })returns the sameSwapQuotethe hook polls, andpassage.superstate.getOutputToken({ contractAddress, chain })the output token. - More formatting helpers in
@passage-cl/react/universal:shortenAddress,formattedPricePerShare.
Common questions
Why does the user sign a message before swapping?
Why does the user sign a message before swapping?
The flow has two identities: the OAuth CoinList session is who is buying, and the external wallet is where shares are delivered.
authorizeWallet links them - the user signs an ownership challenge, and the SDK allow-lists that address on the swap contract. It’s one-time per wallet per offer, and returns success immediately on later calls if the wallet is already authorized.Why does my wallet ask for two transactions?
Why does my wallet ask for two transactions?
A swap needs an ERC-20
approve (for input + fee) before the swap itself, so the contract can pull the stablecoin. A wallet that already holds a non-zero allowance too small for the swap needs one extra reset-to-zero transaction first, because USDT-style tokens reject a non-zero to non-zero approve. Every read-only check (status, allowance) runs before the first popup, so the user never signs a transaction that those checks could have stopped.How fresh is the quote, and what if the price moves?
How fresh is the quote, and what if the price moves?
useSwapQuote polls every 15s. On execution, passage.superstate.execute passes a slippage-derived minimum output to the contract, so if the price moves beyond your slippageBps the swap reverts rather than over-charging. The result’s outputAmount is decoded from the on-chain Swapped event when the receipt yields one, and falls back to the quote’s estimate when it does not - outputAmountConfirmed tells you which one you got.Do I need wagmi / Reown AppKit specifically?
Do I need wagmi / Reown AppKit specifically?
No. Anything implementing the five-member
EvmWallet interface works - viem directly, Privy, ethers with a thin adapter. The SDK only calls signMessage, writeContract, broadcastRawTx, and awaitTx; it never sees your wallet library.How do I go to mainnet?
How do I go to mainnet?
This page uses Sepolia everywhere, and the SDK knows the Sepolia swap contract only. CoinList provides the production swap contract address and swap offer ID during onboarding. Set
SWAP_CHAIN to "ethereum_mainnet", point SWAP_CONTRACT_ADDRESS at the mainnet contract, and the wallet adapter’s CHAINS map handles the network switch. CheckoutContainer runs on mainnet once the SDK ships that contract.Next step
See the checkout in the partner demo
The partner demo’s checkout feature renders
CheckoutContainer with its own wallets.