Skip to content

Swap Building

The swap build endpoint returns an unsigned VersionedTransaction that you sign client-side and submit back.

Flow

1. POST /v1/swap/build  →  unsigned TX (base64)
2. Sign with your wallet (client-side)
3. POST /v1/swap         →  submit via Jito

Non-Custodial

Venum never touches your private keys. The transaction is built with your public key as the signer, returned unsigned, and you sign it locally. We only see the signed transaction when you submit it.

Request

bash
POST /v1/swap/build
json
{
  "inputMint": "So11111111111111111111111111111111111111112",
  "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "amount": "1000000000",
  "slippageBps": 100,
  "userPublicKey": "YourWalletPublicKeyBase58"
}

What's in the Transaction

The returned transaction contains:

  1. Compute budgetSetComputeUnitLimit sized per DEX type (200K-600K)
  2. Fee transfer — SPL token transfer of 0.5% of input amount to Venum fee wallet
  3. Swap instruction(s) — The actual DEX swap (may include tick array init for CLMM/DLMM)

Quote ID

The response includes a quoteId that's valid for 30 seconds. You must include this when submitting the signed transaction. This prevents replay attacks and ensures the fee matches the original quote.

json
{
  "transaction": "AQAAAA...base64...==",
  "quoteId": "q_42_1712000000000",
  "estimatedOutput": "134520000",
  "minOutput": "133174800",
  "feeLamports": "5000000",
  "feeBps": 50,
  "computeUnits": 400000
}

Signing Example

typescript
import { VersionedTransaction } from '@solana/web3.js';

// Decode the unsigned transaction
const txBytes = Buffer.from(response.transaction, 'base64');
const tx = VersionedTransaction.deserialize(txBytes);

// Sign with your keypair
tx.sign([yourKeypair]);

// Encode back to base64 for submission
const signedBase64 = Buffer.from(tx.serialize()).toString('base64');