Skip to main content
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.
Increase a position by trading a stablecoin into a YES or NO outcome token. Submit a trade, and the system opens an order, routes to offchain liquidity, and settles onchain.
1

Choose an Outcome Token

Start with the outcome mint you want to increase. If you need to find outcome mints first, use Discover Prediction Markets.
2

Request an Increase Trade

Request a trade from a stablecoin into the outcome token using /order. This opens an increase order and writes your limit price and side (YES or NO) into the User Order Escrow account while escrowes your stablecoin (USDC or CASH).Increase Position
const API_BASE_URL = "https://dev-quote-api.dflow.net";
const API_KEY = process.env.DFLOW_API_KEY; // Optional

const inputMint = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC
const outcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS";
const amount = 25_000_000; // 25 USDC (6 decimals)

const queryParams = new URLSearchParams();
queryParams.append("inputMint", inputMint);
queryParams.append("outputMint", outcomeMint);
queryParams.append("amount", amount.toString());
queryParams.append("userPublicKey", keypair.publicKey.toBase58());

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

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

Sign and Submit the Transaction

Sign the transaction returned by /order and submit it to Solana.
const transactionBuffer = Buffer.from(orderResponse.transaction, "base64");
const transaction = VersionedTransaction.deserialize(transactionBuffer);

transaction.sign([keypair]);
const signature = await connection.sendTransaction(transaction);
4

Monitor Order Status

Poll /order-status for async orders. This returns fills and the final status.
const statusResponse = await fetch(
  `${API_BASE_URL}/order-status?signature=${signature}`,
  { headers }
).then((x) => x.json());

console.log(statusResponse.status, statusResponse.fills);
5

Fill the Increase Order

You do not call a separate endpoint to fill the order. The settlement authority reads your limit price and side from User Order Escrow, submits a limit IOC to offchain liquidity, and settles onchain. You receive outcome tokens, unused stablecoins are refunded, platform fees are transferred, and the settlement stablecoin moves to the Settlement Vault.
A limit IOC (Immediate‑Or‑Cancel) order executes immediately at the limit price (or better) for whatever size is available right now. Any unfilled portion is canceled instead of resting on the book.
const statusResponse = await fetch(
  `${API_BASE_URL}/order-status?signature=${signature}`,
  { headers }
).then((x) => x.json());

if (statusResponse.status === "closed") {
  console.log("Order filled", statusResponse.fills);
} else {
  console.log("Order status:", statusResponse.status);
}
Fill Increase Order

API Routes

Cookbook Repository

This recipe, along with many more, is available in the DFlow Cookbook Repo. You can clone it and start coding immediately.