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, request an API key for higher rate limits.
Prediction market outcome token trades use platformFeeScale, not platformFeeBps. The fee is calculated dynamically using the formula k * p * (1 - p) * c, where k is platformFeeScale / 1000, p is the outcome token price (0–1), and c is the trade volume. platformFeeMode is ignored for outcome token trades; the fee is always collected in the settlement mint.
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 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

Request an order with platformFeeScale

const outcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS";

const queryParams = new URLSearchParams();
queryParams.append("inputMint", DFLOW_SETTLEMENT_MINT);
queryParams.append("outputMint", outcomeMint);
queryParams.append("amount", "1000000"); // 1 USDC (6 decimals)
queryParams.append("platformFeeScale", "50"); // k = 0.050 in formula k * p * (1 - p) * c
queryParams.append("feeAccount", "YourSettlementMintTokenAccountAddress");
queryParams.append("userPublicKey", keypair.publicKey.toBase58());

const orderResponse = await fetch(
  `${DFLOW_TRADE_API_URL}/order?${queryParams.toString()}`,
  { headers }
).then((r) => r.json());
3

Fee account setup

The feeAccount parameter is required and must be a token account that holds the settlement mint (USDC or CASH). Outcome token accounts cannot receive the fee.
The fee account must match the settlement mint. Outcome tokens themselves cannot be used as fee accounts.
4

Check fee in response

The /order response includes a platformFee object showing the calculated fee.
if (orderResponse.platformFee) {
  console.log("Platform fee details:", {
    amount: orderResponse.platformFee.amount,
    feeBps: orderResponse.platformFee.feeBps,
    feeAccount: orderResponse.platformFee.feeAccount,
  });
}

Buy Outcome Tokens

Open a prediction market position from any input token.

Prediction Market Fees

How fees work for prediction markets, including the dynamic fee formula.

Add Platform Fees (Spot)

Add fees to standard spot swaps with platformFeeBps.

Authenticate Requests

Authenticate requests for production rate limits.

API Routes