@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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { DRAW_DISCRIMINATOR, Draw, DrawResolvedEvent, POOL_DISCRIMINATOR, PackBoughtEvent, Pool, PoolCreatedEvent, PrizesFundedEvent, RandomnessRetriedEvent, TokensSoldEvent, WALLET_ACTIVITY_DISCRIMINATOR, WalletActivity, decodeDraw, decodePool, decodeWalletActivity, findActivityPda, findDrawPda, findIdentityPda, findPoolPda, t as index_d_exports } from "./generated/index.js";
2
- import { $n as assertClusterUrl, Gn as CLUSTER_ENDPOINTS, J as buildMessage, Jn as DEVNET_HTTP, K as BuildOptions, Kn as ClientConfig, Nn as METAPLEX_PROGRAM_ADDRESS, Pn as PLATFORM_ADMIN, Qn as GaboxRpcSubscriptions, Vn as TOKEN_PROGRAM_ADDRESS, Wn as WSOL_MINT, Xn as GaboxClient, Y as withRemainingAccounts, Yn as DEVNET_WS, Zn as GaboxRpc, _n as ASSOCIATED_TOKEN_PROGRAM_ADDRESS, ar as RouteMode, er as clusterNamedBy, ir as Route, nr as defaultRoute, nt as VenueKind, on as LAUNCH_DECIMALS, or as RouteProvider, q as GaboxTransactionMessage, qn as Cluster, rr as websocketUrlFor, t as index_d_exports$1, tr as createClient, tt as ResolvedVenue, zn as SYSTEM_PROGRAM_ADDRESS } from "./index-CA0m7AKk.js";
1
+ import { DRAW_DISCRIMINATOR, Draw, DrawResolvedEvent, POOL_DISCRIMINATOR, PacksBoughtEvent, Pool, PoolCreatedEvent, PrizeClaimedEvent, PrizesFundedEvent, RandomnessRetriedEvent, TokensSoldEvent, WALLET_ACTIVITY_DISCRIMINATOR, WalletActivity, decodeDraw, decodePool, decodeWalletActivity, findActivityPda, findDrawPda, findIdentityPda, findPoolPda, t as index_d_exports } from "./generated/index.js";
2
+ import { Cr as createClient, Dr as RouteMode, Er as Route, Or as RouteProvider, Rn as ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Sr as clusterNamedBy, Tr as websocketUrlFor, _r as DEVNET_WS, br as GaboxRpcSubscriptions, ct as buildMessage, fr as WSOL_MINT, gr as DEVNET_HTTP, gt as VenueKind, hr as Cluster, ht as ResolvedVenue, lr as TOKEN_PROGRAM_ADDRESS, lt as withRemainingAccounts, mr as ClientConfig, nr as PLATFORM_ADMIN, ot as BuildOptions, pr as CLUSTER_ENDPOINTS, sr as SYSTEM_PROGRAM_ADDRESS, st as GaboxTransactionMessage, t as index_d_exports$1, tr as METAPLEX_PROGRAM_ADDRESS, vr as GaboxClient, wn as LAUNCH_DECIMALS, wr as defaultRoute, xr as assertClusterUrl, yr as GaboxRpc } from "./index-CQcBMEah.js";
3
3
  import { Address, AddressesByLookupTableAddress, Instruction, InstructionWithData, ProgramDerivedAddress, ReadonlyUint8Array, TransactionSigner } from "@solana/kit";
4
4
  //#region src/math.d.ts
5
5
  /**
@@ -29,6 +29,22 @@ export declare const MAX_MULTIPLIER_BPS = 200000;
29
29
  export declare const TICKETS = 65536;
30
30
  /** The prize table has exactly this many slots. Unused slots are all-zero. */
31
31
  export declare const TIERS = 8;
32
+ /**
33
+ * `constants::MAX_BATCH_SIZE`. The most packs one `buy_packs` call opens. A limit per purchase,
34
+ * not on pending packs: any number of buyers and overlapping purchases are fine, because every
35
+ * pending draw carries its own reservation.
36
+ */
37
+ export declare const MAX_BATCH_SIZE = 5;
38
+ /** One pack's outcome inside a settled batch: the tier it landed on and the tokens it pays. */
39
+ export type PackResult = {
40
+ tier: number;
41
+ amount: bigint;
42
+ };
43
+ /** What a batch pays: every pack's result in order, and their sum. */
44
+ export type Settlement = {
45
+ total: bigint;
46
+ results: PackResult[];
47
+ };
32
48
  /** One row of the immutable prize table. Counts, not cumulative thresholds. */
33
49
  export type Tier = {
34
50
  /** `floor(base * multiplierBps / 10_000)` tokens. `0` only on an unused row. */
@@ -126,6 +142,45 @@ export declare function quote(base: bigint, tiers: readonly Readonly<Tier>[], in
126
142
  * A ticket past the last row returns `0`, which cannot happen for a validated table.
127
143
  */
128
144
  export declare function choose(prizes: readonly Prize[], ticket: number): bigint;
145
+ /** `count` is a `u8` the program bounds at `MAX_BATCH_SIZE`. Zero is refused before any trade. */
146
+ export declare function checkedCount(count: number): number;
147
+ /**
148
+ * `math::uncapped`. Every tier's award for this base before any inventory cap, `0n` on an unused
149
+ * row. A ticketed tier that would pay nothing is refused, the same as in `quote`.
150
+ */
151
+ export declare function uncappedAmounts(base: bigint, tiers: readonly Readonly<Tier>[]): bigint[];
152
+ /** `math::min_tier`. The ticketed tier with the smallest award. Expiry pays it for every pack. */
153
+ export declare function minTier(uncapped: readonly bigint[], tiers: readonly Readonly<Tier>[]): number;
154
+ /**
155
+ * `math::choose_index`. Which tier a 16-bit ticket lands on: the rows are consecutive ranges in
156
+ * table order. Exactly 65,536 tickets, so there is no modulo and no bias.
157
+ */
158
+ export declare function chooseIndex(tiers: readonly Readonly<Tier>[], ticket: number): number;
159
+ /**
160
+ * `math::reserve_for`. What a purchase of `count` packs adds to `pool.reserved`:
161
+ * `min(count * uncappedMax, free + count * packTokens)`. Settlement in order can never pay more
162
+ * than either bound, so this is the least reservation that keeps the vault solvent whatever the
163
+ * outcomes. With `count = 1` it is exactly the single pack's capped maximum.
164
+ */
165
+ export declare function reserveFor(count: number, packTokens: bigint, uncappedMax: bigint, free: bigint): bigint;
166
+ /**
167
+ * `math::settle_with`. Settle a batch in order from explicit tickets.
168
+ *
169
+ * Pack k's table caps every tier at what the vault can pay after packs 1..k-1 paid out, counting
170
+ * the batch's own tokens as they arrive: pack 1 sees `freeSnapshot + packTokens`, and every later
171
+ * pack sees the remainder plus one more pack. So no pack can lose its own base to an earlier pack,
172
+ * and the total never exceeds `reserveFor(...)`.
173
+ *
174
+ * With `timedOut` every pack pays its smallest tier, and `tickets` is ignored.
175
+ */
176
+ export declare function settleWith(tiers: readonly Readonly<Tier>[], packTokens: bigint, freeSnapshot: bigint, count: number, tickets: readonly number[], timedOut?: boolean): Settlement;
177
+ /**
178
+ * The top prize each pack of a purchase can still win if every pack before it won its own top
179
+ * prize: the worst case for the later packs, which is what a buyer should see next to the first
180
+ * pack's table. `caps[0]` is the first pack's capped maximum; on a deep vault every entry is the
181
+ * uncapped jackpot, on a thin one the later entries fall towards one pack.
182
+ */
183
+ export declare function perPackCaps(tiers: readonly Readonly<Tier>[], packTokens: bigint, freeSnapshot: bigint, count: number): bigint[];
129
184
  /** `math::resolve_reservation`. Release the unwon part of a maximum, keep the award reserved. */
130
185
  export declare function resolveReservation(reserved: bigint, maximum: bigint, award: bigint): bigint;
131
186
  /** The largest `multiplierBps` on any ticketed row. `0` for a table with no rows. */
@@ -141,6 +196,12 @@ export declare function averageMultiplierBps(tiers: readonly Readonly<Tier>[]):
141
196
  //#region src/accounts.d.ts
142
197
  export declare const DRAW_POOL_OFFSET = 8;
143
198
  export declare const DRAW_PURCHASER_OFFSET: number;
199
+ /**
200
+ * The `settled` byte: after pool, purchaser, nonce, bump, seq_start, count, two slots, attempts,
201
+ * eight tiers, pack_tokens, free_snapshot and reserved. `test/surface.test.ts` pins it against the
202
+ * generated encoder.
203
+ */
204
+ export declare const DRAW_SETTLED_OFFSET: number;
144
205
  export declare const POOL_CREATOR_OFFSET = 8;
145
206
  export declare const POOL_MINT_OFFSET: number;
146
207
  export declare function fetchPoolByMint(client: GaboxClient, mint: Address): Promise<Pool | null>;
@@ -148,7 +209,7 @@ export declare function fetchPoolAt(client: GaboxClient, address: Address): Prom
148
209
  export declare function fetchDraw(client: GaboxClient, address: Address): Promise<Draw | null>;
149
210
  /**
150
211
  * A wallet's lifetime pack-buying activity, or `null` before it has bought its first pack.
151
- * `buy_pack` creates this account `init_if_needed`, so a fresh wallet has none yet.
212
+ * `buy_packs` creates this account `init_if_needed`, so a fresh wallet has none yet.
152
213
  */
153
214
  export declare function fetchWalletActivity(client: GaboxClient, wallet: Address): Promise<WalletActivity | null>;
154
215
  export type PoolRecord = {
@@ -167,6 +228,12 @@ export type DrawQuery = {
167
228
  export declare function listDraws(client: GaboxClient, query?: DrawQuery): Promise<DrawRecord[]>;
168
229
  export declare const listDrawsByPool: (client: GaboxClient, pool: Address) => Promise<DrawRecord[]>;
169
230
  export declare const listDrawsByPurchaser: (client: GaboxClient, purchaser: Address) => Promise<DrawRecord[]>;
231
+ /**
232
+ * A purchaser's draws that settled without paying: the callback could not use the purchaser's coin
233
+ * account, so the tokens wait in the vault as `owed` until `claimPrize` or `claimPrizeTo` pays
234
+ * them. A pending draw is not in this list, and a paid one no longer exists.
235
+ */
236
+ export declare function fetchOwedDraws(client: GaboxClient, purchaser: Address): Promise<DrawRecord[]>;
170
237
  export declare function fetchVaultBalance(client: GaboxClient, mint: Address): Promise<bigint>;
171
238
  export type PoolInventory = {
172
239
  poolAddress: Address;
@@ -196,8 +263,17 @@ export declare const CREATE_MACHINE_COMPUTE_UNITS = 350000;
196
263
  * Measured at `178,690`, `163,686` and `157,692` on the curve, and `113,891`, `110,922` and
197
264
  * `106,387` on CPMM. The curve buy is dearer because a coin's first trade also creates the platform
198
265
  * and creator fee vaults.
266
+ *
267
+ * One figure for every `count` from 1 to `MAX_BATCH_SIZE`: a purchase of five packs is still one
268
+ * trade, one draw and one request. The per-pack work runs in the oracle's callback, on the oracle's
269
+ * own budget. The devnet end-to-end test re-measures count 1 and 5.
199
270
  */
200
271
  export declare const BUY_PACK_COMPUTE_UNITS = 235000;
272
+ /**
273
+ * `claim_prize`: create the purchaser's ATA when it is missing, one transfer, close the draw. An
274
+ * estimate until the devnet run measures it; a caller may override it.
275
+ */
276
+ export declare const CLAIM_PRIZE_COMPUTE_UNITS = 80000;
201
277
  /**
202
278
  * A WSOL wrap, a venue sale, and the WSOL close. Measured at `94,246`, `86,745` and `88,246` on the
203
279
  * curve, and `61,545`, `55,576` and `57,046` on CPMM.
@@ -209,6 +285,15 @@ export declare const REDEEM_COMPUTE_UNITS = 125000;
209
285
  * on a pool quoted in another token is cheaper, `17,635`, because nothing has to be unwrapped.
210
286
  */
211
287
  export declare const CLAIM_COMPUTE_UNITS = 55000;
288
+ /**
289
+ * A harvest of one locked CPMM position: `collect_cp_fees` on the lock program, which withdraws
290
+ * LP through CPMM and pays both sides out.
291
+ *
292
+ * Measured at `102,221` on devnet on 2026-09-19 (tx `5s7xvy23…`), with both token accounts
293
+ * created in the same transaction and the WSOL one closed again. `82,697` of that is the lock
294
+ * program itself.
295
+ */
296
+ export declare const HARVEST_COMPUTE_UNITS = 150000;
212
297
  /** An instruction for the compute budget program: no accounts, all of it in the data. */
213
298
  export type ComputeBudgetInstruction = Instruction<string, readonly []> & InstructionWithData<ReadonlyUint8Array>;
214
299
  export declare function getSetComputeUnitLimitInstruction(units: number): ComputeBudgetInstruction;
@@ -232,14 +317,17 @@ export type GaboxEvent = {
232
317
  name: 'PrizesFunded';
233
318
  data: PrizesFundedEvent;
234
319
  } | {
235
- name: 'PackBought';
236
- data: PackBoughtEvent;
320
+ name: 'PacksBought';
321
+ data: PacksBoughtEvent;
237
322
  } | {
238
323
  name: 'RandomnessRetried';
239
324
  data: RandomnessRetriedEvent;
240
325
  } | {
241
326
  name: 'DrawResolved';
242
327
  data: DrawResolvedEvent;
328
+ } | {
329
+ name: 'PrizeClaimed';
330
+ data: PrizeClaimedEvent;
243
331
  } | {
244
332
  name: 'TokensSold';
245
333
  data: TokensSoldEvent;
@@ -255,7 +343,10 @@ export declare function fetchEvents(client: GaboxClient, signature: string): Pro
255
343
  export type ResolvedDraw = DrawResolvedEvent & {
256
344
  address: Address;
257
345
  };
258
- /** Poll final resolution events for one closed draw address. There is no separate Ready/claim state to poll instead. */
346
+ /**
347
+ * The `DrawResolved` event of one draw, found through the draw address's own signature history.
348
+ * `paid` says whether the tokens reached the purchaser in the callback or wait for a claim.
349
+ */
259
350
  export declare function findResolvedDraw(client: GaboxClient, address: Address): Promise<ResolvedDraw | null>;
260
351
  //#endregion
261
352
  //#region src/ids.d.ts
@@ -276,7 +367,7 @@ export declare const INSTRUCTIONS_SYSVAR: Address;
276
367
  export declare const RETRY_SLOTS = 300n;
277
368
  /** `constants.rs`. After this many slots from the purchase, anyone may expire the draw. */
278
369
  export declare const TIMEOUT_SLOTS = 216000n;
279
- /** `constants.rs`. Three requests in total, counting the one `buy_pack` makes. */
370
+ /** `constants.rs`. Three requests in total, counting the one `buy_packs` makes. */
280
371
  export declare const MAX_ATTEMPTS = 3;
281
372
  /**
282
373
  * `constants.rs`. Tokens in one pack, in base units: 1,000,000 tokens at the fixed 6 decimals, or
@@ -315,7 +406,12 @@ export type PackOffer = {
315
406
  pool: Address;
316
407
  /** The fixed token count of one pack. Every prize is a multiple of this. */
317
408
  packTokens: bigint;
318
- /** What the venue charges for `packTokens` right now, its own fees included. The pack price. */
409
+ /** How many packs this offer prices, 1 to `MAX_BATCH_SIZE`. */
410
+ count: number;
411
+ /**
412
+ * What the venue charges for `count` packs right now, its own fees included. The whole purchase
413
+ * price, in the quote token.
414
+ */
319
415
  quoteAmount: bigint;
320
416
  /** The pool's quote asset. Both venues settle in it; there is no native-SOL path. */
321
417
  quoteMint: Address;
@@ -324,8 +420,8 @@ export type PackOffer = {
324
420
  /** The quote mint's symbol, from Metaplex or Token-2022 metadata. `null` when it has none. */
325
421
  quoteSymbol: string | null;
326
422
  /**
327
- * The same pack price in lamports, through the client's route provider. Equal to `quoteAmount` on
328
- * a WSOL pool, and `null` when no route can price it.
423
+ * The same purchase price in lamports, through the client's route provider. Equal to
424
+ * `quoteAmount` on a WSOL pool, and `null` when no route can price it.
329
425
  */
330
426
  solAmount: bigint | null;
331
427
  /** What the seed cost the creator at creation, in the quote token. Display only. */
@@ -334,21 +430,33 @@ export type PackOffer = {
334
430
  seedTokens: bigint;
335
431
  /** Which venue the buy would route to right now. */
336
432
  venue: VenueKind;
337
- /** The frozen prize table this pack would get: real amounts, already capped by inventory. */
433
+ /** The first pack's prize table: real amounts, already capped by inventory. */
338
434
  prizes: Prize[];
339
- /** The top prize, after the cap. Sign `minMaximum` just below this. */
435
+ /** The first pack's top prize, after the cap. Sign `minFirstMaximum` just below this. */
340
436
  maximum: bigint;
341
- /** The smallest prize. Also what a timed-out draw pays. */
437
+ /** The first pack's smallest prize. Also what a timed-out pack pays. */
342
438
  minimum: bigint;
343
439
  /**
344
440
  * The top prize with no inventory cap: the jackpot in tokens. Equal to `maximum` unless the
345
441
  * inventory cap bites.
346
442
  */
347
443
  uncapped: bigint;
444
+ /**
445
+ * The top prize each pack can still win if every pack before it won its own top prize. One
446
+ * entry per pack; `perPackCaps[0]` equals `maximum`.
447
+ */
448
+ perPackCaps: bigint[];
449
+ /**
450
+ * What this purchase would add to `pool.reserved`:
451
+ * `min(count * uncapped, free + count * packTokens)`.
452
+ */
453
+ batchReserved: bigint;
348
454
  /** Vault balance, `pool.reserved`, and the difference. */
349
455
  inventory: bigint;
350
456
  reserved: bigint;
351
457
  free: bigint;
458
+ /** The same as `free`: the `Draw.freeSnapshot` this purchase would record. */
459
+ freeSnapshot: bigint;
352
460
  /** `pool.nextSeq === 0`. No pack has been sold yet. */
353
461
  isFirstPack: boolean;
354
462
  /**
@@ -364,6 +472,8 @@ export type PackOffer = {
364
472
  averageMultiplierBps: number;
365
473
  };
366
474
  export type GetOfferOptions = {
475
+ /** How many packs to price. Defaults to one. */
476
+ count?: number;
367
477
  /** Force a venue instead of reading the LaunchLab pool's `status`. */
368
478
  venue?: VenueKind;
369
479
  /** The buyer, when you already know it. Only changes the account list, never the numbers. */
@@ -374,7 +484,7 @@ export type GetOfferOptions = {
374
484
  * quote mint and its metadata. A non-SOL pool adds one HTTP call to the route provider for
375
485
  * `solAmount`.
376
486
  *
377
- * Throws when the coin has no pool.
487
+ * Throws when the coin has no pool, or when the curve has fewer whole packs left than `count`.
378
488
  */
379
489
  export declare function getOffer(client: GaboxClient, mint: Address, options?: GetOfferOptions): Promise<PackOffer>;
380
490
  /** The three display fields `getOffer` reads separately from the price. */
@@ -386,12 +496,12 @@ export type QuoteDisplayFields = {
386
496
  /**
387
497
  * The same computation with the reads already done. Useful when a caller holds a `ResolvedVenue`
388
498
  * and wants to re-price without touching the network. `quoteAmount` is
389
- * `venue.quoteBuy(pool.packTokens)`.
499
+ * `venue.quoteBuy(pool.packTokens * count)`.
390
500
  *
391
501
  * `display` is optional: a caller that only wants the prize numbers can leave it out, and the three
392
502
  * display fields then report the quote's own base units with no symbol and no SOL price.
393
503
  */
394
- export declare function offerFromState(inventory: PoolInventory, venue: VenueKind, quoteAmount: bigint, display?: QuoteDisplayFields): PackOffer;
504
+ export declare function offerFromState(inventory: PoolInventory, venue: VenueKind, quoteAmount: bigint, display?: QuoteDisplayFields, count?: number): PackOffer;
395
505
  /**
396
506
  * How short of the top prize a pool is, in tokens. `0` when it pays the whole table.
397
507
  *
@@ -404,9 +514,20 @@ export declare function seedShortfall(offer: PackOffer): bigint;
404
514
  //#region src/pdas.d.ts
405
515
  /** `["pool", mint]`. One pool per coin. */
406
516
  export declare const poolAddress: (mint: Address) => Promise<Address>;
407
- /** `["draw", pool, seq]`, with the sequence as eight little-endian bytes. */
408
- export declare const drawAddress: (pool: Address, seq: bigint) => Promise<Address>;
409
- /** The per-wallet `WalletActivity` PDA. `buy_pack` derives it from the purchaser automatically. */
517
+ /**
518
+ * `["draw", pool, purchaser, nonce]`, with the nonce as eight little-endian bytes. The buyer's
519
+ * client picks the nonce, so two buyers, or two purchases of one buyer, never name the same draw.
520
+ * The pool's sequence counter is not in the address any more; the program assigns `seqStart`
521
+ * when the purchase executes.
522
+ */
523
+ export declare const drawAddress: (pool: Address, purchaser: Address, nonce: bigint) => Promise<Address>;
524
+ /**
525
+ * A random `u64` nonce for one purchase. `buyPacks` draws one per build. A nonce that is still in
526
+ * use fails the purchase at the program; one whose draw already closed names a new draw, so a
527
+ * rebuilt transaction must never reuse the nonce of a purchase that may have landed.
528
+ */
529
+ export declare function randomNonce(): bigint;
530
+ /** The per-wallet `WalletActivity` PDA. `buy_packs` derives it from the purchaser automatically. */
410
531
  export declare const activityAddress: (wallet: Address) => Promise<Address>;
411
532
  /** `["identity"]` under Gabox. The PDA the program signs its randomness request with. */
412
533
  export declare const vrfIdentityAddress: () => Promise<Address>;
@@ -565,6 +686,32 @@ export declare function assertRouteIsSafe(route: Route, expect: {
565
686
  */
566
687
  export declare function solPriceOf(client: GaboxClient, quoteMint: Address, amount: bigint): Promise<bigint | null>;
567
688
  //#endregion
689
+ //#region src/settle.d.ts
690
+ /** `math::ticket`. Pack `k`'s 16-bit ticket for this pool and purchase. */
691
+ export declare function ticketFor(randomness: Uint8Array | ReadonlyUint8Array, pool: Address, seqStart: bigint, k: number): Promise<number>;
692
+ export type SettleInput = {
693
+ /** The pool's tier table, as the draw snapshotted it. */
694
+ tiers: readonly Readonly<Tier>[];
695
+ packTokens: bigint;
696
+ /** `vault - reserved` at purchase, before the batch's own tokens. */
697
+ freeSnapshot: bigint;
698
+ count: number;
699
+ pool: Address;
700
+ seqStart: bigint;
701
+ randomness: Uint8Array | ReadonlyUint8Array;
702
+ /** An expired draw pays every pack its smallest tier; the randomness is then all zero. */
703
+ timedOut?: boolean;
704
+ };
705
+ /** `math::settle`. What the callback paid, or owed, for this purchase. */
706
+ export declare function settle(input: SettleInput): Promise<Settlement>;
707
+ /**
708
+ * The settlement of a draw that is still on chain: settled but not yet claimed. The account alone
709
+ * carries everything, so this needs no event and no indexer. `total` equals `draw.owed`.
710
+ *
711
+ * A pending draw (`settled === false`) has no randomness yet; this throws for it.
712
+ */
713
+ export declare function settleDraw(draw: Draw): Promise<Settlement>;
714
+ //#endregion
568
715
  //#region src/tx/quoteLeg.d.ts
569
716
  /** Where the money for a purchase comes from. */
570
717
  export type PayWith = 'sol' | 'quote';
@@ -653,18 +800,22 @@ export declare function computeUnitsWithRoute(own: number, leg: QuoteLeg): numbe
653
800
  */
654
801
  export declare function routeSizeHint(cause: unknown, leg: QuoteLeg): unknown;
655
802
  //#endregion
656
- //#region src/tx/buyPack.d.ts
657
- export type BuyPackInput = {
803
+ //#region src/tx/buyPacks.d.ts
804
+ export type BuyPacksInput = {
658
805
  mint: Address;
659
806
  purchaser: TransactionSigner;
807
+ /** How many packs, 1 to `MAX_BATCH_SIZE`. */
808
+ count: number;
809
+ /** The draw's nonce. Left out, a random one is drawn. */
810
+ nonce?: bigint;
660
811
  /**
661
- * The venue slippage cap, in the pool's quote token. The transaction puts this much of the quote
662
- * token in the buyer's quote account before the buy, so it must cover the real price. Anything
663
- * left over stays there, or comes back as SOL on a WSOL pool.
812
+ * The venue slippage cap for the whole batch, in the pool's quote token. The transaction puts
813
+ * this much of the quote token in the buyer's quote account before the buy, so it must cover the
814
+ * real price. Anything left over stays there, or comes back as SOL on a WSOL pool.
664
815
  */
665
816
  maxQuoteIn: bigint;
666
- /** The floor on the top prize this pack may win. Refresh the offer if it fails. */
667
- minMaximum: bigint;
817
+ /** The floor on the first pack's top prize. Refresh the offer if it fails. */
818
+ minFirstMaximum: bigint;
668
819
  /** Caps every lamport the handler sees: venue account rent and the VRF request. */
669
820
  maxNativeDebit: bigint;
670
821
  /**
@@ -674,10 +825,26 @@ export type BuyPackInput = {
674
825
  payWith?: PayWith;
675
826
  /** Force a venue instead of reading the LaunchLab pool's `status`. */
676
827
  venue?: VenueKind;
677
- /** Pin `pool.nextSeq` to make a rebuild fail rather than buy a second pack. */
678
- seq?: bigint;
679
828
  } & Partial<BuildOptions>;
680
- export declare function buyPack(client: GaboxClient, input: BuyPackInput): Promise<GaboxTransactionMessage>;
829
+ export type BuyPacksResult = {
830
+ message: GaboxTransactionMessage;
831
+ /** The draw this purchase opens. Watch it with `fetchDraw` and `findResolvedDraw`. */
832
+ draw: Address;
833
+ nonce: bigint;
834
+ /**
835
+ * `pool.nextSeq` when the message was built. The program assigns the real `seqStart` when the
836
+ * purchase executes, so another buyer landing first moves it; read it from `PacksBought`.
837
+ */
838
+ seqStart: bigint;
839
+ count: number;
840
+ };
841
+ export declare function buyPacks(client: GaboxClient, input: BuyPacksInput): Promise<BuyPacksResult>;
842
+ export type BuyPackInput = Omit<BuyPacksInput, 'count' | 'minFirstMaximum'> & {
843
+ /** The floor on the top prize this pack may win. Refresh the offer if it fails. */
844
+ minMaximum: bigint;
845
+ };
846
+ /** One pack: `buyPacks` with `count: 1`. Same result shape, so the draw address is known. */
847
+ export declare function buyPack(client: GaboxClient, input: BuyPackInput): Promise<BuyPacksResult>;
681
848
  //#endregion
682
849
  //#region src/tx/createMachine.d.ts
683
850
  /** Which quote asset a new machine is priced in. Defaults to wrapped SOL. */
@@ -789,20 +956,49 @@ export type RetryDrawInput = {
789
956
  draw: Address;
790
957
  maxVrfDebit: bigint;
791
958
  } & Partial<BuildOptions>;
959
+ /** Another randomness request for a draw whose earlier attempts have not landed. Any signer. */
792
960
  export declare function retryDraw(client: GaboxClient, input: RetryDrawInput): Promise<GaboxTransactionMessage>;
793
961
  export type ExpireDrawInput = {
794
962
  payer: TransactionSigner;
795
963
  pool: Address;
796
964
  draw: Address;
797
965
  } & Partial<BuildOptions>;
966
+ /**
967
+ * Fix a timed-out purchase at every pack's smallest tier, from `TIMEOUT_SLOTS` after the purchase.
968
+ * Any signer. The purchaser's ATA address is passed whether or not the account exists: the program
969
+ * pays it if it can and owes the total otherwise.
970
+ */
798
971
  export declare function expireDraw(client: GaboxClient, input: ExpireDrawInput): Promise<GaboxTransactionMessage>;
972
+ export type ClaimPrizeInput = {
973
+ /** Any signer. Pays the transaction and, when the purchaser's ATA is missing, its rent. */
974
+ payer: TransactionSigner;
975
+ draw: Address;
976
+ } & Partial<BuildOptions>;
977
+ /** Pay an owed prize to the purchaser's coin ATA, creating it if needed. Permissionless. */
978
+ export declare function claimPrize(client: GaboxClient, input: ClaimPrizeInput): Promise<GaboxTransactionMessage>;
979
+ export type ClaimPrizeToInput = {
980
+ /** The draw's purchaser. Nobody else can redirect a prize. */
981
+ purchaser: TransactionSigner;
982
+ draw: Address;
983
+ /** Any existing classic token account for the coin that the purchaser owns. Nothing is created. */
984
+ destination: Address;
985
+ } & Partial<BuildOptions>;
986
+ /** The purchaser pays their own owed prize to a coin account they name. */
987
+ export declare function claimPrizeTo(client: GaboxClient, input: ClaimPrizeToInput): Promise<GaboxTransactionMessage>;
799
988
  export type DrawAvailability = {
800
989
  attempts: number;
990
+ /** True once the callback or an expiry fixed the outcome. `owed` is then what a claim pays. */
991
+ settled: boolean;
992
+ owed: bigint;
801
993
  slotsUntilRetry: bigint;
802
994
  slotsUntilExpiry: bigint;
995
+ /** The oracle's callback is still accepted: pending, and before the deadline. */
996
+ canDeliver: boolean;
803
997
  canRetry: boolean;
804
998
  canExpire: boolean;
999
+ canClaim: boolean;
805
1000
  };
1001
+ /** What can still happen to a draw, or `null` when it is closed. */
806
1002
  export declare function drawAvailability(client: GaboxClient, address: Address): Promise<DrawAvailability | null>;
807
1003
  //#endregion
808
1004
  //#region src/tx/fundPrizes.d.ts
@@ -865,5 +1061,5 @@ export type OracleAccounts = {
865
1061
  */
866
1062
  export declare function oracleAccounts(): Promise<OracleAccounts>;
867
1063
  //#endregion
868
- export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, BuildOptions, CLUSTER_ENDPOINTS, ClientConfig, Cluster, DEVNET_HTTP, DEVNET_WS, DRAW_DISCRIMINATOR, type Draw, GaboxClient, GaboxRpc, GaboxRpcSubscriptions, GaboxTransactionMessage, LAUNCH_DECIMALS, METAPLEX_PROGRAM_ADDRESS, PLATFORM_ADMIN, POOL_DISCRIMINATOR, type Pool, Route, RouteMode, RouteProvider, SYSTEM_PROGRAM_ADDRESS, TOKEN_PROGRAM_ADDRESS, WALLET_ACTIVITY_DISCRIMINATOR, WSOL_MINT, type WalletActivity, assertClusterUrl, buildMessage, clusterNamedBy, createClient, decodeDraw, decodePool, decodeWalletActivity, defaultRoute, findActivityPda, findDrawPda, findIdentityPda, findPoolPda, index_d_exports as generated, index_d_exports$1 as raydium, websocketUrlFor, withRemainingAccounts };
1064
+ export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, BuildOptions, CLUSTER_ENDPOINTS, ClientConfig, Cluster, DEVNET_HTTP, DEVNET_WS, DRAW_DISCRIMINATOR, type Draw, type DrawResolvedEvent, GaboxClient, GaboxRpc, GaboxRpcSubscriptions, GaboxTransactionMessage, LAUNCH_DECIMALS, METAPLEX_PROGRAM_ADDRESS, PLATFORM_ADMIN, POOL_DISCRIMINATOR, type PacksBoughtEvent, type Pool, type PoolCreatedEvent, type PrizeClaimedEvent, type PrizesFundedEvent, type RandomnessRetriedEvent, Route, RouteMode, RouteProvider, SYSTEM_PROGRAM_ADDRESS, TOKEN_PROGRAM_ADDRESS, type TokensSoldEvent, WALLET_ACTIVITY_DISCRIMINATOR, WSOL_MINT, type WalletActivity, assertClusterUrl, buildMessage, clusterNamedBy, createClient, decodeDraw, decodePool, decodeWalletActivity, defaultRoute, findActivityPda, findDrawPda, findIdentityPda, findPoolPda, index_d_exports as generated, index_d_exports$1 as raydium, websocketUrlFor, withRemainingAccounts };
869
1065
  //# sourceMappingURL=index.d.ts.map