@gabox-labs/sdk 0.1.1

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.
@@ -0,0 +1,823 @@
1
+ import { DRAW_DISCRIMINATOR, Draw, DrawResolvedEvent, DrawStatus, POOL_DISCRIMINATOR, PackBoughtEvent, Pool, PoolCreatedEvent, PrizeRedeemedEvent, PrizesFundedEvent, RandomnessRetriedEvent, Referral, ReferralLink, TokensSoldEvent, decodeDraw, decodePool, findDrawPda, findIdentityPda, findPoolPda, findReferralLinkPda, t as index_d_exports } from "./generated/index.js";
2
+ import { At as ClientConfig, Bt as websocketUrlFor, Ct as PUMP_SWAP_PROGRAM_ADDRESS, Et as SYSTEM_PROGRAM_ADDRESS, Ft as GaboxRpc, It as GaboxRpcSubscriptions, Lt as assertClusterUrl, Mt as DEVNET_HTTP, Nt as DEVNET_WS, Pt as GaboxClient, Rt as clusterNamedBy, bt as PUMP_FEE_PROGRAM_ADDRESS, ct as VenueKind, gt as MAYHEM_PROGRAM_ADDRESS, ht as ASSOCIATED_TOKEN_PROGRAM_ADDRESS, jt as Cluster, kt as CLUSTER_ENDPOINTS, t as index_d_exports$1, xt as PUMP_PROGRAM_ADDRESS, zt as createClient } from "./index-BxvSkzCO.js";
3
+ import { AccountMeta, Address, AddressesByLookupTableAddress, Instruction, InstructionWithData, ProgramDerivedAddress, ReadonlyUint8Array, TransactionMessage, TransactionMessageWithBlockhashLifetime, TransactionMessageWithFeePayerSigner, TransactionSigner } from "@solana/kit";
4
+ //#region src/math.d.ts
5
+ /**
6
+ * A bigint port of `programs/gabox-v2/src/math.rs`.
7
+ *
8
+ * The point is that a client can show a buyer the exact prize table the program will freeze into
9
+ * their `Draw`, before they pay. Every rounding step here matches the Rust, including the direction
10
+ * of each division. `test/math.test.ts` runs the same vectors as `programs/gabox-v2/tests/
11
+ * economics.rs`.
12
+ *
13
+ * All amounts are `bigint`, in the mint's smallest unit. `multiplierBps` and `tickets` are numbers
14
+ * because both are `u32` in the program and both stay small.
15
+ */
16
+ /** Basis points. A multiplier of 10_000 pays back exactly one pack. */
17
+ export declare const BPS = 10000n;
18
+ /** `math::share`. `bps` basis points of `amount`, rounded down. */
19
+ export declare function share(amount: bigint, bps: bigint): bigint;
20
+ /** Ticket counts must sum to this. A uniform 16-bit word then maps with no modulo bias. */
21
+ export declare const TICKETS = 65536;
22
+ /** The prize table has exactly this many slots. Unused slots are all-zero. */
23
+ export declare const TIERS = 8;
24
+ /** One row of the immutable prize table. Counts, not cumulative thresholds. */
25
+ export type Tier = {
26
+ /** `floor(base * multiplierBps / 10_000)` tokens. `0` only on an unused row. */
27
+ multiplierBps: number;
28
+ /** Out of 65,536. `0` marks the row unused, and then `multiplierBps` must be `0` too. */
29
+ tickets: number;
30
+ };
31
+ /** One row of a frozen offer: a real token amount, already capped by inventory. */
32
+ export type Prize = {
33
+ amount: bigint;
34
+ tickets: number;
35
+ };
36
+ /** What `buy_pack` writes into the `Draw`. `minimum` is also the timeout payout. */
37
+ export type Offer = {
38
+ prizes: Prize[];
39
+ maximum: bigint;
40
+ minimum: bigint;
41
+ };
42
+ /** Thrown by every function here. `code` matches a `GaboxError` variant name. */
43
+ export declare class GaboxMathError extends Error {
44
+ readonly code: string;
45
+ constructor(code: string, message: string);
46
+ }
47
+ /** Creator-facing presets. The creator picks the jackpot size; the profile chooses its odds. */
48
+ export type RiskProfile = "conservative" | "balanced" | "jackpot";
49
+ /** `math::tokens`. Floor division, and an overflow past u64 is an error, not a wrap. */
50
+ export declare function tierAmount(base: bigint, multiplierBps: number): bigint;
51
+ /**
52
+ * `math::validate`. Checks the table alone, with no base.
53
+ *
54
+ * Three rules, and each one closes a way to sell a bad ticket:
55
+ * - ticket counts sum to exactly 65,536, so the 16-bit draw is uniform;
56
+ * - an unused row is all-zero, so a hidden multiplier cannot ride along;
57
+ * - the expected multiplier over all tickets is at most 1x, so the table cannot promise more
58
+ * tokens than a pack buys. This bounds tokens, not cash value.
59
+ */
60
+ export declare function validateTiers(tiers: readonly Tier[]): void;
61
+ /**
62
+ * `math::validate_pack`. Every ticketed tier must pay at least one token for a pack of this size.
63
+ *
64
+ * The program checks this once at creation. At `PACK_TOKENS` no sane table fails it; it exists so
65
+ * a table cannot sell a ticket that can only win zero.
66
+ */
67
+ export declare function validatePack(packTokens: bigint, tiers: readonly Tier[]): void;
68
+ /**
69
+ * `math::seed_tokens`. The seed a table needs, in tokens.
70
+ *
71
+ * The first pack must be able to pay the largest tier in full. The pack itself brings `packTokens`
72
+ * into the vault, so the vault has to hold the rest beforehand:
73
+ *
74
+ * seedTokens = uncappedMaximum(packTokens, tiers) - packTokens
75
+ *
76
+ * A 5x jackpot on a 1M-token pack needs a 4M-token seed. A table whose top tier pays exactly one
77
+ * pack needs no seed. A top tier below one pack is refused: every ticket would lose.
78
+ *
79
+ * `initialize_pool` computes this number itself and buys exactly that many tokens on the curve.
80
+ * The creator only signs a maximum SOL cost.
81
+ */
82
+ export declare function seedTokens(packTokens: bigint, tiers: readonly Tier[]): bigint;
83
+ /**
84
+ * Derive a fully valid four-outcome rarity ladder from a jackpot multiplier and a risk preset.
85
+ *
86
+ * Mythic is exactly `jackpotBps`. Rare and Epic interpolate between sub-1x launch values
87
+ * and Mythic as the jackpot grows, so the four payouts remain strictly ordered even at 1x.
88
+ * The profile assigns fixed slices of one pack's EV budget to the three higher rarities. Whatever
89
+ * remains of the 95% target becomes Common. Integer rounding is always downward, so the result
90
+ * cannot cross the program's 100% expected-value ceiling.
91
+ *
92
+ * The seed this table needs is `seedTokens(packTokens, tiers)`: `(jackpotBps - 10_000)` bps of
93
+ * one pack.
94
+ */
95
+ export declare function jackpotTiers(jackpotBps: number, profile: RiskProfile): Tier[];
96
+ /**
97
+ * `math::uncapped_maximum`. The largest tier's award for this base, before any inventory cap.
98
+ *
99
+ * At `packTokens` this is the jackpot in tokens. `seedTokens` is this minus one pack.
100
+ */
101
+ export declare function uncappedMaximum(base: bigint, tiers: readonly Tier[]): bigint;
102
+ /**
103
+ * `math::quote`. The offer a pack of `base` tokens would freeze right now. `base` is always
104
+ * `pool.packTokens`; the parameter stays general so the vectors can use small numbers.
105
+ *
106
+ * `inventory` is the vault's token balance and `reserved` is `pool.reserved`. The difference is
107
+ * free inventory. This pack's own `base` is added to it, because the purchase and the offer are
108
+ * one transaction — the tokens are in the vault before the draw is written.
109
+ *
110
+ * Every amount is capped at what is actually available. A tier that rounds to zero tokens is an
111
+ * error: the pool must not sell a ticket that can only win nothing.
112
+ */
113
+ export declare function quote(base: bigint, tiers: readonly Tier[], inventory: bigint, reserved: bigint): Offer;
114
+ /**
115
+ * `math::choose`. Which prize a 16-bit ticket wins.
116
+ *
117
+ * The rows are consecutive ranges in table order, so this is a running total and a comparison.
118
+ * A ticket past the last row returns `0`, which cannot happen for a validated table.
119
+ */
120
+ export declare function choose(prizes: readonly Prize[], ticket: number): bigint;
121
+ /** `math::resolve_reservation`. Release the unwon part of a maximum, keep the award reserved. */
122
+ export declare function resolveReservation(reserved: bigint, maximum: bigint, award: bigint): bigint;
123
+ /** The largest `multiplierBps` on any ticketed row. `0` for a table with no rows. */
124
+ export declare function maxMultiplierBps(tiers: readonly Tier[]): number;
125
+ /**
126
+ * The expected multiplier over all 65,536 tickets, in basis points. Rounded down.
127
+ *
128
+ * `validateTiers` caps this at 10,000. A table at 9,800 keeps 2% of every pack's tokens in the
129
+ * vault on average, which is what lets a pool survive a run of top-tier wins.
130
+ */
131
+ export declare function averageMultiplierBps(tiers: readonly Tier[]): number;
132
+ //#endregion
133
+ //#region src/accounts.d.ts
134
+ /** `Draw.pool` sits straight after the discriminator. */
135
+ export declare const DRAW_POOL_OFFSET = 8;
136
+ /** `Draw.purchaser` sits after the discriminator and `pool`. */
137
+ export declare const DRAW_PURCHASER_OFFSET: number;
138
+ /** `Pool.creator` sits straight after the discriminator. */
139
+ export declare const POOL_CREATOR_OFFSET = 8;
140
+ /** `Pool.mint` sits after the discriminator and `creator`. */
141
+ export declare const POOL_MINT_OFFSET: number;
142
+ /** `ReferralLink.referrer` sits after the discriminator and `referee`. */
143
+ export declare const REFERRAL_LINK_REFERRER_OFFSET: number;
144
+ /** The pool for a coin, or `null` when the coin has no machine. */
145
+ export declare function fetchPoolByMint(client: GaboxClient, mint: Address): Promise<Pool | null>;
146
+ /**
147
+ * A pool by its own address, or `null`.
148
+ *
149
+ * `fetchPoolByMint` is the usual way in, because a coin's mint is the natural key. This one is for
150
+ * the other direction: a `Draw` names its pool and not its mint, so a client holding a draw reads
151
+ * the pool to learn which coin it belongs to.
152
+ */
153
+ export declare function fetchPoolAt(client: GaboxClient, address: Address): Promise<Pool | null>;
154
+ /** A draw by address, or `null`. Delivered and legacy-claimed draws are closed. */
155
+ export declare function fetchDraw(client: GaboxClient, address: Address): Promise<Draw | null>;
156
+ /** Accrued referral reward for one referrer and pool, or zero when no referred pack has settled. */
157
+ export declare function fetchReferralReward(client: GaboxClient, pool: Address, referrer: Address): Promise<Referral | null>;
158
+ export type PoolRecord = {
159
+ address: Address;
160
+ data: Pool;
161
+ };
162
+ export type DrawRecord = {
163
+ address: Address;
164
+ data: Draw;
165
+ };
166
+ /**
167
+ * Every current-layout machine, by discriminator and account size. Older devnet
168
+ * pools predate seed fields and must not be decoded with the current schema.
169
+ *
170
+ * There is no on-chain registry — the design says so on purpose — so discovery is this scan plus
171
+ * the `PoolCreated` event. Public RPCs limit `getProgramAccounts`, so an app that lists machines
172
+ * for users should cache the result rather than call this per page view.
173
+ */
174
+ export declare function listPools(client: GaboxClient): Promise<PoolRecord[]>;
175
+ /** Every draw of one pool, pending or ready. Closed draws are gone and never appear. */
176
+ export declare function listDrawsByPool(client: GaboxClient, pool: Address): Promise<DrawRecord[]>;
177
+ /**
178
+ * Every open draw of one wallet, across all pools. This is the "what am I owed" query.
179
+ *
180
+ * An address is already base58, so it goes into the filter unchanged.
181
+ */
182
+ export declare function listDrawsByPurchaser(client: GaboxClient, purchaser: Address): Promise<DrawRecord[]>;
183
+ export type DrawQuery = {
184
+ /** A pool PDA. */
185
+ pool?: Address;
186
+ /** A buyer's wallet. */
187
+ purchaser?: Address;
188
+ };
189
+ /**
190
+ * Open draws, narrowed by pool, by purchaser, or by both.
191
+ *
192
+ * Both filters in one scan, because a UI asks for exactly that: "my pulls on this machine". Two
193
+ * separate scans and an intersection in the client would move twice the bytes and could disagree
194
+ * with itself, since the two reads happen at different slots. With neither filter this lists every
195
+ * open draw of every machine.
196
+ */
197
+ export declare function listDraws(client: GaboxClient, query?: DrawQuery): Promise<DrawRecord[]>;
198
+ export type ReferralLinkRecord = {
199
+ address: Address;
200
+ data: ReferralLink;
201
+ };
202
+ /**
203
+ * Every wallet bound to one referrer. This is the "who did I refer" query.
204
+ *
205
+ * A scan, because a link is seeded on the referee and nothing on chain indexes it by referrer.
206
+ * The list is small in practice, and a dashboard reads it once per load, not per poll.
207
+ */
208
+ export declare function listReferralLinksByReferrer(client: GaboxClient, referrer: Address): Promise<ReferralLinkRecord[]>;
209
+ /** The vault's token balance. `0` when the vault does not exist yet. */
210
+ export declare function fetchVaultBalance(client: GaboxClient, mint: Address, tokenProgram?: Address): Promise<bigint>;
211
+ export type PoolInventory = {
212
+ pool: Pool;
213
+ poolAddress: Address;
214
+ vault: Address;
215
+ /** The vault's whole token balance. */
216
+ inventory: bigint;
217
+ /** `pool.reserved`: maximum awards reserved by pending draws. */
218
+ reserved: bigint;
219
+ /** `inventory - reserved`. What a new pack's prizes can be paid from, besides its own tokens. */
220
+ free: bigint;
221
+ };
222
+ /**
223
+ * A pool with its live inventory. This is the pair every price display needs: the tiers are
224
+ * immutable, but what they actually pay depends on what is free in the vault right now.
225
+ *
226
+ * # Why one request reads both accounts
227
+ *
228
+ * The oracle callback lowers the vault and `pool.reserved` in one transaction, a few seconds after
229
+ * a buy. Two separate reads can land on either side of it: the old `reserved` with the new, smaller
230
+ * vault. That pair looks insolvent, and `quote` rightly refuses it. One `getMultipleAccounts` call
231
+ * returns both accounts from the same slot, so the pair is always one the chain actually held.
232
+ */
233
+ export declare function fetchPoolInventory(client: GaboxClient, mint: Address): Promise<PoolInventory | null>;
234
+ /** The generated `Tier` uses the same field names as `math.ts`, so this is only a widening. */
235
+ export declare const tiersOf: (pool: Pool) => Tier[];
236
+ /**
237
+ * The offer a pack of `base` tokens would freeze against this inventory. Pure — the same
238
+ * computation `buy_pack` performs, and the reason a client can show real amounts before paying.
239
+ */
240
+ export declare const offerFor: (inventory: PoolInventory, base: bigint) => Offer;
241
+ //#endregion
242
+ //#region src/compute.d.ts
243
+ export declare const COMPUTE_BUDGET_PROGRAM_ADDRESS: Address;
244
+ /** The runtime's per-transaction ceiling. A larger request is rejected outright. */
245
+ export declare const MAX_COMPUTE_UNIT_LIMIT = 1400000;
246
+ /** What an instruction gets when no `SetComputeUnitLimit` is present. */
247
+ export declare const DEFAULT_COMPUTE_UNIT_LIMIT = 200000;
248
+ /**
249
+ * UNVERIFIED: none of the three figures below has been measured on chain. They are headroom, chosen
250
+ * above what these instruction mixes plausibly cost. Measure them on devnet before they matter: the
251
+ * prioritisation fee is `price x requested limit`, so a request three times too large costs three
252
+ * times too much on every pack.
253
+ */
254
+ /** Pump `create_v2` plus `initialize_pool` plus a seed buy, in one transaction. */
255
+ export declare const CREATE_MACHINE_COMPUTE_UNITS = 600000;
256
+ /** A venue buy, an escrow transfer, a draw init and a VRF request. */
257
+ export declare const BUY_PACK_COMPUTE_UNITS = 500000;
258
+ /** A vault transfer, or a vault transfer plus a venue sale. */
259
+ export declare const REDEEM_COMPUTE_UNITS = 300000;
260
+ /** `bind_referrer` riding ahead of a pack: one small account init. */
261
+ export declare const BIND_REFERRER_COMPUTE_UNITS = 50000;
262
+ /** An instruction for the compute budget program: no accounts, all of it in the data. */
263
+ export type ComputeBudgetInstruction = Instruction<string, readonly []> & InstructionWithData<ReadonlyUint8Array>;
264
+ export declare function getSetComputeUnitLimitInstruction(units: number): ComputeBudgetInstruction;
265
+ /**
266
+ * `SetComputeUnitPrice(microLamports)` — the priority fee, per compute unit.
267
+ *
268
+ * No default, deliberately. The fee that lands a transaction is a property of the network at the
269
+ * moment you send it. A hardcoded price is either money burnt on an idle chain or a transaction
270
+ * that quietly stops landing under load. Sample `getRecentPrioritizationFees`, or take it from
271
+ * config.
272
+ */
273
+ export declare function getSetComputeUnitPriceInstruction(microLamports: number | bigint): ComputeBudgetInstruction;
274
+ /** The compute budget prefix a builder prepends: a limit, and a price only when one is asked for. */
275
+ export declare function computeBudgetInstructions(units: number, microLamports?: number | bigint): ComputeBudgetInstruction[];
276
+ //#endregion
277
+ //#region src/ids.d.ts
278
+ /** `declare_id!` in `programs/gabox-v2/src/lib.rs`. */
279
+ export declare const GABOX_PROGRAM_ID: Address<"GaBoxR9nYcK1zeu8EvSJVHV3SrYpCFmvbh2MLgobMcUA">;
280
+ /** Classic SPL Token. The quote side of every Pump trade uses it, because the quote is WSOL. */
281
+ export declare const TOKEN_PROGRAM_ADDRESS: Address;
282
+ /**
283
+ * Token-2022. Pump `create_v2` mints here, so every coin a machine is built on is a Token-2022
284
+ * mint and the pool vault ATA lives under this program.
285
+ */
286
+ export declare const TOKEN_2022_PROGRAM_ADDRESS: Address;
287
+ /** Wrapped SOL. The quote mint on both venues. */
288
+ export declare const WSOL_MINT: Address;
289
+ /** MagicBlock's ephemeral VRF program. `vrf.rs` pins it and refuses any other. */
290
+ export declare const VRF_PROGRAM_ADDRESS: Address;
291
+ /**
292
+ * MagicBlock's default oracle queue. The program pins this one address, so a pool creator cannot
293
+ * point a draw at an oracle they control.
294
+ */
295
+ export declare const VRF_DEFAULT_QUEUE: Address;
296
+ /** The seed of both identity PDAs. See `pdas.ts` — there are two, under different programs. */
297
+ export declare const IDENTITY_SEED: Uint8Array<ArrayBuffer>;
298
+ export declare const SLOT_HASHES_SYSVAR: Address;
299
+ export declare const INSTRUCTIONS_SYSVAR: Address;
300
+ /** `state.rs`. A retry may not run sooner than this after the last attempt. */
301
+ export declare const RETRY_SLOTS = 300n;
302
+ /** `state.rs`. After this many slots from the purchase, anyone may expire the draw. */
303
+ export declare const TIMEOUT_SLOTS = 216000n;
304
+ /** `state.rs`. Three requests in total, counting the one `buy_pack` makes. */
305
+ export declare const MAX_ATTEMPTS = 3;
306
+ /**
307
+ * `state.rs`. Tokens in one pack, in base units: 1,000,000 tokens at Pump's fixed 6 decimals, or
308
+ * 0.1% of the 1,000,000,000 supply. Every pool sells packs of this size. The venue decides what a
309
+ * pack costs, so the pack price follows the coin. Read `pool.packTokens` rather than this when a
310
+ * pool is at hand: a later program version may change the constant.
311
+ */
312
+ export declare const PACK_TOKENS: bigint;
313
+ /** `state.rs`. The creator's per-pack fee, in bps of what the venue charged, may not exceed this. */
314
+ export declare const MAX_FEE_BPS = 100;
315
+ /** Referral reward: 1% of the creator fee, deducted from that fee. */
316
+ export declare const REFERRAL_FEE_BPS = 100n;
317
+ /** `state.rs`. The protocol's share of every pack's venue cost and of every sale's proceeds, in bps. */
318
+ export declare const PROTOCOL_FEE_BPS = 100n;
319
+ /**
320
+ * `PROTOCOL_FEE_COLLECTOR` in `state.rs`. Every pack pays 1% of its venue cost here, on top of
321
+ * that cost. Every sale through the program pays 1% of its proceeds here: SOL on Pump, WSOL (into the
322
+ * collector's WSOL ATA) on PumpSwap. The same key holds the program's upgrade authority.
323
+ *
324
+ * The generated instructions pin it as an `address` constraint, and `test/instruction-data.test.ts`
325
+ * checks this copy against the IDL.
326
+ */
327
+ export declare const PROTOCOL_FEE_COLLECTOR: Address;
328
+ //#endregion
329
+ //#region src/events.d.ts
330
+ export type GaboxEvent = {
331
+ name: 'PoolCreated';
332
+ data: PoolCreatedEvent;
333
+ } | {
334
+ name: 'PrizesFunded';
335
+ data: PrizesFundedEvent;
336
+ } | {
337
+ name: 'PackBought';
338
+ data: PackBoughtEvent;
339
+ } | {
340
+ name: 'RandomnessRetried';
341
+ data: RandomnessRetriedEvent;
342
+ } | {
343
+ name: 'DrawResolved';
344
+ data: DrawResolvedEvent;
345
+ } | {
346
+ name: 'PrizeRedeemed';
347
+ data: PrizeRedeemedEvent;
348
+ } | {
349
+ name: 'TokensSold';
350
+ data: TokensSoldEvent;
351
+ };
352
+ /** Decode one `Program data:` payload, or `null` when it is not one of ours. */
353
+ export declare function decodeEvent(data: Uint8Array): GaboxEvent | null;
354
+ /**
355
+ * Every gabox event in a transaction's logs, in order.
356
+ *
357
+ * A log line that is not `Program data:`, or whose payload matches no discriminator, is skipped
358
+ * rather than reported. Another program in the same transaction emits its own events, and they are
359
+ * not an error here.
360
+ */
361
+ export declare function decodeEvents(logs: readonly string[]): GaboxEvent[];
362
+ /** Fetch a transaction and decode the gabox events it emitted. */
363
+ export declare function fetchEvents(client: GaboxClient, signature: string): Promise<GaboxEvent[]>;
364
+ export type WatchDrawOptions = {
365
+ /** Stop watching. The returned promise then rejects with the abort reason. */
366
+ signal?: AbortSignal;
367
+ /** Called on every account change, including the ones that are still `Pending`. */
368
+ onChange?: (draw: Draw) => void;
369
+ };
370
+ /**
371
+ * Watch one draw and resolve when its callback delivers the prize.
372
+ *
373
+ * The first notification is the account as it is now, so a draw that resolved before the call
374
+ * resolves the promise immediately. Automatic delivery closes the account, so the watcher rebuilds
375
+ * the resolved snapshot from the purchase and resolution events when it sees that closure.
376
+ *
377
+ * There is no timeout here on purpose. The program's own deadline is 216,000 slots, which is about
378
+ * a day, and a UI should decide its own patience rather than inherit one.
379
+ */
380
+ export declare function watchDraw(client: GaboxClient, address: Address, options?: WatchDrawOptions): Promise<Draw>;
381
+ //#endregion
382
+ //#region src/lookupTables.d.ts
383
+ export declare const DEVNET_LOOKUP_TABLE_ADDRESS: Address<"Cx4ri1BU2bnDXPjnJykF3nbY2u4MD5pPvzFCJtNizWFa">;
384
+ export declare const DEVNET_LOOKUP_TABLE_ADDRESSES: readonly Address[];
385
+ export declare const DEVNET_ADDRESS_LOOKUP_TABLES: AddressesByLookupTableAddress;
386
+ /**
387
+ * The tables a client compresses with when its config names none.
388
+ *
389
+ * Only devnet has a shared table today. Mainnet gets one when the program is deployed there; until
390
+ * then a mainnet or localnet client compresses with nothing, and a message over 1,232 bytes fails
391
+ * in `buildMessage` with a request for tables. Pass `addressLookupTables` to `createClient` to
392
+ * supply your own.
393
+ */
394
+ export declare function defaultAddressLookupTables(cluster: Cluster): AddressesByLookupTableAddress;
395
+ //#endregion
396
+ //#region src/offer.d.ts
397
+ export type PackOffer = {
398
+ mint: Address;
399
+ pool: Address;
400
+ /** The fixed token count of one pack. Every prize is a multiple of this. */
401
+ packTokens: bigint;
402
+ /** What the venue charges for `packTokens` right now, its own fees included. The pack price. */
403
+ quoteLamports: bigint;
404
+ /** The creator's fee, in bps of `quoteLamports`. */
405
+ feeBps: number;
406
+ /** The creator's fee at this price, paid on top of `quoteLamports`. */
407
+ feeLamports: bigint;
408
+ /** The protocol's 1% of `quoteLamports`, also paid on top. */
409
+ protocolLamports: bigint;
410
+ /** What the seed cost the creator at creation. Display only. */
411
+ seedLamports: bigint;
412
+ /** Tokens the seed locked in the vault: `(maxMultiplier - 1x)` packs. */
413
+ seedTokens: bigint;
414
+ /** Which venue the buy would route to right now. */
415
+ venue: VenueKind;
416
+ /** The frozen prize table this pack would get: real amounts, already capped by inventory. */
417
+ prizes: Prize[];
418
+ /** The top prize, after the cap. Sign `minMaximum` just below this. */
419
+ maximum: bigint;
420
+ /** The smallest prize. Also what a timed-out draw pays. */
421
+ minimum: bigint;
422
+ /** The top prize with no inventory cap: the jackpot in tokens. Equal to `maximum` unless the
423
+ * inventory cap bites. */
424
+ uncapped: bigint;
425
+ /** Vault balance, `pool.reserved`, and the difference. */
426
+ inventory: bigint;
427
+ reserved: bigint;
428
+ free: bigint;
429
+ /** `pool.nextSeq === 0`. No pack has been sold yet. */
430
+ isFirstPack: boolean;
431
+ /**
432
+ * Does the pool pay the whole table right now?
433
+ *
434
+ * `offer.maximum === uncapped`. The seed guarantees this for the first pack. Later it is a
435
+ * quality signal: a capped top prize is legal and the pool still sells the pack. It just pays
436
+ * less than the table says, and a buyer should see that.
437
+ */
438
+ isSeeded: boolean;
439
+ /** The largest and the ticket-weighted average multiplier of the immutable table, in bps. */
440
+ maxMultiplierBps: number;
441
+ averageMultiplierBps: number;
442
+ };
443
+ export type GetOfferOptions = {
444
+ /** Force a venue instead of reading the bonding curve's `complete` flag. */
445
+ venue?: VenueKind;
446
+ /** The buyer, when you already know it. Only changes the account list, never the numbers. */
447
+ user?: Address;
448
+ };
449
+ /**
450
+ * The full offer for one machine. Two round trips: the pool and its vault, then the venue.
451
+ *
452
+ * Throws when the coin has no pool.
453
+ */
454
+ export declare function getOffer(client: GaboxClient, mint: Address, options?: GetOfferOptions): Promise<PackOffer>;
455
+ /**
456
+ * The same computation with the reads already done. Useful when a caller holds a `ResolvedVenue`
457
+ * and wants to re-price without touching the network. `quoteLamports` is
458
+ * `venue.quoteBuy(pool.packTokens)`.
459
+ */
460
+ export declare function offerFromState(inventory: PoolInventory, venue: VenueKind, quoteLamports: bigint): PackOffer;
461
+ /**
462
+ * How short of the top prize a pool is, in tokens. `0` when it pays the whole table.
463
+ *
464
+ * The pack brings its own `packTokens` into the vault before the offer is computed, so the vault
465
+ * only has to hold `uncapped - packTokens` beforehand. Anything already reserved by another draw
466
+ * does not count. A donation of this size through `fund_prizes` uncaps the top prize again.
467
+ */
468
+ export declare function seedShortfall(offer: PackOffer): bigint;
469
+ //#endregion
470
+ //#region src/pdas.d.ts
471
+ /** `['referral', referee]`. A wallet's permanent referral binding. */
472
+ export declare function referralLinkAddress(referee: Address): Promise<Address>;
473
+ /** `['referral', pool, referrer]`. A referrer's accrued rewards for one pool. */
474
+ export declare function referralAddress(pool: Address, referrer: Address): Promise<Address>;
475
+ /** `["pool", mint]`. One pool per coin, and the mint alone is the seed. */
476
+ export declare function poolAddress(mint: Address): Promise<Address>;
477
+ /** `["draw", pool, seq_u64_le]`. `seq` is `pool.nextSeq` at the moment of the purchase. */
478
+ export declare function drawAddress(pool: Address, seq: bigint): Promise<Address>;
479
+ /**
480
+ * `["identity"]` under gabox. This is the PDA gabox signs the VRF request with — the `identity`
481
+ * account of the `Oracle` group on `buy_pack` and `retry_draw`.
482
+ */
483
+ export declare function vrfIdentityAddress(): Promise<Address>;
484
+ /**
485
+ * `["identity", gabox_program_id]` under the **VRF program**. A different address from
486
+ * `vrfIdentityAddress`, and it belongs to the other side: MagicBlock signs the `deliver_draw`
487
+ * callback with it. A client never puts it in an instruction. It is here so a client can recognise
488
+ * the signer on a callback transaction.
489
+ */
490
+ export declare function scopedVrfIdentityAddress(): Promise<ProgramDerivedAddress>;
491
+ /**
492
+ * An associated token account. The seed order is `[owner, token_program, mint]`, which is the ATA
493
+ * program's own order and not the argument order most callers remember.
494
+ */
495
+ export declare function associatedTokenAddress(owner: Address, mint: Address, tokenProgram?: Address): Promise<Address>;
496
+ /**
497
+ * The protocol fee collector's WSOL ATA, under classic SPL Token. A sale on PumpSwap pays its
498
+ * protocol fee here. The account must exist before the first PumpSwap sale; see `DEPLOYMENT.md`.
499
+ */
500
+ export declare function feeCollectorWsolAddress(): Promise<Address>;
501
+ /**
502
+ * The pool's prize inventory: the pool PDA's ATA for the mint's own token program.
503
+ *
504
+ * `tokenProgram` defaults to Token-2022 because Pump `create_v2` mints there, and every machine is
505
+ * built on a coin Pump created. Pass the mint's real owner if you have it.
506
+ */
507
+ export declare function vaultAddress(mint: Address, tokenProgram?: Address): Promise<Address>;
508
+ //#endregion
509
+ //#region src/tx/message.d.ts
510
+ /**
511
+ * What every builder returns: a version 0 message with a fee-payer signer and a blockhash
512
+ * lifetime, ready for `signTransactionMessageWithSigners`.
513
+ *
514
+ * Named, and built only from types `@solana/kit` exports, so the published declaration file
515
+ * refers to kit's types instead of copying them. `pipe`'s inferred type is a long intersection
516
+ * of kit-internal brands, and a copy of a branded type is not assignable to the original.
517
+ */
518
+ export type GaboxTransactionMessage = Extract<TransactionMessage, {
519
+ version: 0;
520
+ }> & TransactionMessageWithFeePayerSigner & TransactionMessageWithBlockhashLifetime;
521
+ export type BuildOptions = {
522
+ /** Compute units to request. Each builder passes its own default. */
523
+ computeUnitLimit: number;
524
+ /** Priority fee in micro-lamports per compute unit. Left out, no price instruction is added. */
525
+ computeUnitPrice?: number | bigint;
526
+ /** Defaults to the client's tables, which the cluster chose. Pass `{}` to disable compression. */
527
+ addressLookupTables?: AddressesByLookupTableAddress;
528
+ };
529
+ /**
530
+ * Build the message. One RPC read, for the blockhash.
531
+ *
532
+ * The blockhash expires in about a minute, so build the message when the user is ready to sign
533
+ * rather than when the page loads.
534
+ */
535
+ export declare function buildMessage(client: GaboxClient, feePayer: TransactionSigner, instructions: Instruction[], options: BuildOptions): Promise<GaboxTransactionMessage>;
536
+ /** Append `remainingAccounts` to a generated instruction, which is how a venue's list is passed. */
537
+ export declare function withRemainingAccounts<T extends Instruction>(instruction: T, remaining: readonly NonNullable<T['accounts']>[number][]): T;
538
+ //#endregion
539
+ //#region src/tx/buyPack.d.ts
540
+ export type BuyPackInput = {
541
+ mint: Address;
542
+ /** Pays for everything and signs. Becomes `draw.purchaser`. */
543
+ purchaser: TransactionSigner;
544
+ /** Slippage cap on the venue trade, in lamports (WSOL on PumpSwap). Must be positive. */
545
+ maxQuoteIn: bigint;
546
+ /** Floor on the top prize, in tokens. */
547
+ minMaximum: bigint;
548
+ /** Cap on venue debit + creator fee + protocol fee + VRF request, in lamports. Rent and tx fee
549
+ * are extra. */
550
+ maxTotalDebit: bigint;
551
+ /** Force a venue. Left out, the bonding curve's `complete` flag decides. */
552
+ venue?: VenueKind;
553
+ /**
554
+ * Pin the draw's sequence number instead of reading `pool.nextSeq` now.
555
+ *
556
+ * The draw's address is `["draw", pool, seq]`, so a caller that has already told somebody which
557
+ * draw this purchase will create has to keep that promise if it rebuilds the message - after a
558
+ * stale blockhash, say. Rebuilding without a pin reads `nextSeq` again, and if the first attempt
559
+ * actually landed, the second one buys a **second pack** at the next sequence number rather than
560
+ * failing. With the pin it fails on the `init` constraint, which is the right outcome.
561
+ */
562
+ seq?: bigint;
563
+ /**
564
+ * Lamports to wrap into the buyer's WSOL account on the PumpSwap route. Left out, the builder
565
+ * wraps `maxQuoteIn`: the venue never takes more than that, and any surplus stays in the buyer's
566
+ * own WSOL account.
567
+ */
568
+ wrapLamports?: bigint;
569
+ /** Append PumpSwap's optional cashback account. Only for a cashback coin. */
570
+ cashback?: boolean;
571
+ /**
572
+ * A referrer to bind before the purchase, in the same transaction.
573
+ *
574
+ * A share link leaves the referrer's wallet in a cookie, and the first pack is where it matters:
575
+ * `bind_referrer` runs one instruction ahead of `buy_pack`, so the pack that converts the buyer
576
+ * is the pack that pays. Ignored when the buyer already has a link (the chain wins), when it
577
+ * names the buyer, or when it is the all-zero address. The link's rent is extra, on top of
578
+ * `maxTotalDebit`.
579
+ */
580
+ referrer?: Address;
581
+ } & Partial<BuildOptions>;
582
+ export declare function buyPack(client: GaboxClient, input: BuyPackInput): Promise<GaboxTransactionMessage>;
583
+ //#endregion
584
+ //#region src/tx/createMachine.d.ts
585
+ export type CreateMachineInput = {
586
+ /** Pays for everything and signs both instructions. Becomes `pool.creator`. */
587
+ creator: TransactionSigner;
588
+ /** A fresh keypair for the coin. Signs `create_v2` and is never needed again. */
589
+ mintKeypair: TransactionSigner;
590
+ name: string;
591
+ symbol: string;
592
+ /** The metadata URI Pump writes onto the mint. */
593
+ uri: string;
594
+ /** The creator's fee per pack, in bps of what the venue charges. `0` to `MAX_FEE_BPS`. Immutable. */
595
+ feeBps: number;
596
+ /** Controls how much probability moves from Common into Rare, Epic, and Mythic. */
597
+ riskProfile: RiskProfile;
598
+ /**
599
+ * The jackpot: the largest tier's multiplier, in bps. `10_000` is 1x and needs no seed;
600
+ * `50_000` is 5x and seeds four packs of tokens. Immutable.
601
+ */
602
+ jackpotBps: number;
603
+ /**
604
+ * The creator's slippage cap on the seed buy, in lamports. Pump fails the buy above it.
605
+ * Take `seedCostEstimate` and add a margin. Ignored for a 1x jackpot, which buys nothing.
606
+ */
607
+ maxSeedLamports: bigint;
608
+ /** Which Pump fee recipient to use, as an index. Left out, one is picked at random. */
609
+ feeRecipientIndex?: number;
610
+ /** Same, for the buyback recipient list. */
611
+ buybackRecipientIndex?: number;
612
+ } & Partial<BuildOptions>;
613
+ /**
614
+ * Build the transaction message. Sign it with both `creator` and `mintKeypair`.
615
+ *
616
+ * Reads Pump's `Global` account, because two of the buy accounts — the fee recipient and the
617
+ * buyback fee recipient — are chosen from lists held there. Nothing else needs the chain: the coin
618
+ * does not exist yet, so every other account is a derivation.
619
+ */
620
+ export declare function createMachine(client: GaboxClient, input: CreateMachineInput): Promise<GaboxTransactionMessage>;
621
+ /**
622
+ * What the seed for this jackpot costs, fees included, and how many tokens it is.
623
+ *
624
+ * The coin does not exist yet, so the price is Pump's default new curve. Nothing else trades on
625
+ * it before `initialize_pool` runs in the same transaction, so this is exact up to a change in
626
+ * Pump's fee settings between the read and the send. Add a small margin for `maxSeedLamports`.
627
+ */
628
+ export declare function seedCostEstimate(client: GaboxClient, jackpotBps: number, riskProfile: RiskProfile): Promise<{
629
+ tiers: Tier[];
630
+ seedTokens: bigint;
631
+ lamports: bigint;
632
+ }>;
633
+ /**
634
+ * The Pump buy accounts for the seed, built without reading the bonding curve.
635
+ *
636
+ * The curve does not exist yet — `create_v2` in the same transaction is what creates it — so
637
+ * `resolveVenue` cannot be used here. Everything the account list needs is known anyway: the
638
+ * creator vault follows from the `creator` argument that `create_v2` records on the curve, and the
639
+ * two fee recipients come from `Global`.
640
+ */
641
+ export declare function pumpSeedBuyAccounts(client: GaboxClient, options: {
642
+ mint: Address;
643
+ user: Address;
644
+ feeRecipientIndex?: number;
645
+ buybackRecipientIndex?: number;
646
+ }): Promise<AccountMeta[]>;
647
+ //#endregion
648
+ //#region src/tx/draw.d.ts
649
+ export type RetryDrawInput = {
650
+ /** Pays the oracle fee and the transaction fee. Any wallet. */
651
+ payer: TransactionSigner;
652
+ pool: Address;
653
+ draw: Address;
654
+ /** Cap on what the oracle request may take from `payer`, in lamports. */
655
+ maxVrfDebit: bigint;
656
+ } & Partial<BuildOptions>;
657
+ export declare function retryDraw(client: GaboxClient, input: RetryDrawInput): Promise<GaboxTransactionMessage>;
658
+ export type ExpireDrawInput = {
659
+ /** Only pays the transaction fee. `expire_draw` itself has no signer account. */
660
+ payer: TransactionSigner;
661
+ pool: Address;
662
+ draw: Address;
663
+ } & Partial<BuildOptions>;
664
+ export declare function expireDraw(client: GaboxClient, input: ExpireDrawInput): Promise<GaboxTransactionMessage>;
665
+ export type DrawAvailability = {
666
+ status: DrawStatus;
667
+ attempts: number;
668
+ /** Slots remaining before a retry is allowed. `0` when it is allowed now. */
669
+ slotsUntilRetry: bigint;
670
+ /** Slots remaining before the draw can be expired. `0` when it can be expired now. */
671
+ slotsUntilExpiry: bigint;
672
+ /** All three conditions the program checks for `retry_draw`, together. */
673
+ canRetry: boolean;
674
+ /** The one condition `expire_draw` checks. */
675
+ canExpire: boolean;
676
+ };
677
+ /**
678
+ * What a client may do to a draw right now.
679
+ *
680
+ * Reads the draw and the current slot, and reproduces the program's three retry conditions and its
681
+ * one expiry condition. Showing a disabled button with a countdown beats sending a transaction that
682
+ * fails with `RetryTooSoon`.
683
+ */
684
+ export declare function drawAvailability(client: GaboxClient, draw: Address): Promise<DrawAvailability | null>;
685
+ //#endregion
686
+ //#region src/tx/fundPrizes.d.ts
687
+ export type FundPrizesInput = {
688
+ mint: Address;
689
+ /** The donor. Signs, and the tokens leave its account. */
690
+ funder: TransactionSigner;
691
+ /** Tokens to donate, in the mint's smallest unit. Must be positive. */
692
+ amount: bigint;
693
+ /**
694
+ * The account the tokens come from. Defaults to the funder's associated token account, which is
695
+ * where a wallet holds them. Any token account the funder is the authority of works.
696
+ */
697
+ source?: Address;
698
+ } & Partial<BuildOptions>;
699
+ export declare function fundPrizes(client: GaboxClient, input: FundPrizesInput): Promise<GaboxTransactionMessage>;
700
+ export type FundPrizesWithBuyInput = {
701
+ mint: Address;
702
+ /** The donor. Buys the tokens, then gives them away. Signs both instructions. */
703
+ funder: TransactionSigner;
704
+ /** Exact tokens to buy and donate. `seedShortfall(offer)` is the amount that uncaps the top prize. */
705
+ tokens: bigint;
706
+ /** The donor's slippage cap on the buy, in lamports (WSOL on PumpSwap). */
707
+ maxQuoteIn: bigint;
708
+ /** Force a venue. Left out, the bonding curve's `complete` flag decides. */
709
+ venue?: VenueKind;
710
+ /**
711
+ * Lamports to wrap on the PumpSwap route. Left out, `maxQuoteIn`. The venue never takes more
712
+ * than that, and any surplus stays in the donor's own WSOL account.
713
+ */
714
+ wrapLamports?: bigint;
715
+ } & Partial<BuildOptions>;
716
+ /**
717
+ * Buy tokens at the venue with SOL and donate them to the vault, in one transaction.
718
+ *
719
+ * This is what a donor with SOL and no coins needs. `fundPrizes` moves tokens the donor already
720
+ * holds; this one buys them first. Both are irrevocable — there is no withdrawal instruction, and
721
+ * no authority can move vault tokens.
722
+ *
723
+ * Three instructions on the curve route: create the donor's token account if it is missing, buy,
724
+ * donate. Pump creates the account itself, but the idempotent instruction costs nothing when it
725
+ * already exists and it makes the transaction correct on its own terms. The PumpSwap route adds the
726
+ * WSOL create/fund/sync prefix, for the same reason `buyPack` does: PumpSwap spends WSOL.
727
+ */
728
+ export declare function fundPrizesWithBuy(client: GaboxClient, input: FundPrizesWithBuyInput): Promise<GaboxTransactionMessage>;
729
+ //#endregion
730
+ //#region src/tx/redeem.d.ts
731
+ export type SellTokensInput = {
732
+ mint: Address;
733
+ /** Wallet that owns the tokens and signs the venue sale. */
734
+ seller: TransactionSigner;
735
+ /** Exact token amount to sell. Must be positive. */
736
+ amount: bigint;
737
+ /** Floor on the venue's net output, in lamports or WSOL, before the protocol fee. Must be
738
+ * positive: the program rejects zero, because a zero floor is not slippage protection. */
739
+ minQuoteOutput: bigint;
740
+ /** Force a venue. Left out, the bonding curve's `complete` flag decides. */
741
+ venue?: VenueKind;
742
+ } & Partial<BuildOptions>;
743
+ /**
744
+ * Sell a prize that the VRF callback already delivered to the wallet, through `sell_tokens`.
745
+ *
746
+ * The program needs the coin's pool: it keeps the vault out of the venue's account list. A mint
747
+ * with no pool cannot be sold this way; use a plain venue trade for that.
748
+ */
749
+ export declare function sellTokens(client: GaboxClient, input: SellTokensInput): Promise<GaboxTransactionMessage>;
750
+ export type ClaimPrizeInput = {
751
+ mint: Address;
752
+ /** The wallet that bought the legacy pack. Only it can settle the draw. */
753
+ purchaser: TransactionSigner;
754
+ /** The draw to redeem. */
755
+ draw: Address;
756
+ } & Partial<BuildOptions>;
757
+ /** Transfer a legacy resolve-only award into the purchaser's token account and close the draw. */
758
+ export declare function claimPrize(client: GaboxClient, input: ClaimPrizeInput): Promise<GaboxTransactionMessage>;
759
+ export type SellPrizeInput = ClaimPrizeInput & {
760
+ /**
761
+ * The seller's floor on the venue's net output, in lamports or WSOL. Must be positive: the
762
+ * program rejects zero, because a zero floor is not slippage protection.
763
+ *
764
+ * This is the venue's own net quote, before the protocol fee. It is not net of the transaction
765
+ * fee or of any rent the transaction pays.
766
+ */
767
+ minQuoteOutput: bigint;
768
+ /** Force a venue. Left out, the bonding curve's `complete` flag decides. */
769
+ venue?: VenueKind;
770
+ };
771
+ /**
772
+ * Claim and sell a legacy resolve-only draw in one transaction.
773
+ *
774
+ * The award is read off the draw so the caller can price the sale before signing. A draw that has
775
+ * not resolved has no award yet, and this throws rather than building a sale of zero tokens.
776
+ */
777
+ export declare function sellPrize(client: GaboxClient, input: SellPrizeInput): Promise<GaboxTransactionMessage>;
778
+ /**
779
+ * Quote the award held by a legacy open draw before the seller signs a floor.
780
+ *
781
+ * Read the draw, ask the venue, and subtract your own slippage tolerance to get `minQuoteOutput`.
782
+ */
783
+ export declare function quoteSellPrize(client: GaboxClient, mint: Address, draw: Address, user: Address): Promise<{
784
+ award: bigint;
785
+ grossOutput: bigint;
786
+ }>;
787
+ //#endregion
788
+ //#region src/referral.d.ts
789
+ export type ReferralResolution = Readonly<{
790
+ link: Address;
791
+ referrer: Address;
792
+ referral: Address;
793
+ }>;
794
+ /** Resolve the purchaser's permanent referral binding for a pack purchase. */
795
+ export declare function resolveReferral(client: GaboxClient, purchaser: Address, pool: Address): Promise<ReferralResolution | null>;
796
+ /** Bind a wallet to a referrer. The purchaser signs and the binding is permanent. */
797
+ export declare function bindReferrer(client: GaboxClient, referee: TransactionSigner, referrer: Address, options?: Partial<BuildOptions>): Promise<GaboxTransactionMessage>;
798
+ /** Claim all accrued referral rewards for one pool. */
799
+ export declare function claimReferral(client: GaboxClient, referrer: TransactionSigner, pool: Address, options?: Partial<BuildOptions>): Promise<GaboxTransactionMessage>;
800
+ //#endregion
801
+ //#region src/vrf.d.ts
802
+ /** The four accounts, named as the generated client names them. */
803
+ export type OracleAccounts = {
804
+ /** `["identity"]` under gabox. The PDA gabox signs the randomness request with. */
805
+ identity: Address;
806
+ /** MagicBlock's default queue. Writable. */
807
+ queue: Address;
808
+ /** The VRF program itself. */
809
+ program: Address;
810
+ /** The slot-hashes sysvar, which seeds the request. */
811
+ slotHashes: Address;
812
+ };
813
+ /**
814
+ * Build the group. Nothing here reads the chain, so it is safe to call on every render.
815
+ *
816
+ * The generated instruction builders default `queue`, `program` and `slotHashes` on their own, so
817
+ * passing this whole object is belt and braces. It is worth having anyway: a caller can show the
818
+ * four accounts a draw request will touch before asking for a signature.
819
+ */
820
+ export declare function oracleAccounts(): Promise<OracleAccounts>;
821
+ //#endregion
822
+ export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, CLUSTER_ENDPOINTS, ClientConfig, Cluster, DEVNET_HTTP, DEVNET_WS, DRAW_DISCRIMINATOR, type Draw, GaboxClient, GaboxRpc, GaboxRpcSubscriptions, MAYHEM_PROGRAM_ADDRESS, POOL_DISCRIMINATOR, PUMP_FEE_PROGRAM_ADDRESS, PUMP_PROGRAM_ADDRESS, PUMP_SWAP_PROGRAM_ADDRESS, type Pool, type Referral, type ReferralLink, SYSTEM_PROGRAM_ADDRESS, assertClusterUrl, clusterNamedBy, createClient, decodeDraw, decodePool, findDrawPda, findIdentityPda, findPoolPda, findReferralLinkPda, index_d_exports as generated, index_d_exports$1 as pump, websocketUrlFor };
823
+ //# sourceMappingURL=index.d.ts.map