@gabox-labs/sdk 0.6.0 → 0.7.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 +84 -0
- package/README.md +113 -34
- package/dist/gabox-DGTCh34U.js +2338 -0
- package/dist/gabox-DGTCh34U.js.map +1 -0
- package/dist/generated/index.d.ts +89 -36
- package/dist/generated/index.js +2 -2289
- package/dist/generated/index.js.map +1 -1
- package/dist/{index-BDfGvmgF.d.ts → index-C4at2cZ_.d.ts} +304 -54
- package/dist/index.d.ts +333 -34
- package/dist/index.js +884 -506
- 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-B-l9V3O-.js → raydium-CU-tZzIk.js} +869 -191
- package/dist/raydium-CU-tZzIk.js.map +1 -0
- package/llms.txt +4 -2
- package/package.json +1 -1
- package/skills/gabox-sdk/SKILL.md +27 -14
- package/skills/gabox-sdk/references/api.md +78 -26
- package/dist/raydium-B-l9V3O-.js.map +0 -1
|
@@ -17,9 +17,17 @@ Gabox charges no fee at all. Every price the SDK shows already includes Raydium'
|
|
|
17
17
|
curve, 0.5% to the Gabox platform wallet and 0.5% to the coin creator plus Raydium's trade fee; after
|
|
18
18
|
graduation, the CPMM pool fee and the pool creator fee.
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
A machine is priced in one quote asset, fixed when the pool is created. It defaults to wrapped SOL,
|
|
21
|
+
and any quote Raydium enabled on LaunchLab works; `raydium.fetchQuoteConfig(client, mint)` says
|
|
22
|
+
whether a mint is one of them, and `raydium.isQuoteSupported` is the boolean version. The quote may
|
|
23
|
+
be classic SPL Token or Token-2022; the coin is always classic SPL Token.
|
|
24
|
+
|
|
25
|
+
Buyers pay in SOL either way. On a WSOL pool every builder wraps the SOL its trade needs and closes
|
|
26
|
+
the WSOL account afterwards, so the wallet spends and receives plain SOL; that close also unwraps any
|
|
27
|
+
WSOL the wallet already held. On any other pool a route provider swaps SOL into the quote token **in
|
|
28
|
+
the same transaction** as the Gabox instruction, and back after a sale. `createClient` gives mainnet
|
|
29
|
+
`jupiterRoute()`; devnet has no router, so pass `route: raydiumCpmmRoute(pool)` with a CPMM pool for
|
|
30
|
+
the SOL pair. `payWith: 'quote'` and `receive: 'quote'` skip the swap.
|
|
23
31
|
|
|
24
32
|
```ts
|
|
25
33
|
import { buyPack, createClient, getOffer } from '@gabox-labs/sdk';
|
|
@@ -35,24 +43,29 @@ const message = await buyPack(gabox, {
|
|
|
35
43
|
});
|
|
36
44
|
```
|
|
37
45
|
|
|
38
|
-
`offer.quoteAmount` is the exact venue price for one pack
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
`offer.quoteAmount` is the exact venue price for one pack, in the pool's quote token;
|
|
47
|
+
`offer.solAmount` is the same price in lamports, with `offer.quoteDecimals` and `offer.quoteSymbol`
|
|
48
|
+
for showing it. `maxQuoteIn` is the slippage cap in the quote token, and the amount put in the
|
|
49
|
+
buyer's quote account first. `maxNativeDebit` is a separate cap on the lamports the handler watches:
|
|
50
|
+
the VRF request and any venue account rent.
|
|
41
51
|
|
|
42
52
|
For creation use `createMachine` with `name`, `symbol`, `uri`, `maxSeedQuoteIn` and
|
|
43
|
-
`maxSeedNativeDebit`. Metaplex limits the three strings to 32, 10 and 200 UTF-8 bytes.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
`maxSeedNativeDebit`. Metaplex limits the three strings to 32, 10 and 200 UTF-8 bytes. Add
|
|
54
|
+
`quote: { mint }` and `raise` for a machine priced in another token: `raise` is
|
|
55
|
+
`total_quote_fund_raising` in that token's base units, and a WSOL pool uses the raise the program
|
|
56
|
+
pins instead. Everything else about the launch is pinned. It buys a mandatory seed: enough for a 3x
|
|
57
|
+
top prize on the first pack, or the table's full top prize when that pays less than 3x. A table's
|
|
58
|
+
top tier can be at most 20x. Pass `extraSeedTokens` to buy more seed in the same trade, and read
|
|
59
|
+
`seedCostEstimate` for the mandatory, extra and total amounts plus the exact cost.
|
|
48
60
|
|
|
49
61
|
`raydium.resolveVenue(client, { mint, user })` says which venue is live. It throws while a coin is
|
|
50
62
|
migrating, which on devnet lasts under a minute. A migrated CPMM pool can sit at any address, so the
|
|
51
63
|
SDK proves it from its own data and reads its fee tier, vaults and oracle out of the pool account.
|
|
52
64
|
|
|
53
|
-
Creators collect their share with `raydium.claimCreatorFee(client, { creator })`, which
|
|
54
|
-
coin they launched
|
|
55
|
-
|
|
65
|
+
Creators collect their share with `raydium.claimCreatorFee(client, { creator, quoteMint })`, which
|
|
66
|
+
sweeps every coin they launched against that quote, and
|
|
67
|
+
`raydium.collectCreatorFee(client, { mint, creator })` for one graduated coin.
|
|
68
|
+
`raydium.fetchCreatorFees` reads both, per quote asset.
|
|
56
69
|
|
|
57
70
|
`buyPack` keeps a per-wallet `WalletActivity` account (`fetchWalletActivity(client, wallet)`, `null`
|
|
58
71
|
before a wallet's first purchase); it resolves the account itself.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
All chain-touching functions take `client: GaboxClient` first. Addresses use `Address`; all token
|
|
4
4
|
amounts use base-unit `bigint`. Every venue is Raydium: LaunchLab before a coin graduates, Raydium
|
|
5
|
-
CPMM after. Both settle in
|
|
5
|
+
CPMM after. Both settle in the pool's own quote asset, which defaults to wrapped SOL.
|
|
6
6
|
|
|
7
7
|
## Client and reads
|
|
8
8
|
|
|
@@ -15,13 +15,15 @@ CPMM after. Both settle in WSOL.
|
|
|
15
15
|
| `listPools(client)` / `listDrawsByPurchaser(client, wallet)` | current account scans |
|
|
16
16
|
| `fetchWalletActivity(client, wallet)` | `WalletActivity \| null`, a buyer's lifetime `packsBought`/`nativeSpent` |
|
|
17
17
|
|
|
18
|
-
`Pool` records `creator`, `mint`, `vault`, `quoteMint`
|
|
19
|
-
`
|
|
20
|
-
SPL Token
|
|
18
|
+
`Pool` records `creator`, `mint`, `vault`, `quoteMint`, `packTokens`, `seedQuoteAmount`, `tiers`,
|
|
19
|
+
`nextSeq`, `reserved`, `quoteConfig` (LaunchLab's global config for the quote) and
|
|
20
|
+
`quoteTokenProgram` (classic SPL Token or Token-2022). It stores no base token program, because the
|
|
21
|
+
coin is always classic SPL Token, and no fee, because Gabox charges none.
|
|
21
22
|
|
|
22
|
-
`PackOffer` gives `quoteAmount` (the whole pack price, the venue's fees
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
`PackOffer` gives `quoteAmount` (the whole pack price in the quote token, the venue's fees
|
|
24
|
+
included), `quoteMint`, `quoteDecimals`, `quoteSymbol`, `solAmount` (the same price in lamports
|
|
25
|
+
through the route provider, or `null`), `venue` (`'launchlab'` or `'cpmm'`), the frozen prize table,
|
|
26
|
+
`maximum`, `minimum`, `uncapped`, the inventory numbers and `isSeeded`.
|
|
25
27
|
|
|
26
28
|
## Builders
|
|
27
29
|
|
|
@@ -29,17 +31,22 @@ Each returns a kit transaction message. Nothing here signs or sends.
|
|
|
29
31
|
|
|
30
32
|
| Function | Input highlights |
|
|
31
33
|
| --- | --- |
|
|
32
|
-
| `createMachine` | `name`, `symbol`, `uri`, `tiers?`, `maxSeedQuoteIn`, `maxSeedNativeDebit`, `extraSeedTokens?` |
|
|
33
|
-
| `buyPack` | `maxQuoteIn`, `minMaximum`, `maxNativeDebit`, `venue?`, `seq?` |
|
|
34
|
+
| `createMachine` | `name`, `symbol`, `uri`, `tiers?`, `quote?`, `raise?`, `payWith?`, `maxSeedQuoteIn`, `maxSeedNativeDebit`, `extraSeedTokens?` |
|
|
35
|
+
| `buyPack` | `maxQuoteIn`, `minMaximum`, `maxNativeDebit`, `payWith?`, `venue?`, `seq?` |
|
|
34
36
|
| `fundPrizes` | donate coins the funder already holds into the prize vault |
|
|
35
|
-
| `sellTokens` | `amount`, `minQuoteOutput`, `maxNativeDebit`, `venue?` |
|
|
37
|
+
| `sellTokens` | `amount`, `minQuoteOutput`, `maxNativeDebit`, `receive?`, `venue?` |
|
|
36
38
|
| `retryDraw` / `expireDraw` | permissionless recovery |
|
|
37
|
-
| `raydium.claimCreatorFee` | `creator
|
|
39
|
+
| `raydium.claimCreatorFee` | `creator`, `quoteMint?`; sweeps every coin that wallet launched against that quote |
|
|
38
40
|
| `raydium.collectCreatorFee` | `mint`, `creator`; one graduated coin's CPMM creator fee |
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
afterwards, so the wallet spends and receives plain SOL. Closing unwraps any WSOL the
|
|
42
|
-
held.
|
|
42
|
+
On a WSOL pool every builder wraps the SOL its trade needs into the wallet's WSOL account and closes
|
|
43
|
+
that account afterwards, so the wallet spends and receives plain SOL. Closing unwraps any WSOL the
|
|
44
|
+
wallet already held.
|
|
45
|
+
|
|
46
|
+
On any other pool the wallet's quote account is created if missing, and `payWith: 'sol'` (the
|
|
47
|
+
default) prepends a swap that turns SOL into the quote token. `receive: 'sol'` appends the reverse
|
|
48
|
+
after a sale. `payWith: 'quote'` and `receive: 'quote'` skip the swap. The swap and the Gabox
|
|
49
|
+
instruction always share one transaction.
|
|
43
50
|
|
|
44
51
|
`createMachine` builds one transaction with LaunchLab's `initialize_v2` first and `initialize_pool`
|
|
45
52
|
second. The mint keypair and the creator both sign. It buys a mandatory seed,
|
|
@@ -53,9 +60,16 @@ top prize when that pays less than 3x. A table's top tier can be at most 20x. `e
|
|
|
53
60
|
either: the program declares it `init_if_needed`, so Anchor does that and the purchaser pays its rent
|
|
54
61
|
once.
|
|
55
62
|
|
|
56
|
-
`maxQuoteIn` and `maxSeedQuoteIn` are venue slippage caps in
|
|
57
|
-
|
|
58
|
-
what the handler watches: venue account rent, and
|
|
63
|
+
`maxQuoteIn` and `maxSeedQuoteIn` are venue slippage caps in the quote token, and each is also the
|
|
64
|
+
amount put in the wallet's quote account before the trade. `maxNativeDebit` and
|
|
65
|
+
`maxSeedNativeDebit` are separate lamport caps for what the handler watches: venue account rent, and
|
|
66
|
+
the VRF request on a pack buy.
|
|
67
|
+
|
|
68
|
+
`createMachine` takes `quote: { mint }` and `raise`. The quote defaults to wrapped SOL, whose raise
|
|
69
|
+
the program pins per cluster; any other quote needs a `raise` in its own base units, at or above
|
|
70
|
+
`min_quote_fund_raising` in its config. `seedCostEstimate(client, tiers?, { extraSeedTokens?,
|
|
71
|
+
quote?, raise? })` reports the seed cost in the quote token, its decimals and symbol, the raise, and
|
|
72
|
+
`solAmount` through the route provider.
|
|
59
73
|
|
|
60
74
|
## The venue
|
|
61
75
|
|
|
@@ -64,11 +78,18 @@ what the handler watches: venue account rent, and the VRF request on a pack buy.
|
|
|
64
78
|
| `raydium.resolveVenue(client, { mint, user, venue? })` | `ResolvedVenue`: `kind`, `program`, `poolState`, `status`, `creator`, `ammConfig`, `remainingCurveBase`, `buyAccounts`, `sellAccounts`, `quoteBuy`, `quoteSell` |
|
|
65
79
|
| `raydium.curveQuote(client, mint, tokens)` | the buy price, for a display |
|
|
66
80
|
| `raydium.sellQuote(client, mint, tokens)` | the sale proceeds |
|
|
67
|
-
| `raydium.newCurveBuyCost(client, tokens)` | what a buy costs on a curve that does not exist yet |
|
|
68
|
-
| `raydium.findCpmmPool(client, { mint, creator, cpswapConfig })` | the migrated CPMM pool, proved from its own data |
|
|
69
|
-
| `raydium.fetchCurveSettings(client)` | the fee rates, the migrate fee and the CPMM fee tier, read from chain |
|
|
70
|
-
| `raydium.fetchCreatorFees(client, { creator, mint? })` | `{
|
|
71
|
-
| `raydium.
|
|
81
|
+
| `raydium.newCurveBuyCost(client, tokens, { quoteConfig, raise })` | what a buy costs on a curve that does not exist yet |
|
|
82
|
+
| `raydium.findCpmmPool(client, { mint, creator, cpswapConfig, quoteMint? })` | the migrated CPMM pool, proved from its own data |
|
|
83
|
+
| `raydium.fetchCurveSettings(client, quoteConfig)` | the fee rates, the migrate fee and the CPMM fee tier, read from chain |
|
|
84
|
+
| `raydium.fetchCreatorFees(client, { creator, mint?, quoteMint? })` | `{ quoteMint, curveQuote, cpmmQuote, cpmmTokens }` |
|
|
85
|
+
| `raydium.fetchQuoteConfig(client, mint)` | LaunchLab's global config for a quote, or `null` |
|
|
86
|
+
| `raydium.isQuoteSupported(client, mint)` | can a machine be priced in this mint? |
|
|
87
|
+
| `raydium.fetchQuoteAsset(client, mint)` | the config, token program, decimals, symbol and minimum raise |
|
|
88
|
+
| `raydium.quoteAccountFor(user, quoteMint, quoteTokenProgram)` | the account both venues settle in |
|
|
89
|
+
| `raydium.wsolAccountFor(user)` | the same, for a WSOL pool |
|
|
90
|
+
|
|
91
|
+
`resolveVenue` takes an optional `quote: { mint, config, tokenProgram }`. Left out, it reads the
|
|
92
|
+
Gabox pool for it, so a caller that already holds a `Pool` saves a round trip by passing it.
|
|
72
93
|
|
|
73
94
|
`resolveVenue` follows the LaunchLab pool's `status`: `0` routes to the curve, `2` to the CPMM pool,
|
|
74
95
|
and `1` throws because the coin is migrating right now. A migrated CPMM pool does not have to sit at
|
|
@@ -90,16 +111,47 @@ Raydium's.
|
|
|
90
111
|
shape. `raydium.getCurveBuyExactInInstruction(client, input, ids?)` builds a plain curve buy that
|
|
91
112
|
Gabox never makes itself; the devnet end-to-end test uses it to buy a curve out and force graduation.
|
|
92
113
|
|
|
114
|
+
`initialize_pool`'s `venue` account has no generated default, because LaunchLab has a different
|
|
115
|
+
address on each cluster and a default would be wrong on one of them. Every builder here passes it
|
|
116
|
+
from `raydiumIds(client.cluster)`; a caller using the generated builder directly has to do the same.
|
|
117
|
+
|
|
93
118
|
`raydiumIds(cluster)` gives one cluster's Raydium deployment. Mainnet and devnet run different
|
|
94
|
-
programs and PDAs, and
|
|
95
|
-
which is what the program's default build pins.
|
|
119
|
+
programs and PDAs, and a WSOL launch raises 3 SOL on devnet where mainnet raises 85. `localnet` uses
|
|
120
|
+
the mainnet set, which is what the program's default build pins.
|
|
121
|
+
|
|
122
|
+
## Routes
|
|
123
|
+
|
|
124
|
+
A route provider swaps SOL into a pool's quote token, and back. `createClient` gives mainnet
|
|
125
|
+
`jupiterRoute()` and every other cluster `null`; pass `route` to override, or `null` to switch the
|
|
126
|
+
swap leg off.
|
|
127
|
+
|
|
128
|
+
| Function | Result |
|
|
129
|
+
| --- | --- |
|
|
130
|
+
| `jupiterRoute({ url?, slippageBps? })` | a `RouteProvider` over Jupiter's swap API, for mainnet |
|
|
131
|
+
| `raydiumCpmmRoute(poolAddress)` | a `RouteProvider` over one Raydium CPMM pool, for devnet |
|
|
132
|
+
| `routeQuoteIn(client, provider, { quoteMint, amount, user })` | a swap that buys at least `amount`, exact-out first |
|
|
133
|
+
| `routeQuoteOut(client, provider, { quoteMint, amount, user })` | a swap that turns `amount` into SOL |
|
|
134
|
+
| `solPriceOf(client, quoteMint, amount)` | the exact-out SOL cost of `amount`, or `null` |
|
|
135
|
+
| `assertRouteIsSafe(route, { forbidden, settlesIn })` | refuse a route that touches Gabox state or settles elsewhere |
|
|
136
|
+
|
|
137
|
+
A `Route` is `{ instructions, lookupTables, inAmount, outAmount, mode, computeUnits }`. `mode` is
|
|
138
|
+
`'exactOut'` or `'exactIn'`: the amounts are bounds, so an exact-out route states the most it spends
|
|
139
|
+
and an exact-in route the least it pays out.
|
|
140
|
+
|
|
141
|
+
`computeUnits` is what the swap costs on top of the Gabox instruction, because the two share one
|
|
142
|
+
budget. A builder adds it to its own limit and caps the total at `MAX_COMPUTE_UNIT_LIMIT`; an
|
|
143
|
+
explicit `computeUnitLimit` still wins. Jupiter returns the number with the route, falling back to
|
|
144
|
+
`JUPITER_DEFAULT_COMPUTE_UNITS` when its response carries none; `raydiumCpmmRoute` uses
|
|
145
|
+
`CPMM_ROUTE_COMPUTE_UNITS`, measured on devnet, which holds because it is always one pool. Jupiter answers `NO_ROUTES_FOUND` for exact-out whenever the best route
|
|
146
|
+
has more than one hop, which is why `routeQuoteIn` falls back to exact-in and leaves the change in
|
|
147
|
+
the buyer's quote account.
|
|
96
148
|
|
|
97
149
|
## Events
|
|
98
150
|
|
|
99
151
|
`decodeEvents` and `fetchEvents` return only `PoolCreated`, `PrizesFunded`, `PackBought`,
|
|
100
152
|
`RandomnessRetried`, `DrawResolved` and `TokensSold`. None carries a Gabox fee field any more.
|
|
101
|
-
`PackBought` reports `quoteDebit` (what the venue charged
|
|
102
|
-
`vrfNativeDebit` and `totalNativeDebit`.
|
|
153
|
+
`PackBought` reports `quoteMint`, `quoteDebit` (what the venue charged, in that token),
|
|
154
|
+
`nativeDebit` (venue account rent), `vrfNativeDebit` and `totalNativeDebit`.
|
|
103
155
|
|
|
104
156
|
Delivery closes a draw atomically; use `findResolvedDraw` rather than a Ready or claim flow. It
|
|
105
157
|
searches a bounded recent signature history, so production indexers should persist `DrawResolved`
|