Overview
Swap operations emit detailed progress events through theonEvent callback. These events allow you to track cross-chain swaps, source and destination transactions, permits, and quote calculations in real-time.
Event Callback
Event Type
SWAP_STEP_COMPLETE
Emitted each time a swap step completes.
Event name constant from
NEXUS_EVENTS.SWAP_STEP_COMPLETEThe swap step that completed
Swap Step Structure
Step Types Reference
Initialization Steps
Swap operation started.Properties:
completed: true
Calculating optimal swap route and quote.Properties:
completed: boolean- Initially false, true when route is determined
Permit Steps
Creating permit from user wallet to ephemeral wallet.Properties:
completed: booleansymbol: string- Token symbolchain: { id, name }- Chain information
typeID includes chain ID and token symbol.Creating permit for source chain swap.Properties:
completed: booleansymbol: string- Token symbolchain: { id, name }- Chain information
typeID includes chain ID and token symbol.Source Chain Steps
Executing batched swap transactions on source chains.Properties:
completed: boolean
Source chain swap transaction hash received.Properties:
completed: truechain: { id, name }- Source chainexplorerURL: string- Transaction explorer link
typeID includes chain ID.Bridge Steps
Bridge deposit transaction for cross-chain swap.Properties:
data.chain: { id, name }- Source chaindata.hash: Hex- Transaction hashdata.explorerURL: string- Explorer link
typeID includes chain ID.Request for Funds ID received.Properties:
completed: truedata: number- RFF ID
Destination Chain Steps
Executing batched swap on destination chain.Properties:
completed: boolean
Destination chain swap transaction hash.Properties:
completed: truechain: { id, name }- Destination chainexplorerURL: string- Transaction explorer link
typeID includes chain ID.Completion Steps
Swap completed successfully.Properties:
completed: true
Swap skipped because sufficient balance already exists on destination chain.Properties:
completed: truedata.destination- Output informationdata.input- Input informationdata.gas- Gas estimation
swapAndExecute when user has enough balance on destination.Data Structure:Examples
Basic Swap Progress
React Swap Progress Component
Tracking Transaction Hashes
Handling Swap Skipped
Multi-Chain Swap Tracking
Progress Percentage
Detailed Step Logging
Cross-Chain Swap Detection
Timing Analysis
Best Practices
-
Track by typeID: Use
typeIDfor unique identification, especially for chain-specific steps. -
Check completed flag: Not all steps emit with
completed: trueinitially. -
Display explorer links: Show
explorerURLwhen available for transaction verification. - Handle SWAP_SKIPPED: This indicates an optimization where swap was unnecessary.
-
Show chain context: Display
step.chainandstep.symbolwhen present. -
Cross-chain indicators: Detect cross-chain swaps via
BRIDGE_DEPOSITandRFF_IDsteps. - Progress estimation: Swap operations have variable step counts depending on route.
- Error handling: Wrap event handlers in try-catch to prevent crashes.
Related Hooks
- Swap Intent Hook - Approve swap operations
Related Events
- Bridge Steps - Track bridge operation progress