Documentation

Cross-chain swap

Cross-chain swaps move assets between Videpay networks: e.g. consolidate Polygon Amoy revenue to Base Sepolia treasury. Use the same CreateSwapDTO with different source.chain and destination.chain; flowType becomes cross-chain and bridgeAsset fields appear in responses. Multichain treasury ops without opening twelve tabs.

Need machine-readable request/response bodies for your AI or codebase? Download this page as plain Markdown.

When should I use this?

  • You receive USDC on multiple chains and want to consolidate.
  • Treasury prefers one chain but customers pay on another.
  • Rebalancing liquidity across chain balances.

Why use Videpay?

  • Same API surface as same-chain: only chain values differ.
  • routing.bridgeAsset and bridgeAdapterName control bridge path.
  • bridgeAsset and bridgeEstimate in responses show bridge metadata.
  • All five swap webhook events apply to cross-chain flows.

Consolidate to Base treasury

Customers pay on Polygon Amoy but your treasury is on Base Sepolia. You POST /swap with source.chain base and destination.chain polygon (or vice versa). swap.initiated fires on the source chain; swap.completed includes bridge metadata. Chain-hopping, documented.

How cross-chain swaps work

  1. Quote with POST /swap/quote-fee: response includes bridgeAsset and estimatedBridgeAmount.
  2. Create swap with different source.chain and destination.chain.
  3. Source leg executes on origin chain (swap.initiated).
  4. Bridge message propagates to destination chain.
  5. swap.completed when destination leg delivers; swap.failed on timeout or revert.

Dashboard features

Dashboard → Cross-chain swap

Pick source and destination chains, preview bridge fees and estimated delivery, set minimumAmountOut for slippage protection, and monitor bridge progress from the swap detail view.

Quote cross-chain fee

FieldTypeRequiredDescription
businessIduuidNoTarget business. Omit when your API key is scoped to one business.
source.chainstringYesSource chain (e.g. base, polygon). Sandbox resolves to testnets.
source.assetstringYesAsset symbol or on-chain token address to sell.
source.amountdecimal stringYesHuman-readable amount to swap from merchant balance.
destination.chainstringYesDestination chain. Same as source.chain for same-chain swaps.
destination.assetstringYesAsset symbol or address to receive.
destination.recipientaddressYesWallet that receives the output asset.
destination.minimumAmountOutdecimal stringNoOptional floor for destination amount. Recommended to protect against slippage.
slippageBpsintegerNoSlippage tolerance in basis points (1–5000). Default 100.
deadlineSecondsintegerNoSwap validity window in seconds (60–86400). Default 900.
referencestringNoYour reconciliation reference (max 120).
metadataobjectNoArbitrary JSON stored on the swap record.
routing.bridgeAssetstringNoCross-chain only: bridge asset override. Omit for auto-routing.
routing.dexAdapterNamestringNoDEX adapter override (e.g. UNISWAP_V3). Default: auto.
routing.bridgeAdapterNamestringNoBridge adapter override (e.g. STARGATE). Default: auto.
routing.sameChainPoolFeeBpsintegerNoSame-chain Uniswap V3 pool fee tier override in bps.
routing.sourcePoolFeeBpsintegerNoCross-chain source-side pool fee override in bps.
routing.destinationPoolFeeBpsintegerNoCross-chain destination-side pool fee override in bps.
routing.bridgeDatahex stringNoRaw bridge adapter bytes payload. Defaults to 0x.
POST/swap/quote-fee

Quote fees and bridge estimate for a cross-chain swap.

Headers

headers
01x-api-key: sk_AbCdEfGhIj_XyZ1234567890abcdefghijklmnopqrstuvwxyz01234502Content-Type: application/json

Request body

request.json
01{02  "source": {03    "chain": "base",04    "asset": "USDC",05    "amount": "5000"06  },07  "destination": {08    "chain": "polygon",09    "asset": "USDC",10    "recipient": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",11    "minimumAmountOut": "4950"12  },13  "slippageBps": 50,14  "deadlineSeconds": 1800,15  "reference": "swap-base-polygon-001",16  "routing": {17    "bridgeAsset": "USDC",18    "bridgeAdapterName": "STARGATE"19  }20}

Create a cross-chain swap

FieldTypeRequiredDescription
businessIduuidNoTarget business. Omit when your API key is scoped to one business.
source.chainstringYesSource chain (e.g. base, polygon). Sandbox resolves to testnets.
source.assetstringYesAsset symbol or on-chain token address to sell.
source.amountdecimal stringYesHuman-readable amount to swap from merchant balance.
destination.chainstringYesDestination chain. Same as source.chain for same-chain swaps.
destination.assetstringYesAsset symbol or address to receive.
destination.recipientaddressYesWallet that receives the output asset.
destination.minimumAmountOutdecimal stringNoOptional floor for destination amount. Recommended to protect against slippage.
slippageBpsintegerNoSlippage tolerance in basis points (1–5000). Default 100.
deadlineSecondsintegerNoSwap validity window in seconds (60–86400). Default 900.
referencestringNoYour reconciliation reference (max 120).
metadataobjectNoArbitrary JSON stored on the swap record.
routing.bridgeAssetstringNoCross-chain only: bridge asset override. Omit for auto-routing.
routing.dexAdapterNamestringNoDEX adapter override (e.g. UNISWAP_V3). Default: auto.
routing.bridgeAdapterNamestringNoBridge adapter override (e.g. STARGATE). Default: auto.
routing.sameChainPoolFeeBpsintegerNoSame-chain Uniswap V3 pool fee tier override in bps.
routing.sourcePoolFeeBpsintegerNoCross-chain source-side pool fee override in bps.
routing.destinationPoolFeeBpsintegerNoCross-chain destination-side pool fee override in bps.
routing.bridgeDatahex stringNoRaw bridge adapter bytes payload. Defaults to 0x.
POST/swap

Execute a cross-chain swap. source.chain and destination.chain must differ. Emits swap.prepared.

Headers

headers
01x-api-key: sk_AbCdEfGhIj_XyZ1234567890abcdefghijklmnopqrstuvwxyz01234502Content-Type: application/json

Request body

request.json
01{02  "source": {03    "chain": "base",04    "asset": "USDC",05    "amount": "5000"06  },07  "destination": {08    "chain": "polygon",09    "asset": "USDC",10    "recipient": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",11    "minimumAmountOut": "4950"12  },13  "slippageBps": 50,14  "deadlineSeconds": 1800,15  "reference": "swap-base-polygon-001",16  "routing": {17    "bridgeAsset": "USDC",18    "bridgeAdapterName": "STARGATE"19  }20}
GET/swap/swp_xchain_5c8d2e1f-9a3b-4c7d-8e6f-1a2b3c4d5e6f

Retrieve cross-chain swap with bridge metadata.

Headers

headers
01x-api-key: sk_AbCdEfGhIj_XyZ1234567890abcdefghijklmnopqrstuvwxyz01234502Content-Type: application/json
POST/swap/swp_xchain_5c8d2e1f-9a3b-4c7d-8e6f-1a2b3c4d5e6f/sync

Sync cross-chain swap state from source or bridge txHash.

Headers

headers
01x-api-key: sk_AbCdEfGhIj_XyZ1234567890abcdefghijklmnopqrstuvwxyz01234502Content-Type: application/json

Request body

request.json
01{02  "txHash": "0xsourceSwapTx..."03}

Routing hints

Optional routing object on CreateSwapDTO lets you override bridge and DEX adapters. Omit for backend auto-routing.

FieldTypeRequiredDescription
routing.bridgeAssetstringNoCross-chain only: bridge asset override. Omit for auto-routing.
routing.dexAdapterNamestringNoDEX adapter override (e.g. UNISWAP_V3). Default: auto.
routing.bridgeAdapterNamestringNoBridge adapter override (e.g. STARGATE). Default: auto.
routing.sameChainPoolFeeBpsintegerNoSame-chain Uniswap V3 pool fee tier override in bps.
routing.sourcePoolFeeBpsintegerNoCross-chain source-side pool fee override in bps.
routing.destinationPoolFeeBpsintegerNoCross-chain destination-side pool fee override in bps.
routing.bridgeDatahex stringNoRaw bridge adapter bytes payload. Defaults to 0x.

Cross-chain response fields

FieldTypeRequiredDescription
bridgeAssetobjectNoIntermediate asset used for bridging (usually USDC).
bridgeEstimateobjectNoamount / amountRaw expected across the bridge.
source.messageIdstringNoBridge message identifier on cross-chain swaps.
destination.deliveredAmountstringNoActual amount received on destination chain.

Webhooks you'll receive

Register a webhook endpoint and verify the X-Protocol-Signature header on every delivery before fulfilling orders or updating your database.

Webhookswap.prepared

Sent when a swap record is created and ready for execution.

Delivery headers

webhook-headers
01Content-Type: application/json02User-Agent: Protocol-Webhooks/1.003X-Protocol-Event: swap.prepared04X-Protocol-Delivery: wev_1a2b3c4d-5e6f-7890-abcd-ef123456789005X-Protocol-Business-Id: a1b2c3d4-e5f6-7890-abcd-ef123456789006X-Protocol-Attempt: 107X-Protocol-Signature: sha256=abc123def456...
Webhookswap.initiated

Sent when the swap transaction is submitted on the source chain.

Delivery headers

webhook-headers
01Content-Type: application/json02User-Agent: Protocol-Webhooks/1.003X-Protocol-Event: swap.initiated04X-Protocol-Delivery: wev_1a2b3c4d-5e6f-7890-abcd-ef123456789005X-Protocol-Business-Id: a1b2c3d4-e5f6-7890-abcd-ef123456789006X-Protocol-Attempt: 107X-Protocol-Signature: sha256=abc123def456...
Webhookswap.completed

Sent when a cross-chain swap finishes successfully.

Delivery headers

webhook-headers
01Content-Type: application/json02User-Agent: Protocol-Webhooks/1.003X-Protocol-Event: swap.completed04X-Protocol-Delivery: wev_1a2b3c4d-5e6f-7890-abcd-ef123456789005X-Protocol-Business-Id: a1b2c3d4-e5f6-7890-abcd-ef123456789006X-Protocol-Attempt: 107X-Protocol-Signature: sha256=abc123def456...
Webhookswap.updated

Sent when swap progress changes before terminal status.

Delivery headers

webhook-headers
01Content-Type: application/json02User-Agent: Protocol-Webhooks/1.003X-Protocol-Event: swap.updated04X-Protocol-Delivery: wev_1a2b3c4d-5e6f-7890-abcd-ef123456789005X-Protocol-Business-Id: a1b2c3d4-e5f6-7890-abcd-ef123456789006X-Protocol-Attempt: 107X-Protocol-Signature: sha256=abc123def456...
Webhookswap.failed

Sent when a swap fails after initiation.

Delivery headers

webhook-headers
01Content-Type: application/json02User-Agent: Protocol-Webhooks/1.003X-Protocol-Event: swap.failed04X-Protocol-Delivery: wev_1a2b3c4d-5e6f-7890-abcd-ef123456789005X-Protocol-Business-Id: a1b2c3d4-e5f6-7890-abcd-ef123456789006X-Protocol-Attempt: 107X-Protocol-Signature: sha256=abc123def456...