@gabox-labs/sdk 0.1.1 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gabox-labs/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "The Solana Kit SDK for gabox-v2: generated instruction builders, PDAs, Pump/PumpSwap venue accounts, and the pack flow.",
6
6
  "license": "MIT",
@@ -97,23 +97,23 @@ On the Pump route the seller gets SOL. On PumpSwap (a graduated coin) the seller
97
97
  ## Flow 3: create a machine
98
98
 
99
99
  ```ts
100
- import { createMachine, seedCostEstimate } from '@gabox-labs/sdk';
100
+ import { createMachine, DEFAULT_TIERS, seedCostEstimate } from '@gabox-labs/sdk';
101
101
  import { generateKeyPairSigner } from '@solana/kit';
102
102
 
103
103
  const mintKeypair = await generateKeyPairSigner();
104
- const seed = await seedCostEstimate(gabox, 50_000, 'balanced');
104
+ const seed = await seedCostEstimate(gabox); // DEFAULT_TIERS
105
105
  const message = await createMachine(gabox, {
106
106
  creator, mintKeypair, // two signers
107
107
  name, symbol, uri, // Pump metadata
108
108
  feeBps: 100, // creator fee, 0..100 (max 1%)
109
- riskProfile: 'balanced', // 'conservative' | 'balanced' | 'jackpot'
110
- jackpotBps: 50_000, // top prize = 5 packs
109
+ tiers: DEFAULT_TIERS, // optional; default top prize = 20 packs
111
110
  maxSeedLamports: (seed.lamports * 105n) / 100n,
112
111
  });
113
112
  ```
114
113
 
115
- The creator buys the **seed** that backs the jackpot: a jackpot needs four extra packs of
116
- tokens, 10× needs nine, needs none. Preview the table with `jackpotTiers(jackpotBps, profile)`.
114
+ The creator buys the **seed** that backs the top prize. `DEFAULT_TIERS` needs nineteen extra packs
115
+ of tokens. Pass a custom eight-row `Tier[]` only after validating its odds and seed with
116
+ `seedCostEstimate(gabox, tiers)`; the SDK and program both validate it.
117
117
 
118
118
  ## Flow 4: stuck draws (permissionless)
119
119
 
@@ -124,8 +124,9 @@ if (s?.canRetry) await retryDraw(gabox, { payer, pool, draw, maxVrfDebit: 5_000
124
124
  if (s?.canExpire) await expireDraw(gabox, { payer, pool, draw });
125
125
  ```
126
126
 
127
- Retry: 300 slots after the last attempt, 3 attempts total. Expire: after 216,000 slots (~1 day);
128
- pays the **smallest** prize, not a refund. Show `slotsUntilRetry` / `slotsUntilExpiry` as a countdown.
127
+ Retry: 300 slots after the last attempt, 3 attempts total. Expire: after 216,000 slots (~1 day),
128
+ only while the draw is `Pending`; it pays the **smallest** prize, not a refund. A `Ready` draw must
129
+ go through normal delivery. Show `slotsUntilRetry` / `slotsUntilExpiry` as a countdown.
129
130
 
130
131
  ## Referrals
131
132
 
@@ -152,7 +153,7 @@ if (generated.isGaboxV2Error(error, message)) console.log(generated.getGaboxV2Er
152
153
  ```
153
154
 
154
155
  Common: `SlippageExceeded`, `PrizeCapChanged` (refresh the offer), `RetryTooSoon`,
155
- `RetryUnavailable`, `NotExpired`, `InvalidReferral`, `ZeroAmount`.
156
+ `RetryUnavailable`, `NotExpired`, `NotPending`, `InvalidReferral`, `ZeroAmount`.
156
157
 
157
158
  ## Do not
158
159
 
@@ -36,14 +36,14 @@ blockhash set, ready for `signTransactionMessageWithSigners`. All amounts are `b
36
36
 
37
37
  | function | input | signers |
38
38
  | --- | --- | --- |
39
- | `createMachine` | `{ creator; mintKeypair; name; symbol; uri; feeBps: number; riskProfile: RiskProfile; jackpotBps: number; maxSeedLamports: bigint; feeRecipientIndex?; buybackRecipientIndex? }` | creator, mintKeypair |
40
- | `seedCostEstimate` | `(client, jackpotBps: number, riskProfile: RiskProfile) => Promise<{ tiers: Tier[]; seedTokens: bigint; lamports: bigint }>` | read only |
39
+ | `createMachine` | `{ creator; mintKeypair; name; symbol; uri; feeBps: number; tiers?: readonly Tier[]; maxSeedLamports: bigint; feeRecipientIndex?; buybackRecipientIndex? }` | creator, mintKeypair |
40
+ | `seedCostEstimate` | `(client, tiers?: readonly Tier[]) => Promise<{ tiers: readonly Tier[]; seedTokens: bigint; lamports: bigint }>` | read only |
41
41
  | `buyPack` | `{ mint; purchaser; maxQuoteIn: bigint; minMaximum: bigint; maxTotalDebit: bigint; seq?: bigint; venue?; wrapLamports?; cashback?; referrer?: Address }` | purchaser |
42
42
  | `sellTokens` | `{ mint; seller; amount: bigint; minQuoteOutput: bigint; venue? }` | seller |
43
43
  | `fundPrizes` | `{ mint; funder; amount: bigint; source?: Address }` | funder |
44
44
  | `fundPrizesWithBuy` | `{ mint; funder; tokens: bigint; maxQuoteIn: bigint; venue?; wrapLamports? }` | funder |
45
45
  | `retryDraw` | `{ payer; pool; draw; maxVrfDebit: bigint }` | payer (anyone) |
46
- | `expireDraw` | `{ payer; pool; draw }` | payer (anyone) |
46
+ | `expireDraw` | `{ payer; pool; draw }` | payer (anyone); only for an expired `Pending` draw |
47
47
  | `bindReferrer` | `(client, referee: TransactionSigner, referrer: Address, options?) ` | referee |
48
48
  | `claimReferral` | `(client, referrer: TransactionSigner, pool: Address, options?)` | referrer |
49
49
  | `claimPrize`, `sellPrize`, `quoteSellPrize` | legacy draws only (created before automatic delivery) | purchaser |
@@ -95,10 +95,10 @@ Also the generated `findPoolPda`, `findDrawPda`, `findReferralLinkPda`, `findIde
95
95
 
96
96
  ## Math (`src/math.ts`), pure
97
97
 
98
- | function | signature |
99
- | --- | --- |
98
+ | function | signature | notes |
99
+ | --- | --- | --- |
100
100
  | `share` | `(amount: bigint, bps: bigint) => bigint` |
101
- | `jackpotTiers` | `(jackpotBps: number, profile: RiskProfile) => Tier[]` |
101
+ | `DEFAULT_TIERS` | `readonly Tier[]` | 75% / 20% / 4% / 1% odds at 0.52× / 1.2× / 3× / 20× |
102
102
  | `seedTokens` | `(packTokens: bigint, tiers: Tier[]) => bigint` |
103
103
  | `quote` | `(base: bigint, tiers: Tier[], inventory: bigint, reserved: bigint) => Offer` |
104
104
  | `uncappedMaximum` | `(base: bigint, tiers: Tier[]) => bigint` |
@@ -108,8 +108,7 @@ Also the generated `findPoolPda`, `findDrawPda`, `findReferralLinkPda`, `findIde
108
108
  | `validateTiers`, `validatePack` | throw `GaboxMathError` on a bad table |
109
109
 
110
110
  Types: `Tier = { multiplierBps: number; tickets: number }`, `Prize = { amount: bigint; tickets: number }`,
111
- `Offer = { prizes: Prize[]; maximum: bigint; minimum: bigint }`,
112
- `RiskProfile = 'conservative' | 'balanced' | 'jackpot'`. Constants `BPS = 10_000n`, `TICKETS = 65_536`,
111
+ `Offer = { prizes: Prize[]; maximum: bigint; minimum: bigint }`. Constants `BPS = 10_000n`, `TICKETS = 65_536`,
113
112
  `TIERS = 8`.
114
113
 
115
114
  ## Constants (`src/ids.ts`)