DEX swaps execute on-chain through smart contracts. Unlike CEX swaps, DEX swaps require users to connect their wallet, sign transactions, and broadcast them to the blockchain. In API v2, DEX swaps use the same /quotes and /exchanges endpoints as CEX swaps — pass types=dex to get only DEX quotes, or filter the response by type: "dex". The quoteId is the single identifier passed through the entire flow — no route objects required.
Best For: Users who want true decentralized swaps, keep custody of their funds, and interact directly with on-chain liquidity sources like Uniswap, CowSwap, and 1inch.
Stellar Trustline Requirement: Ensure the destination account has required trustlines before initiating the swap. Houdini does not create trustlines automatically.
Bulk fetch DEX-supported tokens and cache to your DB, or search by name/symbol. Note each token’s id.
2
Get Quotes
Call GET /quotes with token IDs and optional slippage. Select the quote with type: "dex".
3
Check Approvals (if requiresApproval: true)
If the quote has requiresApproval: true, call POST /dex/approve with quoteId and addressFrom. Returns on-chain approval transactions and/or signatures needed. Skip this step if requiresApproval: false.
4
Handle Approvals (if needed)
Broadcast approval transactions via user’s wallet.
5
Handle Signatures (if needed)
Have user sign EIP-712 typed data. For chained signatures, call POST /dex/chainSignatures until isComplete: true.
6
Create Order
Call POST /exchanges with quoteId, addressTo, addressFrom, and any collected signatures.
7
Broadcast & Confirm
If not off-chain, have user broadcast the transaction. Then call POST /dex/confirmTx with the transaction hash.
8
Monitor Status
Poll GET /orders/{houdiniId} until statusLabel is FINISHED.
Only run this step if requiresApproval: true on the selected quote. If requiresApproval is false, skip Steps 3–5 and go directly to Step 6: Create Order.
Call POST /dex/approve with just the quoteId and user’s wallet address:
const response = await fetch('https://api-partner.houdiniswap.com/v2/dex/approve', { method: 'POST', headers: { 'Authorization': `${API_KEY}:${API_SECRET}`, 'Content-Type': 'application/json', 'x-user-ip': userIp, 'x-user-agent': userAgent, 'x-user-timezone': userTimezone }, body: JSON.stringify({ quoteId: '69155e0bdb5ab0cbe27e2709', // from /quotes addressFrom: '0x45CF73349a4895fabA18c0f51f06D79f0794898D' // user wallet })});const { approvals, signatures } = await response.json();// approvals: on-chain approval transactions to broadcast (may be empty)// signatures: EIP-712 typed data to sign (may be empty)
Response Fields:
approvals: Array of { data, to, from, fromChain } transactions to broadcast (may be empty)
signatures: Array of EIP-712 typed data objects to sign (may be empty)
You may receive both approvals and signatures. Handle approvals first, then signatures.
You must call /dex/confirmTx in both cases. For on-chain swaps, pass the txHash. For off-chain swaps, omit txHash. Without this call, the order will not be processed.
Poll every 30 seconds. DEX swaps typically complete in seconds to a few minutes depending on network congestion. For real-time updates without polling, use the WebSocket API.