ACTIVITY_TYPE_EXECUTE_SWAP_V2 returns a swapRequestId. Query get_swap_status with it to observe the full lifecycle — including failures that occur before broadcast, such as pre-flight simulation failures. Same-chain and cross-chain swaps share the same query and the same response shape; provider-specific state machines are normalized to three states: PENDING, COMPLETED, FAILED.
Swaps is currently an Early Access Product. Contact us to enable it for your organization.
Lifecycle model
Turnkey normalizes swap lifecycle to three states across same-chain and cross-chain routes:- PENDING: still in flight. Broadcast pending, origin transaction not yet included, or (cross-chain) destination-side execution not yet settled.
- COMPLETED: the user received the destination asset. Terminal, happy path.
- FAILED: the swap will not fill as intended. Reported only when Turnkey knows what the user holds. Terminal.
bridge_pending, delayed, submitted, and so on) collapse into PENDING on purpose. Every state maps to exactly one customer action: PENDING means wait, COMPLETED means you got the output, FAILED means look at what you hold and consider re-swapping.
Query get_swap_status
Queryget_swap_status with:
string
required
The organization that executed the swap: the same organization the execute activity was submitted against, parent or sub-organization.
string
required
The handle returned by
ACTIVITY_TYPE_EXECUTE_SWAP_V2, e.g. sha256:9a80031c2def....cURL
JavaScript
Response fields
status: normalized state.PENDING,COMPLETED, orFAILED.swapKind:SAME_CHAINorCROSS_CHAIN. Set at execute time; does not change.provider: the provider that executed the swap. Present when known.inputToken,outputToken,inputAmount: echoed from the execute intent.originTxHash: origin-chain transaction hash. Present once the swap is broadcast, for both same-chain and cross-chain routes.destinationTxHashes: array of destination-chain transaction hashes onCOMPLETED. Cross-chain only.outputAmount: actual amount received, onCOMPLETED. May lag thestatustransition by seconds while the monitor fetches the final settled amount.refund: present onFAILEDwhen funds moved and came back. Containsasset(CAIP-19),amount(raw onchain units), andtxHash. See What FAILED means.error: present onFAILED. Containsreason(ORIGIN_TRANSACTION_FAILEDorPROVIDER_FILL_FAILED),message(human-readable detail),originTxError(decoded revert detail, origin failures only), andproviderReason(provider-specific detail, fill failures only). See What FAILED means.updatedAt: last observed state change, as a Unix timestamp in milliseconds (stringified).
Same-chain vs. cross-chain differences
The response shape is identical. Two behaviors differ in practice:- Timing. Same-chain swaps reach a terminal state within roughly one block time of the origin chain. Cross-chain swaps can take tens of seconds to several minutes depending on the route. Each quote’s
estimatedTimeSecondsis the per-swap estimate. - Field population.
destinationTxHashesis populated only for cross-chainCOMPLETEDswaps. Same-chain outcomes are fully described byoriginTxHash: onCOMPLETED, that transaction delivered the output; onFAILED, either the transaction reverted or — iforiginTxHashis absent — the swap failed before broadcast and nothing moved onchain.
swapKind (SAME_CHAIN or CROSS_CHAIN) tells you which model applies. Branch on it client-side only where the difference matters — for example, showing a bridge-progress state for cross-chain PENDING — and otherwise treat both kinds uniformly through the three-state model.
What FAILED means
FAILED is set as soon as Relay reports a failure. Refund details (asset, amount, txHash) are populated in a subsequent enrichment pass and may be absent when FAILED first appears. Keep polling if you need the refund details. PENDING means the destination leg may still fill — it does not indicate a refund is in flight.
On FAILED, two fields together describe the outcome:
error.reason— why it failed:ORIGIN_TRANSACTION_FAILED(the origin transaction failed pre-flight simulation or reverted onchain) orPROVIDER_FILL_FAILED(the origin transaction succeeded but the provider could not fill).error.messageand, for origin failures,error.originTxErrorcarry the decoded detail, including the full revert chain.refund— present when funds moved and came back:refund.asset(CAIP-19),refund.amount(raw onchain units), andrefund.txHash. The refunded asset can differ from the original input if the route included an origin-side swap, and it lands on the origin chain.
If the user still wants the swap, re-quote — with the refunded asset as the new input where a refund occurred. Caveats worth surfacing to end users:
- A refund is reduced by refund gas and any origin-side swap losses; it will not equal the original input.
- A re-swap is a new swap: new quote, new fees, new slippage.
- If the original destination was another chain, the re-swap is again cross-chain.
Polling cadence
- Same-chain: poll every ~1 second while
PENDING. Typically settles within one block time. - Cross-chain: poll every 5 to 10 seconds while
PENDING. Settlement can take from tens of seconds to several minutes depending on route.
Next steps
- End-to-end example: full flow from enable to confirmation.
- Execute a swap: request semantics that generate the poll handle.