woopwoop

Trading

The instructions that trade woop coins, with their accounts in order.

Four instructions trade a coin. Discriminators and argument layouts are in the interface file; the SDK builds all four.

InstructionWhenArguments
curve_buyOn the curve, not during the opening or a Fair Blockamount_in: u64 (quote, fees included), min_out: u64
curve_sell_instantOn the curve, sameamount: u64 (coins), min_out: u64
curve_orderOn the curve, any time (the fair opening's buys are orders)buy: bool, amount: u64
wamm_swapGraduatedbuy: bool, amount_in: u64, min_out: u64

Curve trade accounts

curve_buy, curve_sell_instant and curve_order take the same 17 accounts first:

#Account
0tradersigner, writableOwns the coins and the position
1payersigner, writablePays the position's rent (can be the trader)
2curve config["curve_config"]
3curvewritable["curve", mint]
4mint
5quote mint
6coin vaultwritablethe curve's coin account
7quote vaultwritablethe curve's pair-token account
8lock["curve_lock", mint]
9lock vaultwritablethe lock's coin account
10trader's coin accountwritablethe trader's own Token-2022 ATA (create it first)
11trader's quote accountwritablethe trader's pair-token ATA (wrapped SOL on SOL pairs)
12positionwritable["curve_pos", mint, trader], created if needed
13$WOOP tokensthe trader's $WOOP account for half fees, else the program id
14token programToken-2022
15quote token program
16system program
  • curve_buy fills from the Exit Queue first if you pass its fillable orders (oldest first, floor at or under the price) as extra writable accounts after these 17. With none, it buys from the curve alone.
  • curve_order adds 17: the order ["curve_order", mint, trader] (writable) and 18: the system program. The order settles with its block a couple of seconds later and woop's keeper pays it out to the trader; there's nothing more to send.

WAMM pool swap accounts

wamm_swap (after graduation):

#Account
0tradersigner
1curve config
2curve (the pool)writable
3mint
4quote mint
5coin vaultwritable
6quote vaultwritable
7trader's coin accountwritable
8trader's quote accountwritable
9$WOOP tokens(or the program id)
10token programToken-2022
11quote token program

Rules the program enforces

  • Fair opening: for 60 s after launch, buys only go in as orders, up to a per-wallet cap.
  • Fair Blocks: while block_open, instant trades fail (they reopen when it settles, 2–3 s). A new block needs an order of at least v0 / 2000.
  • Instant sells cost 10%, take at most a fifth of the wallet's position per sell, and one per minute. Selling more goes through a Fair Block order at 1.5%.
  • The creator can't sell before graduation; their buys go into the lock.
  • The last buy on a curve stops at 760M sold and spends only what that takes.

A full buy

On a SOL pair, wrap the SOL into the trader's wrapped-SOL account first and close it after. With the SDK:

ts
import { buyInstructions, fetchCurve, fetchCurveConfig, quoteBuy } from '@usewoop/sdk';

const curve = await fetchCurve(connection, mint);
const cfg = await fetchCurveConfig(connection);
const quote = quoteBuy(curve, cfg, 100_000_000n, { slippageBps: 300n }); // 0.1 SOL in
const ixs = buyInstructions({ curve, wallet, amountIn: 100_000_000n, minOut: quote.minOut });
// create both ATAs → wrap SOL → curve_buy (or wamm_swap once graduated) → unwrap