woopwoop

TypeScript SDK

@usewoop/sdk: decode, quote and trade woop coins on the program, in TypeScript.

@usewoop/sdk does everything on these pages in TypeScript: account decoding, the program's exact maths, instruction building and event parsing. Its quotes are checked against mainnet: a simulated buy has to match the SDK's quote to the unit.

bash
npm i @usewoop/sdk @solana/web3.js @solana/spl-token

Read

ts
import { fetchAllCurves, fetchCurve, fetchCurveConfig, fetchCoinMetadata, phase, marketCap, curveProgress } from '@usewoop/sdk';

const curves = await fetchAllCurves(connection); // every woop coin
const curve = await fetchCurve(connection, mint); // one coin (null if it isn't a woop coin)
const cfg = await fetchCurveConfig(connection);
const meta = await fetchCoinMetadata(connection, mint); // name, symbol, image, description, banner, links

phase(curve); // 'fair-opening' | 'trading' | 'fair-block' | 'graduating' | 'graduated' | 'refund'
marketCap(curve, 9); // in the pair token (9 = SOL's decimals)
curveProgress(curve); // 0–100

Quote and trade

ts
import { quoteBuy, quoteSell, instantSellLimit, buyInstructions, sellInstructions, fairBlockInstructions } from '@usewoop/sdk';

const q = quoteBuy(curve, cfg, 100_000_000n, { slippageBps: 300n }); // 0.1 SOL in → { out, fee, minOut }
const ixs = buyInstructions({ curve, wallet, amountIn: 100_000_000n, minOut: q.minOut });

const s = quoteSell(curve, cfg, 5_000_000_000_000n); // 5M coins
const sellIxs = sellInstructions({ curve, wallet, amount: 5_000_000_000_000n, minOut: s.minOut });

// during the fair opening or a Fair Block: an order, settled at one price and paid out by woop
const orderIxs = fairBlockInstructions({ curve, wallet, buy: true, amount: 100_000_000n });

buyInstructions and sellInstructions pick the curve or the WAMM pool from the coin's status, create the wallet's accounts, and wrap and unwrap SOL on SOL pairs. Lower-level builders: curveBuyInstruction, curveSellInstruction, fairBlockOrderInstruction and wammSwapInstruction.

Stream

ts
import { parseEvents, WOOP_PROGRAM_ID } from '@usewoop/sdk';

connection.onLogs(WOOP_PROGRAM_ID, ({ logs }) => {
  for (const e of parseEvents(logs)) console.log(e.name, e);
});

Everything it exports

Area
ConstantsWOOP_PROGRAM_ID, TOKEN_2022, SUPPLY, CURVE_SUPPLY, VIRTUAL_BASE, STATUS, ACCOUNT_DISC, EVENT_DISC, IX_DISC, SEEDS
AddressescurveAddress, curveConfigAddress, lockAddress, positionAddress, orderAddress, exitAddress, blockAddress, quotePriceAddress, coinAccount, quoteAccount
AccountsdecodeCurve, decodeCurveConfig, decodePosition, decodeExitOrder, fetchCurve, fetchAllCurves, fetchCurveConfig, fetchExitOrders, phase
MathscurveBuy, curveSell, swapOut, feeBps, spotPrice, marketCap, curveProgress, remainingToGraduate, quoteBuy, quoteSell, instantSellLimit
InstructionsbuyInstructions, sellInstructions, fairBlockInstructions, curveBuyInstruction, curveSellInstruction, fairBlockOrderInstruction, wammSwapInstruction
EventsparseEvents, decodeEvent
MetadatafetchCoinMetadata

The Anchor interface file ships with it as @usewoop/sdk/idl, and is also at /integrators/woop_core.json.