Skip to main content

Install

npm install @pmx/parimutuel-sdk
Peer dependencies (install if you don’t already have them):
npm install @solana/web3.js @solana/spl-token @coral-xyz/anchor bn.js

Initialize the Client

import { Connection, PublicKey } from "@solana/web3.js";
import { ParimutuelClient, PMX_PROGRAM_ID } from "@pmx/parimutuel-sdk";

const connection = new Connection(
  "https://api.devnet.solana.com",
  "confirmed"
);
const programId = new PublicKey(PMX_PROGRAM_ID);
const client = new ParimutuelClient(connection, programId);
PMX_PROGRAM_ID is exported as a constant so you don’t need to hardcode it.

Environment Setup

A typical .env for a bot or backend:
SOLANA_RPC_URL=https://api.devnet.solana.com
AGENT_PRIVATE_KEY=<your-base58-private-key>
USDC_MINT=4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
Load and create a signing wallet:
import { Keypair } from "@solana/web3.js";
import bs58 from "bs58";

const wallet = Keypair.fromSecretKey(
  bs58.decode(process.env.AGENT_PRIVATE_KEY!)
);
const usdcMint = new PublicKey(process.env.USDC_MINT!);

Sign and Submit Helper

Every SDK transaction builder returns an unsigned Transaction. You sign locally and submit:
async function signAndSend(tx: Transaction): Promise<string> {
  tx.sign(wallet);
  const sig = await connection.sendRawTransaction(tx.serialize());
  await connection.confirmTransaction(sig, "confirmed");
  return sig;
}

What’s Included

ExportPurpose
ParimutuelClientMain class — reads, quotes, and transaction builders
quoteBuy, quoteSellPure quote functions (no RPC needed)
getImpliedOddsCalculate current odds from reserves
PDA helpersDerive on-chain account addresses
toRawUsdc, fromRawUsdcConvert between USDC floats and raw integers
Error classesTyped errors for clean error handling
Type interfacesMarketData, WalletPosition, ListMarketsFilter, CreateMarketFullResult, and more

Next Steps

SDK Quickstart

Read a market and place a trade in 10 lines

Full Reference

Every method, type, and constant