events object to subscribe to widget lifecycle events. Every callback receives { event, state } where state is a snapshot of the full widget state and event is a discriminated union of named sub-events.
Callback summary
onConnectWallet
Fires when a wallet connects to the widget, and on the click that initiates connection.
Sub-events:
ConnectWallet:click— Connect Wallet button clicked. Params:{}.ConnectWallet:connect— A wallet actually connected (explicit click, eager auto-reconnect, or embedded provider).
ConnectWallet:connect params:
ConnectWallet:click carries no params. Check event.name before reading
connect-specific fields.onConnectWalletClick
Fires when the Connect Wallet button is clicked. Same payload type as onConnectWallet, but only emits ConnectWallet:click.
onAllowToken
Token approval (approve) or signed-permit (permit1 / permit2) lifecycle.
Sub-events:
AllowToken:request— Approval or permit initiated.AllowToken:sent— Transaction signed and broadcast.AllowToken:confirmed— Transaction confirmed on-chain, or permit signed.AllowToken:failed— Transaction failed or permit rejected.
onWrapETH
Fires during ETH → WETH wrapping. Used as a pre-step for Delta Swaps that start from native ETH.
Sub-events: WrapETH:click, WrapETH:request, WrapETH:sent, WrapETH:confirmed, WrapETH:failed.
Params: ethAmountWei, wethAddress, chainId, tradeMode, txHash (if sent+), txReceipt (if confirmed/failed), error (if failed).
onSwap
The most common callback. Fires for both Delta and Market Swap lifecycles.
Sub-events:
Swap:click— Confirmation drawer opened.Swap:request— Swap initiated.Swap:sent— Tx signed and broadcast (market), or Delta order submitted.Swap:confirmed— Tx confirmed (market), or Delta order filled.Swap:failed— Tx failed or Delta order failed.Swap:cancelled— User replaced / cancelled the pending tx, or the Delta order was cancelled.
Sub-event-specific:
txHash, callsId, order (Delta), txReceipt, callsReceipt, error, cancelTxDetails.
onTwapOrder
TWAP (Time-Weighted Average Price) order lifecycle. TWAP splits a large trade into smaller slices executed over a duration.
Sub-events: TwapOrder:click, TwapOrder:request, TwapOrder:sent, TwapOrder:confirmed, TwapOrder:failed.
Params: Delta or bridge price, order (if sent+), error (if failed), plus form-state fields (tokenFrom, tokenTo, sendAmount, receiveAmount, receiverAddress, srcChainId, destChainId, connectedAccount, side).
onLimitOrder
Delta limit-order lifecycle.
Sub-events: LimitOrder:click, LimitOrder:request, LimitOrder:sent, LimitOrder:confirmed (rare; orders typically fill later), LimitOrder:failed.
Params: Delta price, order, error (if failed), plus form-state fields including limitPrice and orderDeadline.
onOTCOrder
OTC (Over-The-Counter) order lifecycle. Similar to limit orders but for OTC trades.
Sub-events: OTCOrder:click, OTCOrder:request, OTCOrder:sent, OTCOrder:confirmed (rare), OTCOrder:failed.
Params: OTC price, order (if not failed), error (if failed), plus form-state fields including otcPrice and orderDeadline.
onCancelTx
Fires when the user replaces a pending swap tx with a “cancel” tx (same nonce, zero value) to drop it.
Sub-events: CancelTx:request, CancelTx:sent, CancelTx:confirmed, CancelTx:failed.
Params:
onCancelOrder
Fires when the user cancels a Delta or OTC order.
Sub-events:
CancelOrder:request— Cancel initiated (tx or typed-data signing).CancelOrder:sentTx— Cancel tx signed and broadcast. Fires for OTC orders and for ETH Delta orders cancelled viawithdrawAndCancel. Non-ETH Delta orders skip this stage (they cancel via signed typed-data).CancelOrder:confirmed— Cancel tx mined, or typed-data posted.CancelOrder:failed— Cancel failed.
onFillOTCOrder
Fires when the user fills an existing OTC order (acts as the taker).
Sub-events: FillOTCOrder:request, FillOTCOrder:sent, FillOTCOrder:confirmed, FillOTCOrder:failed.
Params: orderHash, orderType: "OTC", orderSubType, txHash (if sent+), callsId (if sendCalls), txReceipt (if confirmed), callsReceipt, error (if failed).
onSettingsChange
Fires when the user changes widget settings.
Sub-events:
Settings:switchSwapMode— Switched between Market and Delta. Params:{ swapMode: "market" | "delta" }.Settings:saveSettings— User saved settings. Payload is the fullSettingsState:slippageTolerance,transactionSpeed("slow" | "standard" | "fast" | "custom"),swapMode,eip1559Enabled,degenMode,disabledDexes,bridgePreference("auto" | "fastest" | "bestReturn"),disabledBridges.Settings:changeBridgePreferences— Bridge preferences changed independently (e.g. from Compare Quotes). Params:bridgePreference,disabledBridges.
onFormInputChange
Fires whenever any input changes in any trading form.
Sub-event: FormInput:change.
Params (discriminated by form):
Common to all variants:
Variant-specific:
form: "swap"— addsside: "SELL" | "BUY". Whenside === "SELL", payload carriessendAmount(notreceiveAmount); whenside === "BUY",receiveAmount(notsendAmount).form: "twap"— addsside,orderSplit(slice count),orderInterval(seconds),orderDeadline(Unix seconds),slippage.form: "limit"— addslimitPrice,orderDeadline. BothsendAmountandreceiveAmountpresent.form: "otc"— addsotcPrice,orderDeadline. BothsendAmountandreceiveAmountpresent.
onPriceChange
Fires when price info refreshes or the price-query state changes.
Sub-events:
PriceUpdate— Price was successfully (re)fetched.PriceQueryUpdate— Price-query state changed (data, isLoading, error).
Lifecycle of a successful market swap
For a wallet-connected market swap that requires token approval, events fire in this order:onConnectWallet—ConnectWallet:click(user clicks), thenConnectWallet:connectonce a wallet attaches.onFormInputChange—FormInput:changefor every field edit.onPriceChange—PriceQueryUpdate(loading / refetching) andPriceUpdate(successful fetch) as quotes refresh.onAllowToken—AllowToken:request→AllowToken:sent→AllowToken:confirmed. Skipped if allowance already covers the trade or the flow uses a permit signature only.onWrapETH— for Delta Swaps with ETH astokenFrom, the user is asked to wrap first:WrapETH:click→WrapETH:request→WrapETH:sent→WrapETH:confirmed.onSwap—Swap:click→Swap:request→Swap:sent→Swap:confirmed. Replace withSwap:failedorSwap:cancelledon the unhappy path.onCancelTx— only if the user explicitly cancels a pending market swap tx:CancelTx:request→CancelTx:sent→CancelTx:confirmed.
Swap:sent with swapMode: "delta" and an order param). The order is filled off-band, so Swap:confirmed may arrive minutes later, or be missed entirely if the user closes the widget.
Limit, OTC, and TWAP flows replace step 6 with their respective callbacks (onLimitOrder, onOTCOrder, onTwapOrder).
Related pages
- Wallet management —
onConnectWalletandonConnectWalletClickpatterns. - Widget API reference — full callback type signatures.