Skip to content
QSwapDocs

Transaction lifecycle

Every swap runs through one state machine, from getting the order to the receipt. Try it.

Swap lifecycleLive demo, running real codePress an event to move the state machine.
IdleGetting orderSign in walletLandingSuccess
FailedOrder expired
Current phase
Idle
Button shows
Swap
Ready
isBusy = false
Events

Path so far: Idle
Source: src/features/docs-site/swap-model.ts → txReducer()

Phases

What you see in each phase
Getting orderButton locked
Sign in walletButton lockedYour wallet is open
LandingButton locked
Success · Failed · Order expiredButton free
15 s: taking longerAbout 60–90 s: the blockhash expires and the order with it
Source: src/features/docs-site/swap-model.ts

An order is valid until its blockhash expires, about 60 to 90 seconds on Solana (lastValidBlockHeight). If you take longer to sign, or the transaction can't land in time, /swap/execute fails with an expiry code and the app gets you a new price.

Safe by construction

Three safety nets
  • Double-clickSecond click ignored
  • Order expires before it landsNew price, you sign again
  • Reject in walletBack to idle, nothing sent
Source: src/features/docs-site/swap-model.ts