TradeWidget exposes callbacks for quote resolution, wallet connections, transaction lifecycle reporting, and error handling.
Example
Supported callbacks
Event behavior notes
onQuoteis deduplicated, so identical resolved quotes are not emitted repeatedlyonQuotecan fire after the initial quote load, a manual refresh, or an auto-refresh when the resolved quote changedonConnectonly reportsnamespace,address, andwalletName; it does not identify whether the connection came from the origin or destination sideonApproveandonSwapare submission hooks, not simple button-click hooksonTxSubmittedis the generic submission event for bothapproveandswaponTxConfirmedis the generic confirmation event for bothapproveandswaponErrorwithsource: "quote"andstatusCode: 429can come either from the Delora API or from the widget’s own local quote cooldown
- successful quotes auto-refresh every 60 seconds while the selection stays stable
- auto-refresh stops after 5 consecutive refresh cycles
- more than 15 quote requests within 5 seconds triggers a local cooldown
- the cooldown lasts 5 seconds
- during that window,
onErrorcan emit a quote error withstatusCode: 429even if the backend did not return 429
Error sources
onError can report the following source values:
metadataconfigurationquoteselectionwalletbalancesexecutionunsupported
status, statusCode, and the original error object.
