@gabox-labs/sdk 0.2.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 +310 -0
- package/README.md +173 -438
- package/dist/{gaboxV2-CV2XltqC.js → gabox-DGTCh34U.js} +575 -1584
- package/dist/gabox-DGTCh34U.js.map +1 -0
- package/dist/generated/index.d.ts +384 -752
- package/dist/generated/index.js +116 -338
- package/dist/generated/index.js.map +1 -1
- package/dist/index-C4at2cZ_.d.ts +1184 -0
- package/dist/index.d.ts +474 -432
- package/dist/index.js +1186 -1374
- package/dist/index.js.map +1 -1
- package/dist/raydium/index.d.ts +2 -0
- package/dist/raydium/index.js +2 -0
- package/dist/raydium-CU-tZzIk.js +3282 -0
- package/dist/raydium-CU-tZzIk.js.map +1 -0
- package/llms.txt +7 -3
- package/package.json +11 -16
- package/skills/gabox-sdk/SKILL.md +57 -146
- package/skills/gabox-sdk/references/api.md +155 -145
- package/dist/gaboxV2-CV2XltqC.js.map +0 -1
- package/dist/index-BxvSkzCO.d.ts +0 -471
- package/dist/pump/index.d.ts +0 -2
- package/dist/pump/index.js +0 -2
- package/dist/pump-D0K_0uiC.js +0 -1531
- package/dist/pump-D0K_0uiC.js.map +0 -1
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
import { AccountMeta, Address, AddressesByLookupTableAddress, Instruction, Rpc, RpcSubscriptions, SolanaRpcApi, SolanaRpcSubscriptionsApi, TransactionMessage, TransactionMessageWithBlockhashLifetime, TransactionMessageWithFeePayerSigner, TransactionSigner } from "@solana/kit";
|
|
2
|
+
//#region src/route/types.d.ts
|
|
3
|
+
/** Which of the two swap modes produced a route. */
|
|
4
|
+
type RouteMode = 'exactOut' | 'exactIn';
|
|
5
|
+
/** One priced swap, ready to put in a transaction message. */
|
|
6
|
+
type Route = {
|
|
7
|
+
/** The swap's own instructions, in order. No compute budget instruction is included. */
|
|
8
|
+
instructions: Instruction[];
|
|
9
|
+
/** The lookup tables the instructions above were compressed against. */
|
|
10
|
+
lookupTables: AddressesByLookupTableAddress;
|
|
11
|
+
/** The input amount. Exact for an exact-in route, a maximum for an exact-out one. */
|
|
12
|
+
inAmount: bigint;
|
|
13
|
+
/** The output amount. Exact for an exact-out route, a minimum for an exact-in one. */
|
|
14
|
+
outAmount: bigint;
|
|
15
|
+
mode: RouteMode;
|
|
16
|
+
/**
|
|
17
|
+
* The compute units this route needs, on top of what the Gabox instruction uses.
|
|
18
|
+
*
|
|
19
|
+
* The swap shares one transaction with the Gabox instruction, so it shares the budget too. Each
|
|
20
|
+
* provider states its own figure: Jupiter returns one with the route, and the CPMM provider uses
|
|
21
|
+
* a measured number, because it is always one pool. A builder adds this to its own limit and caps
|
|
22
|
+
* the total at the runtime's ceiling.
|
|
23
|
+
*/
|
|
24
|
+
computeUnits: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Something that can price and build a swap between two mints for one wallet.
|
|
28
|
+
*
|
|
29
|
+
* `client` comes first, the way every chain-touching function in this SDK takes it. `user` is the
|
|
30
|
+
* wallet that will sign: its token accounts are the swap's own source and destination, and the
|
|
31
|
+
* provider creates whichever of them is missing.
|
|
32
|
+
*/
|
|
33
|
+
type RouteProvider = {
|
|
34
|
+
/** Buy exactly `amount` of `output`, spending as much `input` as the route needs. */
|
|
35
|
+
exactOut(client: GaboxClient, input: Address, output: Address, amount: bigint, user: Address): Promise<Route>;
|
|
36
|
+
/** Spend exactly `amount` of `input` and take whatever `output` it buys. */
|
|
37
|
+
exactIn(client: GaboxClient, input: Address, output: Address, amount: bigint, user: Address): Promise<Route>;
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/rpc.d.ts
|
|
41
|
+
type Cluster = 'devnet' | 'mainnet-beta' | 'localnet';
|
|
42
|
+
/** Solana's public endpoints, and the test validator's default ports. */
|
|
43
|
+
declare const CLUSTER_ENDPOINTS: Readonly<Record<Cluster, {
|
|
44
|
+
url: string;
|
|
45
|
+
wsUrl: string;
|
|
46
|
+
}>>;
|
|
47
|
+
declare const DEVNET_HTTP: string;
|
|
48
|
+
declare const DEVNET_WS: string;
|
|
49
|
+
type GaboxRpc = Rpc<SolanaRpcApi>;
|
|
50
|
+
type GaboxRpcSubscriptions = RpcSubscriptions<SolanaRpcSubscriptionsApi>;
|
|
51
|
+
type ClientConfig = {
|
|
52
|
+
/** The cluster this client talks to. Required: see the file comment. */
|
|
53
|
+
cluster: Cluster;
|
|
54
|
+
/** HTTP endpoint. Defaults to the cluster's entry in `CLUSTER_ENDPOINTS`. */
|
|
55
|
+
url?: string;
|
|
56
|
+
/**
|
|
57
|
+
* WebSocket endpoint. Left out, it follows `url`: `https` becomes `wss`, `http` becomes `ws`.
|
|
58
|
+
* When `url` is left out too, it is the cluster's default.
|
|
59
|
+
*/
|
|
60
|
+
wsUrl?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Address lookup tables every builder compresses with. Defaults to the cluster's shared table,
|
|
63
|
+
* which only devnet has today; other clusters default to none. Pass `{}` to disable compression.
|
|
64
|
+
*/
|
|
65
|
+
addressLookupTables?: AddressesByLookupTableAddress;
|
|
66
|
+
/**
|
|
67
|
+
* How a buyer pays in SOL for a machine priced in another token.
|
|
68
|
+
*
|
|
69
|
+
* Mainnet defaults to Jupiter, which is where the liquidity is. Devnet and localnet default to
|
|
70
|
+
* none, because Jupiter does not serve them: pass `raydiumCpmmRoute(pool)` with a CPMM pool that
|
|
71
|
+
* holds the SOL/quote pair. `null` disables the swap leg, and `payWith: 'sol'` then fails on a
|
|
72
|
+
* pool quoted in anything but WSOL.
|
|
73
|
+
*/
|
|
74
|
+
route?: RouteProvider | null;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Everything the SDK needs to talk to one cluster. Pass it to every chain-touching function.
|
|
78
|
+
*
|
|
79
|
+
* A plain object, so a caller who needs a custom transport can spread it:
|
|
80
|
+
* `{ ...createClient({ cluster }), rpc: createSolanaRpcFromTransport(transport) }`.
|
|
81
|
+
*/
|
|
82
|
+
type GaboxClient = Readonly<{
|
|
83
|
+
cluster: Cluster;
|
|
84
|
+
url: string;
|
|
85
|
+
wsUrl: string;
|
|
86
|
+
rpc: GaboxRpc;
|
|
87
|
+
rpcSubscriptions: GaboxRpcSubscriptions;
|
|
88
|
+
addressLookupTables: AddressesByLookupTableAddress;
|
|
89
|
+
/** The swap provider a SOL payment routes through, or `null` when this cluster has none. */
|
|
90
|
+
route: RouteProvider | null;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* The cluster a URL names, from its text alone. A substring check, deliberately: providers spell
|
|
94
|
+
* it many ways. `null` when the URL names none, which is a local validator or a private endpoint.
|
|
95
|
+
*/
|
|
96
|
+
declare function clusterNamedBy(url: string): Cluster | 'testnet' | null;
|
|
97
|
+
/**
|
|
98
|
+
* Refuse a URL that contradicts the declared cluster. Exported so a script can check a URL before
|
|
99
|
+
* it does anything else with it. The rules are in the file comment.
|
|
100
|
+
*/
|
|
101
|
+
declare function assertClusterUrl(cluster: Cluster, url: string): void;
|
|
102
|
+
/** `https://x` becomes `wss://x`, `http://x` becomes `ws://x`. Anything else is returned as is. */
|
|
103
|
+
declare function websocketUrlFor(url: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* The SDK's init step. Call it once and pass the result everywhere.
|
|
106
|
+
*
|
|
107
|
+
* Both RPC clients are created together because everything in this SDK that watches a draw needs
|
|
108
|
+
* the pair: the subscription reports the change, and the RPC reads the account that changed.
|
|
109
|
+
*/
|
|
110
|
+
declare function createClient(config: ClientConfig): GaboxClient;
|
|
111
|
+
/**
|
|
112
|
+
* The swap provider a cluster gets when the caller names none.
|
|
113
|
+
*
|
|
114
|
+
* Jupiter on mainnet, nothing anywhere else. Jupiter's API only prices mainnet liquidity, and a
|
|
115
|
+
* devnet caller has to say which pool to route through, so there is nothing to guess.
|
|
116
|
+
*/
|
|
117
|
+
declare function defaultRoute(cluster: Cluster): RouteProvider | null;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/raydium/abi.d.ts
|
|
120
|
+
/** One account slot: its IDL name and the privileges the venue's own ABI gives it. */
|
|
121
|
+
type VenueAccountSpec = {
|
|
122
|
+
readonly name: string;
|
|
123
|
+
readonly writable: boolean;
|
|
124
|
+
readonly signer: boolean;
|
|
125
|
+
};
|
|
126
|
+
type VenueInstructionAbi = {
|
|
127
|
+
readonly name: string;
|
|
128
|
+
readonly discriminator: Uint8Array;
|
|
129
|
+
readonly accounts: readonly VenueAccountSpec[];
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* The Raydium deployment of one cluster. Mainnet and devnet run different programs, so every
|
|
133
|
+
* address here differs between the two.
|
|
134
|
+
*
|
|
135
|
+
* Two things are deliberately absent, and both for the same reason: the program reads them from
|
|
136
|
+
* the chain instead of pinning them. The CPMM fee tier comes from the Gabox platform config and
|
|
137
|
+
* from the migrated pool's own data. The quote assets come from Raydium's own LaunchLab
|
|
138
|
+
* `GlobalConfig` accounts, one per quote mint, so there is no list of quotes here.
|
|
139
|
+
*/
|
|
140
|
+
type RaydiumClusterIds = {
|
|
141
|
+
/** Raydium LaunchLab, the bonding curve a Gabox coin launches and trades on first. */
|
|
142
|
+
readonly launchlab: Address;
|
|
143
|
+
/** PDA(["vault_auth_seed"], launchlab). Signs LaunchLab's own vault transfers. */
|
|
144
|
+
readonly launchlabAuthority: Address;
|
|
145
|
+
/** PDA(["__event_authority"], launchlab). */
|
|
146
|
+
readonly launchlabEventAuthority: Address;
|
|
147
|
+
/** PDA(["platform_config", PLATFORM_ADMIN], launchlab). The Gabox platform on LaunchLab. */
|
|
148
|
+
readonly gaboxPlatform: Address;
|
|
149
|
+
/** Raydium CPMM, the pool a Gabox coin graduates into. */
|
|
150
|
+
readonly cpmm: Address;
|
|
151
|
+
/** PDA(["vault_and_lp_mint_auth_seed"], cpmm). */
|
|
152
|
+
readonly cpmmAuthority: Address;
|
|
153
|
+
/**
|
|
154
|
+
* The raise a WSOL-quoted curve must reach before the coin graduates, in lamports.
|
|
155
|
+
*
|
|
156
|
+
* The program pins this one value, and only for a WSOL pool: it knows what SOL is worth to its
|
|
157
|
+
* own product and cannot say the same about USDC or a stock token. A pool quoted in any other
|
|
158
|
+
* asset picks its own raise, and LaunchLab checks it against `min_quote_fund_raising` in that
|
|
159
|
+
* quote's own global config.
|
|
160
|
+
*/
|
|
161
|
+
readonly launchQuoteRaise: bigint;
|
|
162
|
+
};
|
|
163
|
+
declare const RAYDIUM_MAINNET_IDS: RaydiumClusterIds;
|
|
164
|
+
declare const RAYDIUM_DEVNET_IDS: RaydiumClusterIds;
|
|
165
|
+
/**
|
|
166
|
+
* Wrapped SOL: the default quote, and the one every price in SOL is measured in. Gabox accepts any
|
|
167
|
+
* quote Raydium enabled on LaunchLab, so this is not the only one.
|
|
168
|
+
*/
|
|
169
|
+
declare const WSOL_MINT: Address;
|
|
170
|
+
/** Metaplex Token Metadata, which LaunchLab's create instruction writes to. */
|
|
171
|
+
declare const METAPLEX_PROGRAM_ADDRESS: Address;
|
|
172
|
+
/**
|
|
173
|
+
* `PLATFORM_ADMIN` in the program's constants.rs. The Gabox platform config PDA derives from this
|
|
174
|
+
* wallet, and LaunchLab pays the platform share of every curve trade to it.
|
|
175
|
+
*/
|
|
176
|
+
declare const PLATFORM_ADMIN: Address;
|
|
177
|
+
/** The coin supply every Gabox launch mints: 1,000,000,000 coins at 6 decimals. */
|
|
178
|
+
declare const LAUNCH_SUPPLY = 1000000000000000n;
|
|
179
|
+
/** The part of the supply the LaunchLab curve sells: 793,100,000 coins. */
|
|
180
|
+
declare const LAUNCH_TOTAL_BASE_SELL = 793100000000000n;
|
|
181
|
+
/** Classic SPL Token. The base coin is always under it, on both venues. */
|
|
182
|
+
declare const TOKEN_PROGRAM_ADDRESS: Address;
|
|
183
|
+
/**
|
|
184
|
+
* Token-2022. A quote mint may be under it, inside the bounded profile the program's
|
|
185
|
+
* `tokens::validate_quote_mint` accepts. The base coin never is.
|
|
186
|
+
*/
|
|
187
|
+
declare const TOKEN_2022_PROGRAM_ADDRESS: Address;
|
|
188
|
+
declare const ASSOCIATED_TOKEN_PROGRAM_ADDRESS: Address;
|
|
189
|
+
declare const SYSTEM_PROGRAM_ADDRESS: Address;
|
|
190
|
+
/** The rent sysvar. LaunchLab's create instruction still takes it. */
|
|
191
|
+
declare const RENT_SYSVAR_ADDRESS: Address;
|
|
192
|
+
/**
|
|
193
|
+
* The first eight bytes of each Raydium account this SDK decodes. `adapter.ts` checks them before
|
|
194
|
+
* it reads a field, so an account of the wrong type fails loudly instead of decoding as rubbish.
|
|
195
|
+
*
|
|
196
|
+
* LaunchLab and CPMM give their pool account the same eight bytes, because Anchor derives a
|
|
197
|
+
* discriminator from the struct name alone and both are called `PoolState`. The two programs own
|
|
198
|
+
* different accounts, so the pair never collides in practice.
|
|
199
|
+
*/
|
|
200
|
+
declare const LAUNCHLAB_POOL_STATE_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
201
|
+
declare const LAUNCHLAB_GLOBAL_CONFIG_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
202
|
+
declare const LAUNCHLAB_PLATFORM_CONFIG_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
203
|
+
declare const CPMM_POOL_STATE_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
204
|
+
declare const CPMM_AMM_CONFIG_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
205
|
+
/**
|
|
206
|
+
* `initialize_v2` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — cross-checked against interfaces.json.
|
|
207
|
+
*/
|
|
208
|
+
declare const LAUNCHLAB_INITIALIZE: VenueInstructionAbi;
|
|
209
|
+
/**
|
|
210
|
+
* `buy_exact_in` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — not in interfaces.json (the program never builds it).
|
|
211
|
+
* The last three accounts are not in the IDL. LaunchLab reads them from the remaining
|
|
212
|
+
* accounts, in this order.
|
|
213
|
+
*/
|
|
214
|
+
declare const LAUNCHLAB_BUY_EXACT_IN: VenueInstructionAbi;
|
|
215
|
+
/**
|
|
216
|
+
* `buy_exact_out` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — cross-checked against interfaces.json.
|
|
217
|
+
* The last three accounts are not in the IDL. LaunchLab reads them from the remaining
|
|
218
|
+
* accounts, in this order.
|
|
219
|
+
*/
|
|
220
|
+
declare const LAUNCHLAB_BUY_EXACT_OUT: VenueInstructionAbi;
|
|
221
|
+
/**
|
|
222
|
+
* `sell_exact_in` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — cross-checked against interfaces.json.
|
|
223
|
+
* The last three accounts are not in the IDL. LaunchLab reads them from the remaining
|
|
224
|
+
* accounts, in this order.
|
|
225
|
+
*/
|
|
226
|
+
declare const LAUNCHLAB_SELL_EXACT_IN: VenueInstructionAbi;
|
|
227
|
+
/**
|
|
228
|
+
* `claim_creator_fee` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — not in interfaces.json (the program never builds it).
|
|
229
|
+
*/
|
|
230
|
+
declare const LAUNCHLAB_CLAIM_CREATOR_FEE: VenueInstructionAbi;
|
|
231
|
+
/**
|
|
232
|
+
* `swap_base_output` on `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C` — cross-checked against interfaces.json.
|
|
233
|
+
*/
|
|
234
|
+
declare const CPMM_SWAP_BASE_OUTPUT: VenueInstructionAbi;
|
|
235
|
+
/**
|
|
236
|
+
* `swap_base_input` on `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C` — cross-checked against interfaces.json.
|
|
237
|
+
*/
|
|
238
|
+
declare const CPMM_SWAP_BASE_INPUT: VenueInstructionAbi;
|
|
239
|
+
/**
|
|
240
|
+
* `collect_creator_fee` on `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C` — not in interfaces.json (the program never builds it).
|
|
241
|
+
* The last account is not in the IDL snapshot; see `CPMM_CREATOR_FEE_SHARE_ACCOUNT` in
|
|
242
|
+
* scripts/codegen.mjs. Derive it as PDA(["creator_fee_share", creator, amm_config]).
|
|
243
|
+
*/
|
|
244
|
+
declare const CPMM_COLLECT_CREATOR_FEE: VenueInstructionAbi;
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/raydium/ids.d.ts
|
|
247
|
+
/** The name the rest of the SDK uses for one cluster's Raydium deployment. */
|
|
248
|
+
type RaydiumIds = RaydiumClusterIds;
|
|
249
|
+
/**
|
|
250
|
+
* The decimals every Gabox coin is launched with. `venue/launch.rs` refuses any other value, and
|
|
251
|
+
* `tokens.rs` refuses a pool mint that does not have exactly this many.
|
|
252
|
+
*/
|
|
253
|
+
declare const LAUNCH_DECIMALS = 6;
|
|
254
|
+
/**
|
|
255
|
+
* The Raydium deployment of each cluster.
|
|
256
|
+
*
|
|
257
|
+
* `localnet` uses the mainnet set. A local validator normally clones the mainnet Raydium programs,
|
|
258
|
+
* and the program's own default `anchor build` pins the mainnet addresses too; the `devnet` cargo
|
|
259
|
+
* feature is what swaps them. Pass your own ids to a builder if your validator clones devnet.
|
|
260
|
+
*/
|
|
261
|
+
declare const RAYDIUM_IDS: Readonly<Record<Cluster, RaydiumIds>>;
|
|
262
|
+
/** The Raydium deployment one cluster trades on. Throws for a cluster this SDK does not know. */
|
|
263
|
+
declare function raydiumIds(cluster: Cluster): RaydiumIds;
|
|
264
|
+
/** LaunchLab's PDA seeds, and the two Gabox coins are always sorted against. */
|
|
265
|
+
declare const LAUNCHLAB_SEEDS: {
|
|
266
|
+
/** `["vault_auth_seed"]`. */
|
|
267
|
+
readonly authority: "vault_auth_seed";
|
|
268
|
+
/** `["__event_authority"]`. */
|
|
269
|
+
readonly eventAuthority: "__event_authority";
|
|
270
|
+
/** `["global_config", quote_mint, u8 curve_type, u16 big-endian index]`. */
|
|
271
|
+
readonly globalConfig: "global_config";
|
|
272
|
+
/** `["platform_config", platform_admin]`. */
|
|
273
|
+
readonly platformConfig: "platform_config";
|
|
274
|
+
/** `["pool", base_mint, quote_mint]`. */
|
|
275
|
+
readonly pool: "pool";
|
|
276
|
+
/** `["pool_vault", pool_state, mint]`. */
|
|
277
|
+
readonly vault: "pool_vault";
|
|
278
|
+
/** `["creator_fee_vault_auth_seed"]`, the authority over every creator fee vault. */
|
|
279
|
+
readonly creatorFeeVaultAuthority: "creator_fee_vault_auth_seed";
|
|
280
|
+
};
|
|
281
|
+
/** CPMM's PDA seeds. */
|
|
282
|
+
declare const CPMM_SEEDS: {
|
|
283
|
+
/** `["vault_and_lp_mint_auth_seed"]`. */
|
|
284
|
+
readonly authority: "vault_and_lp_mint_auth_seed";
|
|
285
|
+
/** `["pool", amm_config, token_0_mint, token_1_mint]`, the mints sorted by byte order. */
|
|
286
|
+
readonly pool: "pool";
|
|
287
|
+
/** `["pool_vault", pool_state, mint]`. */
|
|
288
|
+
readonly vault: "pool_vault";
|
|
289
|
+
/** `["observation", pool_state]`. */
|
|
290
|
+
readonly observation: "observation";
|
|
291
|
+
/** `["creator_fee_share", creator, amm_config]`. */
|
|
292
|
+
readonly creatorFeeShare: "creator_fee_share";
|
|
293
|
+
};
|
|
294
|
+
/** Metaplex's metadata PDA seed: `["metadata", metaplex, mint]`. */
|
|
295
|
+
declare const METADATA_SEED = "metadata";
|
|
296
|
+
/**
|
|
297
|
+
* Every rate LaunchLab and CPMM state is out of 1,000,000, not out of 10,000. A `trade_fee_rate`
|
|
298
|
+
* of 5,000 is 0.5%.
|
|
299
|
+
*/
|
|
300
|
+
declare const RATE_DENOMINATOR = 1000000n;
|
|
301
|
+
/** The share-fee receiver Gabox never passes, so its rate is always zero on every trade. */
|
|
302
|
+
declare const SHARE_FEE_RATE = 0n;
|
|
303
|
+
/** `CurveParams::Constant`, the only curve shape Gabox launches. */
|
|
304
|
+
declare const CONSTANT_CURVE_TAG = 0;
|
|
305
|
+
/** `migrate_type` 1: the coin graduates into a CPMM pool, not into an AMM pool. */
|
|
306
|
+
declare const MIGRATE_TO_CPMM = 1;
|
|
307
|
+
/** `AmmCreatorFeeOn::QuoteToken`, so the CPMM creator fee is paid in the pool's quote asset. */
|
|
308
|
+
declare const CREATOR_FEE_ON_QUOTE = 0;
|
|
309
|
+
/** LaunchLab pool `status`: still selling on the curve. */
|
|
310
|
+
declare const LAUNCHLAB_STATUS_FUND = 0;
|
|
311
|
+
/** LaunchLab pool `status`: the raise is complete and Raydium's bot is migrating the coin. */
|
|
312
|
+
declare const LAUNCHLAB_STATUS_MIGRATE = 1;
|
|
313
|
+
/** LaunchLab pool `status`: the coin has graduated and trades on its CPMM pool. */
|
|
314
|
+
declare const LAUNCHLAB_STATUS_TRADE = 2;
|
|
315
|
+
/** Metaplex's own limits on the three strings a creator picks, in UTF-8 bytes. */
|
|
316
|
+
declare const METADATA_LIMITS: {
|
|
317
|
+
readonly name: 32;
|
|
318
|
+
readonly symbol: 10;
|
|
319
|
+
readonly uri: 200;
|
|
320
|
+
};
|
|
321
|
+
/** Raydium sorts a CPMM pair by raw address byte order. */
|
|
322
|
+
declare function sortedMints(a: Address, b: Address): [Address, Address];
|
|
323
|
+
/** Compare two addresses the way the runtime does: by their 32 raw bytes, not by base58 text. */
|
|
324
|
+
declare function compareAddresses(a: Address, b: Address): number;
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/raydium/adapter.d.ts
|
|
327
|
+
/**
|
|
328
|
+
* The `amount` field of an SPL token account: bytes 64 to 72, little-endian.
|
|
329
|
+
*
|
|
330
|
+
* Both venues and every Gabox account use classic SPL Token, whose account is 165 bytes. The
|
|
331
|
+
* Token-2022 layout shares those first 165 bytes, so this reader covers a Token-2022 account too.
|
|
332
|
+
*/
|
|
333
|
+
declare function tokenAccountAmount(data: Uint8Array): bigint;
|
|
334
|
+
/** The `mint` and `owner` of an SPL token account: bytes 0 to 32 and 32 to 64. */
|
|
335
|
+
declare function tokenAccountOwnerAndMint(data: Uint8Array): {
|
|
336
|
+
mint: Address;
|
|
337
|
+
owner: Address;
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* The `decimals` of a mint. Both token programs share the first 82 bytes, so one reader covers a
|
|
341
|
+
* classic SPL mint and a Token-2022 one.
|
|
342
|
+
*/
|
|
343
|
+
declare function mintDecimals(data: Uint8Array): number;
|
|
344
|
+
/**
|
|
345
|
+
* The `symbol` of a Metaplex token metadata account, or `null` when it carries none.
|
|
346
|
+
*
|
|
347
|
+
* Layout: a one-byte key, `update_authority` and `mint`, then the three Borsh strings `name`,
|
|
348
|
+
* `symbol` and `uri`. Metaplex stores them at their maximum length, NUL padded.
|
|
349
|
+
*/
|
|
350
|
+
declare function metaplexSymbol(data: Uint8Array): string | null;
|
|
351
|
+
/**
|
|
352
|
+
* The `symbol` a Token-2022 mint stores in its own `TokenMetadata` extension, or `null`.
|
|
353
|
+
*
|
|
354
|
+
* The extensions are a TLV list: a u16 type, a u16 length, then the value. The metadata value is
|
|
355
|
+
* `update_authority`, `mint`, then the Borsh strings `name`, `symbol` and `uri`.
|
|
356
|
+
*/
|
|
357
|
+
declare function token2022Symbol(data: Uint8Array): string | null;
|
|
358
|
+
/** The curve pool of one coin, as far as pricing and routing need it. */
|
|
359
|
+
type LaunchlabPoolState = {
|
|
360
|
+
/** 0 while the curve still sells, 1 while Raydium migrates the coin, 2 once it has graduated. */
|
|
361
|
+
status: number;
|
|
362
|
+
baseDecimals: number;
|
|
363
|
+
quoteDecimals: number;
|
|
364
|
+
/** 1 means the coin graduates into a CPMM pool. Every Gabox launch pins this. */
|
|
365
|
+
migrateType: number;
|
|
366
|
+
supply: bigint;
|
|
367
|
+
/** The part of the supply the curve sells. The curve cannot sell more than this. */
|
|
368
|
+
totalBaseSell: bigint;
|
|
369
|
+
/** The curve's virtual reserves. `virtualQuote / virtualBase` is the starting price. */
|
|
370
|
+
virtualBase: bigint;
|
|
371
|
+
virtualQuote: bigint;
|
|
372
|
+
/** Coins the curve has already sold, and quote it has already raised. */
|
|
373
|
+
realBase: bigint;
|
|
374
|
+
realQuote: bigint;
|
|
375
|
+
totalQuoteFundRaising: bigint;
|
|
376
|
+
migrateFee: bigint;
|
|
377
|
+
globalConfig: Address;
|
|
378
|
+
platformConfig: Address;
|
|
379
|
+
baseMint: Address;
|
|
380
|
+
quoteMint: Address;
|
|
381
|
+
baseVault: Address;
|
|
382
|
+
quoteVault: Address;
|
|
383
|
+
/** The coin creator. LaunchLab pays the creator share of every trade to this wallet's vault. */
|
|
384
|
+
creator: Address;
|
|
385
|
+
/** 0 means the CPMM creator fee is paid in the quote token only. Every Gabox launch pins it. */
|
|
386
|
+
ammCreatorFeeOn: number;
|
|
387
|
+
};
|
|
388
|
+
/** The bytes the decoder above reads, discriminator included. The account itself is longer. */
|
|
389
|
+
declare const LAUNCHLAB_POOL_STATE_HEAD_SIZE = 367;
|
|
390
|
+
declare function decodeLaunchlabPool(data: Uint8Array): LaunchlabPoolState;
|
|
391
|
+
/**
|
|
392
|
+
* LaunchLab's settings for one quote asset.
|
|
393
|
+
*
|
|
394
|
+
* One of these exists for every quote Raydium enabled, and only Raydium's admin can create one. So
|
|
395
|
+
* the account itself is what proves a quote is allowed: the program checks the same four things in
|
|
396
|
+
* `venue/launch.rs` before it opens a pool.
|
|
397
|
+
*/
|
|
398
|
+
type LaunchlabGlobalConfig = {
|
|
399
|
+
/** 0 is the constant product curve, the only shape Gabox launches. */
|
|
400
|
+
curveType: number;
|
|
401
|
+
index: number;
|
|
402
|
+
/** The quote LaunchLab keeps at graduation. It lowers the curve's own starting reserves. */
|
|
403
|
+
migrateFee: bigint;
|
|
404
|
+
/** Raydium's own share of every curve trade, out of 1,000,000. */
|
|
405
|
+
tradeFeeRate: bigint;
|
|
406
|
+
/** The smallest raise LaunchLab accepts for this quote, in its own base units. */
|
|
407
|
+
minQuoteFundRaising: bigint;
|
|
408
|
+
quoteMint: Address;
|
|
409
|
+
};
|
|
410
|
+
declare const LAUNCHLAB_GLOBAL_CONFIG_HEAD_SIZE = 115;
|
|
411
|
+
declare function decodeLaunchlabGlobalConfig(data: Uint8Array): LaunchlabGlobalConfig;
|
|
412
|
+
/** The Gabox platform on LaunchLab. Its two rates are the platform and creator shares. */
|
|
413
|
+
type LaunchlabPlatformConfig = {
|
|
414
|
+
/** Receives the platform share of every curve trade. */
|
|
415
|
+
platformFeeWallet: Address;
|
|
416
|
+
/** The platform share of every curve trade, out of 1,000,000. 5,000 is 0.5%. */
|
|
417
|
+
feeRate: bigint;
|
|
418
|
+
/** The coin creator's share of every curve trade, out of 1,000,000. 5,000 is 0.5%. */
|
|
419
|
+
creatorFeeRate: bigint;
|
|
420
|
+
/** The CPMM fee tier a coin of this platform graduates into. */
|
|
421
|
+
cpswapConfig: Address;
|
|
422
|
+
/**
|
|
423
|
+
* When this is a real wallet, it becomes the CPMM pool creator at graduation instead of the coin
|
|
424
|
+
* creator. Gabox leaves it empty, so its coin creators keep the CPMM creator fee.
|
|
425
|
+
*/
|
|
426
|
+
platformCpCreator: Address;
|
|
427
|
+
};
|
|
428
|
+
/** Everything before `curve_params`, discriminator included. */
|
|
429
|
+
declare const LAUNCHLAB_PLATFORM_CONFIG_HEAD_SIZE: number;
|
|
430
|
+
declare function decodeLaunchlabPlatformConfig(data: Uint8Array): LaunchlabPlatformConfig;
|
|
431
|
+
/** The pool a graduated Gabox coin trades in. */
|
|
432
|
+
type CpmmPoolState = {
|
|
433
|
+
ammConfig: Address;
|
|
434
|
+
/** LaunchLab sets this to the coin creator at migration. It earns the CPMM creator fee. */
|
|
435
|
+
poolCreator: Address;
|
|
436
|
+
token0Vault: Address;
|
|
437
|
+
token1Vault: Address;
|
|
438
|
+
token0Mint: Address;
|
|
439
|
+
token1Mint: Address;
|
|
440
|
+
token0Program: Address;
|
|
441
|
+
token1Program: Address;
|
|
442
|
+
observationKey: Address;
|
|
443
|
+
/** Bit flags. Bit 2 set (value 4) means swaps are switched off. */
|
|
444
|
+
status: number;
|
|
445
|
+
mint0Decimals: number;
|
|
446
|
+
mint1Decimals: number;
|
|
447
|
+
/** Fees the pool owes and a swap must not spend. Subtract them from the vault balances. */
|
|
448
|
+
protocolFeesToken0: bigint;
|
|
449
|
+
protocolFeesToken1: bigint;
|
|
450
|
+
fundFeesToken0: bigint;
|
|
451
|
+
fundFeesToken1: bigint;
|
|
452
|
+
creatorFeesToken0: bigint;
|
|
453
|
+
creatorFeesToken1: bigint;
|
|
454
|
+
/** Unix seconds. Swaps fail before it. */
|
|
455
|
+
openTime: bigint;
|
|
456
|
+
/** 0 charges the creator fee on whichever token comes in, 1 only token 0, 2 only token 1. */
|
|
457
|
+
creatorFeeOn: number;
|
|
458
|
+
/** `false` switches the creator fee off entirely. */
|
|
459
|
+
enableCreatorFee: boolean;
|
|
460
|
+
};
|
|
461
|
+
declare const CPMM_POOL_STATE_HEAD_SIZE = 413;
|
|
462
|
+
/**
|
|
463
|
+
* The full byte length of a CPMM `PoolState`, trailing padding included. A `getProgramAccounts`
|
|
464
|
+
* scan filters on it, so it has to be the whole account and not only the part decoded above.
|
|
465
|
+
*/
|
|
466
|
+
declare const CPMM_POOL_STATE_SIZE = 637;
|
|
467
|
+
/**
|
|
468
|
+
* Byte offsets a `getProgramAccounts` scan matches on. They are the same offsets `venue/trade.rs`
|
|
469
|
+
* reads the fields at, so a pool that passes the scan passes the program's own check.
|
|
470
|
+
*/
|
|
471
|
+
declare const CPMM_POOL_OFFSETS: {
|
|
472
|
+
readonly ammConfig: 8;
|
|
473
|
+
readonly poolCreator: 40;
|
|
474
|
+
readonly token0Mint: 168;
|
|
475
|
+
readonly token1Mint: 200;
|
|
476
|
+
readonly enableCreatorFee: 390;
|
|
477
|
+
};
|
|
478
|
+
declare function decodeCpmmPool(data: Uint8Array): CpmmPoolState;
|
|
479
|
+
/** One CPMM fee tier. Every rate is out of 1,000,000. */
|
|
480
|
+
type CpmmAmmConfig = {
|
|
481
|
+
index: number;
|
|
482
|
+
disableCreatePool: boolean;
|
|
483
|
+
/** The pool's own fee on every swap. Devnet tier 5 is 5,000, which is 0.50%. */
|
|
484
|
+
tradeFeeRate: bigint;
|
|
485
|
+
/** Raydium's share of the trade fee, not an extra charge on the swap. */
|
|
486
|
+
protocolFeeRate: bigint;
|
|
487
|
+
fundFeeRate: bigint;
|
|
488
|
+
/** The pool creator's fee on every swap. Devnet tier 5 is 4,000, which is 0.40%. */
|
|
489
|
+
creatorFeeRate: bigint;
|
|
490
|
+
};
|
|
491
|
+
declare const CPMM_AMM_CONFIG_HEAD_SIZE = 116;
|
|
492
|
+
declare function decodeCpmmAmmConfig(data: Uint8Array): CpmmAmmConfig;
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/raydium/curve.d.ts
|
|
495
|
+
/**
|
|
496
|
+
* Raydium's own price math, ported to bigint.
|
|
497
|
+
*
|
|
498
|
+
* Every function here is a line-by-line port of Raydium's TypeScript, which is itself the same math
|
|
499
|
+
* their on-chain programs run. The point is that a buyer sees the exact number the venue will
|
|
500
|
+
* charge, not an estimate: `buy_pack` passes the pack size as an exact-tokens-out amount, and the
|
|
501
|
+
* program then requires the token delta to equal one pack.
|
|
502
|
+
*
|
|
503
|
+
* Sources, read on 2026-09-18:
|
|
504
|
+
*
|
|
505
|
+
* - `raydium/launchpad/curve/constantProductCurve.ts` and `curve.ts` (LaunchLab)
|
|
506
|
+
* - `raydium/cpmm/curve/calculator.ts`, `constantProduct.ts` and `fee.ts` (CPMM)
|
|
507
|
+
*
|
|
508
|
+
* Raydium uses `BN`, which truncates toward zero on division. Every value here is a non-negative
|
|
509
|
+
* bigint, where `/` truncates the same way, so a plain `/` is the faithful port of their `.div()`.
|
|
510
|
+
* Where they round up they call a ceiling helper, and so does this file. Nothing is approximated
|
|
511
|
+
* and no step is reordered: a division that happens before a subtraction there happens before it
|
|
512
|
+
* here, because the two orders give different answers.
|
|
513
|
+
*
|
|
514
|
+
* Every rate is out of 1,000,000, not out of 10,000.
|
|
515
|
+
*/
|
|
516
|
+
/** `ceilDiv(a, b, denominator)` in Raydium's code: `ceil(a * b / denominator)`. */
|
|
517
|
+
declare function ceilDivRate(amount: bigint, rate: bigint, denominator?: bigint): bigint;
|
|
518
|
+
/** `ceil(numerator / denominator)` for non-negative values. */
|
|
519
|
+
declare function ceilDiv(numerator: bigint, denominator: bigint): bigint;
|
|
520
|
+
/**
|
|
521
|
+
* The amount before a fee was taken, given the amount after it: `ceil(post * 1e6 / (1e6 - rate))`.
|
|
522
|
+
*
|
|
523
|
+
* Raydium calls this `calculatePreFee` on the curve and `calculatePreFeeAmount` on CPMM. Both are
|
|
524
|
+
* the same expression.
|
|
525
|
+
*/
|
|
526
|
+
declare function preFeeAmount(postFeeAmount: bigint, rate: bigint): bigint;
|
|
527
|
+
/** The four reserve numbers a curve price depends on. Read them off the pool account. */
|
|
528
|
+
type CurveReserves = {
|
|
529
|
+
virtualBase: bigint;
|
|
530
|
+
virtualQuote: bigint;
|
|
531
|
+
realBase: bigint;
|
|
532
|
+
realQuote: bigint;
|
|
533
|
+
/** The most the curve will ever sell. A buy larger than what is left is capped at it. */
|
|
534
|
+
totalBaseSell: bigint;
|
|
535
|
+
};
|
|
536
|
+
/** The three fee rates a curve trade pays, each out of 1,000,000. */
|
|
537
|
+
type CurveFeeRates = {
|
|
538
|
+
/** `trade_fee_rate` on LaunchLab's global config: Raydium's own share. */
|
|
539
|
+
tradeFeeRate: bigint;
|
|
540
|
+
/** `fee_rate` on the platform config: the Gabox platform's share. */
|
|
541
|
+
platformFeeRate: bigint;
|
|
542
|
+
/** `creator_fee_rate` on the platform config: the coin creator's share. */
|
|
543
|
+
creatorFeeRate: bigint;
|
|
544
|
+
};
|
|
545
|
+
/**
|
|
546
|
+
* The whole fee a curve trade pays. Gabox never passes a share-fee receiver, so the fourth rate
|
|
547
|
+
* Raydium supports is always zero and is left out here.
|
|
548
|
+
*/
|
|
549
|
+
declare function totalCurveFeeRate(rates: CurveFeeRates): bigint;
|
|
550
|
+
/** Coins the curve still has to sell. A buy cannot take more than this. */
|
|
551
|
+
declare function remainingBase(pool: CurveReserves): bigint;
|
|
552
|
+
/**
|
|
553
|
+
* Quote needed to buy exactly `tokens` coins on the curve, fees included.
|
|
554
|
+
*
|
|
555
|
+
* This is `Curve.buyExactOut` with no token transfer fee, which is always the case for Gabox: both
|
|
556
|
+
* mints are classic SPL Token and carry no transfer-fee extension.
|
|
557
|
+
*
|
|
558
|
+
* Raydium caps the amount at what the curve has left to sell and still returns a price, so this
|
|
559
|
+
* does the same. A caller that needs the whole `tokens` must check `remainingBase` first;
|
|
560
|
+
* `resolveVenue` does.
|
|
561
|
+
*/
|
|
562
|
+
declare function curveBuyExactOut(pool: CurveReserves, rates: CurveFeeRates, tokens: bigint): bigint;
|
|
563
|
+
/**
|
|
564
|
+
* Coins `quote` buys on the curve right now, fees already taken off the spend.
|
|
565
|
+
*
|
|
566
|
+
* This is `Curve.buyExactIn`. It is what a raw `buy_exact_in` pays out, which the devnet end-to-end
|
|
567
|
+
* test uses to push a curve to graduation.
|
|
568
|
+
*/
|
|
569
|
+
declare function curveBuyExactIn(pool: CurveReserves, rates: CurveFeeRates, quote: bigint): bigint;
|
|
570
|
+
/**
|
|
571
|
+
* Quote a sale of exactly `tokens` coins returns, net of fees. This is `Curve.sellExactIn`.
|
|
572
|
+
*/
|
|
573
|
+
declare function curveSellExactIn(pool: CurveReserves, rates: CurveFeeRates, tokens: bigint): bigint;
|
|
574
|
+
/** What a launch pins, and what the starting reserves follow from. */
|
|
575
|
+
type LaunchParams = {
|
|
576
|
+
/** The whole supply the coin is minted with. */
|
|
577
|
+
supply: bigint;
|
|
578
|
+
/** The part of it the curve sells. */
|
|
579
|
+
totalBaseSell: bigint;
|
|
580
|
+
/** The quote the curve must raise before the coin graduates. */
|
|
581
|
+
quoteRaise: bigint;
|
|
582
|
+
/** Coins locked in a vesting schedule. Always zero for a Gabox launch. */
|
|
583
|
+
totalLockedAmount?: bigint;
|
|
584
|
+
/** The quote LaunchLab keeps at graduation, from its global config. */
|
|
585
|
+
migrateFee?: bigint;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* The virtual reserves LaunchLab gives a coin that does not exist yet.
|
|
589
|
+
*
|
|
590
|
+
* This is `LaunchConstantProductCurve.getInitParam`. `createMachine` needs it because the seed buy
|
|
591
|
+
* runs in the same transaction that creates the coin: there is no pool account to read yet, and the
|
|
592
|
+
* reserves follow from the pinned launch shape alone.
|
|
593
|
+
*
|
|
594
|
+
* Checked against Raydium's own published numbers for the mainnet Gabox launch shape (supply
|
|
595
|
+
* 1,000,000,000 coins, 793,100,000 sold on the curve, 85 SOL raised, no migrate fee):
|
|
596
|
+
* `virtualBase` 1,073,025,605,596,382 and `virtualQuote` 30,000,852,951.
|
|
597
|
+
*/
|
|
598
|
+
declare function initialCurve(params: LaunchParams): CurveReserves;
|
|
599
|
+
/** One side of a CPMM swap, after the pool's own unspendable fee balances are taken off. */
|
|
600
|
+
type CpmmSwapSides = {
|
|
601
|
+
/** Token going in: the quote on a buy, the coin on a sell. */
|
|
602
|
+
inputReserve: bigint;
|
|
603
|
+
/** Token coming out: the coin on a buy, the quote on a sell. */
|
|
604
|
+
outputReserve: bigint;
|
|
605
|
+
};
|
|
606
|
+
/** The two CPMM rates, each out of 1,000,000, plus where the creator fee is charged. */
|
|
607
|
+
type CpmmFeeRates = {
|
|
608
|
+
/** `trade_fee_rate` on the `amm_config`. */
|
|
609
|
+
tradeFeeRate: bigint;
|
|
610
|
+
/** `creator_fee_rate` on the `amm_config`, or zero when the pool switched the fee off. */
|
|
611
|
+
creatorFeeRate: bigint;
|
|
612
|
+
/**
|
|
613
|
+
* `true` when this side's creator fee comes off the input token, `false` when it comes off the
|
|
614
|
+
* output. It follows from the pool's `creator_fee_on` and which token is going in.
|
|
615
|
+
*/
|
|
616
|
+
creatorFeeOnInput: boolean;
|
|
617
|
+
};
|
|
618
|
+
/**
|
|
619
|
+
* Quote a CPMM buy of exactly `tokens` coins costs, both fees included.
|
|
620
|
+
*
|
|
621
|
+
* This is `CurveCalculator.swapBaseOutput`, which is what `swap_base_output` charges.
|
|
622
|
+
*/
|
|
623
|
+
declare function cpmmSwapBaseOutput(sides: CpmmSwapSides, rates: CpmmFeeRates, amountOut: bigint): bigint;
|
|
624
|
+
/**
|
|
625
|
+
* What a CPMM swap of exactly `amountIn` returns, net of both fees.
|
|
626
|
+
*
|
|
627
|
+
* This is `CurveCalculator.swapBaseInput`, which is what `swap_base_input` pays out.
|
|
628
|
+
*/
|
|
629
|
+
declare function cpmmSwapBaseInput(sides: CpmmSwapSides, rates: CpmmFeeRates, amountIn: bigint): bigint;
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region src/raydium/venue.d.ts
|
|
632
|
+
type VenueKind = 'launchlab' | 'cpmm';
|
|
633
|
+
/**
|
|
634
|
+
* The quote asset one pool is bound to, as the pool records it.
|
|
635
|
+
*
|
|
636
|
+
* `config` is LaunchLab's global config for the mint: the account that proves Raydium enabled the
|
|
637
|
+
* quote, and the account both venues check the trade against. `tokenProgram` owns the mint, and the
|
|
638
|
+
* user's quote ATA lives under it.
|
|
639
|
+
*/
|
|
640
|
+
type QuoteBinding = {
|
|
641
|
+
mint: Address;
|
|
642
|
+
config: Address;
|
|
643
|
+
tokenProgram: Address;
|
|
644
|
+
};
|
|
645
|
+
/** Everything `resolveVenue` learned, plus the pure functions that follow from it. */
|
|
646
|
+
type ResolvedVenue = {
|
|
647
|
+
kind: VenueKind;
|
|
648
|
+
/** The program to pass as the `venue` account. */
|
|
649
|
+
program: Address;
|
|
650
|
+
mint: Address;
|
|
651
|
+
quoteMint: Address;
|
|
652
|
+
/** The token program the quote mint lives under: classic SPL Token, or Token-2022. */
|
|
653
|
+
quoteTokenProgram: Address;
|
|
654
|
+
/** The trader's quote ATA. Both venues settle here, and the program pins this address. */
|
|
655
|
+
userQuoteToken: Address;
|
|
656
|
+
/** The venue's own pool: the LaunchLab curve pool, or the migrated CPMM pool. */
|
|
657
|
+
poolState: Address;
|
|
658
|
+
/** The LaunchLab pool's `status`: 0 funding, 1 migrating, 2 graduated. */
|
|
659
|
+
status: number;
|
|
660
|
+
/** The coin creator. LaunchLab and CPMM both pay their creator fee to this wallet. */
|
|
661
|
+
creator: Address;
|
|
662
|
+
/** The CPMM fee tier the pool names. Equal to the LaunchLab program on the curve venue. */
|
|
663
|
+
ammConfig: Address | null;
|
|
664
|
+
/** Coins the curve still has to sell. `0n` once the coin has graduated. */
|
|
665
|
+
remainingCurveBase: bigint;
|
|
666
|
+
/** The ordered account list for an exact-coins-out buy, in `remainingAccounts` order. */
|
|
667
|
+
buyAccounts: AccountMeta[];
|
|
668
|
+
/** The ordered account list for a sale. */
|
|
669
|
+
sellAccounts: AccountMeta[];
|
|
670
|
+
/** Quote token an exact-coins-out buy of `tokens` costs right now, the venue's fees included. */
|
|
671
|
+
quoteBuy(tokens: bigint): bigint;
|
|
672
|
+
/** Quote token a sale of `tokens` returns right now, net of the venue's fees. */
|
|
673
|
+
quoteSell(tokens: bigint): bigint;
|
|
674
|
+
};
|
|
675
|
+
type ResolveVenueOptions = {
|
|
676
|
+
mint: Address;
|
|
677
|
+
/** The wallet that will sign the trade. Its token accounts appear in the account list. */
|
|
678
|
+
user: Address;
|
|
679
|
+
/** Force a venue instead of reading the pool's `status`. A wrong choice fails on chain. */
|
|
680
|
+
venue?: VenueKind;
|
|
681
|
+
/** The pool's quote binding. Read from the Gabox pool when it is left out. */
|
|
682
|
+
quote?: QuoteBinding;
|
|
683
|
+
};
|
|
684
|
+
/** The quote binding a Gabox pool records. One account read. */
|
|
685
|
+
declare function fetchQuoteBinding(client: GaboxClient, mint: Address): Promise<QuoteBinding>;
|
|
686
|
+
/**
|
|
687
|
+
* The user's quote associated token account, under the quote's own token program.
|
|
688
|
+
*
|
|
689
|
+
* Both venues settle in this account, never in native SOL. It must exist and hold enough before a
|
|
690
|
+
* pack is bought, and sale proceeds land in it. For a WSOL-quoted pool every builder in `tx/` wraps
|
|
691
|
+
* the SOL it needs into this account and closes it again in the same transaction.
|
|
692
|
+
*/
|
|
693
|
+
declare function quoteAccountFor(user: Address, quoteMint: Address, quoteTokenProgram?: Address): Promise<Address>;
|
|
694
|
+
/** The user's WSOL associated token account. WSOL is always classic SPL Token. */
|
|
695
|
+
declare function wsolAccountFor(user: Address): Promise<Address>;
|
|
696
|
+
/** What LaunchLab's global config and the Gabox platform config say about a curve trade. */
|
|
697
|
+
type CurveSettings = {
|
|
698
|
+
rates: CurveFeeRates;
|
|
699
|
+
/** `migrate_fee` on the global config. The starting reserves depend on it. */
|
|
700
|
+
migrateFee: bigint;
|
|
701
|
+
/** `cpswap_config` on the platform config: the CPMM fee tier a Gabox coin graduates into. */
|
|
702
|
+
cpswapConfig: Address;
|
|
703
|
+
};
|
|
704
|
+
/**
|
|
705
|
+
* Read the quote's global config and the Gabox platform config, and take the four numbers a quote
|
|
706
|
+
* needs out of them.
|
|
707
|
+
*
|
|
708
|
+
* `quoteConfig` is the LaunchLab global config of the pool's quote asset: `pool.quoteConfig`, or
|
|
709
|
+
* the address `raydium.fetchQuoteConfig` derives for a coin that has no pool yet.
|
|
710
|
+
*/
|
|
711
|
+
declare function fetchCurveSettings(client: GaboxClient, quoteConfig: Address, ids?: RaydiumIds): Promise<CurveSettings>;
|
|
712
|
+
declare function resolveVenue(client: GaboxClient, options: ResolveVenueOptions): Promise<ResolvedVenue>;
|
|
713
|
+
/** A CPMM pool that has proved, from its own data, that it is a coin's migrated pool. */
|
|
714
|
+
type MigratedCpmmPool = {
|
|
715
|
+
address: Address;
|
|
716
|
+
pool: CpmmPoolState;
|
|
717
|
+
};
|
|
718
|
+
type FindCpmmPoolOptions = {
|
|
719
|
+
mint: Address;
|
|
720
|
+
/** The coin creator, from the Gabox pool or the LaunchLab pool. */
|
|
721
|
+
creator: Address;
|
|
722
|
+
/** The fee tier the Gabox platform config names. Read it with `fetchCurveSettings`. */
|
|
723
|
+
cpswapConfig: Address;
|
|
724
|
+
/** The pool's quote mint. Defaults to WSOL, which is the default quote. */
|
|
725
|
+
quoteMint?: Address;
|
|
726
|
+
};
|
|
727
|
+
/**
|
|
728
|
+
* Every check the program makes on a CPMM pool account, in one place.
|
|
729
|
+
*
|
|
730
|
+
* `enable_creator_fee` is the one that identifies the migrated pool. Anyone can call CPMM's own
|
|
731
|
+
* `initialize` and open a pool for the same pair with the same creator, but that pool always has
|
|
732
|
+
* the flag false. Only a creator Raydium has permissioned can set it, and LaunchLab's migration is
|
|
733
|
+
* one of those.
|
|
734
|
+
*/
|
|
735
|
+
declare function cpmmPoolMatches(pool: CpmmPoolState, expect: {
|
|
736
|
+
creator: Address;
|
|
737
|
+
token0: Address;
|
|
738
|
+
token1: Address;
|
|
739
|
+
}): boolean;
|
|
740
|
+
/**
|
|
741
|
+
* The CPMM pool LaunchLab migrated a coin into.
|
|
742
|
+
*
|
|
743
|
+
* Two steps, because the pool is not always at a derived address. Raydium migrates into
|
|
744
|
+
* `["pool", cpswap_config, token_0, token_1]` when that account is free, and into a random account
|
|
745
|
+
* when it is not. So: try the derived address, and scan for the pool when it does not hold one.
|
|
746
|
+
*
|
|
747
|
+
* The scan filters on the account length and on the three fields at their fixed offsets, so the
|
|
748
|
+
* RPC does the work and returns at most a handful of accounts. Every candidate still has to pass
|
|
749
|
+
* `cpmmPoolMatches`, and more than one match is an error rather than a guess.
|
|
750
|
+
*/
|
|
751
|
+
declare function findCpmmPool(client: GaboxClient, options: FindCpmmPoolOptions): Promise<MigratedCpmmPool>;
|
|
752
|
+
/**
|
|
753
|
+
* Does this side's creator fee come off the token going in?
|
|
754
|
+
*
|
|
755
|
+
* `creator_fee_on` is 0 when the fee follows the input token, 1 when it is always token 0, and 2
|
|
756
|
+
* when it is always token 1. LaunchLab migrates a Gabox coin with `AmmCreatorFeeOn::QuoteToken`, so
|
|
757
|
+
* the pool charges the creator fee in the quote token only: on the input of a buy, on the output of
|
|
758
|
+
* a sale.
|
|
759
|
+
*/
|
|
760
|
+
declare function creatorFeeOnInput(pool: CpmmPoolState, inputMint: Address): boolean;
|
|
761
|
+
/**
|
|
762
|
+
* Quote token an exact-coins-out buy of `tokens` costs right now, on whichever venue the coin
|
|
763
|
+
* trades. Pass `pool.packTokens` for the pack price.
|
|
764
|
+
*
|
|
765
|
+
* Use `resolveVenue` when you also need the account list, which every transaction builder does.
|
|
766
|
+
* This is for a price display.
|
|
767
|
+
*/
|
|
768
|
+
declare function curveQuote(client: GaboxClient, mint: Address, tokens: bigint, options?: {
|
|
769
|
+
user?: Address;
|
|
770
|
+
venue?: VenueKind;
|
|
771
|
+
quote?: QuoteBinding;
|
|
772
|
+
}): Promise<bigint>;
|
|
773
|
+
/** Quote token a sale of `tokens` returns right now, net of the venue's fees. */
|
|
774
|
+
declare function sellQuote(client: GaboxClient, mint: Address, tokens: bigint, options?: {
|
|
775
|
+
user?: Address;
|
|
776
|
+
venue?: VenueKind;
|
|
777
|
+
quote?: QuoteBinding;
|
|
778
|
+
}): Promise<bigint>;
|
|
779
|
+
/**
|
|
780
|
+
* Quote token an exact-coins-out buy of `tokens` would cost on a curve that does not exist yet,
|
|
781
|
+
* fees included.
|
|
782
|
+
*
|
|
783
|
+
* This is what the seed costs. `initialize_pool` buys it in the same transaction that creates the
|
|
784
|
+
* coin, so the curve is a brand-new LaunchLab curve with the pinned Gabox launch shape at that
|
|
785
|
+
* moment. Exact, unless Raydium changes a fee rate between this read and the send.
|
|
786
|
+
*/
|
|
787
|
+
declare function newCurveBuyCost(client: GaboxClient, tokens: bigint, launch: {
|
|
788
|
+
quoteConfig: Address;
|
|
789
|
+
raise: bigint;
|
|
790
|
+
}): Promise<bigint>;
|
|
791
|
+
/**
|
|
792
|
+
* The starting reserves of a brand-new Gabox curve.
|
|
793
|
+
*
|
|
794
|
+
* `raise` is `total_quote_fund_raising`, in the quote's own base units. It is the one launch number
|
|
795
|
+
* the client picks, so the reserves follow it.
|
|
796
|
+
*/
|
|
797
|
+
declare function newCurveReserves(raise: bigint, migrateFee: bigint): CurveReserves;
|
|
798
|
+
//#endregion
|
|
799
|
+
//#region src/tx/message.d.ts
|
|
800
|
+
/**
|
|
801
|
+
* What every builder returns: a version 0 message with a fee-payer signer and a blockhash
|
|
802
|
+
* lifetime, ready for `signTransactionMessageWithSigners`.
|
|
803
|
+
*
|
|
804
|
+
* Named, and built only from types `@solana/kit` exports, so the published declaration file
|
|
805
|
+
* refers to kit's types instead of copying them. `pipe`'s inferred type is a long intersection
|
|
806
|
+
* of kit-internal brands, and a copy of a branded type is not assignable to the original.
|
|
807
|
+
*/
|
|
808
|
+
type GaboxTransactionMessage = Extract<TransactionMessage, {
|
|
809
|
+
version: 0;
|
|
810
|
+
}> & TransactionMessageWithFeePayerSigner & TransactionMessageWithBlockhashLifetime;
|
|
811
|
+
type BuildOptions = {
|
|
812
|
+
/** Compute units to request. Each builder passes its own default. */
|
|
813
|
+
computeUnitLimit: number;
|
|
814
|
+
/** Priority fee in micro-lamports per compute unit. Left out, no price instruction is added. */
|
|
815
|
+
computeUnitPrice?: number | bigint;
|
|
816
|
+
/** Defaults to the client's tables, which the cluster chose. Pass `{}` to disable compression. */
|
|
817
|
+
addressLookupTables?: AddressesByLookupTableAddress;
|
|
818
|
+
};
|
|
819
|
+
/**
|
|
820
|
+
* Build the message. One RPC read, for the blockhash.
|
|
821
|
+
*
|
|
822
|
+
* The blockhash expires in about a minute, so build the message when the user is ready to sign
|
|
823
|
+
* rather than when the page loads.
|
|
824
|
+
*/
|
|
825
|
+
declare function buildMessage(client: GaboxClient, feePayer: TransactionSigner, instructions: Instruction[], options: BuildOptions): Promise<GaboxTransactionMessage>;
|
|
826
|
+
/** Append `remainingAccounts` to a generated instruction, which is how a venue's list is passed. */
|
|
827
|
+
declare function withRemainingAccounts<T extends Instruction>(instruction: T, remaining: readonly NonNullable<T['accounts']>[number][]): T;
|
|
828
|
+
//#endregion
|
|
829
|
+
//#region src/raydium/accounts.d.ts
|
|
830
|
+
/**
|
|
831
|
+
* Turn `{name -> address}` into the ABI's ordered `AccountMeta[]`.
|
|
832
|
+
*
|
|
833
|
+
* The map is keyed by the IDL's own account names, so a missing entry names the slot it belongs to
|
|
834
|
+
* rather than failing as an off-by-one further down. The role comes from the ABI table alone, never
|
|
835
|
+
* from the caller, which is what keeps this list in step with `venue/abi.rs`.
|
|
836
|
+
*/
|
|
837
|
+
declare function order(abi: VenueInstructionAbi, byName: Record<string, Address>): AccountMeta[];
|
|
838
|
+
/** Everything a LaunchLab trade list needs. Every address is derived, never read off the chain. */
|
|
839
|
+
type LaunchlabTradeAccountsInput = {
|
|
840
|
+
/** Raydium LaunchLab on this cluster. */
|
|
841
|
+
launchlab: Address;
|
|
842
|
+
/** `["vault_auth_seed"]` under LaunchLab. */
|
|
843
|
+
launchlabAuthority: Address;
|
|
844
|
+
/** `["__event_authority"]` under LaunchLab. */
|
|
845
|
+
launchlabEventAuthority: Address;
|
|
846
|
+
/** The global config of the quote asset. */
|
|
847
|
+
globalConfig: Address;
|
|
848
|
+
/** The Gabox platform config. */
|
|
849
|
+
platformConfig: Address;
|
|
850
|
+
/** `["pool", mint, quote_mint]` under LaunchLab. */
|
|
851
|
+
poolState: Address;
|
|
852
|
+
mint: Address;
|
|
853
|
+
quoteMint: Address;
|
|
854
|
+
/** `["pool_vault", pool_state, mint]` under LaunchLab. */
|
|
855
|
+
baseVault: Address;
|
|
856
|
+
/** `["pool_vault", pool_state, quote_mint]` under LaunchLab. */
|
|
857
|
+
quoteVault: Address;
|
|
858
|
+
/** The trader. The one signing slot in the list. */
|
|
859
|
+
user: Address;
|
|
860
|
+
/** The trader's coin ATA. `buy_pack` passes the same address as its own `user_tokens`. */
|
|
861
|
+
userBaseToken: Address;
|
|
862
|
+
/** The trader's quote ATA, under the quote's own token program. Both venues settle here. */
|
|
863
|
+
userQuoteToken: Address;
|
|
864
|
+
/** The quote mint's token program: classic SPL Token, or Token-2022. */
|
|
865
|
+
quoteTokenProgram: Address;
|
|
866
|
+
/** `[platform_config, quote_mint]` under LaunchLab. */
|
|
867
|
+
platformFeeVault: Address;
|
|
868
|
+
/** `[creator, quote_mint]` under LaunchLab, where `creator` is the coin creator. */
|
|
869
|
+
creatorFeeVault: Address;
|
|
870
|
+
};
|
|
871
|
+
/** `buy_exact_out`: 18 accounts. The first argument is the coins wanted, the second the cost cap. */
|
|
872
|
+
declare const launchlabBuyAccounts: (input: LaunchlabTradeAccountsInput) => AccountMeta[];
|
|
873
|
+
/** `sell_exact_in`: the same 18 accounts. `venue/trade.rs` uses one table for both sides. */
|
|
874
|
+
declare const launchlabSellAccounts: (input: LaunchlabTradeAccountsInput) => AccountMeta[];
|
|
875
|
+
/**
|
|
876
|
+
* `buy_exact_in`: the same 18 accounts again. Gabox never forwards this instruction; a wallet sends
|
|
877
|
+
* it on its own, to buy the curve out with a fixed spend.
|
|
878
|
+
*/
|
|
879
|
+
declare const launchlabBuyExactInAccounts: (input: LaunchlabTradeAccountsInput) => AccountMeta[];
|
|
880
|
+
/** Everything a CPMM trade list needs. */
|
|
881
|
+
type CpmmTradeAccountsInput = {
|
|
882
|
+
/** `["vault_and_lp_mint_auth_seed"]` under CPMM. */
|
|
883
|
+
cpmmAuthority: Address;
|
|
884
|
+
/** The fee tier the pool belongs to. Gabox pins the one LaunchLab migrates into. */
|
|
885
|
+
ammConfig: Address;
|
|
886
|
+
/** The migrated pool. */
|
|
887
|
+
poolState: Address;
|
|
888
|
+
mint: Address;
|
|
889
|
+
quoteMint: Address;
|
|
890
|
+
/** `["pool_vault", pool_state, mint]` under CPMM. */
|
|
891
|
+
baseVault: Address;
|
|
892
|
+
/** `["pool_vault", pool_state, quote_mint]` under CPMM. */
|
|
893
|
+
quoteVault: Address;
|
|
894
|
+
/** `["observation", pool_state]` under CPMM. */
|
|
895
|
+
observationState: Address;
|
|
896
|
+
/** The trader. The one signing slot, and read-only here: CPMM does not take its lamports. */
|
|
897
|
+
user: Address;
|
|
898
|
+
userBaseToken: Address;
|
|
899
|
+
userQuoteToken: Address;
|
|
900
|
+
/** The two token programs the pool records. Read them from the pool account, never derive them. */
|
|
901
|
+
baseTokenProgram: Address;
|
|
902
|
+
quoteTokenProgram: Address;
|
|
903
|
+
};
|
|
904
|
+
/** `swap_base_output`: 13 accounts. Note the argument order is `(max_amount_in, amount_out)`. */
|
|
905
|
+
declare const cpmmBuyAccounts: (input: CpmmTradeAccountsInput) => AccountMeta[];
|
|
906
|
+
/** `swap_base_input`: 13 accounts, with the four pairs swapped. */
|
|
907
|
+
declare const cpmmSellAccounts: (input: CpmmTradeAccountsInput) => AccountMeta[];
|
|
908
|
+
//#endregion
|
|
909
|
+
//#region src/raydium/claim.d.ts
|
|
910
|
+
/**
|
|
911
|
+
* The instructions of a curve fee claim, for one quote asset: create the quote account, claim, and
|
|
912
|
+
* close it again when the quote is WSOL.
|
|
913
|
+
*
|
|
914
|
+
* This sweeps **every** coin this wallet launched against that quote, because LaunchLab keeps one
|
|
915
|
+
* vault per wallet per quote asset. There is no per-coin version, and a creator with machines in
|
|
916
|
+
* two quote assets claims once per asset.
|
|
917
|
+
*/
|
|
918
|
+
declare function getClaimCreatorFeeInstructions(creator: TransactionSigner, ids: RaydiumIds, quote: {
|
|
919
|
+
mint: Address;
|
|
920
|
+
tokenProgram: Address;
|
|
921
|
+
}): Promise<Instruction[]>;
|
|
922
|
+
type ClaimCreatorFeeInput = {
|
|
923
|
+
creator: TransactionSigner;
|
|
924
|
+
/** The quote asset to claim. Defaults to wrapped SOL. One claim per quote asset. */
|
|
925
|
+
quoteMint?: Address;
|
|
926
|
+
} & Partial<BuildOptions>;
|
|
927
|
+
/**
|
|
928
|
+
* Claim the curve creator fee for one quote asset.
|
|
929
|
+
*
|
|
930
|
+
* A WSOL claim arrives as SOL, because the builder closes the WSOL account. Any other quote arrives
|
|
931
|
+
* as that token, in the creator's own account.
|
|
932
|
+
*/
|
|
933
|
+
declare function claimCreatorFee(client: GaboxClient, input: ClaimCreatorFeeInput): Promise<GaboxTransactionMessage>;
|
|
934
|
+
/**
|
|
935
|
+
* The instructions of a graduated coin's fee collection: create the quote account, collect, and
|
|
936
|
+
* close it again when the quote is WSOL.
|
|
937
|
+
*
|
|
938
|
+
* This is per coin. `collect_creator_fee` pays out both sides of the pair, so anything owed in the
|
|
939
|
+
* coin itself lands in the creator's coin account and stays there.
|
|
940
|
+
*
|
|
941
|
+
* The coin's quote asset comes from its Gabox pool, so a caller never has to name it.
|
|
942
|
+
*/
|
|
943
|
+
declare function getCollectCreatorFeeInstructions(client: GaboxClient, input: {
|
|
944
|
+
mint: Address;
|
|
945
|
+
creator: TransactionSigner;
|
|
946
|
+
quote?: QuoteBinding;
|
|
947
|
+
}, ids?: RaydiumIds): Promise<Instruction[]>;
|
|
948
|
+
type CollectCreatorFeeInput = {
|
|
949
|
+
mint: Address;
|
|
950
|
+
creator: TransactionSigner;
|
|
951
|
+
/** The coin's quote binding, when it is already at hand. Read from the Gabox pool otherwise. */
|
|
952
|
+
quote?: QuoteBinding;
|
|
953
|
+
} & Partial<BuildOptions>;
|
|
954
|
+
/**
|
|
955
|
+
* Collect one graduated coin's CPMM creator fee.
|
|
956
|
+
*
|
|
957
|
+
* A WSOL-quoted coin pays the quote side out as SOL, because the builder closes the WSOL account.
|
|
958
|
+
* Any other quote arrives as that token.
|
|
959
|
+
*/
|
|
960
|
+
declare function collectCreatorFee(client: GaboxClient, input: CollectCreatorFeeInput): Promise<GaboxTransactionMessage>;
|
|
961
|
+
/** What a creator can collect right now, for one quote asset. Every amount is in base units. */
|
|
962
|
+
type CreatorFees = {
|
|
963
|
+
/** The quote asset these three amounts are measured against. */
|
|
964
|
+
quoteMint: Address;
|
|
965
|
+
/**
|
|
966
|
+
* Quote token waiting in the LaunchLab creator fee vault, across every coin this wallet launched
|
|
967
|
+
* against that quote.
|
|
968
|
+
*/
|
|
969
|
+
curveQuote: bigint;
|
|
970
|
+
/**
|
|
971
|
+
* Quote token the migrated CPMM pool of `mint` owes this creator. `0n` when the coin has not
|
|
972
|
+
* graduated, and `0n` when no `mint` was passed.
|
|
973
|
+
*/
|
|
974
|
+
cpmmQuote: bigint;
|
|
975
|
+
/** Coins the same pool owes this creator. CPMM can charge the fee on either side. */
|
|
976
|
+
cpmmTokens: bigint;
|
|
977
|
+
};
|
|
978
|
+
/**
|
|
979
|
+
* Read both places a creator's fees can sit, for one quote asset.
|
|
980
|
+
*
|
|
981
|
+
* `quoteMint` defaults to wrapped SOL. LaunchLab keeps one vault per wallet per quote, so a creator
|
|
982
|
+
* with machines in two quote assets reads this twice.
|
|
983
|
+
*
|
|
984
|
+
* `mint` is optional. Without it only the curve vault is read, which is the one number that covers
|
|
985
|
+
* every coin of that quote at once. With it the coin's CPMM pool is read too, and a coin that has
|
|
986
|
+
* not graduated reports zeros rather than failing.
|
|
987
|
+
*/
|
|
988
|
+
declare function fetchCreatorFees(client: GaboxClient, input: {
|
|
989
|
+
creator: Address;
|
|
990
|
+
mint?: Address;
|
|
991
|
+
quoteMint?: Address;
|
|
992
|
+
}): Promise<CreatorFees>;
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/raydium/launch.d.ts
|
|
995
|
+
type LaunchInput = {
|
|
996
|
+
/** The coin's mint. A fresh keypair, and it signs. */
|
|
997
|
+
mint: TransactionSigner;
|
|
998
|
+
/**
|
|
999
|
+
* The wallet paying. LaunchLab takes it as both `payer` and `creator`, so this wallet receives
|
|
1000
|
+
* LaunchLab's creator fee and owns the CPMM creator fee after graduation. It must be the same
|
|
1001
|
+
* wallet that signs `initialize_pool`.
|
|
1002
|
+
*/
|
|
1003
|
+
creator: TransactionSigner;
|
|
1004
|
+
name: string;
|
|
1005
|
+
symbol: string;
|
|
1006
|
+
/** The metadata URI. Metaplex stores it on the mint's metadata account. */
|
|
1007
|
+
uri: string;
|
|
1008
|
+
/** The quote asset the coin is priced in. */
|
|
1009
|
+
quoteMint: Address;
|
|
1010
|
+
/** LaunchLab's global config for that quote: `["global_config", quote_mint, 0u8, 0u16]`. */
|
|
1011
|
+
quoteConfig: Address;
|
|
1012
|
+
/** The token program that owns the quote mint: classic SPL Token, or Token-2022. */
|
|
1013
|
+
quoteTokenProgram: Address;
|
|
1014
|
+
/** `total_quote_fund_raising`, in the quote's own base units. */
|
|
1015
|
+
raise: bigint;
|
|
1016
|
+
};
|
|
1017
|
+
/**
|
|
1018
|
+
* Build `initialize_v2` for one cluster's LaunchLab. `ids` is `raydiumIds(client.cluster)`.
|
|
1019
|
+
*
|
|
1020
|
+
* Two slots sign: the mint keypair, which LaunchLab takes as a signer rather than deriving, and the
|
|
1021
|
+
* creator, who pays for everything.
|
|
1022
|
+
*/
|
|
1023
|
+
declare function getLaunchInstruction(input: LaunchInput, ids: RaydiumIds): Promise<Instruction>;
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region src/raydium/pdas.d.ts
|
|
1026
|
+
/** `["vault_auth_seed"]`. LaunchLab signs its own vault transfers with this PDA. */
|
|
1027
|
+
declare const launchlabAuthority: (launchlab: Address) => Promise<Address>;
|
|
1028
|
+
/** `["__event_authority"]`. */
|
|
1029
|
+
declare const launchlabEventAuthority: (launchlab: Address) => Promise<Address>;
|
|
1030
|
+
/**
|
|
1031
|
+
* `["global_config", quote_mint, u8 curve_type, u16 big-endian index]`. The curve settings for one
|
|
1032
|
+
* quote asset. Gabox uses curve type 0 (constant product) and index 0.
|
|
1033
|
+
*/
|
|
1034
|
+
declare const launchlabGlobalConfig: (launchlab: Address, quoteMint: Address, curveType?: number, index?: number) => Promise<Address>;
|
|
1035
|
+
/** `["platform_config", platform_admin]`. The Gabox platform on LaunchLab. */
|
|
1036
|
+
declare const launchlabPlatformConfig: (launchlab: Address, platformAdmin: Address) => Promise<Address>;
|
|
1037
|
+
/** `["pool", base_mint, quote_mint]`. The curve pool of one coin. */
|
|
1038
|
+
declare const launchlabPoolAddress: (launchlab: Address, baseMint: Address, quoteMint: Address) => Promise<Address>;
|
|
1039
|
+
/** `["pool_vault", pool_state, mint]`. One side of a curve pool's reserves. */
|
|
1040
|
+
declare const launchlabVaultAddress: (launchlab: Address, poolState: Address, mint: Address) => Promise<Address>;
|
|
1041
|
+
/**
|
|
1042
|
+
* `[platform_config, quote_mint]`. LaunchLab pays the platform share of every curve trade here.
|
|
1043
|
+
*
|
|
1044
|
+
* The seeds carry no text prefix. That is Raydium's own derivation, not a mistake.
|
|
1045
|
+
*/
|
|
1046
|
+
declare const platformFeeVaultAddress: (launchlab: Address, platformConfig: Address, quoteMint: Address) => Promise<Address>;
|
|
1047
|
+
/**
|
|
1048
|
+
* `[creator, quote_mint]`. LaunchLab pays the creator share of every curve trade here.
|
|
1049
|
+
*
|
|
1050
|
+
* One vault per wallet per quote asset, not one per coin. A creator with several coins collects
|
|
1051
|
+
* all of them with a single `claim_creator_fee`.
|
|
1052
|
+
*/
|
|
1053
|
+
declare const creatorFeeVaultAddress: (launchlab: Address, creator: Address, quoteMint: Address) => Promise<Address>;
|
|
1054
|
+
/** `["creator_fee_vault_auth_seed"]`. The authority `claim_creator_fee` signs the payout with. */
|
|
1055
|
+
declare const creatorFeeVaultAuthority: (launchlab: Address) => Promise<Address>;
|
|
1056
|
+
/** `["metadata", metaplex, mint]` under Metaplex. LaunchLab's create instruction writes it. */
|
|
1057
|
+
declare const metadataAddress: (mint: Address) => Promise<Address>;
|
|
1058
|
+
/** `["vault_and_lp_mint_auth_seed"]`. */
|
|
1059
|
+
declare const cpmmAuthority: (cpmm: Address) => Promise<Address>;
|
|
1060
|
+
/**
|
|
1061
|
+
* `["pool", amm_config, token_0, token_1]`, with the two mints sorted by raw byte order.
|
|
1062
|
+
*
|
|
1063
|
+
* This is where Raydium migrates a coin when the address is free. It is only a first guess: when the
|
|
1064
|
+
* account is taken, the migration lands somewhere else entirely. And the address alone proves
|
|
1065
|
+
* nothing, because anyone can open a CPMM pool for any pair under any config. `findCpmmPool` tries
|
|
1066
|
+
* this address, checks the account data, and scans for the real pool when it does not match.
|
|
1067
|
+
*
|
|
1068
|
+
* There are no vault or observation derivations here on purpose. `venue/trade.rs` reads those three
|
|
1069
|
+
* addresses out of the pool account, and so does this SDK: a migrated pool names its own vaults and
|
|
1070
|
+
* its own oracle, wherever it sits.
|
|
1071
|
+
*/
|
|
1072
|
+
declare const cpmmPoolAddress: (cpmm: Address, ammConfig: Address, mintA: Address, mintB: Address) => Promise<Address>;
|
|
1073
|
+
/**
|
|
1074
|
+
* `["creator_fee_share", creator, amm_config]`. Where CPMM tracks what one creator is owed under
|
|
1075
|
+
* one fee tier.
|
|
1076
|
+
*
|
|
1077
|
+
* `collect_creator_fee` takes this account after the fourteen the mainnet IDL lists. That snapshot
|
|
1078
|
+
* predates the account; Raydium's devnet build declares it and stops with `AccountNotEnoughKeys`
|
|
1079
|
+
* (3005) when it is missing. One account per creator per fee tier, not one per pool.
|
|
1080
|
+
*/
|
|
1081
|
+
declare const cpmmCreatorFeeShare: (cpmm: Address, creator: Address, ammConfig: Address) => Promise<Address>;
|
|
1082
|
+
/** An associated token account. Off-curve owners are allowed: pool PDAs are all off-curve. */
|
|
1083
|
+
declare const ata: (owner: Address, mint: Address, tokenProgram?: Address) => Promise<Address>;
|
|
1084
|
+
//#endregion
|
|
1085
|
+
//#region src/raydium/quote.d.ts
|
|
1086
|
+
/** LaunchLab's settings for one quote, and the address they were read from. */
|
|
1087
|
+
type QuoteConfig = LaunchlabGlobalConfig & {
|
|
1088
|
+
/** `["global_config", quote_mint, u8 0, u16 big-endian 0]` under LaunchLab. */
|
|
1089
|
+
address: Address;
|
|
1090
|
+
};
|
|
1091
|
+
/** Everything a pool, a price and an account list need to know about a quote asset. */
|
|
1092
|
+
type QuoteAsset = {
|
|
1093
|
+
mint: Address;
|
|
1094
|
+
/** The LaunchLab global config `initialize_pool` proves the quote with. */
|
|
1095
|
+
config: Address;
|
|
1096
|
+
/** Classic SPL Token, or Token-2022. The user's quote ATA lives under it. */
|
|
1097
|
+
tokenProgram: Address;
|
|
1098
|
+
decimals: number;
|
|
1099
|
+
/** From Metaplex, or from the Token-2022 metadata extension. `null` when the mint has none. */
|
|
1100
|
+
symbol: string | null;
|
|
1101
|
+
/** Raydium's own share of every curve trade, out of 1,000,000. */
|
|
1102
|
+
tradeFeeRate: bigint;
|
|
1103
|
+
/** The quote LaunchLab keeps at graduation. The starting reserves depend on it. */
|
|
1104
|
+
migrateFee: bigint;
|
|
1105
|
+
/** The smallest `raise` LaunchLab accepts for this quote, in the quote's base units. */
|
|
1106
|
+
minQuoteFundRaising: bigint;
|
|
1107
|
+
};
|
|
1108
|
+
/**
|
|
1109
|
+
* LaunchLab's global config for one quote mint, or `null` when Raydium enabled no such quote.
|
|
1110
|
+
*
|
|
1111
|
+
* Index 0 is the usual config, and the constant-product curve is the only shape Gabox launches, so
|
|
1112
|
+
* those two are fixed here. The decoded `quoteMint` has to be the mint asked for: a config for a
|
|
1113
|
+
* different quote would price the wrong asset.
|
|
1114
|
+
*/
|
|
1115
|
+
declare function fetchQuoteConfig(client: GaboxClient, mint: Address, ids?: RaydiumIds): Promise<QuoteConfig | null>;
|
|
1116
|
+
/** Can a Gabox machine be quoted in this mint? One account read. */
|
|
1117
|
+
declare function isQuoteSupported(client: GaboxClient, mint: Address): Promise<boolean>;
|
|
1118
|
+
/**
|
|
1119
|
+
* The full quote asset: its LaunchLab config, its token program, its decimals and its symbol.
|
|
1120
|
+
*
|
|
1121
|
+
* Two round trips. The first reads the global config, because the config address is derived from
|
|
1122
|
+
* the mint. The second reads the mint and its Metaplex metadata account together.
|
|
1123
|
+
*
|
|
1124
|
+
* Throws when Raydium has no config for the mint, because no pool can be created or traded then.
|
|
1125
|
+
*/
|
|
1126
|
+
declare function fetchQuoteAsset(client: GaboxClient, mint: Address, ids?: RaydiumIds): Promise<QuoteAsset>;
|
|
1127
|
+
/** What a price display needs about a quote mint: its program, its decimals and its symbol. */
|
|
1128
|
+
type QuoteDisplay = {
|
|
1129
|
+
tokenProgram: Address;
|
|
1130
|
+
decimals: number;
|
|
1131
|
+
symbol: string | null;
|
|
1132
|
+
};
|
|
1133
|
+
/**
|
|
1134
|
+
* Read a quote mint and its Metaplex metadata in one call.
|
|
1135
|
+
*
|
|
1136
|
+
* A Token-2022 mint may carry its own `TokenMetadata` extension, and that one wins: it is the
|
|
1137
|
+
* issuer's own record. A classic SPL mint keeps its symbol in a Metaplex account, and a mint with
|
|
1138
|
+
* neither reports `null`.
|
|
1139
|
+
*/
|
|
1140
|
+
declare function fetchQuoteDisplay(client: GaboxClient, mint: Address): Promise<QuoteDisplay>;
|
|
1141
|
+
//#endregion
|
|
1142
|
+
//#region src/raydium/read.d.ts
|
|
1143
|
+
/** An account that may not exist, with its raw bytes and its owning program. */
|
|
1144
|
+
type MaybeAccount$1 = {
|
|
1145
|
+
data: Uint8Array;
|
|
1146
|
+
owner: Address;
|
|
1147
|
+
} | null;
|
|
1148
|
+
/** Read several accounts in one call. A missing account comes back as `null`, not as an error. */
|
|
1149
|
+
declare function readAccounts(rpc: GaboxRpc, addresses: Address[]): Promise<MaybeAccount$1[]>;
|
|
1150
|
+
/** Decode one base64 account payload the RPC returned inside another shape. */
|
|
1151
|
+
declare const decodeBase64: (encoded: string) => Uint8Array;
|
|
1152
|
+
//#endregion
|
|
1153
|
+
//#region src/raydium/trade.d.ts
|
|
1154
|
+
type CurveBuyExactInInput = {
|
|
1155
|
+
mint: Address;
|
|
1156
|
+
/** The coin creator, so the creator fee vault can be derived. Read it off the pool. */
|
|
1157
|
+
creator: Address;
|
|
1158
|
+
/** The wallet spending. It signs, and its quote ATA must already hold `quoteIn`. */
|
|
1159
|
+
user: TransactionSigner;
|
|
1160
|
+
/** Quote token to spend, fees included. */
|
|
1161
|
+
quoteIn: bigint;
|
|
1162
|
+
/** The floor on the coins received. Use `curveBuyExactIn` from `curve.ts` to compute it. */
|
|
1163
|
+
minTokensOut: bigint;
|
|
1164
|
+
/** The pool's quote mint. Defaults to wrapped SOL. */
|
|
1165
|
+
quoteMint?: Address;
|
|
1166
|
+
/** The quote mint's token program. Defaults to classic SPL Token, which is what WSOL uses. */
|
|
1167
|
+
quoteTokenProgram?: Address;
|
|
1168
|
+
};
|
|
1169
|
+
/**
|
|
1170
|
+
* `buy_exact_in` on the curve: spend exactly `quoteIn` of the quote token and take whatever coins
|
|
1171
|
+
* it buys.
|
|
1172
|
+
*
|
|
1173
|
+
* LaunchLab caps the trade at what the curve has left to sell, so a spend larger than the rest of
|
|
1174
|
+
* the raise still succeeds and graduates the coin. Fund the user's quote ATA first. On a WSOL pool
|
|
1175
|
+
* that means wrapping the SOL and closing the account afterwards, the same way the Gabox builders
|
|
1176
|
+
* do.
|
|
1177
|
+
*/
|
|
1178
|
+
declare function getCurveBuyExactInInstruction(client: GaboxClient, input: CurveBuyExactInInput, ids?: RaydiumIds): Promise<Instruction>;
|
|
1179
|
+
declare namespace index_d_exports {
|
|
1180
|
+
export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, CONSTANT_CURVE_TAG, CPMM_AMM_CONFIG_DISCRIMINATOR, CPMM_AMM_CONFIG_HEAD_SIZE, CPMM_COLLECT_CREATOR_FEE, CPMM_POOL_OFFSETS, CPMM_POOL_STATE_DISCRIMINATOR, CPMM_POOL_STATE_HEAD_SIZE, CPMM_POOL_STATE_SIZE, CPMM_SEEDS, CPMM_SWAP_BASE_INPUT, CPMM_SWAP_BASE_OUTPUT, CREATOR_FEE_ON_QUOTE, ClaimCreatorFeeInput, CollectCreatorFeeInput, CpmmAmmConfig, CpmmFeeRates, CpmmPoolState, CpmmSwapSides, CpmmTradeAccountsInput, CreatorFees, CurveBuyExactInInput, CurveFeeRates, CurveReserves, CurveSettings, FindCpmmPoolOptions, LAUNCHLAB_BUY_EXACT_IN, LAUNCHLAB_BUY_EXACT_OUT, LAUNCHLAB_CLAIM_CREATOR_FEE, LAUNCHLAB_GLOBAL_CONFIG_DISCRIMINATOR, LAUNCHLAB_GLOBAL_CONFIG_HEAD_SIZE, LAUNCHLAB_INITIALIZE, LAUNCHLAB_PLATFORM_CONFIG_DISCRIMINATOR, LAUNCHLAB_PLATFORM_CONFIG_HEAD_SIZE, LAUNCHLAB_POOL_STATE_DISCRIMINATOR, LAUNCHLAB_POOL_STATE_HEAD_SIZE, LAUNCHLAB_SEEDS, LAUNCHLAB_SELL_EXACT_IN, LAUNCHLAB_STATUS_FUND, LAUNCHLAB_STATUS_MIGRATE, LAUNCHLAB_STATUS_TRADE, LAUNCH_DECIMALS, LAUNCH_SUPPLY, LAUNCH_TOTAL_BASE_SELL, LaunchInput, LaunchParams, LaunchlabGlobalConfig, LaunchlabPlatformConfig, LaunchlabPoolState, LaunchlabTradeAccountsInput, METADATA_LIMITS, METADATA_SEED, METAPLEX_PROGRAM_ADDRESS, MIGRATE_TO_CPMM, MaybeAccount$1 as MaybeAccount, MigratedCpmmPool, PLATFORM_ADMIN, QuoteAsset, QuoteBinding, QuoteConfig, QuoteDisplay, RATE_DENOMINATOR, RAYDIUM_DEVNET_IDS, RAYDIUM_IDS, RAYDIUM_MAINNET_IDS, RENT_SYSVAR_ADDRESS, RaydiumClusterIds, RaydiumIds, ResolveVenueOptions, ResolvedVenue, SHARE_FEE_RATE, SYSTEM_PROGRAM_ADDRESS, TOKEN_2022_PROGRAM_ADDRESS, TOKEN_PROGRAM_ADDRESS, VenueAccountSpec, VenueInstructionAbi, VenueKind, WSOL_MINT, ata, ceilDiv, ceilDivRate, claimCreatorFee, collectCreatorFee, compareAddresses, cpmmAuthority, cpmmBuyAccounts, cpmmCreatorFeeShare, cpmmPoolAddress, cpmmPoolMatches, cpmmSellAccounts, cpmmSwapBaseInput, cpmmSwapBaseOutput, creatorFeeOnInput, creatorFeeVaultAddress, creatorFeeVaultAuthority, curveBuyExactIn, curveBuyExactOut, curveQuote, curveSellExactIn, decodeBase64, decodeCpmmAmmConfig, decodeCpmmPool, decodeLaunchlabGlobalConfig, decodeLaunchlabPlatformConfig, decodeLaunchlabPool, fetchCreatorFees, fetchCurveSettings, fetchQuoteAsset, fetchQuoteBinding, fetchQuoteConfig, fetchQuoteDisplay, findCpmmPool, getClaimCreatorFeeInstructions, getCollectCreatorFeeInstructions, getCurveBuyExactInInstruction, getLaunchInstruction, initialCurve, isQuoteSupported, launchlabAuthority, launchlabBuyAccounts, launchlabBuyExactInAccounts, launchlabEventAuthority, launchlabGlobalConfig, launchlabPlatformConfig, launchlabPoolAddress, launchlabSellAccounts, launchlabVaultAddress, metadataAddress, metaplexSymbol, mintDecimals, newCurveBuyCost, newCurveReserves, order, platformFeeVaultAddress, preFeeAmount, quoteAccountFor, raydiumIds, readAccounts, remainingBase, resolveVenue, sellQuote, sortedMints, token2022Symbol, tokenAccountAmount, tokenAccountOwnerAndMint, totalCurveFeeRate, wsolAccountFor };
|
|
1181
|
+
}
|
|
1182
|
+
//#endregion
|
|
1183
|
+
export { QuoteBinding as $, assertClusterUrl as $n, CONSTANT_CURVE_TAG as $t, ClaimCreatorFeeInput as A, LAUNCHLAB_SELL_EXACT_IN as An, totalCurveFeeRate as At, cpmmBuyAccounts as B, TOKEN_2022_PROGRAM_ADDRESS as Bn, LaunchlabGlobalConfig as Bt, launchlabPlatformConfig as C, LAUNCHLAB_BUY_EXACT_IN as Cn, cpmmSwapBaseOutput as Ct, platformFeeVaultAddress as D, LAUNCHLAB_INITIALIZE as Dn, initialCurve as Dt, metadataAddress as E, LAUNCHLAB_GLOBAL_CONFIG_DISCRIMINATOR as En, curveSellExactIn as Et, fetchCreatorFees as F, RAYDIUM_DEVNET_IDS as Fn, CpmmAmmConfig as Ft, order as G, CLUSTER_ENDPOINTS as Gn, decodeLaunchlabGlobalConfig as Gt, launchlabBuyAccounts as H, VenueAccountSpec as Hn, LaunchlabPoolState as Ht, getClaimCreatorFeeInstructions as I, RAYDIUM_MAINNET_IDS as In, CpmmPoolState as It, buildMessage as J, DEVNET_HTTP as Jn, metaplexSymbol as Jt, BuildOptions as K, ClientConfig as Kn, decodeLaunchlabPlatformConfig as Kt, getCollectCreatorFeeInstructions as L, RENT_SYSVAR_ADDRESS as Ln, LAUNCHLAB_GLOBAL_CONFIG_HEAD_SIZE as Lt, CreatorFees as M, LAUNCH_TOTAL_BASE_SELL as Mn, CPMM_POOL_OFFSETS as Mt, claimCreatorFee as N, METAPLEX_PROGRAM_ADDRESS as Nn, CPMM_POOL_STATE_HEAD_SIZE as Nt, LaunchInput as O, LAUNCHLAB_PLATFORM_CONFIG_DISCRIMINATOR as On, preFeeAmount as Ot, collectCreatorFee as P, PLATFORM_ADMIN as Pn, CPMM_POOL_STATE_SIZE as Pt, MigratedCpmmPool as Q, GaboxRpcSubscriptions as Qn, tokenAccountOwnerAndMint as Qt, CpmmTradeAccountsInput as R, RaydiumClusterIds as Rn, LAUNCHLAB_PLATFORM_CONFIG_HEAD_SIZE as Rt, launchlabGlobalConfig as S, CPMM_SWAP_BASE_OUTPUT as Sn, cpmmSwapBaseInput as St, launchlabVaultAddress as T, LAUNCHLAB_CLAIM_CREATOR_FEE as Tn, curveBuyExactOut as Tt, launchlabBuyExactInAccounts as U, VenueInstructionAbi as Un, decodeCpmmAmmConfig as Ut, cpmmSellAccounts as V, TOKEN_PROGRAM_ADDRESS as Vn, LaunchlabPlatformConfig as Vt, launchlabSellAccounts as W, WSOL_MINT as Wn, decodeCpmmPool as Wt, CurveSettings as X, GaboxClient as Xn, token2022Symbol as Xt, withRemainingAccounts as Y, DEVNET_WS as Yn, mintDecimals as Yt, FindCpmmPoolOptions as Z, GaboxRpc as Zn, tokenAccountAmount as Zt, cpmmPoolAddress as _, ASSOCIATED_TOKEN_PROGRAM_ADDRESS as _n, CurveFeeRates as _t, decodeBase64 as a, LAUNCHLAB_STATUS_TRADE as an, RouteMode as ar, curveQuote as at, launchlabAuthority as b, CPMM_POOL_STATE_DISCRIMINATOR as bn, ceilDiv as bt, QuoteConfig as c, METADATA_SEED as cn, findCpmmPool as ct, fetchQuoteConfig as d, RAYDIUM_IDS as dn, quoteAccountFor as dt, CPMM_SEEDS as en, clusterNamedBy as er, ResolveVenueOptions as et, fetchQuoteDisplay as f, RaydiumIds as fn, resolveVenue as ft, cpmmCreatorFeeShare as g, sortedMints as gn, CpmmSwapSides as gt, cpmmAuthority as h, raydiumIds as hn, CpmmFeeRates as ht, MaybeAccount$1 as i, LAUNCHLAB_STATUS_MIGRATE as in, Route as ir, creatorFeeOnInput as it, CollectCreatorFeeInput as j, LAUNCH_SUPPLY as jn, CPMM_AMM_CONFIG_HEAD_SIZE as jt, getLaunchInstruction as k, LAUNCHLAB_POOL_STATE_DISCRIMINATOR as kn, remainingBase as kt, QuoteDisplay as l, MIGRATE_TO_CPMM as ln, newCurveBuyCost as lt, ata as m, compareAddresses as mn, wsolAccountFor as mt, CurveBuyExactInInput as n, LAUNCHLAB_SEEDS as nn, defaultRoute as nr, VenueKind as nt, readAccounts as o, LAUNCH_DECIMALS as on, RouteProvider as or, fetchCurveSettings as ot, isQuoteSupported as p, SHARE_FEE_RATE as pn, sellQuote as pt, GaboxTransactionMessage as q, Cluster as qn, decodeLaunchlabPool as qt, getCurveBuyExactInInstruction as r, LAUNCHLAB_STATUS_FUND as rn, websocketUrlFor as rr, cpmmPoolMatches as rt, QuoteAsset as s, METADATA_LIMITS as sn, fetchQuoteBinding as st, index_d_exports as t, CREATOR_FEE_ON_QUOTE as tn, createClient as tr, ResolvedVenue as tt, fetchQuoteAsset as u, RATE_DENOMINATOR as un, newCurveReserves as ut, creatorFeeVaultAddress as v, CPMM_AMM_CONFIG_DISCRIMINATOR as vn, CurveReserves as vt, launchlabPoolAddress as w, LAUNCHLAB_BUY_EXACT_OUT as wn, curveBuyExactIn as wt, launchlabEventAuthority as x, CPMM_SWAP_BASE_INPUT as xn, ceilDivRate as xt, creatorFeeVaultAuthority as y, CPMM_COLLECT_CREATOR_FEE as yn, LaunchParams as yt, LaunchlabTradeAccountsInput as z, SYSTEM_PROGRAM_ADDRESS as zn, LAUNCHLAB_POOL_STATE_HEAD_SIZE as zt };
|
|
1184
|
+
//# sourceMappingURL=index-C4at2cZ_.d.ts.map
|