Skip to main content

Documentation Index

Fetch the complete documentation index at: https://pond.dflow.net/llms.txt

Use this file to discover all available pages before exploring further.

During development, you can use the developer endpoints without an API key. For production use, you’ll need an API key to avoid rate limits.
1

Set up

Imports, env config, and the wallet used across every step.
import "dotenv/config";

import { Keypair } from "@solana/web3.js";
import bs58 from "bs58";

const DFLOW_TRADE_API_URL = process.env.DFLOW_TRADE_API_URL ?? "https://dev-quote-api.dflow.net";
const DFLOW_API_KEY = process.env.DFLOW_API_KEY; // optional; not needed for dev endpoints
const DFLOW_SETTLEMENT_MINT = process.env.DFLOW_SETTLEMENT_MINT ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC

const SOL_MINT = "So11111111111111111111111111111111111111112";

const keypair = Keypair.fromSecretKey(
  bs58.decode(process.env.SOLANA_PRIVATE_KEY ?? "")
);

const headers: HeadersInit = {};
if (DFLOW_API_KEY) headers["x-api-key"] = DFLOW_API_KEY;
2

Fixed Fees with platformFeeBps

Use platformFeeBps to specify a fixed fee in basis points. Control which token the fee is collected from using platformFeeMode.
const queryParams = new URLSearchParams();
queryParams.append("inputMint", SOL_MINT);
queryParams.append("outputMint", DFLOW_SETTLEMENT_MINT);
queryParams.append("amount", "1000000000");
queryParams.append("platformFeeBps", "50"); // 0.5% fee
queryParams.append("platformFeeMode", "outputMint"); // Collect from output (USDC)
queryParams.append("feeAccount", "YourUSDCTokenAccountAddress");
queryParams.append("userPublicKey", keypair.publicKey.toBase58());

const orderResponse = await fetch(
  `${DFLOW_TRADE_API_URL}/order?${queryParams.toString()}`,
  { headers }
).then((x) => x.json());
/// To collect fee from input mint instead, override the values from above with `.set()` (not `.append()`):
queryParams.set("platformFeeMode", "inputMint");
queryParams.set("feeAccount", "YourSOLTokenAccountAddress"); // Must match input mint
/// For /quote endpoint (imperative swaps)
const quoteResponse = await fetch(
  `${DFLOW_TRADE_API_URL}/quote?${queryParams.toString()}`,
  { headers }
).then((x) => x.json());

/// For /intent endpoint (declarative swaps)
const intentResponse = await fetch(
  `${DFLOW_TRADE_API_URL}/intent?${queryParams.toString()}`,
  { headers }
).then((x) => x.json());
3

Fee Account Setup

The feeAccount parameter is required and must match the fee mint. The account must exist before the trade executes.
The fee account must match the token you’re collecting fees in: input or output mint, based on platformFeeMode.
For prediction market outcome token trades, fees use platformFeeScale instead, and the fee account must be a settlement mint token account. See Add Platform Fees (Prediction Markets).
4

Check Fee in Response

Both /order and /quote responses include platformFee information.
// Reuses the `orderResponse` from the request step above.
if (orderResponse.platformFee) {
  console.log("Platform fee details:", {
    amount: orderResponse.platformFee.amount,
    feeBps: orderResponse.platformFee.feeBps,
    feeAccount: orderResponse.platformFee.feeAccount,
  });
}

Platform Fees

How platform fees work, fee modes, and accepted denominations.

Spot Quickstart

Execute your first spot swap end-to-end.

Add Priority Fees

Control execution speed with priority fees.

Authenticate Requests

Authenticate requests for production rate limits.

API Routes