woopwoop

Events and indexing

Stream every woop launch, trade, Fair Block and graduation from the program's events.

woop_core emits an Anchor event for everything a trading screen shows. Subscribe to the program's logs (or a Yellowstone gRPC stream filtered on the program) and decode each Program data: line: the first 8 bytes are the event's discriminator.

EventDiscriminatorFields
CurveLaunched[202,20,128,231,162,180,61,53]mint, creator, quote_mint, v0: u64, advance: u64, opens_until: i64
CurveTrade[84,229,77,39,245,87,49,105]mint, trader, buy: bool, instant: bool, quote: u64, base: u64, fee: u64, x: u64, sold: u64
BlockSettled[5,6,241,58,120,223,42,68]mint, id: u64, orders: u32, buy_net, buy_used, buy_base, sell_base, sell_quote, x, sold (u64)
CurveGraduated[3,228,116,195,148,182,240,104]mint, pool_quote, pool_base, burned, advance_burned, creator_bonus (u64)
CurveRefunded[25,252,111,228,75,41,123,9]mint, wallet, amount: u64
CurveFeesClaimed[134,227,212,155,241,169,9,62]mint, to_holders, to_creator, to_woop (u64)

Trades and prices

CurveTrade covers instant curve trades (instant: true) and WAMM pool swaps (instant: false). quote and fee are in the pair token, base in coins (6 decimals), and x and sold give the market's state after the trade, so the price needs no extra lookup:

  • on the curve: price = (v0 + x) / (1_111_111_111_111_111 − sold), with v0 from CurveLaunched or the Curve account;
  • in the pool: price = x / sold (x is the pool's quote, sold its coins).

Fair Blocks

A Fair Block settles all its orders at one price: one BlockSettled with the block's buy and sell totals. Each wallet's part is paid out right after, one curve_claim instruction per wallet, which moves the coins (or quote) to it. To show each wallet's trade, read its curve_claim: the trader is the instruction's second account, and the coins and quote it received are the changes in the token balances of its coin and quote accounts. woop's own indexer does exactly this.

Launches and graduation

  • New coin: CurveLaunched. Read the name, ticker and image from the mint's metadata.
  • Final stretch: sold / 760_000_000_000_000 approaching 1.
  • Graduated: CurveGraduated. The pool is the same Curve account: keep the market, switch to pool pricing.
ts
import { parseEvents } from '@usewoop/sdk';

connection.onLogs(WOOP_PROGRAM_ID, ({ logs, signature }) => {
  for (const e of parseEvents(logs)) {
    if (e.name === 'CurveLaunched') onNewPair(e.mint, e.creator, e.quoteMint);
    if (e.name === 'CurveTrade') onTrade(signature, e);
    if (e.name === 'CurveGraduated') onMigrated(e.mint);
  }
});