@gabox-labs/sdk 0.7.1 → 0.9.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 +62 -0
- package/README.md +85 -23
- package/dist/{gabox-DGTCh34U.js → gabox-CuyJYmrS.js} +669 -309
- package/dist/gabox-CuyJYmrS.js.map +1 -0
- package/dist/generated/index.d.ts +458 -92
- package/dist/generated/index.js +214 -54
- package/dist/generated/index.js.map +1 -1
- package/dist/{index-CA0m7AKk.d.ts → index-CQcBMEah.d.ts} +189 -4
- package/dist/index.d.ts +226 -30
- package/dist/index.js +182 -40
- package/dist/index.js.map +1 -1
- package/dist/raydium/index.d.ts +2 -2
- package/dist/raydium/index.js +2 -2
- package/dist/{raydium-CU-tZzIk.js → raydium-DXUJ-g1p.js} +835 -105
- package/dist/raydium-DXUJ-g1p.js.map +1 -0
- package/llms.txt +4 -0
- package/package.json +1 -1
- package/skills/gabox-sdk/SKILL.md +21 -13
- package/skills/gabox-sdk/references/api.md +47 -18
- package/dist/gabox-DGTCh34U.js.map +0 -1
- package/dist/raydium-CU-tZzIk.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,68 @@
|
|
|
3
3
|
All notable changes to `@gabox-labs/sdk`. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
4
4
|
and the project uses [Semantic Versioning](https://semver.org/) with the `0.x` rule from `CONTRIBUTING.md`.
|
|
5
5
|
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [0.9.0] - 2026-09-19
|
|
9
|
+
|
|
10
|
+
**Breaking.** The program now sells packs in purchases of one to five, and pays a prize it cannot
|
|
11
|
+
deliver into an owed balance instead of failing. Every earlier devnet pool is abandoned by this
|
|
12
|
+
program version, so nothing this release reads existed before its deploy.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `buyPacks(client, { count, nonce?, maxQuoteIn, minFirstMaximum, maxNativeDebit, ... })` opens
|
|
17
|
+
`count` packs (1 to `MAX_BATCH_SIZE`, which is 5) in one venue trade with one draw and one
|
|
18
|
+
randomness request. It returns `{ message, draw, nonce, seqStart, count }`. `buyPack` stays as
|
|
19
|
+
the one-pack form with `minMaximum`, and returns the same shape.
|
|
20
|
+
- `getOffer(client, mint, { count })` prices the whole purchase and adds `count`, `perPackCaps`
|
|
21
|
+
(the worst-case top prize of each pack), `batchReserved` and `freeSnapshot`.
|
|
22
|
+
- `settle`, `settleDraw` and `ticketFor` reproduce a purchase's settlement from the oracle's
|
|
23
|
+
randomness, the way the program does it. `reserveFor`, `settleWith`, `perPackCaps`,
|
|
24
|
+
`chooseIndex`, `uncappedAmounts` and `minTier` are the pure parts.
|
|
25
|
+
- `claimPrize` and `claimPrizeTo` pay an owed prize; `fetchOwedDraws` lists what a wallet is owed;
|
|
26
|
+
`drawAvailability` reports `settled`, `owed`, `canDeliver` and `canClaim`.
|
|
27
|
+
- `randomNonce`, and `drawAddress(pool, purchaser, nonce)`.
|
|
28
|
+
- Events `PacksBought` and `PrizeClaimed`. `DrawResolved` carries `draw`, `seqStart`, `count`,
|
|
29
|
+
`total`, `paid` and one `results` entry per pack. `RandomnessRetried` names the draw.
|
|
30
|
+
- `CLAIM_PRIZE_COMPUTE_UNITS`.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- `drawAddress` takes the purchaser and a nonce; the pool's sequence counter is no longer in the
|
|
35
|
+
address. `findResolvedDraw` matches the event's own `draw` field.
|
|
36
|
+
- `Draw` has a new layout and discriminator: a snapshot of the tiers, the pack size and the free
|
|
37
|
+
inventory, plus `settled`, `randomness`, `timedOut` and `owed`. `Pool` has a new discriminator.
|
|
38
|
+
- `expireDraw` refuses a settled draw before sending; the program pays every pack of an expired
|
|
39
|
+
purchase its smallest tier.
|
|
40
|
+
|
|
41
|
+
### Removed
|
|
42
|
+
|
|
43
|
+
- `PackBought`; `PacksBought` replaces it.
|
|
44
|
+
|
|
45
|
+
## [0.8.0] - 2026-09-19
|
|
46
|
+
|
|
47
|
+
The platform's own fees, so the app can show them and claim them.
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
|
|
51
|
+
- `raydium.fetchPlatformFees(client, { quoteMint })` reads the LaunchLab platform fee vault for one
|
|
52
|
+
quote asset, and `raydium.claimPlatformFee(client, { feeWallet, quoteMint })` claims it with
|
|
53
|
+
`claim_platform_fee_from_vault`. Only the wallet the platform config names can sign it.
|
|
54
|
+
- `raydium.fetchLockedPositions(client, owner)` lists every locked CPMM position a wallet holds the
|
|
55
|
+
fee NFT of, with the pool behind it and what it may withdraw now. `raydium.harvestLockedFees`
|
|
56
|
+
builds the lock program's `collect_cp_fees` for one of them. `raydium.lockedFeeLp` is the math,
|
|
57
|
+
checked against the lock program's own event on devnet.
|
|
58
|
+
- `raydiumIds` now carries Raydium's lock program and its authority per cluster, as `lock` and
|
|
59
|
+
`lockAuthority`. `decodeLockedCpLiquidity` reads a lock record, and `CpmmPoolState` gains
|
|
60
|
+
`lpMint` and `lpSupply`.
|
|
61
|
+
- `HARVEST_COMPUTE_UNITS`, measured at `102,221` on devnet.
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
|
|
65
|
+
- `RaydiumIds` is now the generated cluster table plus the lock ids. A caller that passed
|
|
66
|
+
`RAYDIUM_DEVNET_IDS` straight from `abi.ts` into a builder passes `raydiumIds('devnet')` instead.
|
|
67
|
+
|
|
6
68
|
## [0.7.1] - 2026-09-18
|
|
7
69
|
|
|
8
70
|
A product correction. Paying in SOL is for buyers, not for creators.
|
package/README.md
CHANGED
|
@@ -19,7 +19,9 @@ this SDK shows is the venue's own price with the venue's own fees already inside
|
|
|
19
19
|
| coin creator | 0.5% of every trade | the pool's `creator_fee_rate` |
|
|
20
20
|
|
|
21
21
|
Those shares come out of Raydium's revenue, not out of an extra charge Gabox adds. The creator
|
|
22
|
-
collects theirs with `raydium.claimCreatorFee` and `raydium.collectCreatorFee`.
|
|
22
|
+
collects theirs with `raydium.claimCreatorFee` and `raydium.collectCreatorFee`. The platform
|
|
23
|
+
collects its curve share with `raydium.claimPlatformFee`, and after graduation it holds the locked
|
|
24
|
+
LP of every pool, whose trade fees `raydium.harvestLockedFees` pays out.
|
|
23
25
|
|
|
24
26
|
## The quote asset
|
|
25
27
|
|
|
@@ -59,7 +61,7 @@ const client = createClient({
|
|
|
59
61
|
});
|
|
60
62
|
```
|
|
61
63
|
|
|
62
|
-
`payWith: 'quote'` on `
|
|
64
|
+
`payWith: 'quote'` on `buyPacks` skips the swap and spends the token the wallet already holds.
|
|
63
65
|
`receive: 'quote'` does the same for a sale. A WSOL pool ignores both: its quote token is SOL.
|
|
64
66
|
|
|
65
67
|
The swap has to fit in the same 1,232-byte transaction as the buy. When it does not, the builder
|
|
@@ -121,7 +123,7 @@ const message = await createMachine(client, {
|
|
|
121
123
|
|
|
122
124
|
**The creator pays the seed, in the machine's own quote token.** There is no swap here: a machine
|
|
123
125
|
quoted in USDC needs the creator to hold at least `maxSeedQuoteIn` of USDC before this transaction
|
|
124
|
-
runs. Only a buyer arrives holding SOL alone, so only `
|
|
126
|
+
runs. Only a buyer arrives holding SOL alone, so only `buyPacks` and `sellTokens` swap.
|
|
125
127
|
|
|
126
128
|
`raise` is how much the curve must take in before the coin graduates, in the quote's own base units.
|
|
127
129
|
A WSOL pool has it pinned by the program — 85 SOL on mainnet, 3 SOL on devnet — so leave it out
|
|
@@ -143,28 +145,47 @@ can add more with `extraSeedTokens` (default `0n`), which the program adds to th
|
|
|
143
145
|
at most 20x; seed beyond what a 20x prize needs stays in the vault as backup for the draws after a
|
|
144
146
|
top-tier hit.
|
|
145
147
|
|
|
146
|
-
## Buy
|
|
148
|
+
## Buy packs
|
|
147
149
|
|
|
148
150
|
```ts
|
|
149
|
-
const offer = await getOffer(client, mint, { user: purchaser.address });
|
|
150
|
-
const message = await
|
|
151
|
+
const offer = await getOffer(client, mint, { user: purchaser.address, count: 3 });
|
|
152
|
+
const { message, draw, nonce } = await buyPacks(client, {
|
|
151
153
|
mint,
|
|
152
154
|
purchaser,
|
|
155
|
+
count: 3,
|
|
153
156
|
maxQuoteIn: (offer.quoteAmount * 102n) / 100n,
|
|
154
|
-
|
|
157
|
+
minFirstMaximum: (offer.maximum * 98n) / 100n,
|
|
155
158
|
maxNativeDebit: 100_000_000n,
|
|
156
159
|
});
|
|
157
160
|
```
|
|
158
161
|
|
|
159
|
-
`
|
|
160
|
-
|
|
161
|
-
`
|
|
162
|
-
|
|
162
|
+
One purchase opens `count` packs, 1 to `MAX_BATCH_SIZE` (5): one venue trade for all of them, one
|
|
163
|
+
draw, one randomness request. `buyPack` is the same with `count: 1` and `minMaximum` in place of
|
|
164
|
+
`minFirstMaximum`. Both return the message, the draw's address and its nonce, so the caller can
|
|
165
|
+
watch the draw without deriving anything.
|
|
166
|
+
|
|
167
|
+
`offer.quoteAmount` is the exact price the venue will charge for the whole purchase right now, fees
|
|
168
|
+
included, in the pool's quote token. The curve math is a port of Raydium's own, not an estimate, so
|
|
169
|
+
the `PacksBought` event reports the same number unless somebody trades in between. `offer.solAmount`
|
|
170
|
+
is the same price in lamports through the route provider, with `offer.quoteDecimals` and
|
|
163
171
|
`offer.quoteSymbol` for showing it.
|
|
164
172
|
|
|
165
|
-
`
|
|
166
|
-
|
|
167
|
-
|
|
173
|
+
`offer.prizes` and `offer.maximum` are the first pack's table, capped by the vault as it is now. The
|
|
174
|
+
later packs settle in order: each one is capped at what the vault can pay after the packs before
|
|
175
|
+
it, counting the purchase's own tokens as they arrive. `offer.perPackCaps` is the worst case per
|
|
176
|
+
pack, the top prize it keeps if every earlier pack won its own; on a thin vault the later entries
|
|
177
|
+
fall towards one pack, and a screen should show that next to the first table.
|
|
178
|
+
|
|
179
|
+
The draw's address is `["draw", pool, purchaser, nonce]`. The builder draws a random nonce unless
|
|
180
|
+
you pass one, so purchases from several buyers, or several from one buyer sent together, never
|
|
181
|
+
collide. A nonce still in use fails at the program; a nonce whose draw already closed opens a new
|
|
182
|
+
purchase, so never reuse the nonce of a purchase that may have landed.
|
|
183
|
+
|
|
184
|
+
`maxQuoteIn` is the slippage cap for the whole purchase, in the quote token, and the amount put in
|
|
185
|
+
the buyer's quote account before the buy. `minFirstMaximum` is the floor on the first pack's top
|
|
186
|
+
prize; refresh the offer when `PrizeCapChanged` refuses it. `maxNativeDebit` is separate: it caps
|
|
187
|
+
the lamports the handler watches, which are the VRF request and any venue account rent. Gabox adds
|
|
188
|
+
nothing to any of them.
|
|
168
189
|
|
|
169
190
|
## Sell
|
|
170
191
|
|
|
@@ -222,20 +243,56 @@ reads the quote off the Gabox pool itself.
|
|
|
222
243
|
Both pay into the creator's account for the quote mint. When that is WSOL the builders close it, so
|
|
223
244
|
the creator receives SOL; any other quote arrives as that token.
|
|
224
245
|
|
|
246
|
+
## Platform fees
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
const owed = await raydium.fetchPlatformFees(client, { quoteMint }); // owed.curveQuote
|
|
250
|
+
await raydium.claimPlatformFee(client, { feeWallet, quoteMint }); // every coin on that quote
|
|
251
|
+
|
|
252
|
+
const positions = await raydium.fetchLockedPositions(client, feeWallet.address);
|
|
253
|
+
// position.poolAddress, position.claimableLp, position.claimableToken0, position.claimableToken1
|
|
254
|
+
await raydium.harvestLockedFees(client, { owner: feeWallet, position }); // one graduated coin
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The platform's curve share waits in one LaunchLab vault per quote asset, and only the wallet the
|
|
258
|
+
platform config names as `platform_fee_wallet` can claim it. At graduation LaunchLab locks the
|
|
259
|
+
whole CPMM pool's LP under Raydium's lock program and mints one fee NFT to the platform NFT wallet.
|
|
260
|
+
`fetchLockedPositions` finds every such NFT in a wallet, reads the lock record and the pool behind
|
|
261
|
+
each, and computes what the position may withdraw now: the LP growth since the last harvest, as
|
|
262
|
+
`lockedFeeLp` works it out from the pool's `x * y` and LP supply. `harvestLockedFees` withdraws
|
|
263
|
+
that LP and pays both sides of the pair into the owner's accounts, closing the WSOL one.
|
|
264
|
+
|
|
225
265
|
## Wallet activity
|
|
226
266
|
|
|
227
|
-
`
|
|
267
|
+
`buyPacks` keeps a `WalletActivity` account per buyer, at the PDA `findActivityPda({ purchaser })`
|
|
228
268
|
(also `activityAddress(wallet)`). It tracks `packsBought` and `nativeSpent` across every pool.
|
|
229
269
|
`nativeSpent` is what the venue charged in WSOL, which is SOL; Gabox's own rent, the VRF fee and a
|
|
230
|
-
pack bought in any other quote token are not counted. The buyer pays its rent once, on the first
|
|
231
|
-
|
|
232
|
-
first purchase.
|
|
270
|
+
pack bought in any other quote token are not counted. The buyer pays its rent once, on the first
|
|
271
|
+
purchase, and `buyPacks` resolves the account itself. Read it with
|
|
272
|
+
`fetchWalletActivity(client, wallet)`, which returns `null` before a wallet's first purchase.
|
|
233
273
|
|
|
234
274
|
## Draws
|
|
235
275
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
276
|
+
The oracle's callback settles every pack of a purchase from one randomness and pays the total into
|
|
277
|
+
the purchaser's coin account, then closes the draw and returns its rent. `findResolvedDraw(client,
|
|
278
|
+
draw)` finds that `DrawResolved` event: `total`, one `results` entry per pack with its tier and
|
|
279
|
+
amount, the `randomness`, and `paid`.
|
|
280
|
+
|
|
281
|
+
`paid: false` means the callback could not use the purchaser's coin account, because it was
|
|
282
|
+
missing, closed, or no longer the purchaser's. The outcome is still fixed: the draw stays open with
|
|
283
|
+
`settled: true` and the total in `owed`, and nothing can reopen it. `claimPrize(client, { payer,
|
|
284
|
+
draw })` pays it to the purchaser's ATA, creating the account if needed, and anyone may send it.
|
|
285
|
+
`claimPrizeTo(client, { purchaser, draw, destination })` is the purchaser's own way out when they
|
|
286
|
+
changed their ATA's owner: it pays any coin account they own. `fetchOwedDraws(client, purchaser)`
|
|
287
|
+
lists what a wallet is still owed. This path exists so that a buyer cannot make the callback fail,
|
|
288
|
+
read its randomness, and try again; honest buyers never see it.
|
|
289
|
+
|
|
290
|
+
Anyone can check what a purchase won. `settle({ tiers, packTokens, freeSnapshot, count, pool,
|
|
291
|
+
seqStart, randomness })` recomputes every pack's result the way the program does, and
|
|
292
|
+
`settleDraw(draw)` does it from an owed draw's account alone. `drawAvailability(client, draw)` says
|
|
293
|
+
what can still happen to a draw. A stalled draw uses `retryDraw`, and `expireDraw` fixes it at every
|
|
294
|
+
pack's smallest tier after `TIMEOUT_SLOTS`. Existing base tokens can be donated irrevocably with
|
|
295
|
+
`fundPrizes`.
|
|
239
296
|
|
|
240
297
|
## Errors
|
|
241
298
|
|
|
@@ -245,8 +302,13 @@ The generated client decodes the program's own errors by name. The ones a client
|
|
|
245
302
|
| --- | --- |
|
|
246
303
|
| `InvalidVenue` | The account list did not match. Resolve the venue again and rebuild. |
|
|
247
304
|
| `SlippageExceeded` | The price moved past `maxQuoteIn`, or a cost went past `maxNativeDebit`. |
|
|
248
|
-
| `PrizeCapChanged` | The top prize fell below `
|
|
249
|
-
| `IncorrectTokenDelta` | The venue did not deliver exactly
|
|
305
|
+
| `PrizeCapChanged` | The first pack's top prize fell below `minFirstMaximum`. Refresh the offer. |
|
|
306
|
+
| `IncorrectTokenDelta` | The venue did not deliver exactly `count` packs. Usually a curve with fewer whole packs left; buy fewer or wait for graduation. |
|
|
307
|
+
| `TooManyPacks` / `ZeroAmount` | `count` is above `MAX_BATCH_SIZE` or zero. The builder refuses these before sending. |
|
|
308
|
+
| `DrawAlreadySettled` | A retry, an expiry or a second callback reached a draw whose outcome is fixed. Nothing to do. |
|
|
309
|
+
| `DrawNotSettled` | A claim on a draw that is still pending. Wait for the callback. |
|
|
310
|
+
| `DrawExpired` | A callback arrived after the deadline; only `expireDraw` remains. |
|
|
311
|
+
| `WrongDestination` | `claimPrizeTo` was given an account that is not the purchaser's, or not for this coin. |
|
|
250
312
|
| `InvalidLaunch` | The LaunchLab create instruction was missing or did not match the pinned shape. |
|
|
251
313
|
| `InvalidQuote` | The quote mint is not one Raydium enabled, or its Token-2022 profile is one the program refuses. |
|
|
252
314
|
|