@gabox-labs/sdk 0.1.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +249 -1
- package/README.md +116 -458
- package/dist/generated/index.d.ts +334 -755
- package/dist/generated/index.js +2403 -338
- package/dist/generated/index.js.map +1 -1
- package/dist/index-BDfGvmgF.d.ts +934 -0
- package/dist/index.d.ts +211 -472
- package/dist/index.js +539 -1093
- package/dist/index.js.map +1 -1
- package/dist/raydium/index.d.ts +2 -0
- package/dist/raydium/index.js +2 -0
- package/dist/raydium-B-l9V3O-.js +2604 -0
- package/dist/raydium-B-l9V3O-.js.map +1 -0
- package/llms.txt +4 -2
- package/package.json +11 -16
- package/skills/gabox-sdk/SKILL.md +40 -141
- package/skills/gabox-sdk/references/api.md +102 -145
- package/dist/gaboxV2-CV2XltqC.js +0 -3347
- package/dist/gaboxV2-CV2XltqC.js.map +0 -1
- package/dist/index-BxvSkzCO.d.ts +0 -471
- package/dist/pump/index.d.ts +0 -2
- package/dist/pump/index.js +0 -2
- package/dist/pump-D0K_0uiC.js +0 -1531
- package/dist/pump-D0K_0uiC.js.map +0 -1
|
@@ -1,163 +1,62 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: gabox-sdk
|
|
3
|
-
description: Integrate
|
|
3
|
+
description: Integrate Gabox machines on Solana with @gabox-labs/sdk and @solana/kit. Use for Gabox pools, packs, Raydium LaunchLab and CPMM venues, draws, prizes, creator fees, and SDK integration.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Gabox SDK
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function and type: `references/api.md`.
|
|
8
|
+
Gabox binds a prize machine to a brand-new Raydium LaunchLab coin. The coin trades on its LaunchLab
|
|
9
|
+
curve until it raises the pinned amount, then Raydium migrates it into a Raydium CPMM pool. Gabox
|
|
10
|
+
delivers awards and closes draw accounts itself; there is no Ready, claim or sell-prize flow, and no
|
|
11
|
+
referral program.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
Use only devnet clients today. Pass `GaboxClient` first to every chain function; all amounts are
|
|
14
|
+
`bigint`.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
ESM only. Node 24+. `@solana/kit` is a peer dependency. The program is on **devnet only** today.
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
import { createClient } from '@gabox-labs/sdk';
|
|
24
|
-
const gabox = createClient({ cluster: 'devnet' }); // public devnet RPC
|
|
25
|
-
const gabox = createClient({ cluster: 'devnet', url: RPC }); // your provider; wsUrl follows
|
|
26
|
-
```
|
|
16
|
+
Gabox charges no fee at all. Every price the SDK shows already includes Raydium's own fees: on the
|
|
17
|
+
curve, 0.5% to the Gabox platform wallet and 0.5% to the coin creator plus Raydium's trade fee; after
|
|
18
|
+
graduation, the CPMM pool fee and the pool creator fee.
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
## Conventions that trip people up
|
|
33
|
-
|
|
34
|
-
- **All amounts are `bigint`.** Lamports for SOL, base units for tokens (6 decimals: one pack is
|
|
35
|
-
`1_000_000n * 1_000_000n`). Never mix `number` into arithmetic. Basis points are `number`.
|
|
36
|
-
- **Builders return a message, not a signature.** Sign with kit's
|
|
37
|
-
`signTransactionMessageWithSigners` and send with `sendAndConfirmTransactionFactory({ rpc:
|
|
38
|
-
gabox.rpc, rpcSubscriptions: gabox.rpcSubscriptions })`. The SDK never signs or sends.
|
|
39
|
-
- **Build right before signing.** The message carries a blockhash that expires in about a minute.
|
|
40
|
-
- **Address derivation is async.** `await poolAddress(mint)`, `await drawAddress(pool, seq)`.
|
|
41
|
-
- **Low-level `generated.*` functions take `gabox.rpc`**, not the client.
|
|
42
|
-
- **Keep the surface kit-only.** Do not import `@solana/web3.js` to talk to this SDK.
|
|
43
|
-
|
|
44
|
-
## Flow 1: price and buy a pack
|
|
20
|
+
Both venues settle in wrapped SOL. Every builder wraps the SOL its trade needs and closes the WSOL
|
|
21
|
+
account afterwards, so the wallet spends and receives plain SOL. That close also unwraps any WSOL the
|
|
22
|
+
wallet already held.
|
|
45
23
|
|
|
46
24
|
```ts
|
|
47
|
-
import { buyPack,
|
|
25
|
+
import { buyPack, createClient, getOffer } from '@gabox-labs/sdk';
|
|
48
26
|
|
|
27
|
+
const gabox = createClient({ cluster: 'devnet' });
|
|
49
28
|
const offer = await getOffer(gabox, mint, { user: purchaser.address });
|
|
50
|
-
// offer.quoteLamports the pack price now (venue fees included)
|
|
51
|
-
// offer.prizes [{ amount, tickets }], amounts in tokens, already capped by inventory
|
|
52
|
-
// offer.maximum top prize; offer.isSeeded === false means the cap is biting: warn the user
|
|
53
|
-
|
|
54
|
-
const pool = await fetchPoolByMint(gabox, mint);
|
|
55
|
-
const seq = pool!.nextSeq; // pin the draw
|
|
56
|
-
const maxQuoteIn = (offer.quoteLamports * 102n) / 100n; // 2% slippage
|
|
57
29
|
const message = await buyPack(gabox, {
|
|
58
30
|
mint,
|
|
59
|
-
purchaser,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
maxTotalDebit: maxQuoteIn + share(maxQuoteIn, 200n) + 20_000_000n,
|
|
64
|
-
});
|
|
65
|
-
// ...sign and send...
|
|
66
|
-
const draw = await drawAddress(offer.pool, seq);
|
|
67
|
-
const resolved = await watchDraw(gabox, draw, { signal: AbortSignal.timeout(180_000) });
|
|
68
|
-
// resolved.amount = tokens won, already in the purchaser's associated token account
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
The three limits the buyer signs:
|
|
72
|
-
|
|
73
|
-
| limit | caps | set it to |
|
|
74
|
-
| --------------- | -------------------------------------------------------------------- | -------------------------------------- |
|
|
75
|
-
| `maxQuoteIn` | the venue price in lamports | `quoteLamports` + your slippage |
|
|
76
|
-
| `minMaximum` | the top prize in tokens; fails if inventory dropped | `offer.maximum` |
|
|
77
|
-
| `maxTotalDebit` | price + creator fee + protocol fee + randomness fee (both fees ≈ 1%) | `maxQuoteIn + share(maxQuoteIn, 200n) + margin` |
|
|
78
|
-
|
|
79
|
-
`maxTotalDebit` excludes rent and the transaction fee. Add ~0.02 SOL of margin. Always pass `seq`
|
|
80
|
-
so a retry after a stale blockhash cannot buy a second pack.
|
|
81
|
-
|
|
82
|
-
## Flow 2: keep or sell
|
|
83
|
-
|
|
84
|
-
Keeping needs no transaction. Selling routes through the SDK:
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
import { pump, sellTokens } from '@gabox-labs/sdk';
|
|
88
|
-
const gross = await pump.sellQuote(gabox, mint, amount, { user: seller.address });
|
|
89
|
-
const message = await sellTokens(gabox, {
|
|
90
|
-
mint, seller, amount,
|
|
91
|
-
minQuoteOutput: (gross * 95n) / 100n, // must be > 0
|
|
31
|
+
purchaser,
|
|
32
|
+
maxQuoteIn: (offer.quoteAmount * 102n) / 100n,
|
|
33
|
+
minMaximum: (offer.maximum * 98n) / 100n,
|
|
34
|
+
maxNativeDebit: 100_000_000n,
|
|
92
35
|
});
|
|
93
36
|
```
|
|
94
37
|
|
|
95
|
-
|
|
38
|
+
`offer.quoteAmount` is the exact venue price for one pack. `maxQuoteIn` is the slippage cap and the
|
|
39
|
+
number of lamports wrapped first. `maxNativeDebit` is a separate cap on the lamports the handler
|
|
40
|
+
watches: the VRF request and any venue account rent.
|
|
96
41
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
42
|
+
For creation use `createMachine` with `name`, `symbol`, `uri`, `maxSeedQuoteIn` and
|
|
43
|
+
`maxSeedNativeDebit`. Metaplex limits the three strings to 32, 10 and 200 UTF-8 bytes. Everything
|
|
44
|
+
else about the launch is pinned. It buys a mandatory seed: enough for a 3x top prize on the first
|
|
45
|
+
pack, or the table's full top prize when that pays less than 3x. A table's top tier can be at most
|
|
46
|
+
20x. Pass `extraSeedTokens` to buy more seed in the same trade, and read `seedCostEstimate` for the
|
|
47
|
+
mandatory, extra and total amounts plus the exact cost.
|
|
102
48
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
creator, mintKeypair, // two signers
|
|
107
|
-
name, symbol, uri, // Pump metadata
|
|
108
|
-
feeBps: 100, // creator fee, 0..100 (max 1%)
|
|
109
|
-
riskProfile: 'balanced', // 'conservative' | 'balanced' | 'jackpot'
|
|
110
|
-
jackpotBps: 50_000, // top prize = 5 packs
|
|
111
|
-
maxSeedLamports: (seed.lamports * 105n) / 100n,
|
|
112
|
-
});
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
The creator buys the **seed** that backs the jackpot: a 5× jackpot needs four extra packs of
|
|
116
|
-
tokens, 10× needs nine, 1× needs none. Preview the table with `jackpotTiers(jackpotBps, profile)`.
|
|
117
|
-
|
|
118
|
-
## Flow 4: stuck draws (permissionless)
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
import { drawAvailability, expireDraw, retryDraw } from '@gabox-labs/sdk';
|
|
122
|
-
const s = await drawAvailability(gabox, draw);
|
|
123
|
-
if (s?.canRetry) await retryDraw(gabox, { payer, pool, draw, maxVrfDebit: 5_000_000n });
|
|
124
|
-
if (s?.canExpire) await expireDraw(gabox, { payer, pool, draw });
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Retry: 300 slots after the last attempt, 3 attempts total. Expire: after 216,000 slots (~1 day);
|
|
128
|
-
pays the **smallest** prize, not a refund. Show `slotsUntilRetry` / `slotsUntilExpiry` as a countdown.
|
|
129
|
-
|
|
130
|
-
## Referrals
|
|
131
|
-
|
|
132
|
-
```ts
|
|
133
|
-
await bindReferrer(gabox, referee, referrerAddress); // referee signs, permanent
|
|
134
|
-
await buyPack(gabox, { ...input, referrer: referrerAddress }); // or bind + buy in one tx
|
|
135
|
-
await claimReferral(gabox, referrer, poolAddress); // referrer collects
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
The referrer earns 1% of the creator's fee per pack. The buyer pays nothing extra.
|
|
139
|
-
|
|
140
|
-
## Reading state
|
|
141
|
-
|
|
142
|
-
`fetchPoolByMint`, `fetchPoolInventory`, `fetchDraw`, `listPools`, `listDraws({ pool?, purchaser? })`,
|
|
143
|
-
`fetchEvents(gabox, signature)`. `list*` uses `getProgramAccounts`: cache it. Events:
|
|
144
|
-
`PoolCreated`, `PackBought`, `DrawResolved`, `TokensSold`, `PrizesFunded`, `RandomnessRetried`.
|
|
145
|
-
|
|
146
|
-
## Errors
|
|
147
|
-
|
|
148
|
-
```ts
|
|
149
|
-
import { generated } from '@gabox-labs/sdk';
|
|
150
|
-
if (generated.isGaboxV2Error(error, message, generated.GABOX_V2_ERROR__SLIPPAGE_EXCEEDED)) { /* widen maxQuoteIn */ }
|
|
151
|
-
if (generated.isGaboxV2Error(error, message)) console.log(generated.getGaboxV2ErrorMessage(error.context.code));
|
|
152
|
-
```
|
|
49
|
+
`raydium.resolveVenue(client, { mint, user })` says which venue is live. It throws while a coin is
|
|
50
|
+
migrating, which on devnet lasts under a minute. A migrated CPMM pool can sit at any address, so the
|
|
51
|
+
SDK proves it from its own data and reads its fee tier, vaults and oracle out of the pool account.
|
|
153
52
|
|
|
154
|
-
|
|
155
|
-
|
|
53
|
+
Creators collect their share with `raydium.claimCreatorFee(client, { creator })`, which sweeps every
|
|
54
|
+
coin they launched on the curve, and `raydium.collectCreatorFee(client, { mint, creator })` for one
|
|
55
|
+
graduated coin. `raydium.fetchCreatorFees` reads both.
|
|
156
56
|
|
|
157
|
-
|
|
57
|
+
`buyPack` keeps a per-wallet `WalletActivity` account (`fetchWalletActivity(client, wallet)`, `null`
|
|
58
|
+
before a wallet's first purchase); it resolves the account itself.
|
|
158
59
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
- Do not point a `'devnet'` client at any other URL. Use `cluster: 'localnet'` for a test validator.
|
|
163
|
-
- Do not run against mainnet. The program is not deployed there.
|
|
60
|
+
Use `fetchEvents` and `findResolvedDraw` for final delivery, and `retryDraw` or `expireDraw` for
|
|
61
|
+
permissionless recovery. `fundPrizes` moves coins a funder already holds into the irrevocable prize
|
|
62
|
+
vault. See `references/api.md` and the package README for complete signatures.
|
|
@@ -1,149 +1,106 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Client
|
|
8
|
-
|
|
9
|
-
|
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| `createClient` | `(config: ClientConfig) => GaboxClient` | the init step. Throws if the URL contradicts the cluster |
|
|
12
|
-
| `ClientConfig` | `{ cluster: Cluster; url?: string; wsUrl?: string; addressLookupTables?: AddressesByLookupTableAddress }` | `cluster` is required |
|
|
13
|
-
| `GaboxClient` | `{ cluster; url; wsUrl; rpc: GaboxRpc; rpcSubscriptions: GaboxRpcSubscriptions; addressLookupTables }` | a plain object; spread to replace `rpc` |
|
|
14
|
-
| `Cluster` | `'devnet' \| 'mainnet-beta' \| 'localnet'` | |
|
|
15
|
-
| `CLUSTER_ENDPOINTS` | `Record<Cluster, { url; wsUrl }>` | the defaults |
|
|
16
|
-
| `clusterNamedBy` | `(url: string) => Cluster \| 'testnet' \| null` | substring check |
|
|
17
|
-
| `assertClusterUrl` | `(cluster: Cluster, url: string) => void` | the guard, exported for scripts |
|
|
18
|
-
| `websocketUrlFor` | `(url: string) => string` | `https`→`wss`, `http`→`ws` |
|
|
19
|
-
| `defaultAddressLookupTables` | `(cluster: Cluster) => AddressesByLookupTableAddress` | devnet's shared table; `{}` elsewhere |
|
|
20
|
-
| `GaboxRpc`, `GaboxRpcSubscriptions` | kit `Rpc<SolanaRpcApi>`, `RpcSubscriptions<SolanaRpcSubscriptionsApi>` | |
|
|
21
|
-
|
|
22
|
-
## Offers and prices (`src/offer.ts`)
|
|
23
|
-
|
|
24
|
-
| function | signature | notes |
|
|
25
|
-
| --- | --- | --- |
|
|
26
|
-
| `getOffer` | `(client, mint: Address, options?: { user?: Address; venue?: VenueKind }) => Promise<PackOffer>` | two reads: pool + vault, then the venue. Throws if the mint has no machine |
|
|
27
|
-
| `offerFromState` | `(inventory: PoolInventory, venue: VenueKind, quoteLamports: bigint) => PackOffer` | pure |
|
|
28
|
-
| `seedShortfall` | `(offer: PackOffer) => bigint` | tokens that would uncap the top prize |
|
|
29
|
-
|
|
30
|
-
`PackOffer` fields: `mint`, `pool`, `packTokens`, `quoteLamports`, `feeBps`, `feeLamports`,
|
|
31
|
-
`protocolLamports`, `seedLamports`, `seedTokens`, `venue`, `prizes: Prize[]`, `maximum`, `minimum`,
|
|
32
|
-
`uncapped`, `inventory`, `reserved`, `free`, `isFirstPack`, `isSeeded`, `maxMultiplierBps`,
|
|
33
|
-
`averageMultiplierBps`.
|
|
34
|
-
|
|
35
|
-
## Transaction builders (`src/tx/`, `src/referral.ts`)
|
|
36
|
-
|
|
37
|
-
| function | input | signers |
|
|
38
|
-
| --- | --- | --- |
|
|
39
|
-
| `createMachine` | `{ creator; mintKeypair; name; symbol; uri; feeBps: number; riskProfile: RiskProfile; jackpotBps: number; maxSeedLamports: bigint; feeRecipientIndex?; buybackRecipientIndex? }` | creator, mintKeypair |
|
|
40
|
-
| `seedCostEstimate` | `(client, jackpotBps: number, riskProfile: RiskProfile) => Promise<{ tiers: Tier[]; seedTokens: bigint; lamports: bigint }>` | read only |
|
|
41
|
-
| `buyPack` | `{ mint; purchaser; maxQuoteIn: bigint; minMaximum: bigint; maxTotalDebit: bigint; seq?: bigint; venue?; wrapLamports?; cashback?; referrer?: Address }` | purchaser |
|
|
42
|
-
| `sellTokens` | `{ mint; seller; amount: bigint; minQuoteOutput: bigint; venue? }` | seller |
|
|
43
|
-
| `fundPrizes` | `{ mint; funder; amount: bigint; source?: Address }` | funder |
|
|
44
|
-
| `fundPrizesWithBuy` | `{ mint; funder; tokens: bigint; maxQuoteIn: bigint; venue?; wrapLamports? }` | funder |
|
|
45
|
-
| `retryDraw` | `{ payer; pool; draw; maxVrfDebit: bigint }` | payer (anyone) |
|
|
46
|
-
| `expireDraw` | `{ payer; pool; draw }` | payer (anyone) |
|
|
47
|
-
| `bindReferrer` | `(client, referee: TransactionSigner, referrer: Address, options?) ` | referee |
|
|
48
|
-
| `claimReferral` | `(client, referrer: TransactionSigner, pool: Address, options?)` | referrer |
|
|
49
|
-
| `claimPrize`, `sellPrize`, `quoteSellPrize` | legacy draws only (created before automatic delivery) | purchaser |
|
|
50
|
-
| `buildMessage` | `(client, feePayer, instructions: Instruction[], options: BuildOptions)` | assemble your own |
|
|
51
|
-
|
|
52
|
-
Every input also accepts `BuildOptions`: `computeUnitLimit?: number`, `computeUnitPrice?: number | bigint`
|
|
53
|
-
(micro-lamports per unit), `addressLookupTables?`.
|
|
54
|
-
|
|
55
|
-
`drawAvailability(client, draw) => Promise<DrawAvailability | null>` returns
|
|
56
|
-
`{ status, attempts, slotsUntilRetry, slotsUntilExpiry, canRetry, canExpire }`.
|
|
57
|
-
|
|
58
|
-
## Readers (`src/accounts.ts`, `src/events.ts`)
|
|
59
|
-
|
|
60
|
-
| function | returns |
|
|
1
|
+
# Gabox SDK API
|
|
2
|
+
|
|
3
|
+
All chain-touching functions take `client: GaboxClient` first. Addresses use `Address`; all token
|
|
4
|
+
amounts use base-unit `bigint`. Every venue is Raydium: LaunchLab before a coin graduates, Raydium
|
|
5
|
+
CPMM after. Both settle in WSOL.
|
|
6
|
+
|
|
7
|
+
## Client and reads
|
|
8
|
+
|
|
9
|
+
| Function | Result |
|
|
61
10
|
| --- | --- |
|
|
11
|
+
| `createClient({ cluster: 'devnet', ... })` | `GaboxClient` |
|
|
62
12
|
| `fetchPoolByMint(client, mint)` | `Pool \| null` |
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
`lastAttemptSlot`, `attempts`, `maximum`, `minimum`, `prizes`, `amount`, `randomness`, `timedOut`.
|
|
82
|
-
|
|
83
|
-
`GaboxEvent` is a union on `name`: `PoolCreated`, `PrizesFunded`, `PackBought`, `RandomnessRetried`,
|
|
84
|
-
`DrawResolved`, `PrizeRedeemed`, `TokensSold`. `PackBought.data` has `pool`, `seq`, `purchaser`,
|
|
85
|
-
`venue`, `tokensBought`, `venueDebit`, `feeLamports`, `referralLamports`, `protocolLamports`,
|
|
86
|
-
`vrfDebit`, `prizes`. `DrawResolved.data` has `pool`, `seq`, `purchaser`, `amount`, `randomness`,
|
|
87
|
-
`timedOut`.
|
|
88
|
-
|
|
89
|
-
## Addresses (`src/pdas.ts`), all async
|
|
90
|
-
|
|
91
|
-
`poolAddress(mint)`, `drawAddress(pool, seq)`, `vaultAddress(mint, tokenProgram?)`,
|
|
92
|
-
`associatedTokenAddress(owner, mint, tokenProgram?)`, `referralLinkAddress(referee)`,
|
|
93
|
-
`referralAddress(pool, referrer)`, `feeCollectorWsolAddress()`, `vrfIdentityAddress()`.
|
|
94
|
-
Also the generated `findPoolPda`, `findDrawPda`, `findReferralLinkPda`, `findIdentityPda`.
|
|
95
|
-
|
|
96
|
-
## Math (`src/math.ts`), pure
|
|
97
|
-
|
|
98
|
-
| function | signature |
|
|
13
|
+
| `fetchPoolInventory(client, mint)` | pool, vault inventory, reservations, free inventory |
|
|
14
|
+
| `getOffer(client, mint, options?)` | current `PackOffer` |
|
|
15
|
+
| `listPools(client)` / `listDrawsByPurchaser(client, wallet)` | current account scans |
|
|
16
|
+
| `fetchWalletActivity(client, wallet)` | `WalletActivity \| null`, a buyer's lifetime `packsBought`/`nativeSpent` |
|
|
17
|
+
|
|
18
|
+
`Pool` records `creator`, `mint`, `vault`, `quoteMint` (always WSOL), `packTokens`,
|
|
19
|
+
`seedQuoteAmount`, `tiers`, `nextSeq` and `reserved`. It stores no token program, because classic
|
|
20
|
+
SPL Token owns both sides, and no fee, because Gabox charges none.
|
|
21
|
+
|
|
22
|
+
`PackOffer` gives `quoteAmount` (the whole pack price, the venue's fees included), `venue`
|
|
23
|
+
(`'launchlab'` or `'cpmm'`), the frozen prize table, `maximum`, `minimum`, `uncapped`, the inventory
|
|
24
|
+
numbers and `isSeeded`.
|
|
25
|
+
|
|
26
|
+
## Builders
|
|
27
|
+
|
|
28
|
+
Each returns a kit transaction message. Nothing here signs or sends.
|
|
29
|
+
|
|
30
|
+
| Function | Input highlights |
|
|
99
31
|
| --- | --- |
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
`
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
`
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
`
|
|
121
|
-
`
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
32
|
+
| `createMachine` | `name`, `symbol`, `uri`, `tiers?`, `maxSeedQuoteIn`, `maxSeedNativeDebit`, `extraSeedTokens?` |
|
|
33
|
+
| `buyPack` | `maxQuoteIn`, `minMaximum`, `maxNativeDebit`, `venue?`, `seq?` |
|
|
34
|
+
| `fundPrizes` | donate coins the funder already holds into the prize vault |
|
|
35
|
+
| `sellTokens` | `amount`, `minQuoteOutput`, `maxNativeDebit`, `venue?` |
|
|
36
|
+
| `retryDraw` / `expireDraw` | permissionless recovery |
|
|
37
|
+
| `raydium.claimCreatorFee` | `creator`; sweeps every coin that wallet launched on the curve |
|
|
38
|
+
| `raydium.collectCreatorFee` | `mint`, `creator`; one graduated coin's CPMM creator fee |
|
|
39
|
+
|
|
40
|
+
Every builder wraps the SOL its trade needs into the wallet's WSOL account and closes that account
|
|
41
|
+
afterwards, so the wallet spends and receives plain SOL. Closing unwraps any WSOL the wallet already
|
|
42
|
+
held.
|
|
43
|
+
|
|
44
|
+
`createMachine` builds one transaction with LaunchLab's `initialize_v2` first and `initialize_pool`
|
|
45
|
+
second. The mint keypair and the creator both sign. It buys a mandatory seed,
|
|
46
|
+
`seedTokens(PACK_TOKENS, tiers)`: enough for a 3x top prize on the first pack, or the table's full
|
|
47
|
+
top prize when that pays less than 3x. A table's top tier can be at most 20x. `extraSeedTokens`
|
|
48
|
+
(default `0n`) adds more in the same trade. `seedCostEstimate` returns `seedTokens`,
|
|
49
|
+
`extraSeedTokens`, `totalSeedTokens` and the exact `quoteAmount` a fresh curve would charge.
|
|
50
|
+
|
|
51
|
+
`buyPack` also resolves a per-wallet `WalletActivity` account (`findActivityPda({ purchaser })` or
|
|
52
|
+
`activityAddress(wallet)`); callers do not pass it. It does not create the purchaser's coin account
|
|
53
|
+
either: the program declares it `init_if_needed`, so Anchor does that and the purchaser pays its rent
|
|
54
|
+
once.
|
|
55
|
+
|
|
56
|
+
`maxQuoteIn` and `maxSeedQuoteIn` are venue slippage caps in WSOL, and each is also the amount
|
|
57
|
+
wrapped before the trade. `maxNativeDebit` and `maxSeedNativeDebit` are separate lamport caps for
|
|
58
|
+
what the handler watches: venue account rent, and the VRF request on a pack buy.
|
|
59
|
+
|
|
60
|
+
## The venue
|
|
61
|
+
|
|
62
|
+
| Function | Result |
|
|
126
63
|
| --- | --- |
|
|
127
|
-
| `resolveVenue
|
|
128
|
-
| `curveQuote
|
|
129
|
-
| `sellQuote
|
|
130
|
-
| `newCurveBuyCost
|
|
131
|
-
| `
|
|
132
|
-
| `
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
64
|
+
| `raydium.resolveVenue(client, { mint, user, venue? })` | `ResolvedVenue`: `kind`, `program`, `poolState`, `status`, `creator`, `ammConfig`, `remainingCurveBase`, `buyAccounts`, `sellAccounts`, `quoteBuy`, `quoteSell` |
|
|
65
|
+
| `raydium.curveQuote(client, mint, tokens)` | the buy price, for a display |
|
|
66
|
+
| `raydium.sellQuote(client, mint, tokens)` | the sale proceeds |
|
|
67
|
+
| `raydium.newCurveBuyCost(client, tokens)` | what a buy costs on a curve that does not exist yet |
|
|
68
|
+
| `raydium.findCpmmPool(client, { mint, creator, cpswapConfig })` | the migrated CPMM pool, proved from its own data |
|
|
69
|
+
| `raydium.fetchCurveSettings(client)` | the fee rates, the migrate fee and the CPMM fee tier, read from chain |
|
|
70
|
+
| `raydium.fetchCreatorFees(client, { creator, mint? })` | `{ curveLamports, cpmmLamports, cpmmTokens }` |
|
|
71
|
+
| `raydium.wsolAccountFor(user)` | the WSOL account every venue settles in |
|
|
72
|
+
|
|
73
|
+
`resolveVenue` follows the LaunchLab pool's `status`: `0` routes to the curve, `2` to the CPMM pool,
|
|
74
|
+
and `1` throws because the coin is migrating right now. A migrated CPMM pool does not have to sit at
|
|
75
|
+
a derived address, so it proves itself from its own data, and its fee tier, its two vaults and its
|
|
76
|
+
oracle are read out of the pool account. The program checks the same things.
|
|
77
|
+
|
|
78
|
+
`quoteBuy` on the curve throws when the amount is larger than the curve has left to sell. That is not
|
|
79
|
+
a price failure: the program requires an exact one-pack delta, so such a buy cannot succeed until the
|
|
80
|
+
coin graduates.
|
|
81
|
+
|
|
82
|
+
## Math and low-level builders
|
|
83
|
+
|
|
84
|
+
`raydium.curve` exports exact bigint ports of Raydium's own math: `curveBuyExactOut`,
|
|
85
|
+
`curveBuyExactIn`, `curveSellExactIn`, `initialCurve`, `cpmmSwapBaseOutput`, `cpmmSwapBaseInput`, and
|
|
86
|
+
the `ceilDivRate` / `preFeeAmount` helpers they are built from. Every rounding step matches
|
|
87
|
+
Raydium's.
|
|
88
|
+
|
|
89
|
+
`raydium.getLaunchInstruction(input, ids)` builds LaunchLab's `initialize_v2` with the pinned launch
|
|
90
|
+
shape. `raydium.getCurveBuyExactInInstruction(client, input, ids?)` builds a plain curve buy that
|
|
91
|
+
Gabox never makes itself; the devnet end-to-end test uses it to buy a curve out and force graduation.
|
|
92
|
+
|
|
93
|
+
`raydiumIds(cluster)` gives one cluster's Raydium deployment. Mainnet and devnet run different
|
|
94
|
+
programs and PDAs, and devnet raises 3 SOL where mainnet raises 85. `localnet` uses the mainnet set,
|
|
95
|
+
which is what the program's default build pins.
|
|
96
|
+
|
|
97
|
+
## Events
|
|
98
|
+
|
|
99
|
+
`decodeEvents` and `fetchEvents` return only `PoolCreated`, `PrizesFunded`, `PackBought`,
|
|
100
|
+
`RandomnessRetried`, `DrawResolved` and `TokensSold`. None carries a Gabox fee field any more.
|
|
101
|
+
`PackBought` reports `quoteDebit` (what the venue charged), `nativeDebit` (venue account rent),
|
|
102
|
+
`vrfNativeDebit` and `totalNativeDebit`.
|
|
103
|
+
|
|
104
|
+
Delivery closes a draw atomically; use `findResolvedDraw` rather than a Ready or claim flow. It
|
|
105
|
+
searches a bounded recent signature history, so production indexers should persist `DrawResolved`
|
|
106
|
+
events as the authoritative history.
|