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.

On Solana, accounts must hold a rent-exempt balance (lamports) to exist. When you close an empty token account, those lamports are returned to the destination you specify. If you set outcomeAccountRentRecipient when requesting an order, retrieve that value from your stored order params and reuse it as the close destination. Otherwise, choose any destination (typically the user’s wallet).Closing a token account is a standard SPL Token action. DFlow does not provide a dedicated endpoint for this.
1

Choose the rent destination

Decide where the reclaimed rent should go. If your app set outcomeAccountRentRecipient when creating the order, use that address.
import "dotenv/config";

import {
  createBurnInstruction,
  createCloseAccountInstruction,
  getAccount,
} from "@solana/spl-token";
import { Connection, Keypair, PublicKey, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
import bs58 from "bs58";

const SOLANA_RPC_URL = process.env.SOLANA_RPC_URL ?? "https://api.mainnet-beta.solana.com";

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

const userPublicKey = keypair.publicKey.toBase58();

// Optional: reuse the address you set when creating the order.
// If you did not set one, default to the user's wallet.
const outcomeAccountRentRecipient =
  storedOrderParams?.outcomeAccountRentRecipient ?? null;

const rentDestination = outcomeAccountRentRecipient ?? userPublicKey;
2

Burn remaining tokens and close the account

A token account must be empty to close. If it still has a balance, burn the remaining outcome tokens and then close the account to reclaim rent.
const connection = new Connection(SOLANA_RPC_URL, "confirmed");
const owner = keypair; // signer and token account owner

const tokenAccount = new PublicKey("OUTCOME_TOKEN_ACCOUNT");
const outcomeMint = new PublicKey("OUTCOME_TOKEN_MINT");
const rentRecipient = new PublicKey(rentDestination);

const account = await getAccount(connection, tokenAccount);

const instructions = [];
if (account.amount > 0n) {
  instructions.push(
    createBurnInstruction(
      tokenAccount,
      outcomeMint,
      owner.publicKey,
      account.amount
    )
  );
}

instructions.push(
  createCloseAccountInstruction(
    tokenAccount,
    rentRecipient,
    owner.publicKey
  )
);

const tx = new Transaction().add(...instructions);
const signature = await sendAndConfirmTransaction(connection, tx, [owner]);
console.log(`  Tx: https://orbmarkets.io/tx/${signature}`);

Redeem Outcome Tokens

Redeem winning outcome tokens once a market is determined.

Track User Positions

Map wallet balances back to markets and outcomes.

API Routes

This recipe does not call DFlow APIs. It uses a Solana RPC endpoint and the SPL Token program.