@send-fun/sdk 1.1.0 → 2.0.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/README.md +8 -9
- package/dist/index.cjs +777 -433
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +678 -217
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +678 -217
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +777 -433
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/dex/generated/accounts/globalConfig.ts +39 -2
- package/src/dex/generated/accounts/pool.ts +60 -9
- package/src/dex/generated/accounts/rewardAccrual.ts +39 -2
- package/src/dex/generated/errors/sendDex.ts +16 -8
- package/src/dex/generated/events/creatorClaimEvent.ts +3 -2
- package/src/dex/generated/events/poolCreateEvent.ts +8 -2
- package/src/dex/generated/events/tokenCreateEvent.ts +8 -9
- package/src/dex/generated/events/tradeEvent.ts +9 -2
- package/src/dex/generated/index.ts +1 -0
- package/src/dex/generated/instructions/claimCreatorFees.ts +21 -5
- package/src/{nexus → dex}/generated/pdas/creatorFeeConfig.ts +6 -6
- package/src/dex/generated/pdas/index.ts +1 -0
- package/src/dex/generated/plugins/sendDex.ts +3 -0
- package/src/dex/generated/shared/index.ts +52 -0
- package/src/dex/trade.ts +12 -13
- package/src/launchpad/create.ts +13 -38
- package/src/launchpad/generated/accounts/bondingCurve.ts +62 -9
- package/src/launchpad/generated/accounts/globalConfig.ts +39 -2
- package/src/launchpad/generated/accounts/rewardAccrual.ts +39 -2
- package/src/launchpad/generated/errors/sendLaunchpad.ts +12 -4
- package/src/launchpad/generated/events/completeEvent.ts +3 -2
- package/src/launchpad/generated/events/creatorClaimEvent.ts +3 -2
- package/src/launchpad/generated/events/migrateEvent.ts +3 -2
- package/src/launchpad/generated/events/tokenCreateEvent.ts +10 -9
- package/src/launchpad/generated/events/tradeEvent.ts +9 -2
- package/src/launchpad/generated/index.ts +1 -0
- package/src/launchpad/generated/instructions/claimCreatorFees.ts +17 -4
- package/src/launchpad/generated/instructions/createToken.ts +32 -50
- package/src/launchpad/generated/instructions/migrate.ts +79 -12
- package/src/launchpad/generated/pdas/creatorFeeConfig.ts +39 -0
- package/src/launchpad/generated/pdas/index.ts +1 -0
- package/src/launchpad/generated/plugins/sendLaunchpad.ts +3 -0
- package/src/launchpad/generated/shared/index.ts +52 -0
- package/src/launchpad/migrate.ts +7 -4
- package/src/launchpad/trade.ts +15 -15
- package/src/math/amm.ts +40 -33
- package/src/math/fee-decay.ts +3 -2
- package/src/math/fees.ts +4 -2
- package/src/math/internal.ts +1 -1
- package/src/nexus/fee-helpers.ts +10 -5
- package/src/nexus/generated/accounts/altRegistry.ts +41 -2
- package/src/nexus/generated/accounts/feePreset.ts +43 -4
- package/src/nexus/generated/accounts/globalConfig.ts +39 -2
- package/src/nexus/generated/accounts/index.ts +0 -1
- package/src/nexus/generated/accounts/partnerConfig.ts +48 -5
- package/src/nexus/generated/accounts/partnerMetadata.ts +39 -2
- package/src/nexus/generated/accounts/rewardState.ts +41 -2
- package/src/nexus/generated/accounts/sendNexus.accounts.ts +0 -5
- package/src/nexus/generated/accounts/stakingConfig.ts +39 -2
- package/src/nexus/generated/accounts/userRewardDebt.ts +42 -5
- package/src/nexus/generated/accounts/userStakePosition.ts +42 -5
- package/src/nexus/generated/errors/sendNexus.ts +12 -4
- package/src/nexus/generated/index.ts +1 -0
- package/src/nexus/generated/pdas/index.ts +0 -1
- package/src/nexus/generated/plugins/sendNexus.ts +0 -35
- package/src/nexus/generated/shared/index.ts +52 -0
- package/src/nexus/generated/types/dexFees.ts +4 -4
- package/src/nexus/generated/types/index.ts +0 -1
- package/src/nexus/generated/types/launchpadFees.ts +4 -4
- package/src/nexus/staking.ts +45 -41
- package/src/platform.ts +2 -2
- package/src/transfer-fee.ts +19 -17
- package/src/utils/chunk.ts +1 -1
- package/src/utils/index.ts +2 -5
- package/src/utils/mint-info.ts +8 -7
- package/src/utils/partner.ts +1 -1
- package/src/utils/pda.ts +1 -1
- package/src/nexus/generated/accounts/creatorFeeConfig.ts +0 -200
- package/src/nexus/generated/types/callerType.ts +0 -38
- package/src/utils/creator-hash.ts +0 -57
package/dist/index.cjs
CHANGED
|
@@ -30,22 +30,55 @@ var constants_exports = /* @__PURE__ */ __exportAll({
|
|
|
30
30
|
SEND_DEX_PROGRAM_ADDRESS: () => SEND_DEX_PROGRAM_ADDRESS,
|
|
31
31
|
SEND_LAUNCHPAD_PROGRAM_ADDRESS: () => SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
32
32
|
SEND_NEXUS_PROGRAM_ADDRESS: () => SEND_NEXUS_PROGRAM_ADDRESS,
|
|
33
|
-
SYSTEM_PROGRAM_ADDRESS: () => SYSTEM_PROGRAM_ADDRESS,
|
|
33
|
+
SYSTEM_PROGRAM_ADDRESS: () => SYSTEM_PROGRAM_ADDRESS$3,
|
|
34
34
|
TOKEN_2022_PROGRAM_ADDRESS: () => TOKEN_2022_PROGRAM_ADDRESS,
|
|
35
35
|
TOKEN_DECIMALS: () => 6,
|
|
36
36
|
TOKEN_PROGRAM_ADDRESS: () => TOKEN_PROGRAM_ADDRESS,
|
|
37
37
|
USDC_MINT: () => USDC_MINT,
|
|
38
38
|
WSOL_MINT: () => WSOL_MINT
|
|
39
39
|
});
|
|
40
|
-
const SYSTEM_PROGRAM_ADDRESS = (0, _solana_kit.address)("11111111111111111111111111111111");
|
|
40
|
+
const SYSTEM_PROGRAM_ADDRESS$3 = (0, _solana_kit.address)("11111111111111111111111111111111");
|
|
41
41
|
const TOKEN_PROGRAM_ADDRESS = (0, _solana_kit.address)("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
42
42
|
const TOKEN_2022_PROGRAM_ADDRESS = (0, _solana_kit.address)("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
|
43
43
|
const ASSOCIATED_TOKEN_PROGRAM_ADDRESS = (0, _solana_kit.address)("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
|
|
44
44
|
const WSOL_MINT = (0, _solana_kit.address)("So11111111111111111111111111111111111111112");
|
|
45
45
|
const USDC_MINT = (0, _solana_kit.address)("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
46
|
-
const DEFAULT_PARTNER = SYSTEM_PROGRAM_ADDRESS;
|
|
46
|
+
const DEFAULT_PARTNER = SYSTEM_PROGRAM_ADDRESS$3;
|
|
47
47
|
const PYTH_SOL_USD_PRICE_ACCOUNT = (0, _solana_kit.address)("7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE");
|
|
48
48
|
//#endregion
|
|
49
|
+
//#region src/dex/generated/shared/index.ts
|
|
50
|
+
/** The System Program, which owns every address nobody has created an account at yet. */
|
|
51
|
+
const SYSTEM_PROGRAM_ADDRESS$2 = "11111111111111111111111111111111";
|
|
52
|
+
/**
|
|
53
|
+
* Whether an encoded account was created on-chain, rather than merely sent lamports.
|
|
54
|
+
*
|
|
55
|
+
* Anyone can send lamports to an address before its account is created, which leaves it on-chain,
|
|
56
|
+
* owned by the System Program, with no data. This returns `false` for that shape, as it does for an
|
|
57
|
+
* account that does not exist. Any other existing account counts as created, whoever owns it; the
|
|
58
|
+
* `decode*` functions still check the owner.
|
|
59
|
+
*
|
|
60
|
+
* The generated `fetchMaybe*` and `fetchAllMaybe*` helpers apply this rule themselves. Apply it to
|
|
61
|
+
* accounts you fetch or receive another way (subscriptions, batch loaders, caches) before passing
|
|
62
|
+
* them to a `decode*` function, which throws for a lamports-only account: an account passed to it as
|
|
63
|
+
* existing must never come back as the non-existing variant typed as an `Account`.
|
|
64
|
+
*
|
|
65
|
+
* Only a `true` result narrows the type. A lamports-only account is still `exists: true` at runtime,
|
|
66
|
+
* so a `false` result leaves the type unchanged instead of narrowing it to the non-existing variant.
|
|
67
|
+
* The `uncreated` property in the narrowed type is never present; it exists only to prevent that.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const maybeAccount = decodeMyAccount(
|
|
72
|
+
* accountIsCreated(encodedAccount) ? encodedAccount : { address: encodedAccount.address, exists: false },
|
|
73
|
+
* );
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
function accountIsCreated$2(account) {
|
|
77
|
+
const maybeAccount = account;
|
|
78
|
+
if ("exists" in maybeAccount && !maybeAccount.exists) return false;
|
|
79
|
+
return !(maybeAccount.programAddress === SYSTEM_PROGRAM_ADDRESS$2 && maybeAccount.data.length === 0);
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
49
82
|
//#region src/dex/generated/accounts/globalConfig.ts
|
|
50
83
|
/**
|
|
51
84
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -113,21 +146,40 @@ function decodeGlobalConfig$2(encodedAccount) {
|
|
|
113
146
|
}
|
|
114
147
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getGlobalConfigDecoder$2());
|
|
115
148
|
}
|
|
149
|
+
/** Fetches a `GlobalConfig` account, throwing when it does not exist or only holds lamports. */
|
|
116
150
|
async function fetchGlobalConfig$2(rpc, address, config) {
|
|
117
151
|
const maybeAccount = await fetchMaybeGlobalConfig$2(rpc, address, config);
|
|
118
152
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
119
153
|
return maybeAccount;
|
|
120
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Fetches a `GlobalConfig` account, or the non-existing variant when the address holds no
|
|
157
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
158
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
159
|
+
*/
|
|
121
160
|
async function fetchMaybeGlobalConfig$2(rpc, address, config) {
|
|
122
|
-
|
|
161
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
162
|
+
return decodeGlobalConfig$2(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
163
|
+
address,
|
|
164
|
+
exists: false
|
|
165
|
+
});
|
|
123
166
|
}
|
|
167
|
+
/** Fetches `GlobalConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
124
168
|
async function fetchAllGlobalConfig$2(rpc, addresses, config) {
|
|
125
169
|
const maybeAccounts = await fetchAllMaybeGlobalConfig$2(rpc, addresses, config);
|
|
126
170
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
127
171
|
return maybeAccounts;
|
|
128
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Fetches `GlobalConfig` accounts, with the non-existing variant for each address that holds
|
|
175
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
176
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
177
|
+
*/
|
|
129
178
|
async function fetchAllMaybeGlobalConfig$2(rpc, addresses, config) {
|
|
130
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig$2(maybeAccount)
|
|
179
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig$2(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
180
|
+
address: maybeAccount.address,
|
|
181
|
+
exists: false
|
|
182
|
+
}));
|
|
131
183
|
}
|
|
132
184
|
function getGlobalConfigSize$1() {
|
|
133
185
|
return 139;
|
|
@@ -224,7 +276,7 @@ function getPoolEncoder() {
|
|
|
224
276
|
["quoteMint", (0, _solana_kit.getAddressEncoder)()],
|
|
225
277
|
["quoteDecimals", (0, _solana_kit.getU8Encoder)()],
|
|
226
278
|
["coinCreator", (0, _solana_kit.getAddressEncoder)()],
|
|
227
|
-
["
|
|
279
|
+
["padding0", (0, _solana_kit.getArrayEncoder)((0, _solana_kit.getU64Encoder)(), { size: 4 })],
|
|
228
280
|
["baseVault", (0, _solana_kit.getAddressEncoder)()],
|
|
229
281
|
["quoteVault", (0, _solana_kit.getAddressEncoder)()],
|
|
230
282
|
["lpMint", (0, _solana_kit.getAddressEncoder)()],
|
|
@@ -236,7 +288,9 @@ function getPoolEncoder() {
|
|
|
236
288
|
["protocolOwed", (0, _solana_kit.getU64Encoder)()],
|
|
237
289
|
["creatorOwed", (0, _solana_kit.getU64Encoder)()],
|
|
238
290
|
["platformConfig", (0, _solana_kit.getAddressEncoder)()],
|
|
239
|
-
["
|
|
291
|
+
["creatorFeeMode", (0, _solana_kit.getU8Encoder)()],
|
|
292
|
+
["creatorFeeBps", (0, _solana_kit.getU16Encoder)()],
|
|
293
|
+
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 256)]
|
|
240
294
|
]), (value) => ({
|
|
241
295
|
...value,
|
|
242
296
|
discriminator: POOL_DISCRIMINATOR
|
|
@@ -254,7 +308,7 @@ function getPoolDecoder() {
|
|
|
254
308
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
255
309
|
["quoteDecimals", (0, _solana_kit.getU8Decoder)()],
|
|
256
310
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
257
|
-
["
|
|
311
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 4 })],
|
|
258
312
|
["baseVault", (0, _solana_kit.getAddressDecoder)()],
|
|
259
313
|
["quoteVault", (0, _solana_kit.getAddressDecoder)()],
|
|
260
314
|
["lpMint", (0, _solana_kit.getAddressDecoder)()],
|
|
@@ -266,7 +320,9 @@ function getPoolDecoder() {
|
|
|
266
320
|
["protocolOwed", (0, _solana_kit.getU64Decoder)()],
|
|
267
321
|
["creatorOwed", (0, _solana_kit.getU64Decoder)()],
|
|
268
322
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
269
|
-
["
|
|
323
|
+
["creatorFeeMode", (0, _solana_kit.getU8Decoder)()],
|
|
324
|
+
["creatorFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
325
|
+
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 256)]
|
|
270
326
|
]);
|
|
271
327
|
}
|
|
272
328
|
/** Gets the codec for {@link Pool} account data. */
|
|
@@ -288,24 +344,43 @@ function decodePool(encodedAccount) {
|
|
|
288
344
|
}
|
|
289
345
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getPoolDecoder());
|
|
290
346
|
}
|
|
347
|
+
/** Fetches a `Pool` account, throwing when it does not exist or only holds lamports. */
|
|
291
348
|
async function fetchPool(rpc, address, config) {
|
|
292
349
|
const maybeAccount = await fetchMaybePool(rpc, address, config);
|
|
293
350
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
294
351
|
return maybeAccount;
|
|
295
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Fetches a `Pool` account, or the non-existing variant when the address holds no
|
|
355
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
356
|
+
* {@link decodePool} throws for a lamports-only account instead.
|
|
357
|
+
*/
|
|
296
358
|
async function fetchMaybePool(rpc, address, config) {
|
|
297
|
-
|
|
359
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
360
|
+
return decodePool(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
361
|
+
address,
|
|
362
|
+
exists: false
|
|
363
|
+
});
|
|
298
364
|
}
|
|
365
|
+
/** Fetches `Pool` accounts, throwing when any does not exist or only holds lamports. */
|
|
299
366
|
async function fetchAllPool(rpc, addresses, config) {
|
|
300
367
|
const maybeAccounts = await fetchAllMaybePool(rpc, addresses, config);
|
|
301
368
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
302
369
|
return maybeAccounts;
|
|
303
370
|
}
|
|
371
|
+
/**
|
|
372
|
+
* Fetches `Pool` accounts, with the non-existing variant for each address that holds
|
|
373
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
374
|
+
* {@link decodePool} throws for a lamports-only account instead.
|
|
375
|
+
*/
|
|
304
376
|
async function fetchAllMaybePool(rpc, addresses, config) {
|
|
305
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodePool(maybeAccount)
|
|
377
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodePool(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
378
|
+
address: maybeAccount.address,
|
|
379
|
+
exists: false
|
|
380
|
+
}));
|
|
306
381
|
}
|
|
307
382
|
function getPoolSize() {
|
|
308
|
-
return
|
|
383
|
+
return 584;
|
|
309
384
|
}
|
|
310
385
|
//#endregion
|
|
311
386
|
//#region src/dex/generated/accounts/rewardAccrual.ts
|
|
@@ -375,21 +450,40 @@ function decodeRewardAccrual$1(encodedAccount) {
|
|
|
375
450
|
}
|
|
376
451
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getRewardAccrualDecoder$1());
|
|
377
452
|
}
|
|
453
|
+
/** Fetches a `RewardAccrual` account, throwing when it does not exist or only holds lamports. */
|
|
378
454
|
async function fetchRewardAccrual$1(rpc, address, config) {
|
|
379
455
|
const maybeAccount = await fetchMaybeRewardAccrual$1(rpc, address, config);
|
|
380
456
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
381
457
|
return maybeAccount;
|
|
382
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Fetches a `RewardAccrual` account, or the non-existing variant when the address holds no
|
|
461
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
462
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
463
|
+
*/
|
|
383
464
|
async function fetchMaybeRewardAccrual$1(rpc, address, config) {
|
|
384
|
-
|
|
465
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
466
|
+
return decodeRewardAccrual$1(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
467
|
+
address,
|
|
468
|
+
exists: false
|
|
469
|
+
});
|
|
385
470
|
}
|
|
471
|
+
/** Fetches `RewardAccrual` accounts, throwing when any does not exist or only holds lamports. */
|
|
386
472
|
async function fetchAllRewardAccrual$1(rpc, addresses, config) {
|
|
387
473
|
const maybeAccounts = await fetchAllMaybeRewardAccrual$1(rpc, addresses, config);
|
|
388
474
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
389
475
|
return maybeAccounts;
|
|
390
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Fetches `RewardAccrual` accounts, with the non-existing variant for each address that holds
|
|
479
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
480
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
481
|
+
*/
|
|
391
482
|
async function fetchAllMaybeRewardAccrual$1(rpc, addresses, config) {
|
|
392
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeRewardAccrual$1(maybeAccount)
|
|
483
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeRewardAccrual$1(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
484
|
+
address: maybeAccount.address,
|
|
485
|
+
exists: false
|
|
486
|
+
}));
|
|
393
487
|
}
|
|
394
488
|
function getRewardAccrualSize$1() {
|
|
395
489
|
return 130;
|
|
@@ -484,8 +578,8 @@ const SEND_DEX_ERROR__INVALID_POOL_BALANCE = 6008;
|
|
|
484
578
|
const SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE = 6009;
|
|
485
579
|
/** InvalidAuthority: Invalid authority */
|
|
486
580
|
const SEND_DEX_ERROR__INVALID_AUTHORITY = 6010;
|
|
487
|
-
/**
|
|
488
|
-
const
|
|
581
|
+
/** InvalidCoinCreator: Invalid coin creator */
|
|
582
|
+
const SEND_DEX_ERROR__INVALID_COIN_CREATOR = 6011;
|
|
489
583
|
/** InvalidPlatformConfig: Platform config cannot be the default address */
|
|
490
584
|
const SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG = 6012;
|
|
491
585
|
/** ProgramPaused: Program is paused */
|
|
@@ -512,26 +606,31 @@ const SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 7009;
|
|
|
512
606
|
const SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 7010;
|
|
513
607
|
/** NothingToClaim: Nothing to claim */
|
|
514
608
|
const SEND_DEX_ERROR__NOTHING_TO_CLAIM = 7011;
|
|
515
|
-
/**
|
|
516
|
-
const
|
|
609
|
+
/** Unused7012: Unused */
|
|
610
|
+
const SEND_DEX_ERROR__UNUSED7012 = 7012;
|
|
517
611
|
/** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
|
|
518
612
|
const SEND_DEX_ERROR__QUOTE_MINT_PRICE_UNSET = 7013;
|
|
519
613
|
/** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
|
|
520
614
|
const SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 7014;
|
|
615
|
+
/** CreatorFeeTooHigh: Creator fee exceeds the partner's maximum */
|
|
616
|
+
const SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH = 7015;
|
|
617
|
+
/** CreatorFeeModeNotAllowed: Creator fee mode is not allowed by the partner config */
|
|
618
|
+
const SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED = 7016;
|
|
521
619
|
/** InsufficientLiquidity: Insufficient liquidity */
|
|
522
620
|
const SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY = 7100;
|
|
523
621
|
/** InvalidAmount: Invalid amount */
|
|
524
622
|
const SEND_DEX_ERROR__INVALID_AMOUNT = 7101;
|
|
525
623
|
const sendDexErrorMessages = {
|
|
526
624
|
[SEND_DEX_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
625
|
+
[SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED]: `Creator fee mode is not allowed by the partner config`,
|
|
626
|
+
[SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH]: `Creator fee exceeds the partner's maximum`,
|
|
527
627
|
[SEND_DEX_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance in source account`,
|
|
528
628
|
[SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
529
629
|
[SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE]: `Insufficient pool balance`,
|
|
530
630
|
[SEND_DEX_ERROR__INVALID_AMOUNT]: `Invalid amount`,
|
|
531
631
|
[SEND_DEX_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
|
|
532
632
|
[SEND_DEX_ERROR__INVALID_BASE_MINT]: `Invalid base mint`,
|
|
533
|
-
[
|
|
534
|
-
[SEND_DEX_ERROR__INVALID_CREATOR_ID]: `Creator identity is not a decodable wallet address`,
|
|
633
|
+
[SEND_DEX_ERROR__INVALID_COIN_CREATOR]: `Invalid coin creator`,
|
|
535
634
|
[SEND_DEX_ERROR__INVALID_DEPOSIT]: `Invalid deposit`,
|
|
536
635
|
[SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG]: `Platform config cannot be the default address`,
|
|
537
636
|
[SEND_DEX_ERROR__INVALID_POOL_BALANCE]: `Invalid pool balance`,
|
|
@@ -549,6 +648,7 @@ const sendDexErrorMessages = {
|
|
|
549
648
|
[SEND_DEX_ERROR__TEXT_TOO_LONG]: `Text too long`,
|
|
550
649
|
[SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
|
|
551
650
|
[SEND_DEX_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
651
|
+
[SEND_DEX_ERROR__UNUSED7012]: `Unused`,
|
|
552
652
|
[SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
|
|
553
653
|
[SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
|
|
554
654
|
[SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT]: `User token account mint does not match the trade`,
|
|
@@ -564,14 +664,15 @@ function isSendDexError(error, transactionMessage, code) {
|
|
|
564
664
|
//#region src/dex/generated/errors/index.ts
|
|
565
665
|
var errors_exports$2 = /* @__PURE__ */ __exportAll({
|
|
566
666
|
SEND_DEX_ERROR__ARITHMETIC_OVERFLOW: () => SEND_DEX_ERROR__ARITHMETIC_OVERFLOW,
|
|
667
|
+
SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED: () => SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED,
|
|
668
|
+
SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH: () => SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH,
|
|
567
669
|
SEND_DEX_ERROR__INSUFFICIENT_BALANCE: () => SEND_DEX_ERROR__INSUFFICIENT_BALANCE,
|
|
568
670
|
SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY: () => SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY,
|
|
569
671
|
SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE: () => SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE,
|
|
570
672
|
SEND_DEX_ERROR__INVALID_AMOUNT: () => SEND_DEX_ERROR__INVALID_AMOUNT,
|
|
571
673
|
SEND_DEX_ERROR__INVALID_AUTHORITY: () => SEND_DEX_ERROR__INVALID_AUTHORITY,
|
|
572
674
|
SEND_DEX_ERROR__INVALID_BASE_MINT: () => SEND_DEX_ERROR__INVALID_BASE_MINT,
|
|
573
|
-
|
|
574
|
-
SEND_DEX_ERROR__INVALID_CREATOR_ID: () => SEND_DEX_ERROR__INVALID_CREATOR_ID,
|
|
675
|
+
SEND_DEX_ERROR__INVALID_COIN_CREATOR: () => SEND_DEX_ERROR__INVALID_COIN_CREATOR,
|
|
575
676
|
SEND_DEX_ERROR__INVALID_DEPOSIT: () => SEND_DEX_ERROR__INVALID_DEPOSIT,
|
|
576
677
|
SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG: () => SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG,
|
|
577
678
|
SEND_DEX_ERROR__INVALID_POOL_BALANCE: () => SEND_DEX_ERROR__INVALID_POOL_BALANCE,
|
|
@@ -589,6 +690,7 @@ var errors_exports$2 = /* @__PURE__ */ __exportAll({
|
|
|
589
690
|
SEND_DEX_ERROR__TEXT_TOO_LONG: () => SEND_DEX_ERROR__TEXT_TOO_LONG,
|
|
590
691
|
SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE: () => SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE,
|
|
591
692
|
SEND_DEX_ERROR__UNAUTHORIZED: () => SEND_DEX_ERROR__UNAUTHORIZED,
|
|
693
|
+
SEND_DEX_ERROR__UNUSED7012: () => SEND_DEX_ERROR__UNUSED7012,
|
|
592
694
|
SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_INVALID: () => SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_INVALID,
|
|
593
695
|
SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY: () => SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY,
|
|
594
696
|
SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT: () => SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT,
|
|
@@ -598,6 +700,44 @@ var errors_exports$2 = /* @__PURE__ */ __exportAll({
|
|
|
598
700
|
sendDexErrorMessages: () => sendDexErrorMessages
|
|
599
701
|
});
|
|
600
702
|
//#endregion
|
|
703
|
+
//#region src/dex/generated/pdas/creatorFeeConfig.ts
|
|
704
|
+
/**
|
|
705
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
706
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
707
|
+
* to add features, then rerun Codama to update it.
|
|
708
|
+
*
|
|
709
|
+
* @see https://github.com/codama-idl/codama
|
|
710
|
+
*/
|
|
711
|
+
async function findCreatorFeeConfigPda$1(seeds) {
|
|
712
|
+
return await (0, _solana_kit.getProgramDerivedAddress)({
|
|
713
|
+
programAddress: SEND_DEX_PROGRAM_ADDRESS,
|
|
714
|
+
seeds: [
|
|
715
|
+
(0, _solana_kit.getBytesEncoder)().encode(new Uint8Array([
|
|
716
|
+
99,
|
|
717
|
+
114,
|
|
718
|
+
101,
|
|
719
|
+
97,
|
|
720
|
+
116,
|
|
721
|
+
111,
|
|
722
|
+
114,
|
|
723
|
+
95,
|
|
724
|
+
102,
|
|
725
|
+
101,
|
|
726
|
+
101,
|
|
727
|
+
95,
|
|
728
|
+
99,
|
|
729
|
+
111,
|
|
730
|
+
110,
|
|
731
|
+
102,
|
|
732
|
+
105,
|
|
733
|
+
103
|
|
734
|
+
])),
|
|
735
|
+
(0, _solana_kit.getAddressEncoder)().encode(seeds.baseMint),
|
|
736
|
+
(0, _solana_kit.getAddressEncoder)().encode(seeds.quoteMint)
|
|
737
|
+
]
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
//#endregion
|
|
601
741
|
//#region src/dex/generated/pdas/eventAuthority.ts
|
|
602
742
|
const EVENT_AUTHORITY_PDA_ADDRESS$2 = "4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t";
|
|
603
743
|
function findEventAuthorityPda$2() {
|
|
@@ -702,6 +842,7 @@ var pdas_exports$2 = /* @__PURE__ */ __exportAll({
|
|
|
702
842
|
EVENT_AUTHORITY_PDA_ADDRESS: () => EVENT_AUTHORITY_PDA_ADDRESS$2,
|
|
703
843
|
GLOBAL_CONFIG_PDA_ADDRESS: () => GLOBAL_CONFIG_PDA_ADDRESS$2,
|
|
704
844
|
WSOL_REWARD_ACCRUAL_PDA_ADDRESS: () => WSOL_REWARD_ACCRUAL_PDA_ADDRESS$1,
|
|
845
|
+
findCreatorFeeConfigPda: () => findCreatorFeeConfigPda$1,
|
|
705
846
|
findEventAuthorityPda: () => findEventAuthorityPda$2,
|
|
706
847
|
findGlobalConfigPda: () => findGlobalConfigPda$2,
|
|
707
848
|
findLpMintPda: () => findLpMintPda,
|
|
@@ -767,7 +908,7 @@ function getCreatorClaimEventDecoder$1() {
|
|
|
767
908
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
768
909
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
769
910
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
770
|
-
["
|
|
911
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 4 })],
|
|
771
912
|
["claimer", (0, _solana_kit.getAddressDecoder)()],
|
|
772
913
|
["destinationOwner", (0, _solana_kit.getAddressDecoder)()],
|
|
773
914
|
["amount", (0, _solana_kit.getU64Decoder)()],
|
|
@@ -910,7 +1051,7 @@ function getPoolCreateEventDecoder() {
|
|
|
910
1051
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
911
1052
|
["quoteDecimals", (0, _solana_kit.getU8Decoder)()],
|
|
912
1053
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
913
|
-
["
|
|
1054
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 4 })],
|
|
914
1055
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
915
1056
|
["baseVault", (0, _solana_kit.getAddressDecoder)()],
|
|
916
1057
|
["quoteVault", (0, _solana_kit.getAddressDecoder)()],
|
|
@@ -918,7 +1059,9 @@ function getPoolCreateEventDecoder() {
|
|
|
918
1059
|
["lpMinted", (0, _solana_kit.getU64Decoder)()],
|
|
919
1060
|
["baseReserves", (0, _solana_kit.getU64Decoder)()],
|
|
920
1061
|
["quoteReserves", (0, _solana_kit.getU64Decoder)()],
|
|
921
|
-
["timestamp", (0, _solana_kit.getI64Decoder)()]
|
|
1062
|
+
["timestamp", (0, _solana_kit.getI64Decoder)()],
|
|
1063
|
+
["creatorFeeMode", (0, _solana_kit.getU8Decoder)()],
|
|
1064
|
+
["creatorFeeBps", (0, _solana_kit.getU16Decoder)()]
|
|
922
1065
|
]);
|
|
923
1066
|
}
|
|
924
1067
|
/**
|
|
@@ -1055,9 +1198,7 @@ function getTokenCreateEventDecoder$1() {
|
|
|
1055
1198
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
1056
1199
|
["quoteDecimals", (0, _solana_kit.getU8Decoder)()],
|
|
1057
1200
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
1058
|
-
["
|
|
1059
|
-
["creatorId", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
1060
|
-
["creatorFeeConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
1201
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 5 })],
|
|
1061
1202
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
1062
1203
|
["name", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
1063
1204
|
["symbol", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
@@ -1067,7 +1208,9 @@ function getTokenCreateEventDecoder$1() {
|
|
|
1067
1208
|
["creationFee", (0, _solana_kit.getU64Decoder)()],
|
|
1068
1209
|
["baseReserves", (0, _solana_kit.getU64Decoder)()],
|
|
1069
1210
|
["quoteReserves", (0, _solana_kit.getU64Decoder)()],
|
|
1070
|
-
["timestamp", (0, _solana_kit.getI64Decoder)()]
|
|
1211
|
+
["timestamp", (0, _solana_kit.getI64Decoder)()],
|
|
1212
|
+
["creatorFeeMode", (0, _solana_kit.getU8Decoder)()],
|
|
1213
|
+
["creatorFeeBps", (0, _solana_kit.getU16Decoder)()]
|
|
1071
1214
|
]);
|
|
1072
1215
|
}
|
|
1073
1216
|
/**
|
|
@@ -1134,7 +1277,7 @@ function getTradeEventDecoder$1() {
|
|
|
1134
1277
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
1135
1278
|
["user", (0, _solana_kit.getAddressDecoder)()],
|
|
1136
1279
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
1137
|
-
["
|
|
1280
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 4 })],
|
|
1138
1281
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
1139
1282
|
["baseAmount", (0, _solana_kit.getU64Decoder)()],
|
|
1140
1283
|
["quoteAmountGross", (0, _solana_kit.getU64Decoder)()],
|
|
@@ -1149,7 +1292,9 @@ function getTradeEventDecoder$1() {
|
|
|
1149
1292
|
["quoteTransferFee", (0, _solana_kit.getU64Decoder)()],
|
|
1150
1293
|
["baseReserves", (0, _solana_kit.getU64Decoder)()],
|
|
1151
1294
|
["quoteReserves", (0, _solana_kit.getU64Decoder)()],
|
|
1152
|
-
["timestamp", (0, _solana_kit.getI64Decoder)()]
|
|
1295
|
+
["timestamp", (0, _solana_kit.getI64Decoder)()],
|
|
1296
|
+
["creatorFeeMode", (0, _solana_kit.getU8Decoder)()],
|
|
1297
|
+
["creatorFeeBps", (0, _solana_kit.getU16Decoder)()]
|
|
1153
1298
|
]);
|
|
1154
1299
|
}
|
|
1155
1300
|
/**
|
|
@@ -2028,7 +2173,7 @@ async function getClaimCreatorFeesInstructionAsync$1(input) {
|
|
|
2028
2173
|
},
|
|
2029
2174
|
creatorFeeConfig: {
|
|
2030
2175
|
value: input.creatorFeeConfig ?? null,
|
|
2031
|
-
isWritable:
|
|
2176
|
+
isWritable: true
|
|
2032
2177
|
},
|
|
2033
2178
|
nexusGlobalConfig: {
|
|
2034
2179
|
value: null,
|
|
@@ -2079,6 +2224,10 @@ async function getClaimCreatorFeesInstructionAsync$1(input) {
|
|
|
2079
2224
|
baseMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("baseMint", accounts.baseMint.value),
|
|
2080
2225
|
quoteMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("quoteMint", accounts.quoteMint.value)
|
|
2081
2226
|
});
|
|
2227
|
+
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda$1({
|
|
2228
|
+
baseMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("baseMint", accounts.baseMint.value),
|
|
2229
|
+
quoteMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("quoteMint", accounts.quoteMint.value)
|
|
2230
|
+
});
|
|
2082
2231
|
if (!accounts.nexusGlobalConfig.value) accounts.nexusGlobalConfig.value = "3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr";
|
|
2083
2232
|
if (!accounts.quoteVault.value) accounts.quoteVault.value = await (0, _solana_kit.getProgramDerivedAddress)({
|
|
2084
2233
|
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
@@ -2140,7 +2289,7 @@ function getClaimCreatorFeesInstruction$1(input) {
|
|
|
2140
2289
|
},
|
|
2141
2290
|
creatorFeeConfig: {
|
|
2142
2291
|
value: input.creatorFeeConfig ?? null,
|
|
2143
|
-
isWritable:
|
|
2292
|
+
isWritable: true
|
|
2144
2293
|
},
|
|
2145
2294
|
nexusGlobalConfig: {
|
|
2146
2295
|
value: null,
|
|
@@ -3403,6 +3552,7 @@ function sendDexProgram() {
|
|
|
3403
3552
|
pdas: {
|
|
3404
3553
|
pool: findPoolPda,
|
|
3405
3554
|
eventAuthority: findEventAuthorityPda$2,
|
|
3555
|
+
creatorFeeConfig: findCreatorFeeConfigPda$1,
|
|
3406
3556
|
rewardAccrual: findRewardAccrualPda$1,
|
|
3407
3557
|
globalConfig: findGlobalConfigPda$2,
|
|
3408
3558
|
lpMint: findLpMintPda,
|
|
@@ -3449,12 +3599,11 @@ var amm_exports = /* @__PURE__ */ __exportAll({
|
|
|
3449
3599
|
});
|
|
3450
3600
|
const BPS_DIVISOR = 10000n;
|
|
3451
3601
|
const U64_MAX = 18446744073709551615n;
|
|
3452
|
-
/** Each call mirrors a `u64::try_from` in the Rust twin; drop one and an oversized leg fails in the encoder. */
|
|
3453
3602
|
function assertU64(label, value) {
|
|
3454
3603
|
if (value > U64_MAX) throw new RangeError(`${label}: overflows u64`);
|
|
3455
3604
|
return value;
|
|
3456
3605
|
}
|
|
3457
|
-
/**
|
|
3606
|
+
/** Thrown when no transfer delivers exactly `amount` after the transfer fee. */
|
|
3458
3607
|
var TransferFeeNotSettleableError = class extends RangeError {
|
|
3459
3608
|
amount;
|
|
3460
3609
|
mintFee;
|
|
@@ -3469,7 +3618,8 @@ function assertMintFee(fee) {
|
|
|
3469
3618
|
assertBps("MintFee", "bps", fee.bps);
|
|
3470
3619
|
if (fee.maximumFee < 0n || fee.maximumFee > U64_MAX) throw new RangeError("MintFee: maximumFee must fit a u64");
|
|
3471
3620
|
}
|
|
3472
|
-
/** Rounds up, then caps
|
|
3621
|
+
/** Returns the transfer fee on `amount`. Rounds up, then caps at `maximumFee`, in SPL's order.
|
|
3622
|
+
* Returns 0 without `fee`. Throws `RangeError` if `fee` is out of range. */
|
|
3473
3623
|
function feeOn(amount, fee) {
|
|
3474
3624
|
if (fee === void 0) return 0n;
|
|
3475
3625
|
assertMintFee(fee);
|
|
@@ -3477,11 +3627,11 @@ function feeOn(amount, fee) {
|
|
|
3477
3627
|
const raw = ceilDiv(amount * BigInt(fee.bps), BPS_DIVISOR);
|
|
3478
3628
|
return raw < fee.maximumFee ? raw : fee.maximumFee;
|
|
3479
3629
|
}
|
|
3480
|
-
/**
|
|
3630
|
+
/** Returns what the recipient receives when `amount` is sent. `grossUp` is the inverse. */
|
|
3481
3631
|
function amountAfterFee(amount, fee) {
|
|
3482
3632
|
return amount - feeOn(amount, fee);
|
|
3483
3633
|
}
|
|
3484
|
-
/**
|
|
3634
|
+
/** Matches SPL `TransferFee::calculate_pre_fee_amount`. `undefined` if the result does not fit a u64. */
|
|
3485
3635
|
function preFeeAmount(amount, fee) {
|
|
3486
3636
|
const bps = BigInt(fee.bps);
|
|
3487
3637
|
if (bps === 0n) return amount;
|
|
@@ -3497,7 +3647,8 @@ function preFeeAmount(amount, fee) {
|
|
|
3497
3647
|
}
|
|
3498
3648
|
return rawPreFee > U64_MAX ? void 0 : rawPreFee;
|
|
3499
3649
|
}
|
|
3500
|
-
/**
|
|
3650
|
+
/** Returns the amount to send so that exactly `amount` arrives. Returns `amount` without `fee`.
|
|
3651
|
+
* Throws {@link TransferFeeNotSettleableError} if no such amount exists. */
|
|
3501
3652
|
function grossUp(amount, fee) {
|
|
3502
3653
|
if (fee === void 0) return amount;
|
|
3503
3654
|
assertMintFee(fee);
|
|
@@ -3520,7 +3671,8 @@ function sqrtBigInt(value) {
|
|
|
3520
3671
|
}
|
|
3521
3672
|
return x;
|
|
3522
3673
|
}
|
|
3523
|
-
/**
|
|
3674
|
+
/** Returns the constant-product output for `amountIn`, rounded down. Throws `RangeError` on a zero
|
|
3675
|
+
* reserve, a zero `amountIn`, a zero output, or an output past u64. */
|
|
3524
3676
|
function calculateOutput(reserveIn, reserveOut, amountIn) {
|
|
3525
3677
|
if (reserveIn === 0n || reserveOut === 0n) throw new RangeError("calculateOutput: insufficient liquidity");
|
|
3526
3678
|
if (amountIn === 0n) throw new RangeError("calculateOutput: invalid amount");
|
|
@@ -3530,7 +3682,8 @@ function calculateOutput(reserveIn, reserveOut, amountIn) {
|
|
|
3530
3682
|
if (amountOut === 0n) throw new RangeError("calculateOutput: insufficient liquidity");
|
|
3531
3683
|
return assertU64("calculateOutput", amountOut);
|
|
3532
3684
|
}
|
|
3533
|
-
/**
|
|
3685
|
+
/** Returns the input needed for `amountOut`, rounded up. Throws `RangeError` on a zero reserve, a zero
|
|
3686
|
+
* `amountOut`, an `amountOut` not below `reserveOut`, or an input past u64. */
|
|
3534
3687
|
function calculateInputForOutput(reserveIn, reserveOut, amountOut) {
|
|
3535
3688
|
if (reserveIn === 0n || reserveOut === 0n) throw new RangeError("calculateInputForOutput: insufficient liquidity");
|
|
3536
3689
|
if (amountOut === 0n || amountOut >= reserveOut) throw new RangeError("calculateInputForOutput: invalid amount");
|
|
@@ -3593,7 +3746,9 @@ function buyQuote(legs, quoteTransferFee, baseFee) {
|
|
|
3593
3746
|
quoteFromUser: legs.quoteAmount
|
|
3594
3747
|
};
|
|
3595
3748
|
}
|
|
3596
|
-
/**
|
|
3749
|
+
/** Quotes a buy where the buyer receives `baseAmountOut`. With `baseReserveCap`, the vault sends at
|
|
3750
|
+
* most the cap. Guard with `calculateSlippageUp(quoteAmount, bps)`. `quoteAmount` includes the quote
|
|
3751
|
+
* mint's transfer fee. */
|
|
3597
3752
|
function buyExactOut$2(params) {
|
|
3598
3753
|
assertBps("buyExactOut", "feeBps", params.feeBps);
|
|
3599
3754
|
if (params.baseAmountOut === 0n) throw new RangeError("buyExactOut: invalid amount");
|
|
@@ -3606,7 +3761,8 @@ function buyExactOut$2(params) {
|
|
|
3606
3761
|
quoteAmount: quoteFromUser
|
|
3607
3762
|
}, quoteFromUser - legs.quoteAmount, params.baseFee);
|
|
3608
3763
|
}
|
|
3609
|
-
/** Guard with `calculateSlippageDown(baseToUser, bps)`, not
|
|
3764
|
+
/** Quotes a buy that spends `quoteAmountIn`. Guard with `calculateSlippageDown(baseToUser, bps)`, not
|
|
3765
|
+
* `baseAmount`. The program checks the minimum against what the buyer receives. */
|
|
3610
3766
|
function buyExactIn$2(params) {
|
|
3611
3767
|
assertBps("buyExactIn", "feeBps", params.feeBps);
|
|
3612
3768
|
if (params.quoteAmountIn === 0n) throw new RangeError("buyExactIn: invalid amount");
|
|
@@ -3625,7 +3781,7 @@ function buyExactIn$2(params) {
|
|
|
3625
3781
|
quoteAmount: quoteFromUser
|
|
3626
3782
|
}, quoteFromUser - capped.quoteAmount, params.baseFee);
|
|
3627
3783
|
}
|
|
3628
|
-
/** Guard with `calculateSlippageDown(quoteToUser, bps)`, not `quoteAmount`. */
|
|
3784
|
+
/** Quotes a sell of `baseAmountIn`. Guard with `calculateSlippageDown(quoteToUser, bps)`, not `quoteAmount`. */
|
|
3629
3785
|
function sellExactIn$2(params) {
|
|
3630
3786
|
assertBps("sellExactIn", "feeBps", params.feeBps);
|
|
3631
3787
|
if (params.baseAmountIn === 0n) throw new RangeError("sellExactIn: invalid amount");
|
|
@@ -3643,7 +3799,8 @@ function sellExactIn$2(params) {
|
|
|
3643
3799
|
quoteToUser: legs.quoteAmount - quoteTransferFee
|
|
3644
3800
|
};
|
|
3645
3801
|
}
|
|
3646
|
-
/**
|
|
3802
|
+
/** Quotes a sell where the seller receives `quoteAmountOut`. Guard with
|
|
3803
|
+
* `calculateSlippageUp(baseFromUser, bps)`. `baseFromUser` includes the base mint's transfer fee. */
|
|
3647
3804
|
function sellExactOut$2(params) {
|
|
3648
3805
|
assertBps("sellExactOut", "feeBps", params.feeBps);
|
|
3649
3806
|
if (params.quoteAmountOut === 0n) throw new RangeError("sellExactOut: invalid amount");
|
|
@@ -3668,17 +3825,17 @@ function calculateSlippageDown(amount, slippageBps) {
|
|
|
3668
3825
|
assertBps("calculateSlippageDown", "slippageBps", slippageBps);
|
|
3669
3826
|
return assertU64("calculateSlippageDown", floorDiv(amount * (BPS_DIVISOR - BigInt(slippageBps)), BPS_DIVISOR));
|
|
3670
3827
|
}
|
|
3671
|
-
/**
|
|
3828
|
+
/** Returns `sqrt(quoteAmount * baseAmount)`, rounded down. */
|
|
3672
3829
|
function calculateInitialLp(quoteAmount, baseAmount) {
|
|
3673
3830
|
return sqrtBigInt(quoteAmount * baseAmount);
|
|
3674
3831
|
}
|
|
3675
|
-
/**
|
|
3832
|
+
/** Returns the price of one base token in quote tokens, as a float. For display only. */
|
|
3676
3833
|
function calculatePrice(params) {
|
|
3677
3834
|
const { quoteReserves, baseReserves, quoteDecimals, baseDecimals } = params;
|
|
3678
3835
|
if (baseReserves === 0n) return 0;
|
|
3679
3836
|
return Number(quoteReserves) / Number(baseReserves) * 10 ** (baseDecimals - quoteDecimals);
|
|
3680
3837
|
}
|
|
3681
|
-
/**
|
|
3838
|
+
/** Returns the market cap in raw quote units. */
|
|
3682
3839
|
function calculateMarketCap(params) {
|
|
3683
3840
|
const { quoteReserves, baseReserves, baseSupply } = params;
|
|
3684
3841
|
if (baseReserves === 0n) return 0n;
|
|
@@ -3696,7 +3853,7 @@ var trade_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
3696
3853
|
sellExactIn: () => sellExactIn$1,
|
|
3697
3854
|
sellExactOut: () => sellExactOut$1
|
|
3698
3855
|
});
|
|
3699
|
-
/** `baseAmountOut` is
|
|
3856
|
+
/** `baseAmountOut` is the base the buyer receives, after the base mint's transfer fee. */
|
|
3700
3857
|
async function buyExactOut$1(params) {
|
|
3701
3858
|
const quote = buyExactOut$2({
|
|
3702
3859
|
reserveQuote: params.quoteReserves,
|
|
@@ -3754,7 +3911,7 @@ async function sellExactIn$1(params) {
|
|
|
3754
3911
|
quote
|
|
3755
3912
|
};
|
|
3756
3913
|
}
|
|
3757
|
-
/** `quoteAmountOut` is
|
|
3914
|
+
/** `quoteAmountOut` is the quote the seller receives, after the quote mint's transfer fee. */
|
|
3758
3915
|
async function sellExactOut$1(params) {
|
|
3759
3916
|
const quote = sellExactOut$2({
|
|
3760
3917
|
reserveQuote: params.quoteReserves,
|
|
@@ -3828,6 +3985,39 @@ var dex_exports = /* @__PURE__ */ __exportAll({
|
|
|
3828
3985
|
types: () => types_exports$2
|
|
3829
3986
|
});
|
|
3830
3987
|
//#endregion
|
|
3988
|
+
//#region src/launchpad/generated/shared/index.ts
|
|
3989
|
+
/** The System Program, which owns every address nobody has created an account at yet. */
|
|
3990
|
+
const SYSTEM_PROGRAM_ADDRESS$1 = "11111111111111111111111111111111";
|
|
3991
|
+
/**
|
|
3992
|
+
* Whether an encoded account was created on-chain, rather than merely sent lamports.
|
|
3993
|
+
*
|
|
3994
|
+
* Anyone can send lamports to an address before its account is created, which leaves it on-chain,
|
|
3995
|
+
* owned by the System Program, with no data. This returns `false` for that shape, as it does for an
|
|
3996
|
+
* account that does not exist. Any other existing account counts as created, whoever owns it; the
|
|
3997
|
+
* `decode*` functions still check the owner.
|
|
3998
|
+
*
|
|
3999
|
+
* The generated `fetchMaybe*` and `fetchAllMaybe*` helpers apply this rule themselves. Apply it to
|
|
4000
|
+
* accounts you fetch or receive another way (subscriptions, batch loaders, caches) before passing
|
|
4001
|
+
* them to a `decode*` function, which throws for a lamports-only account: an account passed to it as
|
|
4002
|
+
* existing must never come back as the non-existing variant typed as an `Account`.
|
|
4003
|
+
*
|
|
4004
|
+
* Only a `true` result narrows the type. A lamports-only account is still `exists: true` at runtime,
|
|
4005
|
+
* so a `false` result leaves the type unchanged instead of narrowing it to the non-existing variant.
|
|
4006
|
+
* The `uncreated` property in the narrowed type is never present; it exists only to prevent that.
|
|
4007
|
+
*
|
|
4008
|
+
* @example
|
|
4009
|
+
* ```ts
|
|
4010
|
+
* const maybeAccount = decodeMyAccount(
|
|
4011
|
+
* accountIsCreated(encodedAccount) ? encodedAccount : { address: encodedAccount.address, exists: false },
|
|
4012
|
+
* );
|
|
4013
|
+
* ```
|
|
4014
|
+
*/
|
|
4015
|
+
function accountIsCreated$1(account) {
|
|
4016
|
+
const maybeAccount = account;
|
|
4017
|
+
if ("exists" in maybeAccount && !maybeAccount.exists) return false;
|
|
4018
|
+
return !(maybeAccount.programAddress === SYSTEM_PROGRAM_ADDRESS$1 && maybeAccount.data.length === 0);
|
|
4019
|
+
}
|
|
4020
|
+
//#endregion
|
|
3831
4021
|
//#region src/launchpad/generated/types/bondingCurveStatus.ts
|
|
3832
4022
|
/**
|
|
3833
4023
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -3925,7 +4115,7 @@ function getBondingCurveEncoder() {
|
|
|
3925
4115
|
["quoteMint", (0, _solana_kit.getAddressEncoder)()],
|
|
3926
4116
|
["quoteDecimals", (0, _solana_kit.getU8Encoder)()],
|
|
3927
4117
|
["coinCreator", (0, _solana_kit.getAddressEncoder)()],
|
|
3928
|
-
["
|
|
4118
|
+
["padding0", (0, _solana_kit.getArrayEncoder)((0, _solana_kit.getU64Encoder)(), { size: 4 })],
|
|
3929
4119
|
["partner", (0, _solana_kit.getAddressEncoder)()],
|
|
3930
4120
|
["baseVault", (0, _solana_kit.getAddressEncoder)()],
|
|
3931
4121
|
["quoteVault", (0, _solana_kit.getAddressEncoder)()],
|
|
@@ -3937,7 +4127,10 @@ function getBondingCurveEncoder() {
|
|
|
3937
4127
|
["protocolOwed", (0, _solana_kit.getU64Encoder)()],
|
|
3938
4128
|
["creatorOwed", (0, _solana_kit.getU64Encoder)()],
|
|
3939
4129
|
["platformConfig", (0, _solana_kit.getAddressEncoder)()],
|
|
3940
|
-
["
|
|
4130
|
+
["creatorFeeMode", (0, _solana_kit.getU8Encoder)()],
|
|
4131
|
+
["creatorFeeBps", (0, _solana_kit.getU16Encoder)()],
|
|
4132
|
+
["dexCreatorFeeBps", (0, _solana_kit.getU16Encoder)()],
|
|
4133
|
+
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 256)]
|
|
3941
4134
|
]), (value) => ({
|
|
3942
4135
|
...value,
|
|
3943
4136
|
discriminator: BONDING_CURVE_DISCRIMINATOR
|
|
@@ -3959,7 +4152,7 @@ function getBondingCurveDecoder() {
|
|
|
3959
4152
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
3960
4153
|
["quoteDecimals", (0, _solana_kit.getU8Decoder)()],
|
|
3961
4154
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
3962
|
-
["
|
|
4155
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 4 })],
|
|
3963
4156
|
["partner", (0, _solana_kit.getAddressDecoder)()],
|
|
3964
4157
|
["baseVault", (0, _solana_kit.getAddressDecoder)()],
|
|
3965
4158
|
["quoteVault", (0, _solana_kit.getAddressDecoder)()],
|
|
@@ -3971,7 +4164,10 @@ function getBondingCurveDecoder() {
|
|
|
3971
4164
|
["protocolOwed", (0, _solana_kit.getU64Decoder)()],
|
|
3972
4165
|
["creatorOwed", (0, _solana_kit.getU64Decoder)()],
|
|
3973
4166
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
3974
|
-
["
|
|
4167
|
+
["creatorFeeMode", (0, _solana_kit.getU8Decoder)()],
|
|
4168
|
+
["creatorFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
4169
|
+
["dexCreatorFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
4170
|
+
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 256)]
|
|
3975
4171
|
]);
|
|
3976
4172
|
}
|
|
3977
4173
|
/** Gets the codec for {@link BondingCurve} account data. */
|
|
@@ -3993,24 +4189,43 @@ function decodeBondingCurve(encodedAccount) {
|
|
|
3993
4189
|
}
|
|
3994
4190
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getBondingCurveDecoder());
|
|
3995
4191
|
}
|
|
4192
|
+
/** Fetches a `BondingCurve` account, throwing when it does not exist or only holds lamports. */
|
|
3996
4193
|
async function fetchBondingCurve(rpc, address, config) {
|
|
3997
4194
|
const maybeAccount = await fetchMaybeBondingCurve(rpc, address, config);
|
|
3998
4195
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
3999
4196
|
return maybeAccount;
|
|
4000
4197
|
}
|
|
4198
|
+
/**
|
|
4199
|
+
* Fetches a `BondingCurve` account, or the non-existing variant when the address holds no
|
|
4200
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
4201
|
+
* {@link decodeBondingCurve} throws for a lamports-only account instead.
|
|
4202
|
+
*/
|
|
4001
4203
|
async function fetchMaybeBondingCurve(rpc, address, config) {
|
|
4002
|
-
|
|
4204
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
4205
|
+
return decodeBondingCurve(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4206
|
+
address,
|
|
4207
|
+
exists: false
|
|
4208
|
+
});
|
|
4003
4209
|
}
|
|
4210
|
+
/** Fetches `BondingCurve` accounts, throwing when any does not exist or only holds lamports. */
|
|
4004
4211
|
async function fetchAllBondingCurve(rpc, addresses, config) {
|
|
4005
4212
|
const maybeAccounts = await fetchAllMaybeBondingCurve(rpc, addresses, config);
|
|
4006
4213
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
4007
4214
|
return maybeAccounts;
|
|
4008
4215
|
}
|
|
4216
|
+
/**
|
|
4217
|
+
* Fetches `BondingCurve` accounts, with the non-existing variant for each address that holds
|
|
4218
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
4219
|
+
* {@link decodeBondingCurve} throws for a lamports-only account instead.
|
|
4220
|
+
*/
|
|
4009
4221
|
async function fetchAllMaybeBondingCurve(rpc, addresses, config) {
|
|
4010
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeBondingCurve(maybeAccount)
|
|
4222
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeBondingCurve(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4223
|
+
address: maybeAccount.address,
|
|
4224
|
+
exists: false
|
|
4225
|
+
}));
|
|
4011
4226
|
}
|
|
4012
4227
|
function getBondingCurveSize() {
|
|
4013
|
-
return
|
|
4228
|
+
return 618;
|
|
4014
4229
|
}
|
|
4015
4230
|
//#endregion
|
|
4016
4231
|
//#region src/launchpad/generated/accounts/globalConfig.ts
|
|
@@ -4090,21 +4305,40 @@ function decodeGlobalConfig$1(encodedAccount) {
|
|
|
4090
4305
|
}
|
|
4091
4306
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getGlobalConfigDecoder$1());
|
|
4092
4307
|
}
|
|
4308
|
+
/** Fetches a `GlobalConfig` account, throwing when it does not exist or only holds lamports. */
|
|
4093
4309
|
async function fetchGlobalConfig$1(rpc, address, config) {
|
|
4094
4310
|
const maybeAccount = await fetchMaybeGlobalConfig$1(rpc, address, config);
|
|
4095
4311
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
4096
4312
|
return maybeAccount;
|
|
4097
4313
|
}
|
|
4314
|
+
/**
|
|
4315
|
+
* Fetches a `GlobalConfig` account, or the non-existing variant when the address holds no
|
|
4316
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
4317
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
4318
|
+
*/
|
|
4098
4319
|
async function fetchMaybeGlobalConfig$1(rpc, address, config) {
|
|
4099
|
-
|
|
4320
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
4321
|
+
return decodeGlobalConfig$1(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4322
|
+
address,
|
|
4323
|
+
exists: false
|
|
4324
|
+
});
|
|
4100
4325
|
}
|
|
4326
|
+
/** Fetches `GlobalConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
4101
4327
|
async function fetchAllGlobalConfig$1(rpc, addresses, config) {
|
|
4102
4328
|
const maybeAccounts = await fetchAllMaybeGlobalConfig$1(rpc, addresses, config);
|
|
4103
4329
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
4104
4330
|
return maybeAccounts;
|
|
4105
4331
|
}
|
|
4332
|
+
/**
|
|
4333
|
+
* Fetches `GlobalConfig` accounts, with the non-existing variant for each address that holds
|
|
4334
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
4335
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
4336
|
+
*/
|
|
4106
4337
|
async function fetchAllMaybeGlobalConfig$1(rpc, addresses, config) {
|
|
4107
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig$1(maybeAccount)
|
|
4338
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig$1(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4339
|
+
address: maybeAccount.address,
|
|
4340
|
+
exists: false
|
|
4341
|
+
}));
|
|
4108
4342
|
}
|
|
4109
4343
|
function getGlobalConfigSize() {
|
|
4110
4344
|
return 179;
|
|
@@ -4177,21 +4411,40 @@ function decodeRewardAccrual(encodedAccount) {
|
|
|
4177
4411
|
}
|
|
4178
4412
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getRewardAccrualDecoder());
|
|
4179
4413
|
}
|
|
4414
|
+
/** Fetches a `RewardAccrual` account, throwing when it does not exist or only holds lamports. */
|
|
4180
4415
|
async function fetchRewardAccrual(rpc, address, config) {
|
|
4181
4416
|
const maybeAccount = await fetchMaybeRewardAccrual(rpc, address, config);
|
|
4182
4417
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
4183
4418
|
return maybeAccount;
|
|
4184
4419
|
}
|
|
4420
|
+
/**
|
|
4421
|
+
* Fetches a `RewardAccrual` account, or the non-existing variant when the address holds no
|
|
4422
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
4423
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
4424
|
+
*/
|
|
4185
4425
|
async function fetchMaybeRewardAccrual(rpc, address, config) {
|
|
4186
|
-
|
|
4426
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
4427
|
+
return decodeRewardAccrual(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4428
|
+
address,
|
|
4429
|
+
exists: false
|
|
4430
|
+
});
|
|
4187
4431
|
}
|
|
4432
|
+
/** Fetches `RewardAccrual` accounts, throwing when any does not exist or only holds lamports. */
|
|
4188
4433
|
async function fetchAllRewardAccrual(rpc, addresses, config) {
|
|
4189
4434
|
const maybeAccounts = await fetchAllMaybeRewardAccrual(rpc, addresses, config);
|
|
4190
4435
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
4191
4436
|
return maybeAccounts;
|
|
4192
4437
|
}
|
|
4438
|
+
/**
|
|
4439
|
+
* Fetches `RewardAccrual` accounts, with the non-existing variant for each address that holds
|
|
4440
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
4441
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
4442
|
+
*/
|
|
4193
4443
|
async function fetchAllMaybeRewardAccrual(rpc, addresses, config) {
|
|
4194
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeRewardAccrual(maybeAccount)
|
|
4444
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeRewardAccrual(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4445
|
+
address: maybeAccount.address,
|
|
4446
|
+
exists: false
|
|
4447
|
+
}));
|
|
4195
4448
|
}
|
|
4196
4449
|
function getRewardAccrualSize() {
|
|
4197
4450
|
return 130;
|
|
@@ -4320,12 +4573,16 @@ const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 7009;
|
|
|
4320
4573
|
const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 7010;
|
|
4321
4574
|
/** NothingToClaim: Nothing to claim */
|
|
4322
4575
|
const SEND_LAUNCHPAD_ERROR__NOTHING_TO_CLAIM = 7011;
|
|
4323
|
-
/**
|
|
4324
|
-
const
|
|
4576
|
+
/** Unused7012: Unused */
|
|
4577
|
+
const SEND_LAUNCHPAD_ERROR__UNUSED7012 = 7012;
|
|
4325
4578
|
/** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
|
|
4326
4579
|
const SEND_LAUNCHPAD_ERROR__QUOTE_MINT_PRICE_UNSET = 7013;
|
|
4327
4580
|
/** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
|
|
4328
4581
|
const SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 7014;
|
|
4582
|
+
/** CreatorFeeTooHigh: Creator fee exceeds the partner's maximum */
|
|
4583
|
+
const SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH = 7015;
|
|
4584
|
+
/** CreatorFeeModeNotAllowed: Creator fee mode is not allowed by the partner config */
|
|
4585
|
+
const SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED = 7016;
|
|
4329
4586
|
/** InsufficientLiquidity: Insufficient liquidity */
|
|
4330
4587
|
const SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY = 7100;
|
|
4331
4588
|
/** InvalidAmount: Invalid amount */
|
|
@@ -4335,6 +4592,8 @@ const sendLaunchpadErrorMessages = {
|
|
|
4335
4592
|
[SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
4336
4593
|
[SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND]: `Base mint not found`,
|
|
4337
4594
|
[SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY]: `Blocked by held supply`,
|
|
4595
|
+
[SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED]: `Creator fee mode is not allowed by the partner config`,
|
|
4596
|
+
[SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH]: `Creator fee exceeds the partner's maximum`,
|
|
4338
4597
|
[SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE]: `Curve is live`,
|
|
4339
4598
|
[SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance in source account`,
|
|
4340
4599
|
[SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
@@ -4342,7 +4601,6 @@ const sendLaunchpadErrorMessages = {
|
|
|
4342
4601
|
[SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
|
|
4343
4602
|
[SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT]: `Invalid base mint`,
|
|
4344
4603
|
[SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR]: `Invalid coin creator`,
|
|
4345
|
-
[SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID]: `Creator identity is not a decodable wallet address`,
|
|
4346
4604
|
[SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT]: `Invalid Pyth price account`,
|
|
4347
4605
|
[SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED]: `Invalid Pyth feed ID`,
|
|
4348
4606
|
[SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT]: `Invalid quote mint`,
|
|
@@ -4360,6 +4618,7 @@ const sendLaunchpadErrorMessages = {
|
|
|
4360
4618
|
[SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED]: `Token creation is disabled`,
|
|
4361
4619
|
[SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
|
|
4362
4620
|
[SEND_LAUNCHPAD_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
4621
|
+
[SEND_LAUNCHPAD_ERROR__UNUSED7012]: `Unused`,
|
|
4363
4622
|
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
|
|
4364
4623
|
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
|
|
4365
4624
|
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT]: `User token account mint does not match the trade`,
|
|
@@ -4378,6 +4637,8 @@ var errors_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4378
4637
|
SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW: () => SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW,
|
|
4379
4638
|
SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND: () => SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND,
|
|
4380
4639
|
SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY: () => SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY,
|
|
4640
|
+
SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED: () => SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED,
|
|
4641
|
+
SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH: () => SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH,
|
|
4381
4642
|
SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE: () => SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE,
|
|
4382
4643
|
SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE: () => SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE,
|
|
4383
4644
|
SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY: () => SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY,
|
|
@@ -4385,7 +4646,6 @@ var errors_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4385
4646
|
SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY: () => SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY,
|
|
4386
4647
|
SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT: () => SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT,
|
|
4387
4648
|
SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR: () => SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR,
|
|
4388
|
-
SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID: () => SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID,
|
|
4389
4649
|
SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT: () => SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT,
|
|
4390
4650
|
SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED: () => SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED,
|
|
4391
4651
|
SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT: () => SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT,
|
|
@@ -4403,6 +4663,7 @@ var errors_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4403
4663
|
SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED: () => SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED,
|
|
4404
4664
|
SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE: () => SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE,
|
|
4405
4665
|
SEND_LAUNCHPAD_ERROR__UNAUTHORIZED: () => SEND_LAUNCHPAD_ERROR__UNAUTHORIZED,
|
|
4666
|
+
SEND_LAUNCHPAD_ERROR__UNUSED7012: () => SEND_LAUNCHPAD_ERROR__UNUSED7012,
|
|
4406
4667
|
SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID: () => SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID,
|
|
4407
4668
|
SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY: () => SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY,
|
|
4408
4669
|
SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT: () => SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT,
|
|
@@ -4445,6 +4706,44 @@ async function findBondingCurvePda(seeds) {
|
|
|
4445
4706
|
});
|
|
4446
4707
|
}
|
|
4447
4708
|
//#endregion
|
|
4709
|
+
//#region src/launchpad/generated/pdas/creatorFeeConfig.ts
|
|
4710
|
+
/**
|
|
4711
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
4712
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4713
|
+
* to add features, then rerun Codama to update it.
|
|
4714
|
+
*
|
|
4715
|
+
* @see https://github.com/codama-idl/codama
|
|
4716
|
+
*/
|
|
4717
|
+
async function findCreatorFeeConfigPda(seeds) {
|
|
4718
|
+
return await (0, _solana_kit.getProgramDerivedAddress)({
|
|
4719
|
+
programAddress: SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
4720
|
+
seeds: [
|
|
4721
|
+
(0, _solana_kit.getBytesEncoder)().encode(new Uint8Array([
|
|
4722
|
+
99,
|
|
4723
|
+
114,
|
|
4724
|
+
101,
|
|
4725
|
+
97,
|
|
4726
|
+
116,
|
|
4727
|
+
111,
|
|
4728
|
+
114,
|
|
4729
|
+
95,
|
|
4730
|
+
102,
|
|
4731
|
+
101,
|
|
4732
|
+
101,
|
|
4733
|
+
95,
|
|
4734
|
+
99,
|
|
4735
|
+
111,
|
|
4736
|
+
110,
|
|
4737
|
+
102,
|
|
4738
|
+
105,
|
|
4739
|
+
103
|
|
4740
|
+
])),
|
|
4741
|
+
(0, _solana_kit.getAddressEncoder)().encode(seeds.baseMint),
|
|
4742
|
+
(0, _solana_kit.getAddressEncoder)().encode(seeds.quoteMint)
|
|
4743
|
+
]
|
|
4744
|
+
});
|
|
4745
|
+
}
|
|
4746
|
+
//#endregion
|
|
4448
4747
|
//#region src/launchpad/generated/pdas/eventAuthority.ts
|
|
4449
4748
|
const EVENT_AUTHORITY_PDA_ADDRESS$1 = "FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T";
|
|
4450
4749
|
function findEventAuthorityPda$1() {
|
|
@@ -4506,6 +4805,7 @@ var pdas_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4506
4805
|
MIGRATION_AUTHORITY_PDA_ADDRESS: () => MIGRATION_AUTHORITY_PDA_ADDRESS,
|
|
4507
4806
|
WSOL_REWARD_ACCRUAL_PDA_ADDRESS: () => WSOL_REWARD_ACCRUAL_PDA_ADDRESS,
|
|
4508
4807
|
findBondingCurvePda: () => findBondingCurvePda,
|
|
4808
|
+
findCreatorFeeConfigPda: () => findCreatorFeeConfigPda,
|
|
4509
4809
|
findEventAuthorityPda: () => findEventAuthorityPda$1,
|
|
4510
4810
|
findGlobalConfigPda: () => findGlobalConfigPda$1,
|
|
4511
4811
|
findMigrationAuthorityPda: () => findMigrationAuthorityPda,
|
|
@@ -4513,80 +4813,6 @@ var pdas_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4513
4813
|
findWsolRewardAccrualPda: () => findWsolRewardAccrualPda
|
|
4514
4814
|
});
|
|
4515
4815
|
//#endregion
|
|
4516
|
-
//#region src/utils/creator-hash.ts
|
|
4517
|
-
const MAX_CREATOR_PLATFORM_LEN = 32;
|
|
4518
|
-
/** SHA-256 of the LE-u32-length-prefixed platform and id. Frozen: it seeds live PDAs. */
|
|
4519
|
-
async function creatorHashFromId(creatorPlatform, creatorId) {
|
|
4520
|
-
const encoder = new TextEncoder();
|
|
4521
|
-
const platformBuf = encoder.encode(creatorPlatform);
|
|
4522
|
-
const idBuf = encoder.encode(creatorId);
|
|
4523
|
-
if (platformBuf.length > MAX_CREATOR_PLATFORM_LEN) throw new RangeError(`creatorPlatform exceeds ${MAX_CREATOR_PLATFORM_LEN} bytes (got ${platformBuf.length})`);
|
|
4524
|
-
const platformLength = /* @__PURE__ */ new Uint8Array(4);
|
|
4525
|
-
new DataView(platformLength.buffer).setUint32(0, platformBuf.length, true);
|
|
4526
|
-
const idLength = /* @__PURE__ */ new Uint8Array(4);
|
|
4527
|
-
new DataView(idLength.buffer).setUint32(0, idBuf.length, true);
|
|
4528
|
-
const buf = new Uint8Array(4 + platformBuf.length + 4 + idBuf.length);
|
|
4529
|
-
buf.set(platformLength, 0);
|
|
4530
|
-
buf.set(platformBuf, 4);
|
|
4531
|
-
buf.set(idLength, 4 + platformBuf.length);
|
|
4532
|
-
buf.set(idBuf, 4 + platformBuf.length + 4);
|
|
4533
|
-
const hash = new Uint8Array(await crypto.subtle.digest("SHA-256", buf));
|
|
4534
|
-
return (0, _solana_kit.getAddressDecoder)().decode(hash);
|
|
4535
|
-
}
|
|
4536
|
-
/** NUL-pads `text` to `length` bytes, the on-chain `CreatorFeeConfig.platformId` form; throws RangeError if longer. */
|
|
4537
|
-
function encodeCreatorId(text, length) {
|
|
4538
|
-
const bytes = new TextEncoder().encode(text);
|
|
4539
|
-
if (bytes.length > length) throw new RangeError(`text exceeds ${length} bytes (got ${bytes.length})`);
|
|
4540
|
-
const out = new Uint8Array(length);
|
|
4541
|
-
out.set(bytes, 0);
|
|
4542
|
-
return out;
|
|
4543
|
-
}
|
|
4544
|
-
/** Strips NUL padding. Pass this, never the padded array, to {@link creatorHashFromId}: the hash is length-prefixed. */
|
|
4545
|
-
function decodeCreatorId(bytes) {
|
|
4546
|
-
let end = bytes.length;
|
|
4547
|
-
while (end > 0 && bytes[end - 1] === 0) end -= 1;
|
|
4548
|
-
return new TextDecoder().decode(bytes.slice(0, end));
|
|
4549
|
-
}
|
|
4550
|
-
//#endregion
|
|
4551
|
-
//#region src/nexus/generated/pdas/creatorFeeConfig.ts
|
|
4552
|
-
/**
|
|
4553
|
-
* This code was AUTOGENERATED using the Codama library.
|
|
4554
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4555
|
-
* to add features, then rerun Codama to update it.
|
|
4556
|
-
*
|
|
4557
|
-
* @see https://github.com/codama-idl/codama
|
|
4558
|
-
*/
|
|
4559
|
-
async function findCreatorFeeConfigPda(seeds) {
|
|
4560
|
-
return await (0, _solana_kit.getProgramDerivedAddress)({
|
|
4561
|
-
programAddress: SEND_NEXUS_PROGRAM_ADDRESS,
|
|
4562
|
-
seeds: [
|
|
4563
|
-
(0, _solana_kit.getBytesEncoder)().encode(new Uint8Array([
|
|
4564
|
-
99,
|
|
4565
|
-
114,
|
|
4566
|
-
101,
|
|
4567
|
-
97,
|
|
4568
|
-
116,
|
|
4569
|
-
111,
|
|
4570
|
-
114,
|
|
4571
|
-
95,
|
|
4572
|
-
102,
|
|
4573
|
-
101,
|
|
4574
|
-
101,
|
|
4575
|
-
95,
|
|
4576
|
-
98,
|
|
4577
|
-
97,
|
|
4578
|
-
108,
|
|
4579
|
-
97,
|
|
4580
|
-
110,
|
|
4581
|
-
99,
|
|
4582
|
-
101
|
|
4583
|
-
])),
|
|
4584
|
-
(0, _solana_kit.getAddressEncoder)().encode(seeds.creatorHash),
|
|
4585
|
-
(0, _solana_kit.getAddressEncoder)().encode(seeds.quoteMint)
|
|
4586
|
-
]
|
|
4587
|
-
});
|
|
4588
|
-
}
|
|
4589
|
-
//#endregion
|
|
4590
4816
|
//#region src/launchpad/generated/instructions/createToken.ts
|
|
4591
4817
|
/**
|
|
4592
4818
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -4612,12 +4838,12 @@ function getCreateTokenInstructionDataEncoder() {
|
|
|
4612
4838
|
return (0, _solana_kit.transformEncoder)((0, _solana_kit.getStructEncoder)([
|
|
4613
4839
|
["discriminator", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 8)],
|
|
4614
4840
|
["platformConfig", (0, _solana_kit.getAddressEncoder)()],
|
|
4615
|
-
["creatorPlatform", (0, _solana_kit.addEncoderSizePrefix)((0, _solana_kit.getUtf8Encoder)(), (0, _solana_kit.getU32Encoder)())],
|
|
4616
|
-
["creatorId", (0, _solana_kit.addEncoderSizePrefix)((0, _solana_kit.getUtf8Encoder)(), (0, _solana_kit.getU32Encoder)())],
|
|
4617
|
-
["creatorHash", (0, _solana_kit.getAddressEncoder)()],
|
|
4618
4841
|
["name", (0, _solana_kit.addEncoderSizePrefix)((0, _solana_kit.getUtf8Encoder)(), (0, _solana_kit.getU32Encoder)())],
|
|
4619
4842
|
["symbol", (0, _solana_kit.addEncoderSizePrefix)((0, _solana_kit.getUtf8Encoder)(), (0, _solana_kit.getU32Encoder)())],
|
|
4620
|
-
["uri", (0, _solana_kit.addEncoderSizePrefix)((0, _solana_kit.getUtf8Encoder)(), (0, _solana_kit.getU32Encoder)())]
|
|
4843
|
+
["uri", (0, _solana_kit.addEncoderSizePrefix)((0, _solana_kit.getUtf8Encoder)(), (0, _solana_kit.getU32Encoder)())],
|
|
4844
|
+
["creatorFeeMode", (0, _solana_kit.getU8Encoder)()],
|
|
4845
|
+
["creatorFeeBps", (0, _solana_kit.getU16Encoder)()],
|
|
4846
|
+
["dexCreatorFeeBps", (0, _solana_kit.getU16Encoder)()]
|
|
4621
4847
|
]), (value) => ({
|
|
4622
4848
|
...value,
|
|
4623
4849
|
discriminator: CREATE_TOKEN_DISCRIMINATOR
|
|
@@ -4627,12 +4853,12 @@ function getCreateTokenInstructionDataDecoder() {
|
|
|
4627
4853
|
return (0, _solana_kit.getStructDecoder)([
|
|
4628
4854
|
["discriminator", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 8)],
|
|
4629
4855
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
4630
|
-
["creatorPlatform", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
4631
|
-
["creatorId", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
4632
|
-
["creatorHash", (0, _solana_kit.getAddressDecoder)()],
|
|
4633
4856
|
["name", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
4634
4857
|
["symbol", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
4635
|
-
["uri", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())]
|
|
4858
|
+
["uri", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
4859
|
+
["creatorFeeMode", (0, _solana_kit.getU8Decoder)()],
|
|
4860
|
+
["creatorFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
4861
|
+
["dexCreatorFeeBps", (0, _solana_kit.getU16Decoder)()]
|
|
4636
4862
|
]);
|
|
4637
4863
|
}
|
|
4638
4864
|
function getCreateTokenInstructionDataCodec() {
|
|
@@ -4776,33 +5002,9 @@ async function getCreateTokenInstructionAsync(input) {
|
|
|
4776
5002
|
(0, _solana_kit.getAddressEncoder)().encode((0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("quoteMint", accounts.quoteMint.value))
|
|
4777
5003
|
]
|
|
4778
5004
|
});
|
|
4779
|
-
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await (
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
(0, _solana_kit.getBytesEncoder)().encode(new Uint8Array([
|
|
4783
|
-
99,
|
|
4784
|
-
114,
|
|
4785
|
-
101,
|
|
4786
|
-
97,
|
|
4787
|
-
116,
|
|
4788
|
-
111,
|
|
4789
|
-
114,
|
|
4790
|
-
95,
|
|
4791
|
-
102,
|
|
4792
|
-
101,
|
|
4793
|
-
101,
|
|
4794
|
-
95,
|
|
4795
|
-
98,
|
|
4796
|
-
97,
|
|
4797
|
-
108,
|
|
4798
|
-
97,
|
|
4799
|
-
110,
|
|
4800
|
-
99,
|
|
4801
|
-
101
|
|
4802
|
-
])),
|
|
4803
|
-
(0, _solana_kit.getAddressEncoder)().encode((0, _solana_kit_program_client_core.getNonNullResolvedInstructionInput)("creatorHash", args.creatorHash)),
|
|
4804
|
-
(0, _solana_kit.getAddressEncoder)().encode((0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("quoteMint", accounts.quoteMint.value))
|
|
4805
|
-
]
|
|
5005
|
+
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda({
|
|
5006
|
+
baseMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("baseMint", accounts.baseMint.value),
|
|
5007
|
+
quoteMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("quoteMint", accounts.quoteMint.value)
|
|
4806
5008
|
});
|
|
4807
5009
|
if (!accounts.nexusProgram.value) accounts.nexusProgram.value = "7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX";
|
|
4808
5010
|
if (!accounts.nexusGlobalConfig.value) accounts.nexusGlobalConfig.value = "3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr";
|
|
@@ -6487,7 +6689,8 @@ var trade_exports = /* @__PURE__ */ __exportAll({
|
|
|
6487
6689
|
sellExactIn: () => sellExactIn,
|
|
6488
6690
|
sellExactOut: () => sellExactOut
|
|
6489
6691
|
});
|
|
6490
|
-
/** `baseAmountOut` is
|
|
6692
|
+
/** `baseAmountOut` is the base the buyer receives, after the base mint's transfer fee.
|
|
6693
|
+
* The buy is capped at the curve's supply left. Read the result from `quote.baseToUser`. */
|
|
6491
6694
|
async function buyExactOut(params) {
|
|
6492
6695
|
const quote = buyExactOut$2({
|
|
6493
6696
|
reserveQuote: params.virtualQuoteReserves,
|
|
@@ -6547,7 +6750,7 @@ async function sellExactIn(params) {
|
|
|
6547
6750
|
quote
|
|
6548
6751
|
};
|
|
6549
6752
|
}
|
|
6550
|
-
/** `quoteAmountOut` is
|
|
6753
|
+
/** `quoteAmountOut` is the quote the seller receives, after the quote mint's transfer fee. */
|
|
6551
6754
|
async function sellExactOut(params) {
|
|
6552
6755
|
const quote = sellExactOut$2({
|
|
6553
6756
|
reserveQuote: params.virtualQuoteReserves,
|
|
@@ -6595,7 +6798,7 @@ async function buildSellExactOutInstruction(params) {
|
|
|
6595
6798
|
maxAmountIn: params.maxAmountIn
|
|
6596
6799
|
});
|
|
6597
6800
|
}
|
|
6598
|
-
/**
|
|
6801
|
+
/** Returns the percent of the curve's real base sold, from 0 to 100. At 100 the curve can migrate. */
|
|
6599
6802
|
function calculateBondingCurveProgress(params) {
|
|
6600
6803
|
const { realBaseReserves, initialRealBase } = params;
|
|
6601
6804
|
if (initialRealBase === 0n) return 100;
|
|
@@ -6622,33 +6825,25 @@ var create_exports = /* @__PURE__ */ __exportAll({
|
|
|
6622
6825
|
buildCreateTokenInstruction: () => buildCreateTokenInstruction
|
|
6623
6826
|
});
|
|
6624
6827
|
async function buildCreateTokenInstruction(params) {
|
|
6625
|
-
return buildCreateTokenInstructionWithHash(params, await creatorHashFromId(params.creatorPlatform, params.creatorId));
|
|
6626
|
-
}
|
|
6627
|
-
async function buildCreateTokenInstructionWithHash(params, creatorHash) {
|
|
6628
|
-
const [creatorFeeConfig] = await findCreatorFeeConfigPda({
|
|
6629
|
-
creatorHash,
|
|
6630
|
-
quoteMint: params.quoteMint
|
|
6631
|
-
});
|
|
6632
6828
|
return getCreateTokenInstructionAsync({
|
|
6633
6829
|
user: params.user,
|
|
6634
6830
|
payer: params.payer ?? params.user,
|
|
6635
6831
|
coinCreator: params.coinCreator,
|
|
6636
6832
|
baseMint: params.baseMint,
|
|
6637
6833
|
quoteMint: params.quoteMint,
|
|
6638
|
-
creatorFeeConfig,
|
|
6639
6834
|
partner: params.partner,
|
|
6640
6835
|
platformConfig: params.platformConfig,
|
|
6641
6836
|
quoteTokenProgram: params.quoteTokenProgram,
|
|
6642
|
-
creatorPlatform: params.creatorPlatform,
|
|
6643
|
-
creatorId: params.creatorId,
|
|
6644
|
-
creatorHash,
|
|
6645
6837
|
name: params.name,
|
|
6646
6838
|
symbol: params.symbol,
|
|
6647
|
-
uri: params.uri
|
|
6839
|
+
uri: params.uri,
|
|
6840
|
+
creatorFeeMode: params.creatorFeeMode,
|
|
6841
|
+
creatorFeeBps: params.creatorFeeBps,
|
|
6842
|
+
dexCreatorFeeBps: params.dexCreatorFeeBps
|
|
6648
6843
|
});
|
|
6649
6844
|
}
|
|
6650
6845
|
async function buildCreateAndBuyInstructions(params) {
|
|
6651
|
-
const instructions = [await
|
|
6846
|
+
const instructions = [await buildCreateTokenInstruction(params)];
|
|
6652
6847
|
let quote;
|
|
6653
6848
|
if (params.buyQuoteAmount > 0n) {
|
|
6654
6849
|
const buyResult = await buyExactIn({
|
|
@@ -6732,7 +6927,7 @@ function getCompleteEventDecoder() {
|
|
|
6732
6927
|
["baseMint", (0, _solana_kit.getAddressDecoder)()],
|
|
6733
6928
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
6734
6929
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
6735
|
-
["
|
|
6930
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 4 })],
|
|
6736
6931
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
6737
6932
|
["curvePartner", (0, _solana_kit.getAddressDecoder)()],
|
|
6738
6933
|
["isPartner", (0, _solana_kit.getBooleanDecoder)()],
|
|
@@ -6804,7 +6999,7 @@ function getCreatorClaimEventDecoder() {
|
|
|
6804
6999
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
6805
7000
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
6806
7001
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
6807
|
-
["
|
|
7002
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 4 })],
|
|
6808
7003
|
["claimer", (0, _solana_kit.getAddressDecoder)()],
|
|
6809
7004
|
["destinationOwner", (0, _solana_kit.getAddressDecoder)()],
|
|
6810
7005
|
["amount", (0, _solana_kit.getU64Decoder)()],
|
|
@@ -6876,7 +7071,7 @@ function getMigrateEventDecoder() {
|
|
|
6876
7071
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
6877
7072
|
["pool", (0, _solana_kit.getAddressDecoder)()],
|
|
6878
7073
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
6879
|
-
["
|
|
7074
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 4 })],
|
|
6880
7075
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
6881
7076
|
["baseAmount", (0, _solana_kit.getU64Decoder)()],
|
|
6882
7077
|
["quoteAmount", (0, _solana_kit.getU64Decoder)()],
|
|
@@ -7089,9 +7284,7 @@ function getTokenCreateEventDecoder() {
|
|
|
7089
7284
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
7090
7285
|
["quoteDecimals", (0, _solana_kit.getU8Decoder)()],
|
|
7091
7286
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
7092
|
-
["
|
|
7093
|
-
["creatorId", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
7094
|
-
["creatorFeeConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
7287
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 5 })],
|
|
7095
7288
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
7096
7289
|
["name", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
7097
7290
|
["symbol", (0, _solana_kit.addDecoderSizePrefix)((0, _solana_kit.getUtf8Decoder)(), (0, _solana_kit.getU32Decoder)())],
|
|
@@ -7103,7 +7296,10 @@ function getTokenCreateEventDecoder() {
|
|
|
7103
7296
|
["virtualQuoteReserves", (0, _solana_kit.getU64Decoder)()],
|
|
7104
7297
|
["realBaseReserves", (0, _solana_kit.getU64Decoder)()],
|
|
7105
7298
|
["realQuoteReserves", (0, _solana_kit.getU64Decoder)()],
|
|
7106
|
-
["timestamp", (0, _solana_kit.getI64Decoder)()]
|
|
7299
|
+
["timestamp", (0, _solana_kit.getI64Decoder)()],
|
|
7300
|
+
["creatorFeeMode", (0, _solana_kit.getU8Decoder)()],
|
|
7301
|
+
["creatorFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
7302
|
+
["dexCreatorFeeBps", (0, _solana_kit.getU16Decoder)()]
|
|
7107
7303
|
]);
|
|
7108
7304
|
}
|
|
7109
7305
|
/**
|
|
@@ -7170,7 +7366,7 @@ function getTradeEventDecoder() {
|
|
|
7170
7366
|
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
7171
7367
|
["user", (0, _solana_kit.getAddressDecoder)()],
|
|
7172
7368
|
["coinCreator", (0, _solana_kit.getAddressDecoder)()],
|
|
7173
|
-
["
|
|
7369
|
+
["padding0", (0, _solana_kit.getArrayDecoder)((0, _solana_kit.getU64Decoder)(), { size: 4 })],
|
|
7174
7370
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
7175
7371
|
["baseAmount", (0, _solana_kit.getU64Decoder)()],
|
|
7176
7372
|
["quoteAmountGross", (0, _solana_kit.getU64Decoder)()],
|
|
@@ -7186,7 +7382,9 @@ function getTradeEventDecoder() {
|
|
|
7186
7382
|
["virtualQuoteReserves", (0, _solana_kit.getU64Decoder)()],
|
|
7187
7383
|
["realBaseReserves", (0, _solana_kit.getU64Decoder)()],
|
|
7188
7384
|
["realQuoteReserves", (0, _solana_kit.getU64Decoder)()],
|
|
7189
|
-
["timestamp", (0, _solana_kit.getI64Decoder)()]
|
|
7385
|
+
["timestamp", (0, _solana_kit.getI64Decoder)()],
|
|
7386
|
+
["creatorFeeMode", (0, _solana_kit.getU8Decoder)()],
|
|
7387
|
+
["creatorFeeBps", (0, _solana_kit.getU16Decoder)()]
|
|
7190
7388
|
]);
|
|
7191
7389
|
}
|
|
7192
7390
|
/**
|
|
@@ -7393,7 +7591,7 @@ async function getClaimCreatorFeesInstructionAsync(input) {
|
|
|
7393
7591
|
},
|
|
7394
7592
|
creatorFeeConfig: {
|
|
7395
7593
|
value: input.creatorFeeConfig ?? null,
|
|
7396
|
-
isWritable:
|
|
7594
|
+
isWritable: true
|
|
7397
7595
|
},
|
|
7398
7596
|
nexusGlobalConfig: {
|
|
7399
7597
|
value: null,
|
|
@@ -7444,6 +7642,10 @@ async function getClaimCreatorFeesInstructionAsync(input) {
|
|
|
7444
7642
|
baseMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("baseMint", accounts.baseMint.value),
|
|
7445
7643
|
quoteMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("quoteMint", accounts.quoteMint.value)
|
|
7446
7644
|
});
|
|
7645
|
+
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda({
|
|
7646
|
+
baseMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("baseMint", accounts.baseMint.value),
|
|
7647
|
+
quoteMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("quoteMint", accounts.quoteMint.value)
|
|
7648
|
+
});
|
|
7447
7649
|
if (!accounts.nexusGlobalConfig.value) accounts.nexusGlobalConfig.value = "3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr";
|
|
7448
7650
|
if (!accounts.quoteVault.value) accounts.quoteVault.value = await (0, _solana_kit.getProgramDerivedAddress)({
|
|
7449
7651
|
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
@@ -7505,7 +7707,7 @@ function getClaimCreatorFeesInstruction(input) {
|
|
|
7505
7707
|
},
|
|
7506
7708
|
creatorFeeConfig: {
|
|
7507
7709
|
value: input.creatorFeeConfig ?? null,
|
|
7508
|
-
isWritable:
|
|
7710
|
+
isWritable: true
|
|
7509
7711
|
},
|
|
7510
7712
|
nexusGlobalConfig: {
|
|
7511
7713
|
value: null,
|
|
@@ -7987,7 +8189,7 @@ async function getMigrateInstructionAsync(input) {
|
|
|
7987
8189
|
},
|
|
7988
8190
|
creatorFeeConfig: {
|
|
7989
8191
|
value: input.creatorFeeConfig ?? null,
|
|
7990
|
-
isWritable:
|
|
8192
|
+
isWritable: true
|
|
7991
8193
|
},
|
|
7992
8194
|
baseTokenProgram: {
|
|
7993
8195
|
value: null,
|
|
@@ -8012,6 +8214,10 @@ async function getMigrateInstructionAsync(input) {
|
|
|
8012
8214
|
program: {
|
|
8013
8215
|
value: null,
|
|
8014
8216
|
isWritable: false
|
|
8217
|
+
},
|
|
8218
|
+
dexCreatorFeeConfig: {
|
|
8219
|
+
value: input.dexCreatorFeeConfig ?? null,
|
|
8220
|
+
isWritable: true
|
|
8015
8221
|
}
|
|
8016
8222
|
};
|
|
8017
8223
|
if (!accounts.bondingCurve.value) accounts.bondingCurve.value = await findBondingCurvePda({
|
|
@@ -8067,11 +8273,42 @@ async function getMigrateInstructionAsync(input) {
|
|
|
8067
8273
|
});
|
|
8068
8274
|
if (!accounts.dexEventAuthority.value) accounts.dexEventAuthority.value = "4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t";
|
|
8069
8275
|
if (!accounts.nexusProgram.value) accounts.nexusProgram.value = "7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX";
|
|
8276
|
+
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda({
|
|
8277
|
+
baseMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("baseMint", accounts.baseMint.value),
|
|
8278
|
+
quoteMint: (0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("quoteMint", accounts.quoteMint.value)
|
|
8279
|
+
});
|
|
8070
8280
|
if (!accounts.baseTokenProgram.value) accounts.baseTokenProgram.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
8071
8281
|
if (!accounts.associatedTokenProgram.value) accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
8072
8282
|
if (!accounts.systemProgram.value) accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
8073
8283
|
if (!accounts.eventAuthority.value) accounts.eventAuthority.value = EVENT_AUTHORITY_PDA_ADDRESS$1;
|
|
8074
8284
|
if (!accounts.program.value) accounts.program.value = "5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP";
|
|
8285
|
+
if (!accounts.dexCreatorFeeConfig.value) accounts.dexCreatorFeeConfig.value = await (0, _solana_kit.getProgramDerivedAddress)({
|
|
8286
|
+
programAddress: "84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX",
|
|
8287
|
+
seeds: [
|
|
8288
|
+
(0, _solana_kit.getBytesEncoder)().encode(new Uint8Array([
|
|
8289
|
+
99,
|
|
8290
|
+
114,
|
|
8291
|
+
101,
|
|
8292
|
+
97,
|
|
8293
|
+
116,
|
|
8294
|
+
111,
|
|
8295
|
+
114,
|
|
8296
|
+
95,
|
|
8297
|
+
102,
|
|
8298
|
+
101,
|
|
8299
|
+
101,
|
|
8300
|
+
95,
|
|
8301
|
+
99,
|
|
8302
|
+
111,
|
|
8303
|
+
110,
|
|
8304
|
+
102,
|
|
8305
|
+
105,
|
|
8306
|
+
103
|
|
8307
|
+
])),
|
|
8308
|
+
(0, _solana_kit.getAddressEncoder)().encode((0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("baseMint", accounts.baseMint.value)),
|
|
8309
|
+
(0, _solana_kit.getAddressEncoder)().encode((0, _solana_kit_program_client_core.getAddressFromResolvedInstructionAccount)("quoteMint", accounts.quoteMint.value))
|
|
8310
|
+
]
|
|
8311
|
+
});
|
|
8075
8312
|
const getAccountMeta = (0, _solana_kit_program_client_core.getAccountMetaFactory)(programAddress, "programId");
|
|
8076
8313
|
return Object.freeze({
|
|
8077
8314
|
accounts: [
|
|
@@ -8096,7 +8333,8 @@ async function getMigrateInstructionAsync(input) {
|
|
|
8096
8333
|
getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram),
|
|
8097
8334
|
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
8098
8335
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
8099
|
-
getAccountMeta("program", accounts.program)
|
|
8336
|
+
getAccountMeta("program", accounts.program),
|
|
8337
|
+
getAccountMeta("dexCreatorFeeConfig", accounts.dexCreatorFeeConfig)
|
|
8100
8338
|
],
|
|
8101
8339
|
data: getMigrateInstructionDataEncoder().encode({}),
|
|
8102
8340
|
programAddress
|
|
@@ -8167,7 +8405,7 @@ function getMigrateInstruction(input) {
|
|
|
8167
8405
|
},
|
|
8168
8406
|
creatorFeeConfig: {
|
|
8169
8407
|
value: input.creatorFeeConfig ?? null,
|
|
8170
|
-
isWritable:
|
|
8408
|
+
isWritable: true
|
|
8171
8409
|
},
|
|
8172
8410
|
baseTokenProgram: {
|
|
8173
8411
|
value: null,
|
|
@@ -8192,6 +8430,10 @@ function getMigrateInstruction(input) {
|
|
|
8192
8430
|
program: {
|
|
8193
8431
|
value: null,
|
|
8194
8432
|
isWritable: false
|
|
8433
|
+
},
|
|
8434
|
+
dexCreatorFeeConfig: {
|
|
8435
|
+
value: input.dexCreatorFeeConfig ?? null,
|
|
8436
|
+
isWritable: true
|
|
8195
8437
|
}
|
|
8196
8438
|
};
|
|
8197
8439
|
if (!accounts.dexProgram.value) accounts.dexProgram.value = "84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX";
|
|
@@ -8227,7 +8469,8 @@ function getMigrateInstruction(input) {
|
|
|
8227
8469
|
getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram),
|
|
8228
8470
|
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
8229
8471
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
8230
|
-
getAccountMeta("program", accounts.program)
|
|
8472
|
+
getAccountMeta("program", accounts.program),
|
|
8473
|
+
getAccountMeta("dexCreatorFeeConfig", accounts.dexCreatorFeeConfig)
|
|
8231
8474
|
],
|
|
8232
8475
|
data: getMigrateInstructionDataEncoder().encode({}),
|
|
8233
8476
|
programAddress
|
|
@@ -8240,9 +8483,9 @@ function parseMigrateInstruction(instruction) {
|
|
|
8240
8483
|
error.name = "InstructionDiscriminatorMismatchError";
|
|
8241
8484
|
throw error;
|
|
8242
8485
|
}
|
|
8243
|
-
if (instruction.accounts.length <
|
|
8486
|
+
if (instruction.accounts.length < 23) throw new _solana_kit.SolanaError(_solana_kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
8244
8487
|
actualAccountMetas: instruction.accounts.length,
|
|
8245
|
-
expectedAccountMetas:
|
|
8488
|
+
expectedAccountMetas: 23
|
|
8246
8489
|
});
|
|
8247
8490
|
let accountIndex = 0;
|
|
8248
8491
|
const getNextAccount = () => {
|
|
@@ -8274,7 +8517,8 @@ function parseMigrateInstruction(instruction) {
|
|
|
8274
8517
|
associatedTokenProgram: getNextAccount(),
|
|
8275
8518
|
systemProgram: getNextAccount(),
|
|
8276
8519
|
eventAuthority: getNextAccount(),
|
|
8277
|
-
program: getNextAccount()
|
|
8520
|
+
program: getNextAccount(),
|
|
8521
|
+
dexCreatorFeeConfig: getNextAccount()
|
|
8278
8522
|
},
|
|
8279
8523
|
data: getMigrateInstructionDataDecoder().decode(instruction.data)
|
|
8280
8524
|
};
|
|
@@ -8513,6 +8757,7 @@ function sendLaunchpadProgram() {
|
|
|
8513
8757
|
pdas: {
|
|
8514
8758
|
bondingCurve: findBondingCurvePda,
|
|
8515
8759
|
eventAuthority: findEventAuthorityPda$1,
|
|
8760
|
+
creatorFeeConfig: findCreatorFeeConfigPda,
|
|
8516
8761
|
rewardAccrual: findRewardAccrualPda,
|
|
8517
8762
|
globalConfig: findGlobalConfigPda$1,
|
|
8518
8763
|
wsolRewardAccrual: findWsolRewardAccrualPda,
|
|
@@ -8530,7 +8775,7 @@ var plugins_exports$1 = /* @__PURE__ */ __exportAll({ sendLaunchpadProgram: () =
|
|
|
8530
8775
|
//#endregion
|
|
8531
8776
|
//#region src/utils/pda.ts
|
|
8532
8777
|
const addressEncoder = (0, _solana_kit.getAddressEncoder)();
|
|
8533
|
-
/**
|
|
8778
|
+
/** Derives the associated token account of `wallet` for `mint` under `tokenProgram`. */
|
|
8534
8779
|
async function findAssociatedTokenPda(wallet, mint, tokenProgram = TOKEN_PROGRAM_ADDRESS) {
|
|
8535
8780
|
return await (0, _solana_kit.getProgramDerivedAddress)({
|
|
8536
8781
|
programAddress: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
@@ -8546,13 +8791,20 @@ async function findAssociatedTokenPda(wallet, mint, tokenProgram = TOKEN_PROGRAM
|
|
|
8546
8791
|
var migrate_exports = /* @__PURE__ */ __exportAll({ buildMigrateInstruction: () => buildMigrateInstruction });
|
|
8547
8792
|
async function buildMigrateInstruction(params) {
|
|
8548
8793
|
const { quoteTokenProgram } = params;
|
|
8549
|
-
const [[pool], [lpMint]] = await Promise.all([
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8794
|
+
const [[pool], [lpMint], [dexCreatorFeeConfig]] = await Promise.all([
|
|
8795
|
+
findPoolPda({
|
|
8796
|
+
baseMint: params.baseMint,
|
|
8797
|
+
quoteMint: params.quoteMint
|
|
8798
|
+
}),
|
|
8799
|
+
findLpMintPda({
|
|
8800
|
+
baseMint: params.baseMint,
|
|
8801
|
+
quoteMint: params.quoteMint
|
|
8802
|
+
}),
|
|
8803
|
+
findCreatorFeeConfigPda$1({
|
|
8804
|
+
baseMint: params.baseMint,
|
|
8805
|
+
quoteMint: params.quoteMint
|
|
8806
|
+
})
|
|
8807
|
+
]);
|
|
8556
8808
|
const [[poolBaseVault], [poolQuoteVault], [poolLpAccount]] = await Promise.all([
|
|
8557
8809
|
findAssociatedTokenPda(pool, params.baseMint, TOKEN_2022_PROGRAM_ADDRESS),
|
|
8558
8810
|
findAssociatedTokenPda(pool, params.quoteMint, quoteTokenProgram),
|
|
@@ -8562,7 +8814,7 @@ async function buildMigrateInstruction(params) {
|
|
|
8562
8814
|
caller: params.caller,
|
|
8563
8815
|
baseMint: params.baseMint,
|
|
8564
8816
|
quoteMint: params.quoteMint,
|
|
8565
|
-
|
|
8817
|
+
dexCreatorFeeConfig,
|
|
8566
8818
|
poolBaseVault,
|
|
8567
8819
|
poolQuoteVault,
|
|
8568
8820
|
poolLpAccount,
|
|
@@ -8586,7 +8838,8 @@ var launchpad_exports = /* @__PURE__ */ __exportAll({
|
|
|
8586
8838
|
//#endregion
|
|
8587
8839
|
//#region src/math/fee-decay.ts
|
|
8588
8840
|
var fee_decay_exports = /* @__PURE__ */ __exportAll({ calculateFeeDecayPremium: () => calculateFeeDecayPremium });
|
|
8589
|
-
/**
|
|
8841
|
+
/** Returns the fee decay premium in bps, rounded up. The premium falls quadratically from
|
|
8842
|
+
* `decayStartBps - standardFeeBps` at creation to 0 after `decaySeconds`. */
|
|
8590
8843
|
function calculateFeeDecayPremium(params) {
|
|
8591
8844
|
const { currentTimestamp, createdAtTimestamp, decaySeconds, decayStartBps, standardFeeBps } = params;
|
|
8592
8845
|
if (decaySeconds === 0) return 0n;
|
|
@@ -8607,7 +8860,9 @@ function calculateFeeDecayPremium(params) {
|
|
|
8607
8860
|
//#endregion
|
|
8608
8861
|
//#region src/math/fees.ts
|
|
8609
8862
|
var fees_exports = /* @__PURE__ */ __exportAll({ splitFeeAmount: () => splitFeeAmount });
|
|
8610
|
-
/**
|
|
8863
|
+
/** Splits `feeAmount` into protocol, LP and creator shares. LP and creator round down. Protocol gets
|
|
8864
|
+
* the decay premium and all remainders. Throws `RangeError` on a negative or non-integer input,
|
|
8865
|
+
* a zero total bps, or `protocolBps + lpBps` above `baseTotalBps`. */
|
|
8611
8866
|
function splitFeeAmount(args) {
|
|
8612
8867
|
const { feeAmount } = args;
|
|
8613
8868
|
const protocolBps = toBps(args.protocolBps, "protocolBps");
|
|
@@ -8653,6 +8908,39 @@ var math_exports = /* @__PURE__ */ __exportAll({
|
|
|
8653
8908
|
fees: () => fees_exports
|
|
8654
8909
|
});
|
|
8655
8910
|
//#endregion
|
|
8911
|
+
//#region src/nexus/generated/shared/index.ts
|
|
8912
|
+
/** The System Program, which owns every address nobody has created an account at yet. */
|
|
8913
|
+
const SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
8914
|
+
/**
|
|
8915
|
+
* Whether an encoded account was created on-chain, rather than merely sent lamports.
|
|
8916
|
+
*
|
|
8917
|
+
* Anyone can send lamports to an address before its account is created, which leaves it on-chain,
|
|
8918
|
+
* owned by the System Program, with no data. This returns `false` for that shape, as it does for an
|
|
8919
|
+
* account that does not exist. Any other existing account counts as created, whoever owns it; the
|
|
8920
|
+
* `decode*` functions still check the owner.
|
|
8921
|
+
*
|
|
8922
|
+
* The generated `fetchMaybe*` and `fetchAllMaybe*` helpers apply this rule themselves. Apply it to
|
|
8923
|
+
* accounts you fetch or receive another way (subscriptions, batch loaders, caches) before passing
|
|
8924
|
+
* them to a `decode*` function, which throws for a lamports-only account: an account passed to it as
|
|
8925
|
+
* existing must never come back as the non-existing variant typed as an `Account`.
|
|
8926
|
+
*
|
|
8927
|
+
* Only a `true` result narrows the type. A lamports-only account is still `exists: true` at runtime,
|
|
8928
|
+
* so a `false` result leaves the type unchanged instead of narrowing it to the non-existing variant.
|
|
8929
|
+
* The `uncreated` property in the narrowed type is never present; it exists only to prevent that.
|
|
8930
|
+
*
|
|
8931
|
+
* @example
|
|
8932
|
+
* ```ts
|
|
8933
|
+
* const maybeAccount = decodeMyAccount(
|
|
8934
|
+
* accountIsCreated(encodedAccount) ? encodedAccount : { address: encodedAccount.address, exists: false },
|
|
8935
|
+
* );
|
|
8936
|
+
* ```
|
|
8937
|
+
*/
|
|
8938
|
+
function accountIsCreated(account) {
|
|
8939
|
+
const maybeAccount = account;
|
|
8940
|
+
if ("exists" in maybeAccount && !maybeAccount.exists) return false;
|
|
8941
|
+
return !(maybeAccount.programAddress === SYSTEM_PROGRAM_ADDRESS && maybeAccount.data.length === 0);
|
|
8942
|
+
}
|
|
8943
|
+
//#endregion
|
|
8656
8944
|
//#region src/nexus/generated/accounts/altRegistry.ts
|
|
8657
8945
|
/**
|
|
8658
8946
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -8716,111 +9004,43 @@ function decodeAltRegistry(encodedAccount) {
|
|
|
8716
9004
|
}
|
|
8717
9005
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getAltRegistryDecoder());
|
|
8718
9006
|
}
|
|
9007
|
+
/** Fetches a `AltRegistry` account, throwing when it does not exist or only holds lamports. */
|
|
8719
9008
|
async function fetchAltRegistry(rpc, address, config) {
|
|
8720
9009
|
const maybeAccount = await fetchMaybeAltRegistry(rpc, address, config);
|
|
8721
9010
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
8722
9011
|
return maybeAccount;
|
|
8723
9012
|
}
|
|
9013
|
+
/**
|
|
9014
|
+
* Fetches a `AltRegistry` account, or the non-existing variant when the address holds no
|
|
9015
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9016
|
+
* {@link decodeAltRegistry} throws for a lamports-only account instead.
|
|
9017
|
+
*/
|
|
8724
9018
|
async function fetchMaybeAltRegistry(rpc, address, config) {
|
|
8725
|
-
|
|
9019
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
9020
|
+
return decodeAltRegistry(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9021
|
+
address,
|
|
9022
|
+
exists: false
|
|
9023
|
+
});
|
|
8726
9024
|
}
|
|
9025
|
+
/** Fetches `AltRegistry` accounts, throwing when any does not exist or only holds lamports. */
|
|
8727
9026
|
async function fetchAllAltRegistry(rpc, addresses, config) {
|
|
8728
9027
|
const maybeAccounts = await fetchAllMaybeAltRegistry(rpc, addresses, config);
|
|
8729
9028
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
8730
9029
|
return maybeAccounts;
|
|
8731
9030
|
}
|
|
8732
|
-
async function fetchAllMaybeAltRegistry(rpc, addresses, config) {
|
|
8733
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeAltRegistry(maybeAccount));
|
|
8734
|
-
}
|
|
8735
|
-
function getAltRegistrySize() {
|
|
8736
|
-
return 74;
|
|
8737
|
-
}
|
|
8738
|
-
//#endregion
|
|
8739
|
-
//#region src/nexus/generated/accounts/creatorFeeConfig.ts
|
|
8740
9031
|
/**
|
|
8741
|
-
*
|
|
8742
|
-
*
|
|
8743
|
-
*
|
|
8744
|
-
*
|
|
8745
|
-
* @see https://github.com/codama-idl/codama
|
|
9032
|
+
* Fetches `AltRegistry` accounts, with the non-existing variant for each address that holds
|
|
9033
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9034
|
+
* {@link decodeAltRegistry} throws for a lamports-only account instead.
|
|
8746
9035
|
*/
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
74,
|
|
8752
|
-
215,
|
|
8753
|
-
196,
|
|
8754
|
-
130,
|
|
8755
|
-
32
|
|
8756
|
-
]);
|
|
8757
|
-
function getCreatorFeeConfigDiscriminatorBytes() {
|
|
8758
|
-
return (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 8).encode(CREATOR_FEE_CONFIG_DISCRIMINATOR);
|
|
8759
|
-
}
|
|
8760
|
-
/** Gets the encoder for {@link CreatorFeeConfigArgs} account data. */
|
|
8761
|
-
function getCreatorFeeConfigEncoder() {
|
|
8762
|
-
return (0, _solana_kit.transformEncoder)((0, _solana_kit.getStructEncoder)([
|
|
8763
|
-
["discriminator", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 8)],
|
|
8764
|
-
["version", (0, _solana_kit.getU8Encoder)()],
|
|
8765
|
-
["bump", (0, _solana_kit.getU8Encoder)()],
|
|
8766
|
-
["platformIndex", (0, _solana_kit.getU8Encoder)()],
|
|
8767
|
-
["platformId", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 44)],
|
|
8768
|
-
["quoteMint", (0, _solana_kit.getAddressEncoder)()],
|
|
8769
|
-
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 64)]
|
|
8770
|
-
]), (value) => ({
|
|
8771
|
-
...value,
|
|
8772
|
-
discriminator: CREATOR_FEE_CONFIG_DISCRIMINATOR
|
|
9036
|
+
async function fetchAllMaybeAltRegistry(rpc, addresses, config) {
|
|
9037
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeAltRegistry(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9038
|
+
address: maybeAccount.address,
|
|
9039
|
+
exists: false
|
|
8773
9040
|
}));
|
|
8774
9041
|
}
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
return (0, _solana_kit.getStructDecoder)([
|
|
8778
|
-
["discriminator", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 8)],
|
|
8779
|
-
["version", (0, _solana_kit.getU8Decoder)()],
|
|
8780
|
-
["bump", (0, _solana_kit.getU8Decoder)()],
|
|
8781
|
-
["platformIndex", (0, _solana_kit.getU8Decoder)()],
|
|
8782
|
-
["platformId", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 44)],
|
|
8783
|
-
["quoteMint", (0, _solana_kit.getAddressDecoder)()],
|
|
8784
|
-
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 64)]
|
|
8785
|
-
]);
|
|
8786
|
-
}
|
|
8787
|
-
/** Gets the codec for {@link CreatorFeeConfig} account data. */
|
|
8788
|
-
function getCreatorFeeConfigCodec() {
|
|
8789
|
-
return (0, _solana_kit.combineCodec)(getCreatorFeeConfigEncoder(), getCreatorFeeConfigDecoder());
|
|
8790
|
-
}
|
|
8791
|
-
function decodeCreatorFeeConfig(encodedAccount) {
|
|
8792
|
-
if (!("exists" in encodedAccount) || encodedAccount.exists) {
|
|
8793
|
-
if (encodedAccount.programAddress !== "7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX") {
|
|
8794
|
-
const error = /* @__PURE__ */ new Error(`decodeCreatorFeeConfig: account ${encodedAccount.address} is owned by ${encodedAccount.programAddress}, expected ${SEND_NEXUS_PROGRAM_ADDRESS}`);
|
|
8795
|
-
error.name = "AccountOwnerMismatchError";
|
|
8796
|
-
throw error;
|
|
8797
|
-
}
|
|
8798
|
-
if (!(0, _solana_kit.containsBytes)(encodedAccount.data, CREATOR_FEE_CONFIG_DISCRIMINATOR, 0)) {
|
|
8799
|
-
const error = /* @__PURE__ */ new Error(`decodeCreatorFeeConfig: account ${encodedAccount.address} does not match the CreatorFeeConfig discriminator`);
|
|
8800
|
-
error.name = "AccountDiscriminatorMismatchError";
|
|
8801
|
-
throw error;
|
|
8802
|
-
}
|
|
8803
|
-
}
|
|
8804
|
-
return (0, _solana_kit.decodeAccount)(encodedAccount, getCreatorFeeConfigDecoder());
|
|
8805
|
-
}
|
|
8806
|
-
async function fetchCreatorFeeConfig(rpc, address, config) {
|
|
8807
|
-
const maybeAccount = await fetchMaybeCreatorFeeConfig(rpc, address, config);
|
|
8808
|
-
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
8809
|
-
return maybeAccount;
|
|
8810
|
-
}
|
|
8811
|
-
async function fetchMaybeCreatorFeeConfig(rpc, address, config) {
|
|
8812
|
-
return decodeCreatorFeeConfig(await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config));
|
|
8813
|
-
}
|
|
8814
|
-
async function fetchAllCreatorFeeConfig(rpc, addresses, config) {
|
|
8815
|
-
const maybeAccounts = await fetchAllMaybeCreatorFeeConfig(rpc, addresses, config);
|
|
8816
|
-
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
8817
|
-
return maybeAccounts;
|
|
8818
|
-
}
|
|
8819
|
-
async function fetchAllMaybeCreatorFeeConfig(rpc, addresses, config) {
|
|
8820
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeCreatorFeeConfig(maybeAccount));
|
|
8821
|
-
}
|
|
8822
|
-
function getCreatorFeeConfigSize() {
|
|
8823
|
-
return 151;
|
|
9042
|
+
function getAltRegistrySize() {
|
|
9043
|
+
return 74;
|
|
8824
9044
|
}
|
|
8825
9045
|
//#endregion
|
|
8826
9046
|
//#region src/nexus/generated/types/authPlatformEntry.ts
|
|
@@ -8841,29 +9061,6 @@ function getAuthPlatformEntryCodec() {
|
|
|
8841
9061
|
return (0, _solana_kit.combineCodec)(getAuthPlatformEntryEncoder(), getAuthPlatformEntryDecoder());
|
|
8842
9062
|
}
|
|
8843
9063
|
//#endregion
|
|
8844
|
-
//#region src/nexus/generated/types/callerType.ts
|
|
8845
|
-
/**
|
|
8846
|
-
* This code was AUTOGENERATED using the Codama library.
|
|
8847
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
8848
|
-
* to add features, then rerun Codama to update it.
|
|
8849
|
-
*
|
|
8850
|
-
* @see https://github.com/codama-idl/codama
|
|
8851
|
-
*/
|
|
8852
|
-
let CallerType = /* @__PURE__ */ function(CallerType) {
|
|
8853
|
-
CallerType[CallerType["PlatformBondingCurve"] = 0] = "PlatformBondingCurve";
|
|
8854
|
-
CallerType[CallerType["PlatformPool"] = 1] = "PlatformPool";
|
|
8855
|
-
return CallerType;
|
|
8856
|
-
}({});
|
|
8857
|
-
function getCallerTypeEncoder() {
|
|
8858
|
-
return (0, _solana_kit.getEnumEncoder)(CallerType);
|
|
8859
|
-
}
|
|
8860
|
-
function getCallerTypeDecoder() {
|
|
8861
|
-
return (0, _solana_kit.getEnumDecoder)(CallerType);
|
|
8862
|
-
}
|
|
8863
|
-
function getCallerTypeCodec() {
|
|
8864
|
-
return (0, _solana_kit.combineCodec)(getCallerTypeEncoder(), getCallerTypeDecoder());
|
|
8865
|
-
}
|
|
8866
|
-
//#endregion
|
|
8867
9064
|
//#region src/nexus/generated/types/dexFees.ts
|
|
8868
9065
|
/**
|
|
8869
9066
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -8877,7 +9074,7 @@ function getDexFeesEncoder() {
|
|
|
8877
9074
|
["creationFeeCents", (0, _solana_kit.getU64Encoder)()],
|
|
8878
9075
|
["protocolFeeBps", (0, _solana_kit.getU16Encoder)()],
|
|
8879
9076
|
["lpFeeBps", (0, _solana_kit.getU16Encoder)()],
|
|
8880
|
-
["
|
|
9077
|
+
["maxCreatorFeeBps", (0, _solana_kit.getU16Encoder)()],
|
|
8881
9078
|
["feeDecaySeconds", (0, _solana_kit.getU16Encoder)()],
|
|
8882
9079
|
["feeDecayStartBps", (0, _solana_kit.getU16Encoder)()]
|
|
8883
9080
|
]);
|
|
@@ -8887,7 +9084,7 @@ function getDexFeesDecoder() {
|
|
|
8887
9084
|
["creationFeeCents", (0, _solana_kit.getU64Decoder)()],
|
|
8888
9085
|
["protocolFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
8889
9086
|
["lpFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
8890
|
-
["
|
|
9087
|
+
["maxCreatorFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
8891
9088
|
["feeDecaySeconds", (0, _solana_kit.getU16Decoder)()],
|
|
8892
9089
|
["feeDecayStartBps", (0, _solana_kit.getU16Decoder)()]
|
|
8893
9090
|
]);
|
|
@@ -8936,7 +9133,7 @@ function getLaunchpadFeesEncoder() {
|
|
|
8936
9133
|
return (0, _solana_kit.getStructEncoder)([
|
|
8937
9134
|
["creationFeeCents", (0, _solana_kit.getU64Encoder)()],
|
|
8938
9135
|
["protocolFeeBps", (0, _solana_kit.getU16Encoder)()],
|
|
8939
|
-
["
|
|
9136
|
+
["maxCreatorFeeBps", (0, _solana_kit.getU16Encoder)()],
|
|
8940
9137
|
["feeDecaySeconds", (0, _solana_kit.getU16Encoder)()],
|
|
8941
9138
|
["feeDecayStartBps", (0, _solana_kit.getU16Encoder)()]
|
|
8942
9139
|
]);
|
|
@@ -8945,7 +9142,7 @@ function getLaunchpadFeesDecoder() {
|
|
|
8945
9142
|
return (0, _solana_kit.getStructDecoder)([
|
|
8946
9143
|
["creationFeeCents", (0, _solana_kit.getU64Decoder)()],
|
|
8947
9144
|
["protocolFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
8948
|
-
["
|
|
9145
|
+
["maxCreatorFeeBps", (0, _solana_kit.getU16Decoder)()],
|
|
8949
9146
|
["feeDecaySeconds", (0, _solana_kit.getU16Decoder)()],
|
|
8950
9147
|
["feeDecayStartBps", (0, _solana_kit.getU16Decoder)()]
|
|
8951
9148
|
]);
|
|
@@ -8956,13 +9153,9 @@ function getLaunchpadFeesCodec() {
|
|
|
8956
9153
|
//#endregion
|
|
8957
9154
|
//#region src/nexus/generated/types/index.ts
|
|
8958
9155
|
var types_exports = /* @__PURE__ */ __exportAll({
|
|
8959
|
-
CallerType: () => CallerType,
|
|
8960
9156
|
getAuthPlatformEntryCodec: () => getAuthPlatformEntryCodec,
|
|
8961
9157
|
getAuthPlatformEntryDecoder: () => getAuthPlatformEntryDecoder,
|
|
8962
9158
|
getAuthPlatformEntryEncoder: () => getAuthPlatformEntryEncoder,
|
|
8963
|
-
getCallerTypeCodec: () => getCallerTypeCodec,
|
|
8964
|
-
getCallerTypeDecoder: () => getCallerTypeDecoder,
|
|
8965
|
-
getCallerTypeEncoder: () => getCallerTypeEncoder,
|
|
8966
9159
|
getDexFeesCodec: () => getDexFeesCodec,
|
|
8967
9160
|
getDexFeesDecoder: () => getDexFeesDecoder,
|
|
8968
9161
|
getDexFeesEncoder: () => getDexFeesEncoder,
|
|
@@ -9006,7 +9199,7 @@ function getFeePresetEncoder() {
|
|
|
9006
9199
|
["launchpad", getLaunchpadFeesEncoder()],
|
|
9007
9200
|
["dex", getDexFeesEncoder()],
|
|
9008
9201
|
["platformConfig", (0, _solana_kit.getAddressEncoder)()],
|
|
9009
|
-
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(),
|
|
9202
|
+
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 64)]
|
|
9010
9203
|
]), (value) => ({
|
|
9011
9204
|
...value,
|
|
9012
9205
|
discriminator: FEE_PRESET_DISCRIMINATOR
|
|
@@ -9023,7 +9216,7 @@ function getFeePresetDecoder() {
|
|
|
9023
9216
|
["launchpad", getLaunchpadFeesDecoder()],
|
|
9024
9217
|
["dex", getDexFeesDecoder()],
|
|
9025
9218
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
9026
|
-
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(),
|
|
9219
|
+
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 64)]
|
|
9027
9220
|
]);
|
|
9028
9221
|
}
|
|
9029
9222
|
/** Gets the codec for {@link FeePreset} account data. */
|
|
@@ -9045,21 +9238,40 @@ function decodeFeePreset(encodedAccount) {
|
|
|
9045
9238
|
}
|
|
9046
9239
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getFeePresetDecoder());
|
|
9047
9240
|
}
|
|
9241
|
+
/** Fetches a `FeePreset` account, throwing when it does not exist or only holds lamports. */
|
|
9048
9242
|
async function fetchFeePreset(rpc, address, config) {
|
|
9049
9243
|
const maybeAccount = await fetchMaybeFeePreset(rpc, address, config);
|
|
9050
9244
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
9051
9245
|
return maybeAccount;
|
|
9052
9246
|
}
|
|
9247
|
+
/**
|
|
9248
|
+
* Fetches a `FeePreset` account, or the non-existing variant when the address holds no
|
|
9249
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9250
|
+
* {@link decodeFeePreset} throws for a lamports-only account instead.
|
|
9251
|
+
*/
|
|
9053
9252
|
async function fetchMaybeFeePreset(rpc, address, config) {
|
|
9054
|
-
|
|
9253
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
9254
|
+
return decodeFeePreset(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9255
|
+
address,
|
|
9256
|
+
exists: false
|
|
9257
|
+
});
|
|
9055
9258
|
}
|
|
9259
|
+
/** Fetches `FeePreset` accounts, throwing when any does not exist or only holds lamports. */
|
|
9056
9260
|
async function fetchAllFeePreset(rpc, addresses, config) {
|
|
9057
9261
|
const maybeAccounts = await fetchAllMaybeFeePreset(rpc, addresses, config);
|
|
9058
9262
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
9059
9263
|
return maybeAccounts;
|
|
9060
9264
|
}
|
|
9265
|
+
/**
|
|
9266
|
+
* Fetches `FeePreset` accounts, with the non-existing variant for each address that holds
|
|
9267
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9268
|
+
* {@link decodeFeePreset} throws for a lamports-only account instead.
|
|
9269
|
+
*/
|
|
9061
9270
|
async function fetchAllMaybeFeePreset(rpc, addresses, config) {
|
|
9062
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeFeePreset(maybeAccount)
|
|
9271
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeFeePreset(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9272
|
+
address: maybeAccount.address,
|
|
9273
|
+
exists: false
|
|
9274
|
+
}));
|
|
9063
9275
|
}
|
|
9064
9276
|
//#endregion
|
|
9065
9277
|
//#region src/nexus/generated/accounts/globalConfig.ts
|
|
@@ -9129,21 +9341,40 @@ function decodeGlobalConfig(encodedAccount) {
|
|
|
9129
9341
|
}
|
|
9130
9342
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getGlobalConfigDecoder());
|
|
9131
9343
|
}
|
|
9344
|
+
/** Fetches a `GlobalConfig` account, throwing when it does not exist or only holds lamports. */
|
|
9132
9345
|
async function fetchGlobalConfig(rpc, address, config) {
|
|
9133
9346
|
const maybeAccount = await fetchMaybeGlobalConfig(rpc, address, config);
|
|
9134
9347
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
9135
9348
|
return maybeAccount;
|
|
9136
9349
|
}
|
|
9350
|
+
/**
|
|
9351
|
+
* Fetches a `GlobalConfig` account, or the non-existing variant when the address holds no
|
|
9352
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9353
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
9354
|
+
*/
|
|
9137
9355
|
async function fetchMaybeGlobalConfig(rpc, address, config) {
|
|
9138
|
-
|
|
9356
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
9357
|
+
return decodeGlobalConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9358
|
+
address,
|
|
9359
|
+
exists: false
|
|
9360
|
+
});
|
|
9139
9361
|
}
|
|
9362
|
+
/** Fetches `GlobalConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
9140
9363
|
async function fetchAllGlobalConfig(rpc, addresses, config) {
|
|
9141
9364
|
const maybeAccounts = await fetchAllMaybeGlobalConfig(rpc, addresses, config);
|
|
9142
9365
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
9143
9366
|
return maybeAccounts;
|
|
9144
9367
|
}
|
|
9368
|
+
/**
|
|
9369
|
+
* Fetches `GlobalConfig` accounts, with the non-existing variant for each address that holds
|
|
9370
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9371
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
9372
|
+
*/
|
|
9145
9373
|
async function fetchAllMaybeGlobalConfig(rpc, addresses, config) {
|
|
9146
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig(maybeAccount)
|
|
9374
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9375
|
+
address: maybeAccount.address,
|
|
9376
|
+
exists: false
|
|
9377
|
+
}));
|
|
9147
9378
|
}
|
|
9148
9379
|
//#endregion
|
|
9149
9380
|
//#region src/nexus/generated/accounts/partnerConfig.ts
|
|
@@ -9179,7 +9410,8 @@ function getPartnerConfigEncoder() {
|
|
|
9179
9410
|
["launchpad", getLaunchpadFeesEncoder()],
|
|
9180
9411
|
["dex", getDexFeesEncoder()],
|
|
9181
9412
|
["platformConfig", (0, _solana_kit.getAddressEncoder)()],
|
|
9182
|
-
["
|
|
9413
|
+
["allowedCreatorFeeModes", (0, _solana_kit.getU16Encoder)()],
|
|
9414
|
+
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 256)]
|
|
9183
9415
|
]), (value) => ({
|
|
9184
9416
|
...value,
|
|
9185
9417
|
discriminator: PARTNER_CONFIG_DISCRIMINATOR
|
|
@@ -9197,7 +9429,8 @@ function getPartnerConfigDecoder() {
|
|
|
9197
9429
|
["launchpad", getLaunchpadFeesDecoder()],
|
|
9198
9430
|
["dex", getDexFeesDecoder()],
|
|
9199
9431
|
["platformConfig", (0, _solana_kit.getAddressDecoder)()],
|
|
9200
|
-
["
|
|
9432
|
+
["allowedCreatorFeeModes", (0, _solana_kit.getU16Decoder)()],
|
|
9433
|
+
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 256)]
|
|
9201
9434
|
]);
|
|
9202
9435
|
}
|
|
9203
9436
|
/** Gets the codec for {@link PartnerConfig} account data. */
|
|
@@ -9219,24 +9452,43 @@ function decodePartnerConfig(encodedAccount) {
|
|
|
9219
9452
|
}
|
|
9220
9453
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getPartnerConfigDecoder());
|
|
9221
9454
|
}
|
|
9455
|
+
/** Fetches a `PartnerConfig` account, throwing when it does not exist or only holds lamports. */
|
|
9222
9456
|
async function fetchPartnerConfig(rpc, address, config) {
|
|
9223
9457
|
const maybeAccount = await fetchMaybePartnerConfig(rpc, address, config);
|
|
9224
9458
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
9225
9459
|
return maybeAccount;
|
|
9226
9460
|
}
|
|
9461
|
+
/**
|
|
9462
|
+
* Fetches a `PartnerConfig` account, or the non-existing variant when the address holds no
|
|
9463
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9464
|
+
* {@link decodePartnerConfig} throws for a lamports-only account instead.
|
|
9465
|
+
*/
|
|
9227
9466
|
async function fetchMaybePartnerConfig(rpc, address, config) {
|
|
9228
|
-
|
|
9467
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
9468
|
+
return decodePartnerConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9469
|
+
address,
|
|
9470
|
+
exists: false
|
|
9471
|
+
});
|
|
9229
9472
|
}
|
|
9473
|
+
/** Fetches `PartnerConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
9230
9474
|
async function fetchAllPartnerConfig(rpc, addresses, config) {
|
|
9231
9475
|
const maybeAccounts = await fetchAllMaybePartnerConfig(rpc, addresses, config);
|
|
9232
9476
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
9233
9477
|
return maybeAccounts;
|
|
9234
9478
|
}
|
|
9479
|
+
/**
|
|
9480
|
+
* Fetches `PartnerConfig` accounts, with the non-existing variant for each address that holds
|
|
9481
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9482
|
+
* {@link decodePartnerConfig} throws for a lamports-only account instead.
|
|
9483
|
+
*/
|
|
9235
9484
|
async function fetchAllMaybePartnerConfig(rpc, addresses, config) {
|
|
9236
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodePartnerConfig(maybeAccount)
|
|
9485
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodePartnerConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9486
|
+
address: maybeAccount.address,
|
|
9487
|
+
exists: false
|
|
9488
|
+
}));
|
|
9237
9489
|
}
|
|
9238
9490
|
function getPartnerConfigSize() {
|
|
9239
|
-
return
|
|
9491
|
+
return 399;
|
|
9240
9492
|
}
|
|
9241
9493
|
//#endregion
|
|
9242
9494
|
//#region src/nexus/generated/accounts/partnerMetadata.ts
|
|
@@ -9312,21 +9564,40 @@ function decodePartnerMetadata(encodedAccount) {
|
|
|
9312
9564
|
}
|
|
9313
9565
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getPartnerMetadataDecoder());
|
|
9314
9566
|
}
|
|
9567
|
+
/** Fetches a `PartnerMetadata` account, throwing when it does not exist or only holds lamports. */
|
|
9315
9568
|
async function fetchPartnerMetadata(rpc, address, config) {
|
|
9316
9569
|
const maybeAccount = await fetchMaybePartnerMetadata(rpc, address, config);
|
|
9317
9570
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
9318
9571
|
return maybeAccount;
|
|
9319
9572
|
}
|
|
9573
|
+
/**
|
|
9574
|
+
* Fetches a `PartnerMetadata` account, or the non-existing variant when the address holds no
|
|
9575
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9576
|
+
* {@link decodePartnerMetadata} throws for a lamports-only account instead.
|
|
9577
|
+
*/
|
|
9320
9578
|
async function fetchMaybePartnerMetadata(rpc, address, config) {
|
|
9321
|
-
|
|
9579
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
9580
|
+
return decodePartnerMetadata(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9581
|
+
address,
|
|
9582
|
+
exists: false
|
|
9583
|
+
});
|
|
9322
9584
|
}
|
|
9585
|
+
/** Fetches `PartnerMetadata` accounts, throwing when any does not exist or only holds lamports. */
|
|
9323
9586
|
async function fetchAllPartnerMetadata(rpc, addresses, config) {
|
|
9324
9587
|
const maybeAccounts = await fetchAllMaybePartnerMetadata(rpc, addresses, config);
|
|
9325
9588
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
9326
9589
|
return maybeAccounts;
|
|
9327
9590
|
}
|
|
9591
|
+
/**
|
|
9592
|
+
* Fetches `PartnerMetadata` accounts, with the non-existing variant for each address that holds
|
|
9593
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9594
|
+
* {@link decodePartnerMetadata} throws for a lamports-only account instead.
|
|
9595
|
+
*/
|
|
9328
9596
|
async function fetchAllMaybePartnerMetadata(rpc, addresses, config) {
|
|
9329
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodePartnerMetadata(maybeAccount)
|
|
9597
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodePartnerMetadata(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9598
|
+
address: maybeAccount.address,
|
|
9599
|
+
exists: false
|
|
9600
|
+
}));
|
|
9330
9601
|
}
|
|
9331
9602
|
//#endregion
|
|
9332
9603
|
//#region src/nexus/generated/accounts/rewardState.ts
|
|
@@ -9406,21 +9677,40 @@ function decodeRewardState(encodedAccount) {
|
|
|
9406
9677
|
}
|
|
9407
9678
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getRewardStateDecoder());
|
|
9408
9679
|
}
|
|
9680
|
+
/** Fetches a `RewardState` account, throwing when it does not exist or only holds lamports. */
|
|
9409
9681
|
async function fetchRewardState(rpc, address, config) {
|
|
9410
9682
|
const maybeAccount = await fetchMaybeRewardState(rpc, address, config);
|
|
9411
9683
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
9412
9684
|
return maybeAccount;
|
|
9413
9685
|
}
|
|
9686
|
+
/**
|
|
9687
|
+
* Fetches a `RewardState` account, or the non-existing variant when the address holds no
|
|
9688
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9689
|
+
* {@link decodeRewardState} throws for a lamports-only account instead.
|
|
9690
|
+
*/
|
|
9414
9691
|
async function fetchMaybeRewardState(rpc, address, config) {
|
|
9415
|
-
|
|
9692
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
9693
|
+
return decodeRewardState(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9694
|
+
address,
|
|
9695
|
+
exists: false
|
|
9696
|
+
});
|
|
9416
9697
|
}
|
|
9698
|
+
/** Fetches `RewardState` accounts, throwing when any does not exist or only holds lamports. */
|
|
9417
9699
|
async function fetchAllRewardState(rpc, addresses, config) {
|
|
9418
9700
|
const maybeAccounts = await fetchAllMaybeRewardState(rpc, addresses, config);
|
|
9419
9701
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
9420
9702
|
return maybeAccounts;
|
|
9421
9703
|
}
|
|
9704
|
+
/**
|
|
9705
|
+
* Fetches `RewardState` accounts, with the non-existing variant for each address that holds
|
|
9706
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9707
|
+
* {@link decodeRewardState} throws for a lamports-only account instead.
|
|
9708
|
+
*/
|
|
9422
9709
|
async function fetchAllMaybeRewardState(rpc, addresses, config) {
|
|
9423
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeRewardState(maybeAccount)
|
|
9710
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeRewardState(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9711
|
+
address: maybeAccount.address,
|
|
9712
|
+
exists: false
|
|
9713
|
+
}));
|
|
9424
9714
|
}
|
|
9425
9715
|
function getRewardStateSize() {
|
|
9426
9716
|
return 196;
|
|
@@ -9495,21 +9785,40 @@ function decodeStakingConfig(encodedAccount) {
|
|
|
9495
9785
|
}
|
|
9496
9786
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getStakingConfigDecoder());
|
|
9497
9787
|
}
|
|
9788
|
+
/** Fetches a `StakingConfig` account, throwing when it does not exist or only holds lamports. */
|
|
9498
9789
|
async function fetchStakingConfig(rpc, address, config) {
|
|
9499
9790
|
const maybeAccount = await fetchMaybeStakingConfig(rpc, address, config);
|
|
9500
9791
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
9501
9792
|
return maybeAccount;
|
|
9502
9793
|
}
|
|
9794
|
+
/**
|
|
9795
|
+
* Fetches a `StakingConfig` account, or the non-existing variant when the address holds no
|
|
9796
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9797
|
+
* {@link decodeStakingConfig} throws for a lamports-only account instead.
|
|
9798
|
+
*/
|
|
9503
9799
|
async function fetchMaybeStakingConfig(rpc, address, config) {
|
|
9504
|
-
|
|
9800
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
9801
|
+
return decodeStakingConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9802
|
+
address,
|
|
9803
|
+
exists: false
|
|
9804
|
+
});
|
|
9505
9805
|
}
|
|
9806
|
+
/** Fetches `StakingConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
9506
9807
|
async function fetchAllStakingConfig(rpc, addresses, config) {
|
|
9507
9808
|
const maybeAccounts = await fetchAllMaybeStakingConfig(rpc, addresses, config);
|
|
9508
9809
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
9509
9810
|
return maybeAccounts;
|
|
9510
9811
|
}
|
|
9812
|
+
/**
|
|
9813
|
+
* Fetches `StakingConfig` accounts, with the non-existing variant for each address that holds
|
|
9814
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9815
|
+
* {@link decodeStakingConfig} throws for a lamports-only account instead.
|
|
9816
|
+
*/
|
|
9511
9817
|
async function fetchAllMaybeStakingConfig(rpc, addresses, config) {
|
|
9512
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeStakingConfig(maybeAccount)
|
|
9818
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeStakingConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9819
|
+
address: maybeAccount.address,
|
|
9820
|
+
exists: false
|
|
9821
|
+
}));
|
|
9513
9822
|
}
|
|
9514
9823
|
function getStakingConfigSize() {
|
|
9515
9824
|
return 117;
|
|
@@ -9550,7 +9859,7 @@ function getUserRewardDebtEncoder() {
|
|
|
9550
9859
|
["amountSnapshot", (0, _solana_kit.getU64Encoder)()],
|
|
9551
9860
|
["settledVersion", (0, _solana_kit.getU32Encoder)()],
|
|
9552
9861
|
["owed", (0, _solana_kit.getU64Encoder)()],
|
|
9553
|
-
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(),
|
|
9862
|
+
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 64)]
|
|
9554
9863
|
]), (value) => ({
|
|
9555
9864
|
...value,
|
|
9556
9865
|
discriminator: USER_REWARD_DEBT_DISCRIMINATOR
|
|
@@ -9570,7 +9879,7 @@ function getUserRewardDebtDecoder() {
|
|
|
9570
9879
|
["amountSnapshot", (0, _solana_kit.getU64Decoder)()],
|
|
9571
9880
|
["settledVersion", (0, _solana_kit.getU32Decoder)()],
|
|
9572
9881
|
["owed", (0, _solana_kit.getU64Decoder)()],
|
|
9573
|
-
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(),
|
|
9882
|
+
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 64)]
|
|
9574
9883
|
]);
|
|
9575
9884
|
}
|
|
9576
9885
|
/** Gets the codec for {@link UserRewardDebt} account data. */
|
|
@@ -9592,24 +9901,43 @@ function decodeUserRewardDebt(encodedAccount) {
|
|
|
9592
9901
|
}
|
|
9593
9902
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getUserRewardDebtDecoder());
|
|
9594
9903
|
}
|
|
9904
|
+
/** Fetches a `UserRewardDebt` account, throwing when it does not exist or only holds lamports. */
|
|
9595
9905
|
async function fetchUserRewardDebt(rpc, address, config) {
|
|
9596
9906
|
const maybeAccount = await fetchMaybeUserRewardDebt(rpc, address, config);
|
|
9597
9907
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
9598
9908
|
return maybeAccount;
|
|
9599
9909
|
}
|
|
9910
|
+
/**
|
|
9911
|
+
* Fetches a `UserRewardDebt` account, or the non-existing variant when the address holds no
|
|
9912
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9913
|
+
* {@link decodeUserRewardDebt} throws for a lamports-only account instead.
|
|
9914
|
+
*/
|
|
9600
9915
|
async function fetchMaybeUserRewardDebt(rpc, address, config) {
|
|
9601
|
-
|
|
9916
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
9917
|
+
return decodeUserRewardDebt(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9918
|
+
address,
|
|
9919
|
+
exists: false
|
|
9920
|
+
});
|
|
9602
9921
|
}
|
|
9922
|
+
/** Fetches `UserRewardDebt` accounts, throwing when any does not exist or only holds lamports. */
|
|
9603
9923
|
async function fetchAllUserRewardDebt(rpc, addresses, config) {
|
|
9604
9924
|
const maybeAccounts = await fetchAllMaybeUserRewardDebt(rpc, addresses, config);
|
|
9605
9925
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
9606
9926
|
return maybeAccounts;
|
|
9607
9927
|
}
|
|
9928
|
+
/**
|
|
9929
|
+
* Fetches `UserRewardDebt` accounts, with the non-existing variant for each address that holds
|
|
9930
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9931
|
+
* {@link decodeUserRewardDebt} throws for a lamports-only account instead.
|
|
9932
|
+
*/
|
|
9608
9933
|
async function fetchAllMaybeUserRewardDebt(rpc, addresses, config) {
|
|
9609
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeUserRewardDebt(maybeAccount)
|
|
9934
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeUserRewardDebt(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9935
|
+
address: maybeAccount.address,
|
|
9936
|
+
exists: false
|
|
9937
|
+
}));
|
|
9610
9938
|
}
|
|
9611
9939
|
function getUserRewardDebtSize() {
|
|
9612
|
-
return
|
|
9940
|
+
return 214;
|
|
9613
9941
|
}
|
|
9614
9942
|
//#endregion
|
|
9615
9943
|
//#region src/nexus/generated/accounts/userStakePosition.ts
|
|
@@ -9644,7 +9972,7 @@ function getUserStakePositionEncoder() {
|
|
|
9644
9972
|
["amount", (0, _solana_kit.getU64Encoder)()],
|
|
9645
9973
|
["stakeVersion", (0, _solana_kit.getU32Encoder)()],
|
|
9646
9974
|
["settledCount", (0, _solana_kit.getU16Encoder)()],
|
|
9647
|
-
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(),
|
|
9975
|
+
["reserved", (0, _solana_kit.fixEncoderSize)((0, _solana_kit.getBytesEncoder)(), 128)]
|
|
9648
9976
|
]), (value) => ({
|
|
9649
9977
|
...value,
|
|
9650
9978
|
discriminator: USER_STAKE_POSITION_DISCRIMINATOR
|
|
@@ -9661,7 +9989,7 @@ function getUserStakePositionDecoder() {
|
|
|
9661
9989
|
["amount", (0, _solana_kit.getU64Decoder)()],
|
|
9662
9990
|
["stakeVersion", (0, _solana_kit.getU32Decoder)()],
|
|
9663
9991
|
["settledCount", (0, _solana_kit.getU16Decoder)()],
|
|
9664
|
-
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(),
|
|
9992
|
+
["reserved", (0, _solana_kit.fixDecoderSize)((0, _solana_kit.getBytesDecoder)(), 128)]
|
|
9665
9993
|
]);
|
|
9666
9994
|
}
|
|
9667
9995
|
/** Gets the codec for {@link UserStakePosition} account data. */
|
|
@@ -9683,24 +10011,43 @@ function decodeUserStakePosition(encodedAccount) {
|
|
|
9683
10011
|
}
|
|
9684
10012
|
return (0, _solana_kit.decodeAccount)(encodedAccount, getUserStakePositionDecoder());
|
|
9685
10013
|
}
|
|
10014
|
+
/** Fetches a `UserStakePosition` account, throwing when it does not exist or only holds lamports. */
|
|
9686
10015
|
async function fetchUserStakePosition(rpc, address, config) {
|
|
9687
10016
|
const maybeAccount = await fetchMaybeUserStakePosition(rpc, address, config);
|
|
9688
10017
|
(0, _solana_kit.assertAccountExists)(maybeAccount);
|
|
9689
10018
|
return maybeAccount;
|
|
9690
10019
|
}
|
|
10020
|
+
/**
|
|
10021
|
+
* Fetches a `UserStakePosition` account, or the non-existing variant when the address holds no
|
|
10022
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
10023
|
+
* {@link decodeUserStakePosition} throws for a lamports-only account instead.
|
|
10024
|
+
*/
|
|
9691
10025
|
async function fetchMaybeUserStakePosition(rpc, address, config) {
|
|
9692
|
-
|
|
10026
|
+
const maybeAccount = await (0, _solana_kit.fetchEncodedAccount)(rpc, address, config);
|
|
10027
|
+
return decodeUserStakePosition(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
10028
|
+
address,
|
|
10029
|
+
exists: false
|
|
10030
|
+
});
|
|
9693
10031
|
}
|
|
10032
|
+
/** Fetches `UserStakePosition` accounts, throwing when any does not exist or only holds lamports. */
|
|
9694
10033
|
async function fetchAllUserStakePosition(rpc, addresses, config) {
|
|
9695
10034
|
const maybeAccounts = await fetchAllMaybeUserStakePosition(rpc, addresses, config);
|
|
9696
10035
|
(0, _solana_kit.assertAccountsExist)(maybeAccounts);
|
|
9697
10036
|
return maybeAccounts;
|
|
9698
10037
|
}
|
|
10038
|
+
/**
|
|
10039
|
+
* Fetches `UserStakePosition` accounts, with the non-existing variant for each address that holds
|
|
10040
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
10041
|
+
* {@link decodeUserStakePosition} throws for a lamports-only account instead.
|
|
10042
|
+
*/
|
|
9699
10043
|
async function fetchAllMaybeUserStakePosition(rpc, addresses, config) {
|
|
9700
|
-
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeUserStakePosition(maybeAccount)
|
|
10044
|
+
return (await (0, _solana_kit.fetchEncodedAccounts)(rpc, addresses, config)).map((maybeAccount) => decodeUserStakePosition(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
10045
|
+
address: maybeAccount.address,
|
|
10046
|
+
exists: false
|
|
10047
|
+
}));
|
|
9701
10048
|
}
|
|
9702
10049
|
function getUserStakePositionSize() {
|
|
9703
|
-
return
|
|
10050
|
+
return 216;
|
|
9704
10051
|
}
|
|
9705
10052
|
//#endregion
|
|
9706
10053
|
//#region src/nexus/generated/accounts/sendNexus.accounts.ts
|
|
@@ -9719,7 +10066,6 @@ function identifySendNexusAccount(account) {
|
|
|
9719
10066
|
if ("data" in account && account.programAddress !== "7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX") return null;
|
|
9720
10067
|
const data = "data" in account ? account.data : account;
|
|
9721
10068
|
if ((0, _solana_kit.containsBytes)(data, ALT_REGISTRY_DISCRIMINATOR, 0)) return "altRegistry";
|
|
9722
|
-
if ((0, _solana_kit.containsBytes)(data, CREATOR_FEE_CONFIG_DISCRIMINATOR, 0)) return "creatorFeeConfig";
|
|
9723
10069
|
if ((0, _solana_kit.containsBytes)(data, FEE_PRESET_DISCRIMINATOR, 0)) return "feePreset";
|
|
9724
10070
|
if ((0, _solana_kit.containsBytes)(data, GLOBAL_CONFIG_DISCRIMINATOR, 0)) return "globalConfig";
|
|
9725
10071
|
if ((0, _solana_kit.containsBytes)(data, PARTNER_CONFIG_DISCRIMINATOR, 0)) return "partnerConfig";
|
|
@@ -9734,7 +10080,6 @@ function identifySendNexusAccount(account) {
|
|
|
9734
10080
|
//#region src/nexus/generated/accounts/index.ts
|
|
9735
10081
|
var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
9736
10082
|
ALT_REGISTRY_DISCRIMINATOR: () => ALT_REGISTRY_DISCRIMINATOR,
|
|
9737
|
-
CREATOR_FEE_CONFIG_DISCRIMINATOR: () => CREATOR_FEE_CONFIG_DISCRIMINATOR,
|
|
9738
10083
|
FEE_PRESET_DISCRIMINATOR: () => FEE_PRESET_DISCRIMINATOR,
|
|
9739
10084
|
GLOBAL_CONFIG_DISCRIMINATOR: () => GLOBAL_CONFIG_DISCRIMINATOR,
|
|
9740
10085
|
PARTNER_CONFIG_DISCRIMINATOR: () => PARTNER_CONFIG_DISCRIMINATOR,
|
|
@@ -9744,7 +10089,6 @@ var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
|
9744
10089
|
USER_REWARD_DEBT_DISCRIMINATOR: () => USER_REWARD_DEBT_DISCRIMINATOR,
|
|
9745
10090
|
USER_STAKE_POSITION_DISCRIMINATOR: () => USER_STAKE_POSITION_DISCRIMINATOR,
|
|
9746
10091
|
decodeAltRegistry: () => decodeAltRegistry,
|
|
9747
|
-
decodeCreatorFeeConfig: () => decodeCreatorFeeConfig,
|
|
9748
10092
|
decodeFeePreset: () => decodeFeePreset,
|
|
9749
10093
|
decodeGlobalConfig: () => decodeGlobalConfig,
|
|
9750
10094
|
decodePartnerConfig: () => decodePartnerConfig,
|
|
@@ -9754,11 +10098,9 @@ var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
|
9754
10098
|
decodeUserRewardDebt: () => decodeUserRewardDebt,
|
|
9755
10099
|
decodeUserStakePosition: () => decodeUserStakePosition,
|
|
9756
10100
|
fetchAllAltRegistry: () => fetchAllAltRegistry,
|
|
9757
|
-
fetchAllCreatorFeeConfig: () => fetchAllCreatorFeeConfig,
|
|
9758
10101
|
fetchAllFeePreset: () => fetchAllFeePreset,
|
|
9759
10102
|
fetchAllGlobalConfig: () => fetchAllGlobalConfig,
|
|
9760
10103
|
fetchAllMaybeAltRegistry: () => fetchAllMaybeAltRegistry,
|
|
9761
|
-
fetchAllMaybeCreatorFeeConfig: () => fetchAllMaybeCreatorFeeConfig,
|
|
9762
10104
|
fetchAllMaybeFeePreset: () => fetchAllMaybeFeePreset,
|
|
9763
10105
|
fetchAllMaybeGlobalConfig: () => fetchAllMaybeGlobalConfig,
|
|
9764
10106
|
fetchAllMaybePartnerConfig: () => fetchAllMaybePartnerConfig,
|
|
@@ -9774,11 +10116,9 @@ var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
|
9774
10116
|
fetchAllUserRewardDebt: () => fetchAllUserRewardDebt,
|
|
9775
10117
|
fetchAllUserStakePosition: () => fetchAllUserStakePosition,
|
|
9776
10118
|
fetchAltRegistry: () => fetchAltRegistry,
|
|
9777
|
-
fetchCreatorFeeConfig: () => fetchCreatorFeeConfig,
|
|
9778
10119
|
fetchFeePreset: () => fetchFeePreset,
|
|
9779
10120
|
fetchGlobalConfig: () => fetchGlobalConfig,
|
|
9780
10121
|
fetchMaybeAltRegistry: () => fetchMaybeAltRegistry,
|
|
9781
|
-
fetchMaybeCreatorFeeConfig: () => fetchMaybeCreatorFeeConfig,
|
|
9782
10122
|
fetchMaybeFeePreset: () => fetchMaybeFeePreset,
|
|
9783
10123
|
fetchMaybeGlobalConfig: () => fetchMaybeGlobalConfig,
|
|
9784
10124
|
fetchMaybePartnerConfig: () => fetchMaybePartnerConfig,
|
|
@@ -9798,11 +10138,6 @@ var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
|
9798
10138
|
getAltRegistryDiscriminatorBytes: () => getAltRegistryDiscriminatorBytes,
|
|
9799
10139
|
getAltRegistryEncoder: () => getAltRegistryEncoder,
|
|
9800
10140
|
getAltRegistrySize: () => getAltRegistrySize,
|
|
9801
|
-
getCreatorFeeConfigCodec: () => getCreatorFeeConfigCodec,
|
|
9802
|
-
getCreatorFeeConfigDecoder: () => getCreatorFeeConfigDecoder,
|
|
9803
|
-
getCreatorFeeConfigDiscriminatorBytes: () => getCreatorFeeConfigDiscriminatorBytes,
|
|
9804
|
-
getCreatorFeeConfigEncoder: () => getCreatorFeeConfigEncoder,
|
|
9805
|
-
getCreatorFeeConfigSize: () => getCreatorFeeConfigSize,
|
|
9806
10141
|
getFeePresetCodec: () => getFeePresetCodec,
|
|
9807
10142
|
getFeePresetDecoder: () => getFeePresetDecoder,
|
|
9808
10143
|
getFeePresetDiscriminatorBytes: () => getFeePresetDiscriminatorBytes,
|
|
@@ -10240,12 +10575,16 @@ const SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 7009;
|
|
|
10240
10575
|
const SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 7010;
|
|
10241
10576
|
/** NothingToClaim: Nothing to claim */
|
|
10242
10577
|
const SEND_NEXUS_ERROR__NOTHING_TO_CLAIM = 7011;
|
|
10243
|
-
/**
|
|
10244
|
-
const
|
|
10578
|
+
/** Unused7012: Unused */
|
|
10579
|
+
const SEND_NEXUS_ERROR__UNUSED7012 = 7012;
|
|
10245
10580
|
/** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
|
|
10246
10581
|
const SEND_NEXUS_ERROR__QUOTE_MINT_PRICE_UNSET = 7013;
|
|
10247
10582
|
/** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
|
|
10248
10583
|
const SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 7014;
|
|
10584
|
+
/** CreatorFeeTooHigh: Creator fee exceeds the partner's maximum */
|
|
10585
|
+
const SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH = 7015;
|
|
10586
|
+
/** CreatorFeeModeNotAllowed: Creator fee mode is not allowed by the partner config */
|
|
10587
|
+
const SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED = 7016;
|
|
10249
10588
|
/** InsufficientLiquidity: Insufficient liquidity */
|
|
10250
10589
|
const SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY = 7100;
|
|
10251
10590
|
/** InvalidAmount: Invalid amount */
|
|
@@ -10253,6 +10592,8 @@ const SEND_NEXUS_ERROR__INVALID_AMOUNT = 7101;
|
|
|
10253
10592
|
const sendNexusErrorMessages = {
|
|
10254
10593
|
[SEND_NEXUS_ERROR__AMBIGUOUS_FEE_SOURCE]: `Cannot specify both fee_preset and custom_fees`,
|
|
10255
10594
|
[SEND_NEXUS_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
10595
|
+
[SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED]: `Creator fee mode is not allowed by the partner config`,
|
|
10596
|
+
[SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH]: `Creator fee exceeds the partner's maximum`,
|
|
10256
10597
|
[SEND_NEXUS_ERROR__DUPLICATE_AUTH_PLATFORM_NAME]: `Duplicate auth platform name`,
|
|
10257
10598
|
[SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
10258
10599
|
[SEND_NEXUS_ERROR__INSUFFICIENT_STAKE]: `Insufficient stake balance`,
|
|
@@ -10260,7 +10601,6 @@ const sendNexusErrorMessages = {
|
|
|
10260
10601
|
[SEND_NEXUS_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
|
|
10261
10602
|
[SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_INDEX]: `Invalid auth platform index`,
|
|
10262
10603
|
[SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_NAME]: `Invalid auth platform name`,
|
|
10263
|
-
[SEND_NEXUS_ERROR__INVALID_CREATOR_ID]: `Creator identity is not a decodable wallet address`,
|
|
10264
10604
|
[SEND_NEXUS_ERROR__INVALID_DESTINATION]: `Invalid destination account`,
|
|
10265
10605
|
[SEND_NEXUS_ERROR__INVALID_FEE_PRESET]: `Invalid fee configuration`,
|
|
10266
10606
|
[SEND_NEXUS_ERROR__INVALID_MINT]: `Invalid mint`,
|
|
@@ -10294,6 +10634,7 @@ const sendNexusErrorMessages = {
|
|
|
10294
10634
|
[SEND_NEXUS_ERROR__TOO_MANY_AUTH_PLATFORMS]: `Too many auth platforms (max 255)`,
|
|
10295
10635
|
[SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
|
|
10296
10636
|
[SEND_NEXUS_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
10637
|
+
[SEND_NEXUS_ERROR__UNUSED7012]: `Unused`,
|
|
10297
10638
|
[SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
|
|
10298
10639
|
[SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
|
|
10299
10640
|
[SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT]: `User token account mint does not match the trade`,
|
|
@@ -10310,6 +10651,8 @@ function isSendNexusError(error, transactionMessage, code) {
|
|
|
10310
10651
|
var errors_exports = /* @__PURE__ */ __exportAll({
|
|
10311
10652
|
SEND_NEXUS_ERROR__AMBIGUOUS_FEE_SOURCE: () => SEND_NEXUS_ERROR__AMBIGUOUS_FEE_SOURCE,
|
|
10312
10653
|
SEND_NEXUS_ERROR__ARITHMETIC_OVERFLOW: () => SEND_NEXUS_ERROR__ARITHMETIC_OVERFLOW,
|
|
10654
|
+
SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED: () => SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED,
|
|
10655
|
+
SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH: () => SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH,
|
|
10313
10656
|
SEND_NEXUS_ERROR__DUPLICATE_AUTH_PLATFORM_NAME: () => SEND_NEXUS_ERROR__DUPLICATE_AUTH_PLATFORM_NAME,
|
|
10314
10657
|
SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY: () => SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY,
|
|
10315
10658
|
SEND_NEXUS_ERROR__INSUFFICIENT_STAKE: () => SEND_NEXUS_ERROR__INSUFFICIENT_STAKE,
|
|
@@ -10317,7 +10660,6 @@ var errors_exports = /* @__PURE__ */ __exportAll({
|
|
|
10317
10660
|
SEND_NEXUS_ERROR__INVALID_AUTHORITY: () => SEND_NEXUS_ERROR__INVALID_AUTHORITY,
|
|
10318
10661
|
SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_INDEX: () => SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_INDEX,
|
|
10319
10662
|
SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_NAME: () => SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_NAME,
|
|
10320
|
-
SEND_NEXUS_ERROR__INVALID_CREATOR_ID: () => SEND_NEXUS_ERROR__INVALID_CREATOR_ID,
|
|
10321
10663
|
SEND_NEXUS_ERROR__INVALID_DESTINATION: () => SEND_NEXUS_ERROR__INVALID_DESTINATION,
|
|
10322
10664
|
SEND_NEXUS_ERROR__INVALID_FEE_PRESET: () => SEND_NEXUS_ERROR__INVALID_FEE_PRESET,
|
|
10323
10665
|
SEND_NEXUS_ERROR__INVALID_MINT: () => SEND_NEXUS_ERROR__INVALID_MINT,
|
|
@@ -10351,6 +10693,7 @@ var errors_exports = /* @__PURE__ */ __exportAll({
|
|
|
10351
10693
|
SEND_NEXUS_ERROR__TOO_MANY_AUTH_PLATFORMS: () => SEND_NEXUS_ERROR__TOO_MANY_AUTH_PLATFORMS,
|
|
10352
10694
|
SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE: () => SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE,
|
|
10353
10695
|
SEND_NEXUS_ERROR__UNAUTHORIZED: () => SEND_NEXUS_ERROR__UNAUTHORIZED,
|
|
10696
|
+
SEND_NEXUS_ERROR__UNUSED7012: () => SEND_NEXUS_ERROR__UNUSED7012,
|
|
10354
10697
|
SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_INVALID: () => SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_INVALID,
|
|
10355
10698
|
SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY: () => SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY,
|
|
10356
10699
|
SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT: () => SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT,
|
|
@@ -10737,7 +11080,6 @@ var pdas_exports = /* @__PURE__ */ __exportAll({
|
|
|
10737
11080
|
GLOBAL_CONFIG_PDA_ADDRESS: () => GLOBAL_CONFIG_PDA_ADDRESS,
|
|
10738
11081
|
STAKING_CONFIG_PDA_ADDRESS: () => STAKING_CONFIG_PDA_ADDRESS,
|
|
10739
11082
|
findAltRegistryPda: () => findAltRegistryPda,
|
|
10740
|
-
findCreatorFeeConfigPda: () => findCreatorFeeConfigPda,
|
|
10741
11083
|
findDefaultFeePresetPda: () => findDefaultFeePresetPda,
|
|
10742
11084
|
findDefaultPartnerMetadataPda: () => findDefaultPartnerMetadataPda,
|
|
10743
11085
|
findDefaultPartnerPda: () => findDefaultPartnerPda,
|
|
@@ -12151,13 +12493,6 @@ function sendNexusProgram() {
|
|
|
12151
12493
|
fetchAllMaybe: (addresses, config) => fetchAllMaybeAltRegistry(client.rpc, addresses, config),
|
|
12152
12494
|
fetchMaybe: (address, config) => fetchMaybeAltRegistry(client.rpc, address, config)
|
|
12153
12495
|
}),
|
|
12154
|
-
creatorFeeConfig: Object.freeze({
|
|
12155
|
-
...getCreatorFeeConfigCodec(),
|
|
12156
|
-
fetch: (address, config) => fetchCreatorFeeConfig(client.rpc, address, config),
|
|
12157
|
-
fetchAll: (addresses, config) => fetchAllCreatorFeeConfig(client.rpc, addresses, config),
|
|
12158
|
-
fetchAllMaybe: (addresses, config) => fetchAllMaybeCreatorFeeConfig(client.rpc, addresses, config),
|
|
12159
|
-
fetchMaybe: (address, config) => fetchMaybeCreatorFeeConfig(client.rpc, address, config)
|
|
12160
|
-
}),
|
|
12161
12496
|
feePreset: Object.freeze({
|
|
12162
12497
|
...getFeePresetCodec(),
|
|
12163
12498
|
fetch: (address, config) => fetchFeePreset(client.rpc, address, config),
|
|
@@ -12255,7 +12590,6 @@ function sendNexusProgram() {
|
|
|
12255
12590
|
userStakePosition: findUserStakePositionPda,
|
|
12256
12591
|
userRewardDebt: findUserRewardDebtPda,
|
|
12257
12592
|
eventAuthority: findEventAuthorityPda,
|
|
12258
|
-
creatorFeeConfig: findCreatorFeeConfigPda,
|
|
12259
12593
|
altRegistry: findAltRegistryPda
|
|
12260
12594
|
},
|
|
12261
12595
|
identifyAccount: identifySendNexusAccount,
|
|
@@ -12273,7 +12607,8 @@ var fee_helpers_exports = /* @__PURE__ */ __exportAll({
|
|
|
12273
12607
|
effectiveFeeBps: () => effectiveFeeBps,
|
|
12274
12608
|
fetchPartnerFees: () => fetchPartnerFees
|
|
12275
12609
|
});
|
|
12276
|
-
/**
|
|
12610
|
+
/** Fetches the `PartnerConfig` of `partner` on `platformConfig`. Throws if it does not exist.
|
|
12611
|
+
* Use the `platformConfig` of the market you price. A partner's fees differ per platform. */
|
|
12277
12612
|
async function fetchPartnerFees(rpc, partner, platformConfig) {
|
|
12278
12613
|
const [partnerPda] = await findPartnerConfigPda({
|
|
12279
12614
|
partner,
|
|
@@ -12283,10 +12618,13 @@ async function fetchPartnerFees(rpc, partner, platformConfig) {
|
|
|
12283
12618
|
if (!maybeAccount.exists) throw new Error(`No fee config for partner ${partner} on platform ${platformConfig}`);
|
|
12284
12619
|
return maybeAccount.data;
|
|
12285
12620
|
}
|
|
12286
|
-
/**
|
|
12287
|
-
*
|
|
12288
|
-
|
|
12289
|
-
|
|
12621
|
+
/** Returns the `feeBps` a trade pays: the standard rate plus the decay premium. The standard rate
|
|
12622
|
+
* is the protocol and LP rates of `schedule` plus `creatorFeeBps`. `schedule` is the
|
|
12623
|
+
* `PartnerConfig`'s `launchpad` for a curve or `dex` for a pool. `creatorFeeBps` and `createdAt`
|
|
12624
|
+
* are the curve's or pool's. `schedule.maxCreatorFeeBps` has no effect. `createdAt` and `now`
|
|
12625
|
+
* are in unix seconds. */
|
|
12626
|
+
function effectiveFeeBps(schedule, createdAt, now, creatorFeeBps) {
|
|
12627
|
+
const standardFeeBps = schedule.protocolFeeBps + ("lpFeeBps" in schedule ? schedule.lpFeeBps : 0) + creatorFeeBps;
|
|
12290
12628
|
const premium = calculateFeeDecayPremium({
|
|
12291
12629
|
currentTimestamp: now,
|
|
12292
12630
|
createdAtTimestamp: createdAt,
|
|
@@ -12300,7 +12638,7 @@ function effectiveFeeBps(schedule, createdAt, now) {
|
|
|
12300
12638
|
//#region src/utils/chunk.ts
|
|
12301
12639
|
/** RPCs reject a `getMultipleAccounts` call past this many addresses. */
|
|
12302
12640
|
const MAX_ACCOUNTS_PER_REQUEST = 100;
|
|
12303
|
-
/**
|
|
12641
|
+
/** Calls `read` once per 100 addresses. Results follow `addresses` order. */
|
|
12304
12642
|
async function fetchInChunks(addresses, read) {
|
|
12305
12643
|
const chunks = [];
|
|
12306
12644
|
for (let start = 0; start < addresses.length; start += MAX_ACCOUNTS_PER_REQUEST) chunks.push(addresses.slice(start, start + MAX_ACCOUNTS_PER_REQUEST));
|
|
@@ -12335,9 +12673,8 @@ function compareAddresses(a, b) {
|
|
|
12335
12673
|
if (a > b) return 1;
|
|
12336
12674
|
return 0;
|
|
12337
12675
|
}
|
|
12338
|
-
/**
|
|
12339
|
-
*
|
|
12340
|
-
* `StakingConfig.rewardCount` rather than settle a short list. */
|
|
12676
|
+
/** Returns every registered reward mint, disabled mints included, sorted by address.
|
|
12677
|
+
* Throws if the count differs from `StakingConfig.rewardCount`. */
|
|
12341
12678
|
async function getRewardMints(rpc) {
|
|
12342
12679
|
const [stakingConfig] = findStakingConfigPda();
|
|
12343
12680
|
const [accounts, config] = await Promise.all([rpc.getProgramAccounts(SEND_NEXUS_PROGRAM_ADDRESS, {
|
|
@@ -12367,7 +12704,8 @@ async function resolveRewardMints(rpc, rewardMints) {
|
|
|
12367
12704
|
if (!hasProgramAccounts(rpc)) throw new Error("This RPC has no getProgramAccounts, so the reward registry cannot be read from chain. Pass rewardMints explicitly.");
|
|
12368
12705
|
return await getRewardMints(rpc);
|
|
12369
12706
|
}
|
|
12370
|
-
/**
|
|
12707
|
+
/** Builds one `settle` per reward mint. `source` is the mint list, or an RPC to read it from.
|
|
12708
|
+
* `settle` is idempotent. With a partial list, `stake` and `unstake` fail with `RewardsNotSettled`. */
|
|
12371
12709
|
async function buildSettleInstructions(source, params) {
|
|
12372
12710
|
const rewardMints = isRewardMintList(source) ? source : await resolveRewardMints(source, void 0);
|
|
12373
12711
|
return Promise.all(rewardMints.map((rewardMint) => getSettleInstructionAsync({
|
|
@@ -12388,10 +12726,11 @@ async function fetchMissingUserRewardDebts(rpc, user, stakingMint, knownRewardMi
|
|
|
12388
12726
|
return addr;
|
|
12389
12727
|
})), (chunk) => (0, _solana_kit.fetchEncodedAccounts)(rpc, chunk));
|
|
12390
12728
|
const missingMints = [];
|
|
12391
|
-
for (const [index, rewardMint] of rewardMints.entries()) if (!encodedAccounts[index]
|
|
12729
|
+
for (const [index, rewardMint] of rewardMints.entries()) if (!accountIsCreated(encodedAccounts[index])) missingMints.push(rewardMint);
|
|
12392
12730
|
return missingMints;
|
|
12393
12731
|
}
|
|
12394
|
-
/**
|
|
12732
|
+
/** Builds a `create_user_reward_debt` for each missing `UserRewardDebt`, then a `settle` for every
|
|
12733
|
+
* reward mint. The user does not sign these instructions. */
|
|
12395
12734
|
async function buildStakingPreflightInstructions(rpc, params) {
|
|
12396
12735
|
const rewardMints = await resolveRewardMints(rpc, params.rewardMints);
|
|
12397
12736
|
const missingMints = await fetchMissingUserRewardDebts(rpc, params.user, params.stakingMint, rewardMints);
|
|
@@ -12404,13 +12743,14 @@ async function buildStakingPreflightInstructions(rpc, params) {
|
|
|
12404
12743
|
const settleIxs = await buildSettleInstructions(rewardMints, params);
|
|
12405
12744
|
return [...createIxs, ...settleIxs];
|
|
12406
12745
|
}
|
|
12407
|
-
/**
|
|
12746
|
+
/** Returns true if `stake` and `unstake` pass the `settledCount == rewardCount` check. */
|
|
12408
12747
|
async function isFullySettled(rpc, user, stakingMint) {
|
|
12409
12748
|
const [config, position] = await Promise.all([fetchStakingConfigData(rpc), fetchUserStakePositionData(rpc, user, stakingMint)]);
|
|
12410
12749
|
if (position === null) return config.rewardCount === 0;
|
|
12411
12750
|
return position.settledCount === config.rewardCount;
|
|
12412
12751
|
}
|
|
12413
|
-
/**
|
|
12752
|
+
/** The instruction fails with `RewardsNotSettled` until every mint is settled at the current
|
|
12753
|
+
* `stakeVersion`. Run `buildStakingPreflightInstructions` first. */
|
|
12414
12754
|
async function buildStakeInstruction(params) {
|
|
12415
12755
|
return getStakeInstructionAsync({
|
|
12416
12756
|
user: params.user,
|
|
@@ -12419,8 +12759,9 @@ async function buildStakeInstruction(params) {
|
|
|
12419
12759
|
amount: params.amount
|
|
12420
12760
|
});
|
|
12421
12761
|
}
|
|
12422
|
-
/**
|
|
12423
|
-
*
|
|
12762
|
+
/** Run `buildStakingPreflightInstructions` immediately before. The check also passes on an older
|
|
12763
|
+
* settle. Rewards since that settle then accrue on the smaller post-unstake amount, and the
|
|
12764
|
+
* difference is lost. */
|
|
12424
12765
|
async function buildUnstakeInstruction(params) {
|
|
12425
12766
|
return getUnstakeInstructionAsync({
|
|
12426
12767
|
user: params.user,
|
|
@@ -12429,8 +12770,8 @@ async function buildUnstakeInstruction(params) {
|
|
|
12429
12770
|
amount: params.amount
|
|
12430
12771
|
});
|
|
12431
12772
|
}
|
|
12432
|
-
/**
|
|
12433
|
-
* `
|
|
12773
|
+
/** Builds one `claim` per reward mint. A `create_user_reward_debt` comes before each `claim` whose
|
|
12774
|
+
* `UserRewardDebt` is missing: `claim` fails without it. Throws if a mint has no `RewardState`. */
|
|
12434
12775
|
async function buildClaimRewardsInstructions(rpc, params) {
|
|
12435
12776
|
const [stakingConfigAddr] = findStakingConfigPda();
|
|
12436
12777
|
const rewardMints = await resolveRewardMints(rpc, params.rewardMints);
|
|
@@ -12458,13 +12799,13 @@ async function buildClaimRewardsInstructions(rpc, params) {
|
|
|
12458
12799
|
const payer = params.payer ?? params.user;
|
|
12459
12800
|
return (await Promise.all(rewardMints.map(async (rewardMint, index) => {
|
|
12460
12801
|
const encodedRewardState = fetched[index];
|
|
12461
|
-
if (!encodedRewardState
|
|
12802
|
+
if (!accountIsCreated(encodedRewardState)) throw new Error(`RewardState not found for mint ${rewardMint}`);
|
|
12462
12803
|
const { vault } = rewardStateDecoder.decode(encodedRewardState.data);
|
|
12463
12804
|
const encodedMint = fetched[rewardMints.length + index];
|
|
12464
12805
|
const tokenProgram = encodedMint.exists ? encodedMint.programAddress : void 0;
|
|
12465
12806
|
const [destination] = await findAssociatedTokenPda(params.user.address, rewardMint, tokenProgram);
|
|
12466
12807
|
const instructions = [];
|
|
12467
|
-
if (!fetched[rewardMints.length * 2 + index]
|
|
12808
|
+
if (!accountIsCreated(fetched[rewardMints.length * 2 + index])) instructions.push(await getCreateUserRewardDebtInstructionAsync({
|
|
12468
12809
|
user: params.user.address,
|
|
12469
12810
|
payer,
|
|
12470
12811
|
stakingMint: params.stakingMint,
|
|
@@ -12482,7 +12823,8 @@ async function buildClaimRewardsInstructions(rpc, params) {
|
|
|
12482
12823
|
return instructions;
|
|
12483
12824
|
}))).flat();
|
|
12484
12825
|
}
|
|
12485
|
-
/**
|
|
12826
|
+
/** Returns the accounts of `withdraw_fees` for one reward mint. Without `tokenProgram`, reads it
|
|
12827
|
+
* from the mint account. Throws if that account does not exist. */
|
|
12486
12828
|
async function buildWithdrawFeesAccounts(rpc, params) {
|
|
12487
12829
|
const [stakingConfigAddr] = findStakingConfigPda();
|
|
12488
12830
|
const tokenProgram = params.tokenProgram ?? (await rpc.getAccountInfo(params.rewardMint, { encoding: "base64" }).send()).value?.owner;
|
|
@@ -12515,19 +12857,19 @@ async function fetchUserStakePositionData(rpc, user, stakingMint) {
|
|
|
12515
12857
|
const maybePosition = await fetchMaybeUserStakePosition(rpc, positionAddr);
|
|
12516
12858
|
return maybePosition.exists ? maybePosition.data : null;
|
|
12517
12859
|
}
|
|
12518
|
-
/**
|
|
12519
|
-
* can never store: it requires a token mint. */
|
|
12860
|
+
/** Returns false for the system program address, the value of an unbound staking mint. */
|
|
12520
12861
|
function isStakingMintBound(stakingMint) {
|
|
12521
|
-
return stakingMint !== SYSTEM_PROGRAM_ADDRESS;
|
|
12862
|
+
return stakingMint !== SYSTEM_PROGRAM_ADDRESS$3;
|
|
12522
12863
|
}
|
|
12523
|
-
/**
|
|
12864
|
+
/** Returns the staking mint. Throws if no staking mint is bound. A bound staking mint cannot change. */
|
|
12524
12865
|
async function fetchSendMint(rpc) {
|
|
12525
12866
|
const { stakingMint } = await fetchStakingConfigData(rpc);
|
|
12526
12867
|
if (!isStakingMintBound(stakingMint)) throw new Error("Staking mint not yet bound -- nexus not fully initialized");
|
|
12527
12868
|
return stakingMint;
|
|
12528
12869
|
}
|
|
12529
|
-
/**
|
|
12530
|
-
* its own mint
|
|
12870
|
+
/** Returns one entry per reward mint, in `knownRewardMints` order, else sorted by address. Each amount
|
|
12871
|
+
* is in the raw units of its own mint. Do not add them together. Each amount is what the vault sends,
|
|
12872
|
+
* before the mint's transfer fee. */
|
|
12531
12873
|
async function fetchPendingRewards(rpc, user, stakingMint, knownRewardMints) {
|
|
12532
12874
|
const rewardMints = await resolveRewardMints(rpc, knownRewardMints);
|
|
12533
12875
|
if (rewardMints.length === 0) return [];
|
|
@@ -12568,15 +12910,15 @@ async function fetchPendingRewards(rpc, user, stakingMint, knownRewardMints) {
|
|
|
12568
12910
|
return pdas.map(({ rewardMint }, index) => {
|
|
12569
12911
|
const base = index * 3;
|
|
12570
12912
|
const encodedDebt = encodedAccounts[base];
|
|
12571
|
-
const debt = encodedDebt
|
|
12913
|
+
const debt = accountIsCreated(encodedDebt) ? userRewardDebtDecoder.decode(encodedDebt.data) : {
|
|
12572
12914
|
owed: 0n,
|
|
12573
12915
|
accSnapshot: 0n,
|
|
12574
12916
|
amountSnapshot: stakeAmount
|
|
12575
12917
|
};
|
|
12576
12918
|
const encodedLaunchpadAccrual = encodedAccounts[base + 1];
|
|
12577
|
-
const launchpadAcc = encodedLaunchpadAccrual
|
|
12919
|
+
const launchpadAcc = accountIsCreated(encodedLaunchpadAccrual) ? rewardAccrualDecoder.decode(encodedLaunchpadAccrual.data).accPerToken : 0n;
|
|
12578
12920
|
const encodedDexAccrual = encodedAccounts[base + 2];
|
|
12579
|
-
const dexAcc = encodedDexAccrual
|
|
12921
|
+
const dexAcc = accountIsCreated(encodedDexAccrual) ? rewardAccrualDecoder.decode(encodedDexAccrual.data).accPerToken : 0n;
|
|
12580
12922
|
const basis = debt.amountSnapshot < stakeAmount ? debt.amountSnapshot : stakeAmount;
|
|
12581
12923
|
const combined = launchpadAcc + dexAcc;
|
|
12582
12924
|
const accrued = basis * (combined > debt.accSnapshot ? combined - debt.accSnapshot : 0n) / PRECISION;
|
|
@@ -12605,9 +12947,9 @@ var platform_exports = /* @__PURE__ */ __exportAll({
|
|
|
12605
12947
|
PLATFORM_SEED: () => PLATFORM_SEED,
|
|
12606
12948
|
findPlatformAddress: () => findPlatformAddress
|
|
12607
12949
|
});
|
|
12608
|
-
/**
|
|
12950
|
+
/** Seed of the platform PDA. A platform has no on-chain account. */
|
|
12609
12951
|
const PLATFORM_SEED = "platform";
|
|
12610
|
-
/**
|
|
12952
|
+
/** Derives the platform key for `name` under the nexus program. Each name gives a different platform. */
|
|
12611
12953
|
async function findPlatformAddress(name) {
|
|
12612
12954
|
return await (0, _solana_kit.getProgramDerivedAddress)({
|
|
12613
12955
|
programAddress: SEND_NEXUS_PROGRAM_ADDRESS,
|
|
@@ -12649,8 +12991,9 @@ function readEntry(view, start) {
|
|
|
12649
12991
|
basisPoints: view.getUint16(start + FEE_BASIS_POINTS, true)
|
|
12650
12992
|
};
|
|
12651
12993
|
}
|
|
12652
|
-
/** `
|
|
12653
|
-
*
|
|
12994
|
+
/** Decodes the `TransferFeeConfig` extension of a mint. `owner` is the program that owns the account.
|
|
12995
|
+
* Returns `undefined` if the mint has no such extension. Throws `RangeError` if `owner` is not a
|
|
12996
|
+
* token program or `data` is not a valid mint. */
|
|
12654
12997
|
function decodeTransferFeeConfig(data, owner) {
|
|
12655
12998
|
if (owner === TOKEN_PROGRAM_ADDRESS) return void 0;
|
|
12656
12999
|
if (owner !== TOKEN_2022_PROGRAM_ADDRESS) throw new RangeError(`decodeTransferFeeConfig: ${owner} is not a token program`);
|
|
@@ -12679,7 +13022,7 @@ function decodeTransferFeeConfig(data, owner) {
|
|
|
12679
13022
|
offset = next;
|
|
12680
13023
|
}
|
|
12681
13024
|
}
|
|
12682
|
-
/**
|
|
13025
|
+
/** Returns the fee for `epoch`, as SPL `get_epoch_fee` does. The newer entry applies from its own epoch on. */
|
|
12683
13026
|
function transferFeeAtEpoch(config, epoch) {
|
|
12684
13027
|
const entry = epoch >= config.newer.epoch ? config.newer : config.older;
|
|
12685
13028
|
return {
|
|
@@ -12694,8 +13037,9 @@ function mintFeeAtEpoch(data, owner, epoch) {
|
|
|
12694
13037
|
function currentEpoch(rpc, commitment) {
|
|
12695
13038
|
return rpc.getEpochInfo(commitment === void 0 ? void 0 : { commitment }).send().then((info) => info.epoch);
|
|
12696
13039
|
}
|
|
12697
|
-
/**
|
|
12698
|
-
* the cluster
|
|
13040
|
+
/** Reads the transfer fee of each mint for `epoch`. The result is valid only for that epoch.
|
|
13041
|
+
* `epoch` defaults to the current cluster epoch, read with `getEpochInfo`. A mint without a
|
|
13042
|
+
* transfer fee maps to `undefined`. Throws if a mint account is missing or does not decode. */
|
|
12699
13043
|
async function fetchMintFees(rpc, mints, options) {
|
|
12700
13044
|
const commitment = options?.commitment;
|
|
12701
13045
|
const [epoch, accounts] = await Promise.all([options?.epoch ?? currentEpoch(rpc, commitment), fetchInChunks(mints, (chunk) => rpc.getMultipleAccounts(chunk, commitment === void 0 ? { encoding: "base64" } : {
|
|
@@ -12724,7 +13068,8 @@ function decodeMintInfo(mint, data, owner) {
|
|
|
12724
13068
|
tokenProgram: owner
|
|
12725
13069
|
};
|
|
12726
13070
|
}
|
|
12727
|
-
/**
|
|
13071
|
+
/** Reads the decimals and token program of `mint`. Throws if the account does not exist, a token
|
|
13072
|
+
* program does not own it, or it is too short for a mint. */
|
|
12728
13073
|
async function fetchQuoteMintInfo(rpc, mint, commitment) {
|
|
12729
13074
|
const { value } = await rpc.getAccountInfo(mint, commitment === void 0 ? { encoding: "base64" } : {
|
|
12730
13075
|
commitment,
|
|
@@ -12733,7 +13078,8 @@ async function fetchQuoteMintInfo(rpc, mint, commitment) {
|
|
|
12733
13078
|
if (!value) throw new Error(`fetchQuoteMintInfo: no account at ${mint}`);
|
|
12734
13079
|
return decodeMintInfo(mint, new Uint8Array((0, _solana_kit.getBase64Encoder)().encode(value.data[0])), value.owner);
|
|
12735
13080
|
}
|
|
12736
|
-
/**
|
|
13081
|
+
/** Reads the decimals and token program of each mint. Results follow `mints` order. Throws as
|
|
13082
|
+
* {@link fetchQuoteMintInfo} does. */
|
|
12737
13083
|
async function fetchQuoteMintInfos(rpc, mints, commitment) {
|
|
12738
13084
|
if (mints.length === 0) return [];
|
|
12739
13085
|
const value = await fetchInChunks(mints, (chunk) => rpc.getMultipleAccounts(chunk, commitment === void 0 ? { encoding: "base64" } : {
|
|
@@ -12750,9 +13096,7 @@ async function fetchQuoteMintInfos(rpc, mints, commitment) {
|
|
|
12750
13096
|
//#endregion
|
|
12751
13097
|
//#region src/utils/index.ts
|
|
12752
13098
|
var utils_exports = /* @__PURE__ */ __exportAll({
|
|
12753
|
-
|
|
12754
|
-
decodeCreatorId: () => decodeCreatorId,
|
|
12755
|
-
encodeCreatorId: () => encodeCreatorId,
|
|
13099
|
+
accountIsCreated: () => accountIsCreated,
|
|
12756
13100
|
fetchQuoteMintInfo: () => fetchQuoteMintInfo,
|
|
12757
13101
|
fetchQuoteMintInfos: () => fetchQuoteMintInfos,
|
|
12758
13102
|
findAssociatedTokenPda: () => findAssociatedTokenPda
|