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.
| Instruction | When | Arguments |
|---|---|---|
curve_buy | On the curve, not during the opening or a Fair Block | amount_in: u64 (quote, fees included), min_out: u64 |
curve_sell_instant | On the curve, same | amount: u64 (coins), min_out: u64 |
curve_order | On the curve, any time (the fair opening's buys are orders) | buy: bool, amount: u64 |
wamm_swap | Graduated | buy: 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 | ||
|---|---|---|---|
| 0 | trader | signer, writable | Owns the coins and the position |
| 1 | payer | signer, writable | Pays the position's rent (can be the trader) |
| 2 | curve config | ["curve_config"] | |
| 3 | curve | writable | ["curve", mint] |
| 4 | mint | ||
| 5 | quote mint | ||
| 6 | coin vault | writable | the curve's coin account |
| 7 | quote vault | writable | the curve's pair-token account |
| 8 | lock | ["curve_lock", mint] | |
| 9 | lock vault | writable | the lock's coin account |
| 10 | trader's coin account | writable | the trader's own Token-2022 ATA (create it first) |
| 11 | trader's quote account | writable | the trader's pair-token ATA (wrapped SOL on SOL pairs) |
| 12 | position | writable | ["curve_pos", mint, trader], created if needed |
| 13 | $WOOP tokens | the trader's $WOOP account for half fees, else the program id | |
| 14 | token program | Token-2022 | |
| 15 | quote token program | ||
| 16 | system program |
curve_buyfills 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_orderadds 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 | |
|---|---|---|
| 0 | trader | signer |
| 1 | curve config | |
| 2 | curve (the pool) | writable |
| 3 | mint | |
| 4 | quote mint | |
| 5 | coin vault | writable |
| 6 | quote vault | writable |
| 7 | trader's coin account | writable |
| 8 | trader's quote account | writable |
| 9 | $WOOP tokens | (or the program id) |
| 10 | token program | Token-2022 |
| 11 | quote 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 leastv0 / 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