@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.mjs
CHANGED
|
@@ -18,22 +18,55 @@ var constants_exports = /* @__PURE__ */ __exportAll({
|
|
|
18
18
|
SEND_DEX_PROGRAM_ADDRESS: () => SEND_DEX_PROGRAM_ADDRESS,
|
|
19
19
|
SEND_LAUNCHPAD_PROGRAM_ADDRESS: () => SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
20
20
|
SEND_NEXUS_PROGRAM_ADDRESS: () => SEND_NEXUS_PROGRAM_ADDRESS,
|
|
21
|
-
SYSTEM_PROGRAM_ADDRESS: () => SYSTEM_PROGRAM_ADDRESS,
|
|
21
|
+
SYSTEM_PROGRAM_ADDRESS: () => SYSTEM_PROGRAM_ADDRESS$3,
|
|
22
22
|
TOKEN_2022_PROGRAM_ADDRESS: () => TOKEN_2022_PROGRAM_ADDRESS,
|
|
23
23
|
TOKEN_DECIMALS: () => 6,
|
|
24
24
|
TOKEN_PROGRAM_ADDRESS: () => TOKEN_PROGRAM_ADDRESS,
|
|
25
25
|
USDC_MINT: () => USDC_MINT,
|
|
26
26
|
WSOL_MINT: () => WSOL_MINT
|
|
27
27
|
});
|
|
28
|
-
const SYSTEM_PROGRAM_ADDRESS = address("11111111111111111111111111111111");
|
|
28
|
+
const SYSTEM_PROGRAM_ADDRESS$3 = address("11111111111111111111111111111111");
|
|
29
29
|
const TOKEN_PROGRAM_ADDRESS = address("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
30
30
|
const TOKEN_2022_PROGRAM_ADDRESS = address("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
|
31
31
|
const ASSOCIATED_TOKEN_PROGRAM_ADDRESS = address("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
|
|
32
32
|
const WSOL_MINT = address("So11111111111111111111111111111111111111112");
|
|
33
33
|
const USDC_MINT = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
34
|
-
const DEFAULT_PARTNER = SYSTEM_PROGRAM_ADDRESS;
|
|
34
|
+
const DEFAULT_PARTNER = SYSTEM_PROGRAM_ADDRESS$3;
|
|
35
35
|
const PYTH_SOL_USD_PRICE_ACCOUNT = address("7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE");
|
|
36
36
|
//#endregion
|
|
37
|
+
//#region src/dex/generated/shared/index.ts
|
|
38
|
+
/** The System Program, which owns every address nobody has created an account at yet. */
|
|
39
|
+
const SYSTEM_PROGRAM_ADDRESS$2 = "11111111111111111111111111111111";
|
|
40
|
+
/**
|
|
41
|
+
* Whether an encoded account was created on-chain, rather than merely sent lamports.
|
|
42
|
+
*
|
|
43
|
+
* Anyone can send lamports to an address before its account is created, which leaves it on-chain,
|
|
44
|
+
* owned by the System Program, with no data. This returns `false` for that shape, as it does for an
|
|
45
|
+
* account that does not exist. Any other existing account counts as created, whoever owns it; the
|
|
46
|
+
* `decode*` functions still check the owner.
|
|
47
|
+
*
|
|
48
|
+
* The generated `fetchMaybe*` and `fetchAllMaybe*` helpers apply this rule themselves. Apply it to
|
|
49
|
+
* accounts you fetch or receive another way (subscriptions, batch loaders, caches) before passing
|
|
50
|
+
* them to a `decode*` function, which throws for a lamports-only account: an account passed to it as
|
|
51
|
+
* existing must never come back as the non-existing variant typed as an `Account`.
|
|
52
|
+
*
|
|
53
|
+
* Only a `true` result narrows the type. A lamports-only account is still `exists: true` at runtime,
|
|
54
|
+
* so a `false` result leaves the type unchanged instead of narrowing it to the non-existing variant.
|
|
55
|
+
* The `uncreated` property in the narrowed type is never present; it exists only to prevent that.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const maybeAccount = decodeMyAccount(
|
|
60
|
+
* accountIsCreated(encodedAccount) ? encodedAccount : { address: encodedAccount.address, exists: false },
|
|
61
|
+
* );
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function accountIsCreated$2(account) {
|
|
65
|
+
const maybeAccount = account;
|
|
66
|
+
if ("exists" in maybeAccount && !maybeAccount.exists) return false;
|
|
67
|
+
return !(maybeAccount.programAddress === SYSTEM_PROGRAM_ADDRESS$2 && maybeAccount.data.length === 0);
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
37
70
|
//#region src/dex/generated/accounts/globalConfig.ts
|
|
38
71
|
/**
|
|
39
72
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -101,21 +134,40 @@ function decodeGlobalConfig$2(encodedAccount) {
|
|
|
101
134
|
}
|
|
102
135
|
return decodeAccount(encodedAccount, getGlobalConfigDecoder$2());
|
|
103
136
|
}
|
|
137
|
+
/** Fetches a `GlobalConfig` account, throwing when it does not exist or only holds lamports. */
|
|
104
138
|
async function fetchGlobalConfig$2(rpc, address, config) {
|
|
105
139
|
const maybeAccount = await fetchMaybeGlobalConfig$2(rpc, address, config);
|
|
106
140
|
assertAccountExists(maybeAccount);
|
|
107
141
|
return maybeAccount;
|
|
108
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Fetches a `GlobalConfig` account, or the non-existing variant when the address holds no
|
|
145
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
146
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
147
|
+
*/
|
|
109
148
|
async function fetchMaybeGlobalConfig$2(rpc, address, config) {
|
|
110
|
-
|
|
149
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
150
|
+
return decodeGlobalConfig$2(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
151
|
+
address,
|
|
152
|
+
exists: false
|
|
153
|
+
});
|
|
111
154
|
}
|
|
155
|
+
/** Fetches `GlobalConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
112
156
|
async function fetchAllGlobalConfig$2(rpc, addresses, config) {
|
|
113
157
|
const maybeAccounts = await fetchAllMaybeGlobalConfig$2(rpc, addresses, config);
|
|
114
158
|
assertAccountsExist(maybeAccounts);
|
|
115
159
|
return maybeAccounts;
|
|
116
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Fetches `GlobalConfig` accounts, with the non-existing variant for each address that holds
|
|
163
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
164
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
165
|
+
*/
|
|
117
166
|
async function fetchAllMaybeGlobalConfig$2(rpc, addresses, config) {
|
|
118
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig$2(maybeAccount)
|
|
167
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig$2(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
168
|
+
address: maybeAccount.address,
|
|
169
|
+
exists: false
|
|
170
|
+
}));
|
|
119
171
|
}
|
|
120
172
|
function getGlobalConfigSize$1() {
|
|
121
173
|
return 139;
|
|
@@ -212,7 +264,7 @@ function getPoolEncoder() {
|
|
|
212
264
|
["quoteMint", getAddressEncoder()],
|
|
213
265
|
["quoteDecimals", getU8Encoder()],
|
|
214
266
|
["coinCreator", getAddressEncoder()],
|
|
215
|
-
["
|
|
267
|
+
["padding0", getArrayEncoder(getU64Encoder(), { size: 4 })],
|
|
216
268
|
["baseVault", getAddressEncoder()],
|
|
217
269
|
["quoteVault", getAddressEncoder()],
|
|
218
270
|
["lpMint", getAddressEncoder()],
|
|
@@ -224,7 +276,9 @@ function getPoolEncoder() {
|
|
|
224
276
|
["protocolOwed", getU64Encoder()],
|
|
225
277
|
["creatorOwed", getU64Encoder()],
|
|
226
278
|
["platformConfig", getAddressEncoder()],
|
|
227
|
-
["
|
|
279
|
+
["creatorFeeMode", getU8Encoder()],
|
|
280
|
+
["creatorFeeBps", getU16Encoder()],
|
|
281
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 256)]
|
|
228
282
|
]), (value) => ({
|
|
229
283
|
...value,
|
|
230
284
|
discriminator: POOL_DISCRIMINATOR
|
|
@@ -242,7 +296,7 @@ function getPoolDecoder() {
|
|
|
242
296
|
["quoteMint", getAddressDecoder()],
|
|
243
297
|
["quoteDecimals", getU8Decoder()],
|
|
244
298
|
["coinCreator", getAddressDecoder()],
|
|
245
|
-
["
|
|
299
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
246
300
|
["baseVault", getAddressDecoder()],
|
|
247
301
|
["quoteVault", getAddressDecoder()],
|
|
248
302
|
["lpMint", getAddressDecoder()],
|
|
@@ -254,7 +308,9 @@ function getPoolDecoder() {
|
|
|
254
308
|
["protocolOwed", getU64Decoder()],
|
|
255
309
|
["creatorOwed", getU64Decoder()],
|
|
256
310
|
["platformConfig", getAddressDecoder()],
|
|
257
|
-
["
|
|
311
|
+
["creatorFeeMode", getU8Decoder()],
|
|
312
|
+
["creatorFeeBps", getU16Decoder()],
|
|
313
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 256)]
|
|
258
314
|
]);
|
|
259
315
|
}
|
|
260
316
|
/** Gets the codec for {@link Pool} account data. */
|
|
@@ -276,24 +332,43 @@ function decodePool(encodedAccount) {
|
|
|
276
332
|
}
|
|
277
333
|
return decodeAccount(encodedAccount, getPoolDecoder());
|
|
278
334
|
}
|
|
335
|
+
/** Fetches a `Pool` account, throwing when it does not exist or only holds lamports. */
|
|
279
336
|
async function fetchPool(rpc, address, config) {
|
|
280
337
|
const maybeAccount = await fetchMaybePool(rpc, address, config);
|
|
281
338
|
assertAccountExists(maybeAccount);
|
|
282
339
|
return maybeAccount;
|
|
283
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* Fetches a `Pool` account, or the non-existing variant when the address holds no
|
|
343
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
344
|
+
* {@link decodePool} throws for a lamports-only account instead.
|
|
345
|
+
*/
|
|
284
346
|
async function fetchMaybePool(rpc, address, config) {
|
|
285
|
-
|
|
347
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
348
|
+
return decodePool(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
349
|
+
address,
|
|
350
|
+
exists: false
|
|
351
|
+
});
|
|
286
352
|
}
|
|
353
|
+
/** Fetches `Pool` accounts, throwing when any does not exist or only holds lamports. */
|
|
287
354
|
async function fetchAllPool(rpc, addresses, config) {
|
|
288
355
|
const maybeAccounts = await fetchAllMaybePool(rpc, addresses, config);
|
|
289
356
|
assertAccountsExist(maybeAccounts);
|
|
290
357
|
return maybeAccounts;
|
|
291
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Fetches `Pool` accounts, with the non-existing variant for each address that holds
|
|
361
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
362
|
+
* {@link decodePool} throws for a lamports-only account instead.
|
|
363
|
+
*/
|
|
292
364
|
async function fetchAllMaybePool(rpc, addresses, config) {
|
|
293
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodePool(maybeAccount)
|
|
365
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodePool(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
366
|
+
address: maybeAccount.address,
|
|
367
|
+
exists: false
|
|
368
|
+
}));
|
|
294
369
|
}
|
|
295
370
|
function getPoolSize() {
|
|
296
|
-
return
|
|
371
|
+
return 584;
|
|
297
372
|
}
|
|
298
373
|
//#endregion
|
|
299
374
|
//#region src/dex/generated/accounts/rewardAccrual.ts
|
|
@@ -363,21 +438,40 @@ function decodeRewardAccrual$1(encodedAccount) {
|
|
|
363
438
|
}
|
|
364
439
|
return decodeAccount(encodedAccount, getRewardAccrualDecoder$1());
|
|
365
440
|
}
|
|
441
|
+
/** Fetches a `RewardAccrual` account, throwing when it does not exist or only holds lamports. */
|
|
366
442
|
async function fetchRewardAccrual$1(rpc, address, config) {
|
|
367
443
|
const maybeAccount = await fetchMaybeRewardAccrual$1(rpc, address, config);
|
|
368
444
|
assertAccountExists(maybeAccount);
|
|
369
445
|
return maybeAccount;
|
|
370
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Fetches a `RewardAccrual` account, or the non-existing variant when the address holds no
|
|
449
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
450
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
451
|
+
*/
|
|
371
452
|
async function fetchMaybeRewardAccrual$1(rpc, address, config) {
|
|
372
|
-
|
|
453
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
454
|
+
return decodeRewardAccrual$1(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
455
|
+
address,
|
|
456
|
+
exists: false
|
|
457
|
+
});
|
|
373
458
|
}
|
|
459
|
+
/** Fetches `RewardAccrual` accounts, throwing when any does not exist or only holds lamports. */
|
|
374
460
|
async function fetchAllRewardAccrual$1(rpc, addresses, config) {
|
|
375
461
|
const maybeAccounts = await fetchAllMaybeRewardAccrual$1(rpc, addresses, config);
|
|
376
462
|
assertAccountsExist(maybeAccounts);
|
|
377
463
|
return maybeAccounts;
|
|
378
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Fetches `RewardAccrual` accounts, with the non-existing variant for each address that holds
|
|
467
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
468
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
469
|
+
*/
|
|
379
470
|
async function fetchAllMaybeRewardAccrual$1(rpc, addresses, config) {
|
|
380
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeRewardAccrual$1(maybeAccount)
|
|
471
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeRewardAccrual$1(accountIsCreated$2(maybeAccount) ? maybeAccount : {
|
|
472
|
+
address: maybeAccount.address,
|
|
473
|
+
exists: false
|
|
474
|
+
}));
|
|
381
475
|
}
|
|
382
476
|
function getRewardAccrualSize$1() {
|
|
383
477
|
return 130;
|
|
@@ -472,8 +566,8 @@ const SEND_DEX_ERROR__INVALID_POOL_BALANCE = 6008;
|
|
|
472
566
|
const SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE = 6009;
|
|
473
567
|
/** InvalidAuthority: Invalid authority */
|
|
474
568
|
const SEND_DEX_ERROR__INVALID_AUTHORITY = 6010;
|
|
475
|
-
/**
|
|
476
|
-
const
|
|
569
|
+
/** InvalidCoinCreator: Invalid coin creator */
|
|
570
|
+
const SEND_DEX_ERROR__INVALID_COIN_CREATOR = 6011;
|
|
477
571
|
/** InvalidPlatformConfig: Platform config cannot be the default address */
|
|
478
572
|
const SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG = 6012;
|
|
479
573
|
/** ProgramPaused: Program is paused */
|
|
@@ -500,26 +594,31 @@ const SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 7009;
|
|
|
500
594
|
const SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 7010;
|
|
501
595
|
/** NothingToClaim: Nothing to claim */
|
|
502
596
|
const SEND_DEX_ERROR__NOTHING_TO_CLAIM = 7011;
|
|
503
|
-
/**
|
|
504
|
-
const
|
|
597
|
+
/** Unused7012: Unused */
|
|
598
|
+
const SEND_DEX_ERROR__UNUSED7012 = 7012;
|
|
505
599
|
/** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
|
|
506
600
|
const SEND_DEX_ERROR__QUOTE_MINT_PRICE_UNSET = 7013;
|
|
507
601
|
/** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
|
|
508
602
|
const SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 7014;
|
|
603
|
+
/** CreatorFeeTooHigh: Creator fee exceeds the partner's maximum */
|
|
604
|
+
const SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH = 7015;
|
|
605
|
+
/** CreatorFeeModeNotAllowed: Creator fee mode is not allowed by the partner config */
|
|
606
|
+
const SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED = 7016;
|
|
509
607
|
/** InsufficientLiquidity: Insufficient liquidity */
|
|
510
608
|
const SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY = 7100;
|
|
511
609
|
/** InvalidAmount: Invalid amount */
|
|
512
610
|
const SEND_DEX_ERROR__INVALID_AMOUNT = 7101;
|
|
513
611
|
const sendDexErrorMessages = {
|
|
514
612
|
[SEND_DEX_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
613
|
+
[SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED]: `Creator fee mode is not allowed by the partner config`,
|
|
614
|
+
[SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH]: `Creator fee exceeds the partner's maximum`,
|
|
515
615
|
[SEND_DEX_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance in source account`,
|
|
516
616
|
[SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
517
617
|
[SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE]: `Insufficient pool balance`,
|
|
518
618
|
[SEND_DEX_ERROR__INVALID_AMOUNT]: `Invalid amount`,
|
|
519
619
|
[SEND_DEX_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
|
|
520
620
|
[SEND_DEX_ERROR__INVALID_BASE_MINT]: `Invalid base mint`,
|
|
521
|
-
[
|
|
522
|
-
[SEND_DEX_ERROR__INVALID_CREATOR_ID]: `Creator identity is not a decodable wallet address`,
|
|
621
|
+
[SEND_DEX_ERROR__INVALID_COIN_CREATOR]: `Invalid coin creator`,
|
|
523
622
|
[SEND_DEX_ERROR__INVALID_DEPOSIT]: `Invalid deposit`,
|
|
524
623
|
[SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG]: `Platform config cannot be the default address`,
|
|
525
624
|
[SEND_DEX_ERROR__INVALID_POOL_BALANCE]: `Invalid pool balance`,
|
|
@@ -537,6 +636,7 @@ const sendDexErrorMessages = {
|
|
|
537
636
|
[SEND_DEX_ERROR__TEXT_TOO_LONG]: `Text too long`,
|
|
538
637
|
[SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
|
|
539
638
|
[SEND_DEX_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
639
|
+
[SEND_DEX_ERROR__UNUSED7012]: `Unused`,
|
|
540
640
|
[SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
|
|
541
641
|
[SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
|
|
542
642
|
[SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT]: `User token account mint does not match the trade`,
|
|
@@ -552,14 +652,15 @@ function isSendDexError(error, transactionMessage, code) {
|
|
|
552
652
|
//#region src/dex/generated/errors/index.ts
|
|
553
653
|
var errors_exports$2 = /* @__PURE__ */ __exportAll({
|
|
554
654
|
SEND_DEX_ERROR__ARITHMETIC_OVERFLOW: () => SEND_DEX_ERROR__ARITHMETIC_OVERFLOW,
|
|
655
|
+
SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED: () => SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED,
|
|
656
|
+
SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH: () => SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH,
|
|
555
657
|
SEND_DEX_ERROR__INSUFFICIENT_BALANCE: () => SEND_DEX_ERROR__INSUFFICIENT_BALANCE,
|
|
556
658
|
SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY: () => SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY,
|
|
557
659
|
SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE: () => SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE,
|
|
558
660
|
SEND_DEX_ERROR__INVALID_AMOUNT: () => SEND_DEX_ERROR__INVALID_AMOUNT,
|
|
559
661
|
SEND_DEX_ERROR__INVALID_AUTHORITY: () => SEND_DEX_ERROR__INVALID_AUTHORITY,
|
|
560
662
|
SEND_DEX_ERROR__INVALID_BASE_MINT: () => SEND_DEX_ERROR__INVALID_BASE_MINT,
|
|
561
|
-
|
|
562
|
-
SEND_DEX_ERROR__INVALID_CREATOR_ID: () => SEND_DEX_ERROR__INVALID_CREATOR_ID,
|
|
663
|
+
SEND_DEX_ERROR__INVALID_COIN_CREATOR: () => SEND_DEX_ERROR__INVALID_COIN_CREATOR,
|
|
563
664
|
SEND_DEX_ERROR__INVALID_DEPOSIT: () => SEND_DEX_ERROR__INVALID_DEPOSIT,
|
|
564
665
|
SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG: () => SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG,
|
|
565
666
|
SEND_DEX_ERROR__INVALID_POOL_BALANCE: () => SEND_DEX_ERROR__INVALID_POOL_BALANCE,
|
|
@@ -577,6 +678,7 @@ var errors_exports$2 = /* @__PURE__ */ __exportAll({
|
|
|
577
678
|
SEND_DEX_ERROR__TEXT_TOO_LONG: () => SEND_DEX_ERROR__TEXT_TOO_LONG,
|
|
578
679
|
SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE: () => SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE,
|
|
579
680
|
SEND_DEX_ERROR__UNAUTHORIZED: () => SEND_DEX_ERROR__UNAUTHORIZED,
|
|
681
|
+
SEND_DEX_ERROR__UNUSED7012: () => SEND_DEX_ERROR__UNUSED7012,
|
|
580
682
|
SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_INVALID: () => SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_INVALID,
|
|
581
683
|
SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY: () => SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY,
|
|
582
684
|
SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT: () => SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT,
|
|
@@ -586,6 +688,44 @@ var errors_exports$2 = /* @__PURE__ */ __exportAll({
|
|
|
586
688
|
sendDexErrorMessages: () => sendDexErrorMessages
|
|
587
689
|
});
|
|
588
690
|
//#endregion
|
|
691
|
+
//#region src/dex/generated/pdas/creatorFeeConfig.ts
|
|
692
|
+
/**
|
|
693
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
694
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
695
|
+
* to add features, then rerun Codama to update it.
|
|
696
|
+
*
|
|
697
|
+
* @see https://github.com/codama-idl/codama
|
|
698
|
+
*/
|
|
699
|
+
async function findCreatorFeeConfigPda$1(seeds) {
|
|
700
|
+
return await getProgramDerivedAddress({
|
|
701
|
+
programAddress: SEND_DEX_PROGRAM_ADDRESS,
|
|
702
|
+
seeds: [
|
|
703
|
+
getBytesEncoder().encode(new Uint8Array([
|
|
704
|
+
99,
|
|
705
|
+
114,
|
|
706
|
+
101,
|
|
707
|
+
97,
|
|
708
|
+
116,
|
|
709
|
+
111,
|
|
710
|
+
114,
|
|
711
|
+
95,
|
|
712
|
+
102,
|
|
713
|
+
101,
|
|
714
|
+
101,
|
|
715
|
+
95,
|
|
716
|
+
99,
|
|
717
|
+
111,
|
|
718
|
+
110,
|
|
719
|
+
102,
|
|
720
|
+
105,
|
|
721
|
+
103
|
|
722
|
+
])),
|
|
723
|
+
getAddressEncoder().encode(seeds.baseMint),
|
|
724
|
+
getAddressEncoder().encode(seeds.quoteMint)
|
|
725
|
+
]
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
//#endregion
|
|
589
729
|
//#region src/dex/generated/pdas/eventAuthority.ts
|
|
590
730
|
const EVENT_AUTHORITY_PDA_ADDRESS$2 = "4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t";
|
|
591
731
|
function findEventAuthorityPda$2() {
|
|
@@ -690,6 +830,7 @@ var pdas_exports$2 = /* @__PURE__ */ __exportAll({
|
|
|
690
830
|
EVENT_AUTHORITY_PDA_ADDRESS: () => EVENT_AUTHORITY_PDA_ADDRESS$2,
|
|
691
831
|
GLOBAL_CONFIG_PDA_ADDRESS: () => GLOBAL_CONFIG_PDA_ADDRESS$2,
|
|
692
832
|
WSOL_REWARD_ACCRUAL_PDA_ADDRESS: () => WSOL_REWARD_ACCRUAL_PDA_ADDRESS$1,
|
|
833
|
+
findCreatorFeeConfigPda: () => findCreatorFeeConfigPda$1,
|
|
693
834
|
findEventAuthorityPda: () => findEventAuthorityPda$2,
|
|
694
835
|
findGlobalConfigPda: () => findGlobalConfigPda$2,
|
|
695
836
|
findLpMintPda: () => findLpMintPda,
|
|
@@ -755,7 +896,7 @@ function getCreatorClaimEventDecoder$1() {
|
|
|
755
896
|
["quoteMint", getAddressDecoder()],
|
|
756
897
|
["platformConfig", getAddressDecoder()],
|
|
757
898
|
["coinCreator", getAddressDecoder()],
|
|
758
|
-
["
|
|
899
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
759
900
|
["claimer", getAddressDecoder()],
|
|
760
901
|
["destinationOwner", getAddressDecoder()],
|
|
761
902
|
["amount", getU64Decoder()],
|
|
@@ -898,7 +1039,7 @@ function getPoolCreateEventDecoder() {
|
|
|
898
1039
|
["quoteMint", getAddressDecoder()],
|
|
899
1040
|
["quoteDecimals", getU8Decoder()],
|
|
900
1041
|
["coinCreator", getAddressDecoder()],
|
|
901
|
-
["
|
|
1042
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
902
1043
|
["platformConfig", getAddressDecoder()],
|
|
903
1044
|
["baseVault", getAddressDecoder()],
|
|
904
1045
|
["quoteVault", getAddressDecoder()],
|
|
@@ -906,7 +1047,9 @@ function getPoolCreateEventDecoder() {
|
|
|
906
1047
|
["lpMinted", getU64Decoder()],
|
|
907
1048
|
["baseReserves", getU64Decoder()],
|
|
908
1049
|
["quoteReserves", getU64Decoder()],
|
|
909
|
-
["timestamp", getI64Decoder()]
|
|
1050
|
+
["timestamp", getI64Decoder()],
|
|
1051
|
+
["creatorFeeMode", getU8Decoder()],
|
|
1052
|
+
["creatorFeeBps", getU16Decoder()]
|
|
910
1053
|
]);
|
|
911
1054
|
}
|
|
912
1055
|
/**
|
|
@@ -1043,9 +1186,7 @@ function getTokenCreateEventDecoder$1() {
|
|
|
1043
1186
|
["quoteMint", getAddressDecoder()],
|
|
1044
1187
|
["quoteDecimals", getU8Decoder()],
|
|
1045
1188
|
["coinCreator", getAddressDecoder()],
|
|
1046
|
-
["
|
|
1047
|
-
["creatorId", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
1048
|
-
["creatorFeeConfig", getAddressDecoder()],
|
|
1189
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 5 })],
|
|
1049
1190
|
["platformConfig", getAddressDecoder()],
|
|
1050
1191
|
["name", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
1051
1192
|
["symbol", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
@@ -1055,7 +1196,9 @@ function getTokenCreateEventDecoder$1() {
|
|
|
1055
1196
|
["creationFee", getU64Decoder()],
|
|
1056
1197
|
["baseReserves", getU64Decoder()],
|
|
1057
1198
|
["quoteReserves", getU64Decoder()],
|
|
1058
|
-
["timestamp", getI64Decoder()]
|
|
1199
|
+
["timestamp", getI64Decoder()],
|
|
1200
|
+
["creatorFeeMode", getU8Decoder()],
|
|
1201
|
+
["creatorFeeBps", getU16Decoder()]
|
|
1059
1202
|
]);
|
|
1060
1203
|
}
|
|
1061
1204
|
/**
|
|
@@ -1122,7 +1265,7 @@ function getTradeEventDecoder$1() {
|
|
|
1122
1265
|
["quoteMint", getAddressDecoder()],
|
|
1123
1266
|
["user", getAddressDecoder()],
|
|
1124
1267
|
["coinCreator", getAddressDecoder()],
|
|
1125
|
-
["
|
|
1268
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
1126
1269
|
["platformConfig", getAddressDecoder()],
|
|
1127
1270
|
["baseAmount", getU64Decoder()],
|
|
1128
1271
|
["quoteAmountGross", getU64Decoder()],
|
|
@@ -1137,7 +1280,9 @@ function getTradeEventDecoder$1() {
|
|
|
1137
1280
|
["quoteTransferFee", getU64Decoder()],
|
|
1138
1281
|
["baseReserves", getU64Decoder()],
|
|
1139
1282
|
["quoteReserves", getU64Decoder()],
|
|
1140
|
-
["timestamp", getI64Decoder()]
|
|
1283
|
+
["timestamp", getI64Decoder()],
|
|
1284
|
+
["creatorFeeMode", getU8Decoder()],
|
|
1285
|
+
["creatorFeeBps", getU16Decoder()]
|
|
1141
1286
|
]);
|
|
1142
1287
|
}
|
|
1143
1288
|
/**
|
|
@@ -2016,7 +2161,7 @@ async function getClaimCreatorFeesInstructionAsync$1(input) {
|
|
|
2016
2161
|
},
|
|
2017
2162
|
creatorFeeConfig: {
|
|
2018
2163
|
value: input.creatorFeeConfig ?? null,
|
|
2019
|
-
isWritable:
|
|
2164
|
+
isWritable: true
|
|
2020
2165
|
},
|
|
2021
2166
|
nexusGlobalConfig: {
|
|
2022
2167
|
value: null,
|
|
@@ -2067,6 +2212,10 @@ async function getClaimCreatorFeesInstructionAsync$1(input) {
|
|
|
2067
2212
|
baseMint: getAddressFromResolvedInstructionAccount("baseMint", accounts.baseMint.value),
|
|
2068
2213
|
quoteMint: getAddressFromResolvedInstructionAccount("quoteMint", accounts.quoteMint.value)
|
|
2069
2214
|
});
|
|
2215
|
+
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda$1({
|
|
2216
|
+
baseMint: getAddressFromResolvedInstructionAccount("baseMint", accounts.baseMint.value),
|
|
2217
|
+
quoteMint: getAddressFromResolvedInstructionAccount("quoteMint", accounts.quoteMint.value)
|
|
2218
|
+
});
|
|
2070
2219
|
if (!accounts.nexusGlobalConfig.value) accounts.nexusGlobalConfig.value = "3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr";
|
|
2071
2220
|
if (!accounts.quoteVault.value) accounts.quoteVault.value = await getProgramDerivedAddress({
|
|
2072
2221
|
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
@@ -2128,7 +2277,7 @@ function getClaimCreatorFeesInstruction$1(input) {
|
|
|
2128
2277
|
},
|
|
2129
2278
|
creatorFeeConfig: {
|
|
2130
2279
|
value: input.creatorFeeConfig ?? null,
|
|
2131
|
-
isWritable:
|
|
2280
|
+
isWritable: true
|
|
2132
2281
|
},
|
|
2133
2282
|
nexusGlobalConfig: {
|
|
2134
2283
|
value: null,
|
|
@@ -3391,6 +3540,7 @@ function sendDexProgram() {
|
|
|
3391
3540
|
pdas: {
|
|
3392
3541
|
pool: findPoolPda,
|
|
3393
3542
|
eventAuthority: findEventAuthorityPda$2,
|
|
3543
|
+
creatorFeeConfig: findCreatorFeeConfigPda$1,
|
|
3394
3544
|
rewardAccrual: findRewardAccrualPda$1,
|
|
3395
3545
|
globalConfig: findGlobalConfigPda$2,
|
|
3396
3546
|
lpMint: findLpMintPda,
|
|
@@ -3437,12 +3587,11 @@ var amm_exports = /* @__PURE__ */ __exportAll({
|
|
|
3437
3587
|
});
|
|
3438
3588
|
const BPS_DIVISOR = 10000n;
|
|
3439
3589
|
const U64_MAX = 18446744073709551615n;
|
|
3440
|
-
/** Each call mirrors a `u64::try_from` in the Rust twin; drop one and an oversized leg fails in the encoder. */
|
|
3441
3590
|
function assertU64(label, value) {
|
|
3442
3591
|
if (value > U64_MAX) throw new RangeError(`${label}: overflows u64`);
|
|
3443
3592
|
return value;
|
|
3444
3593
|
}
|
|
3445
|
-
/**
|
|
3594
|
+
/** Thrown when no transfer delivers exactly `amount` after the transfer fee. */
|
|
3446
3595
|
var TransferFeeNotSettleableError = class extends RangeError {
|
|
3447
3596
|
amount;
|
|
3448
3597
|
mintFee;
|
|
@@ -3457,7 +3606,8 @@ function assertMintFee(fee) {
|
|
|
3457
3606
|
assertBps("MintFee", "bps", fee.bps);
|
|
3458
3607
|
if (fee.maximumFee < 0n || fee.maximumFee > U64_MAX) throw new RangeError("MintFee: maximumFee must fit a u64");
|
|
3459
3608
|
}
|
|
3460
|
-
/** Rounds up, then caps
|
|
3609
|
+
/** Returns the transfer fee on `amount`. Rounds up, then caps at `maximumFee`, in SPL's order.
|
|
3610
|
+
* Returns 0 without `fee`. Throws `RangeError` if `fee` is out of range. */
|
|
3461
3611
|
function feeOn(amount, fee) {
|
|
3462
3612
|
if (fee === void 0) return 0n;
|
|
3463
3613
|
assertMintFee(fee);
|
|
@@ -3465,11 +3615,11 @@ function feeOn(amount, fee) {
|
|
|
3465
3615
|
const raw = ceilDiv(amount * BigInt(fee.bps), BPS_DIVISOR);
|
|
3466
3616
|
return raw < fee.maximumFee ? raw : fee.maximumFee;
|
|
3467
3617
|
}
|
|
3468
|
-
/**
|
|
3618
|
+
/** Returns what the recipient receives when `amount` is sent. `grossUp` is the inverse. */
|
|
3469
3619
|
function amountAfterFee(amount, fee) {
|
|
3470
3620
|
return amount - feeOn(amount, fee);
|
|
3471
3621
|
}
|
|
3472
|
-
/**
|
|
3622
|
+
/** Matches SPL `TransferFee::calculate_pre_fee_amount`. `undefined` if the result does not fit a u64. */
|
|
3473
3623
|
function preFeeAmount(amount, fee) {
|
|
3474
3624
|
const bps = BigInt(fee.bps);
|
|
3475
3625
|
if (bps === 0n) return amount;
|
|
@@ -3485,7 +3635,8 @@ function preFeeAmount(amount, fee) {
|
|
|
3485
3635
|
}
|
|
3486
3636
|
return rawPreFee > U64_MAX ? void 0 : rawPreFee;
|
|
3487
3637
|
}
|
|
3488
|
-
/**
|
|
3638
|
+
/** Returns the amount to send so that exactly `amount` arrives. Returns `amount` without `fee`.
|
|
3639
|
+
* Throws {@link TransferFeeNotSettleableError} if no such amount exists. */
|
|
3489
3640
|
function grossUp(amount, fee) {
|
|
3490
3641
|
if (fee === void 0) return amount;
|
|
3491
3642
|
assertMintFee(fee);
|
|
@@ -3508,7 +3659,8 @@ function sqrtBigInt(value) {
|
|
|
3508
3659
|
}
|
|
3509
3660
|
return x;
|
|
3510
3661
|
}
|
|
3511
|
-
/**
|
|
3662
|
+
/** Returns the constant-product output for `amountIn`, rounded down. Throws `RangeError` on a zero
|
|
3663
|
+
* reserve, a zero `amountIn`, a zero output, or an output past u64. */
|
|
3512
3664
|
function calculateOutput(reserveIn, reserveOut, amountIn) {
|
|
3513
3665
|
if (reserveIn === 0n || reserveOut === 0n) throw new RangeError("calculateOutput: insufficient liquidity");
|
|
3514
3666
|
if (amountIn === 0n) throw new RangeError("calculateOutput: invalid amount");
|
|
@@ -3518,7 +3670,8 @@ function calculateOutput(reserveIn, reserveOut, amountIn) {
|
|
|
3518
3670
|
if (amountOut === 0n) throw new RangeError("calculateOutput: insufficient liquidity");
|
|
3519
3671
|
return assertU64("calculateOutput", amountOut);
|
|
3520
3672
|
}
|
|
3521
|
-
/**
|
|
3673
|
+
/** Returns the input needed for `amountOut`, rounded up. Throws `RangeError` on a zero reserve, a zero
|
|
3674
|
+
* `amountOut`, an `amountOut` not below `reserveOut`, or an input past u64. */
|
|
3522
3675
|
function calculateInputForOutput(reserveIn, reserveOut, amountOut) {
|
|
3523
3676
|
if (reserveIn === 0n || reserveOut === 0n) throw new RangeError("calculateInputForOutput: insufficient liquidity");
|
|
3524
3677
|
if (amountOut === 0n || amountOut >= reserveOut) throw new RangeError("calculateInputForOutput: invalid amount");
|
|
@@ -3581,7 +3734,9 @@ function buyQuote(legs, quoteTransferFee, baseFee) {
|
|
|
3581
3734
|
quoteFromUser: legs.quoteAmount
|
|
3582
3735
|
};
|
|
3583
3736
|
}
|
|
3584
|
-
/**
|
|
3737
|
+
/** Quotes a buy where the buyer receives `baseAmountOut`. With `baseReserveCap`, the vault sends at
|
|
3738
|
+
* most the cap. Guard with `calculateSlippageUp(quoteAmount, bps)`. `quoteAmount` includes the quote
|
|
3739
|
+
* mint's transfer fee. */
|
|
3585
3740
|
function buyExactOut$2(params) {
|
|
3586
3741
|
assertBps("buyExactOut", "feeBps", params.feeBps);
|
|
3587
3742
|
if (params.baseAmountOut === 0n) throw new RangeError("buyExactOut: invalid amount");
|
|
@@ -3594,7 +3749,8 @@ function buyExactOut$2(params) {
|
|
|
3594
3749
|
quoteAmount: quoteFromUser
|
|
3595
3750
|
}, quoteFromUser - legs.quoteAmount, params.baseFee);
|
|
3596
3751
|
}
|
|
3597
|
-
/** Guard with `calculateSlippageDown(baseToUser, bps)`, not
|
|
3752
|
+
/** Quotes a buy that spends `quoteAmountIn`. Guard with `calculateSlippageDown(baseToUser, bps)`, not
|
|
3753
|
+
* `baseAmount`. The program checks the minimum against what the buyer receives. */
|
|
3598
3754
|
function buyExactIn$2(params) {
|
|
3599
3755
|
assertBps("buyExactIn", "feeBps", params.feeBps);
|
|
3600
3756
|
if (params.quoteAmountIn === 0n) throw new RangeError("buyExactIn: invalid amount");
|
|
@@ -3613,7 +3769,7 @@ function buyExactIn$2(params) {
|
|
|
3613
3769
|
quoteAmount: quoteFromUser
|
|
3614
3770
|
}, quoteFromUser - capped.quoteAmount, params.baseFee);
|
|
3615
3771
|
}
|
|
3616
|
-
/** Guard with `calculateSlippageDown(quoteToUser, bps)`, not `quoteAmount`. */
|
|
3772
|
+
/** Quotes a sell of `baseAmountIn`. Guard with `calculateSlippageDown(quoteToUser, bps)`, not `quoteAmount`. */
|
|
3617
3773
|
function sellExactIn$2(params) {
|
|
3618
3774
|
assertBps("sellExactIn", "feeBps", params.feeBps);
|
|
3619
3775
|
if (params.baseAmountIn === 0n) throw new RangeError("sellExactIn: invalid amount");
|
|
@@ -3631,7 +3787,8 @@ function sellExactIn$2(params) {
|
|
|
3631
3787
|
quoteToUser: legs.quoteAmount - quoteTransferFee
|
|
3632
3788
|
};
|
|
3633
3789
|
}
|
|
3634
|
-
/**
|
|
3790
|
+
/** Quotes a sell where the seller receives `quoteAmountOut`. Guard with
|
|
3791
|
+
* `calculateSlippageUp(baseFromUser, bps)`. `baseFromUser` includes the base mint's transfer fee. */
|
|
3635
3792
|
function sellExactOut$2(params) {
|
|
3636
3793
|
assertBps("sellExactOut", "feeBps", params.feeBps);
|
|
3637
3794
|
if (params.quoteAmountOut === 0n) throw new RangeError("sellExactOut: invalid amount");
|
|
@@ -3656,17 +3813,17 @@ function calculateSlippageDown(amount, slippageBps) {
|
|
|
3656
3813
|
assertBps("calculateSlippageDown", "slippageBps", slippageBps);
|
|
3657
3814
|
return assertU64("calculateSlippageDown", floorDiv(amount * (BPS_DIVISOR - BigInt(slippageBps)), BPS_DIVISOR));
|
|
3658
3815
|
}
|
|
3659
|
-
/**
|
|
3816
|
+
/** Returns `sqrt(quoteAmount * baseAmount)`, rounded down. */
|
|
3660
3817
|
function calculateInitialLp(quoteAmount, baseAmount) {
|
|
3661
3818
|
return sqrtBigInt(quoteAmount * baseAmount);
|
|
3662
3819
|
}
|
|
3663
|
-
/**
|
|
3820
|
+
/** Returns the price of one base token in quote tokens, as a float. For display only. */
|
|
3664
3821
|
function calculatePrice(params) {
|
|
3665
3822
|
const { quoteReserves, baseReserves, quoteDecimals, baseDecimals } = params;
|
|
3666
3823
|
if (baseReserves === 0n) return 0;
|
|
3667
3824
|
return Number(quoteReserves) / Number(baseReserves) * 10 ** (baseDecimals - quoteDecimals);
|
|
3668
3825
|
}
|
|
3669
|
-
/**
|
|
3826
|
+
/** Returns the market cap in raw quote units. */
|
|
3670
3827
|
function calculateMarketCap(params) {
|
|
3671
3828
|
const { quoteReserves, baseReserves, baseSupply } = params;
|
|
3672
3829
|
if (baseReserves === 0n) return 0n;
|
|
@@ -3684,7 +3841,7 @@ var trade_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
3684
3841
|
sellExactIn: () => sellExactIn$1,
|
|
3685
3842
|
sellExactOut: () => sellExactOut$1
|
|
3686
3843
|
});
|
|
3687
|
-
/** `baseAmountOut` is
|
|
3844
|
+
/** `baseAmountOut` is the base the buyer receives, after the base mint's transfer fee. */
|
|
3688
3845
|
async function buyExactOut$1(params) {
|
|
3689
3846
|
const quote = buyExactOut$2({
|
|
3690
3847
|
reserveQuote: params.quoteReserves,
|
|
@@ -3742,7 +3899,7 @@ async function sellExactIn$1(params) {
|
|
|
3742
3899
|
quote
|
|
3743
3900
|
};
|
|
3744
3901
|
}
|
|
3745
|
-
/** `quoteAmountOut` is
|
|
3902
|
+
/** `quoteAmountOut` is the quote the seller receives, after the quote mint's transfer fee. */
|
|
3746
3903
|
async function sellExactOut$1(params) {
|
|
3747
3904
|
const quote = sellExactOut$2({
|
|
3748
3905
|
reserveQuote: params.quoteReserves,
|
|
@@ -3816,6 +3973,39 @@ var dex_exports = /* @__PURE__ */ __exportAll({
|
|
|
3816
3973
|
types: () => types_exports$2
|
|
3817
3974
|
});
|
|
3818
3975
|
//#endregion
|
|
3976
|
+
//#region src/launchpad/generated/shared/index.ts
|
|
3977
|
+
/** The System Program, which owns every address nobody has created an account at yet. */
|
|
3978
|
+
const SYSTEM_PROGRAM_ADDRESS$1 = "11111111111111111111111111111111";
|
|
3979
|
+
/**
|
|
3980
|
+
* Whether an encoded account was created on-chain, rather than merely sent lamports.
|
|
3981
|
+
*
|
|
3982
|
+
* Anyone can send lamports to an address before its account is created, which leaves it on-chain,
|
|
3983
|
+
* owned by the System Program, with no data. This returns `false` for that shape, as it does for an
|
|
3984
|
+
* account that does not exist. Any other existing account counts as created, whoever owns it; the
|
|
3985
|
+
* `decode*` functions still check the owner.
|
|
3986
|
+
*
|
|
3987
|
+
* The generated `fetchMaybe*` and `fetchAllMaybe*` helpers apply this rule themselves. Apply it to
|
|
3988
|
+
* accounts you fetch or receive another way (subscriptions, batch loaders, caches) before passing
|
|
3989
|
+
* them to a `decode*` function, which throws for a lamports-only account: an account passed to it as
|
|
3990
|
+
* existing must never come back as the non-existing variant typed as an `Account`.
|
|
3991
|
+
*
|
|
3992
|
+
* Only a `true` result narrows the type. A lamports-only account is still `exists: true` at runtime,
|
|
3993
|
+
* so a `false` result leaves the type unchanged instead of narrowing it to the non-existing variant.
|
|
3994
|
+
* The `uncreated` property in the narrowed type is never present; it exists only to prevent that.
|
|
3995
|
+
*
|
|
3996
|
+
* @example
|
|
3997
|
+
* ```ts
|
|
3998
|
+
* const maybeAccount = decodeMyAccount(
|
|
3999
|
+
* accountIsCreated(encodedAccount) ? encodedAccount : { address: encodedAccount.address, exists: false },
|
|
4000
|
+
* );
|
|
4001
|
+
* ```
|
|
4002
|
+
*/
|
|
4003
|
+
function accountIsCreated$1(account) {
|
|
4004
|
+
const maybeAccount = account;
|
|
4005
|
+
if ("exists" in maybeAccount && !maybeAccount.exists) return false;
|
|
4006
|
+
return !(maybeAccount.programAddress === SYSTEM_PROGRAM_ADDRESS$1 && maybeAccount.data.length === 0);
|
|
4007
|
+
}
|
|
4008
|
+
//#endregion
|
|
3819
4009
|
//#region src/launchpad/generated/types/bondingCurveStatus.ts
|
|
3820
4010
|
/**
|
|
3821
4011
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -3913,7 +4103,7 @@ function getBondingCurveEncoder() {
|
|
|
3913
4103
|
["quoteMint", getAddressEncoder()],
|
|
3914
4104
|
["quoteDecimals", getU8Encoder()],
|
|
3915
4105
|
["coinCreator", getAddressEncoder()],
|
|
3916
|
-
["
|
|
4106
|
+
["padding0", getArrayEncoder(getU64Encoder(), { size: 4 })],
|
|
3917
4107
|
["partner", getAddressEncoder()],
|
|
3918
4108
|
["baseVault", getAddressEncoder()],
|
|
3919
4109
|
["quoteVault", getAddressEncoder()],
|
|
@@ -3925,7 +4115,10 @@ function getBondingCurveEncoder() {
|
|
|
3925
4115
|
["protocolOwed", getU64Encoder()],
|
|
3926
4116
|
["creatorOwed", getU64Encoder()],
|
|
3927
4117
|
["platformConfig", getAddressEncoder()],
|
|
3928
|
-
["
|
|
4118
|
+
["creatorFeeMode", getU8Encoder()],
|
|
4119
|
+
["creatorFeeBps", getU16Encoder()],
|
|
4120
|
+
["dexCreatorFeeBps", getU16Encoder()],
|
|
4121
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 256)]
|
|
3929
4122
|
]), (value) => ({
|
|
3930
4123
|
...value,
|
|
3931
4124
|
discriminator: BONDING_CURVE_DISCRIMINATOR
|
|
@@ -3947,7 +4140,7 @@ function getBondingCurveDecoder() {
|
|
|
3947
4140
|
["quoteMint", getAddressDecoder()],
|
|
3948
4141
|
["quoteDecimals", getU8Decoder()],
|
|
3949
4142
|
["coinCreator", getAddressDecoder()],
|
|
3950
|
-
["
|
|
4143
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
3951
4144
|
["partner", getAddressDecoder()],
|
|
3952
4145
|
["baseVault", getAddressDecoder()],
|
|
3953
4146
|
["quoteVault", getAddressDecoder()],
|
|
@@ -3959,7 +4152,10 @@ function getBondingCurveDecoder() {
|
|
|
3959
4152
|
["protocolOwed", getU64Decoder()],
|
|
3960
4153
|
["creatorOwed", getU64Decoder()],
|
|
3961
4154
|
["platformConfig", getAddressDecoder()],
|
|
3962
|
-
["
|
|
4155
|
+
["creatorFeeMode", getU8Decoder()],
|
|
4156
|
+
["creatorFeeBps", getU16Decoder()],
|
|
4157
|
+
["dexCreatorFeeBps", getU16Decoder()],
|
|
4158
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 256)]
|
|
3963
4159
|
]);
|
|
3964
4160
|
}
|
|
3965
4161
|
/** Gets the codec for {@link BondingCurve} account data. */
|
|
@@ -3981,24 +4177,43 @@ function decodeBondingCurve(encodedAccount) {
|
|
|
3981
4177
|
}
|
|
3982
4178
|
return decodeAccount(encodedAccount, getBondingCurveDecoder());
|
|
3983
4179
|
}
|
|
4180
|
+
/** Fetches a `BondingCurve` account, throwing when it does not exist or only holds lamports. */
|
|
3984
4181
|
async function fetchBondingCurve(rpc, address, config) {
|
|
3985
4182
|
const maybeAccount = await fetchMaybeBondingCurve(rpc, address, config);
|
|
3986
4183
|
assertAccountExists(maybeAccount);
|
|
3987
4184
|
return maybeAccount;
|
|
3988
4185
|
}
|
|
4186
|
+
/**
|
|
4187
|
+
* Fetches a `BondingCurve` account, or the non-existing variant when the address holds no
|
|
4188
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
4189
|
+
* {@link decodeBondingCurve} throws for a lamports-only account instead.
|
|
4190
|
+
*/
|
|
3989
4191
|
async function fetchMaybeBondingCurve(rpc, address, config) {
|
|
3990
|
-
|
|
4192
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
4193
|
+
return decodeBondingCurve(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4194
|
+
address,
|
|
4195
|
+
exists: false
|
|
4196
|
+
});
|
|
3991
4197
|
}
|
|
4198
|
+
/** Fetches `BondingCurve` accounts, throwing when any does not exist or only holds lamports. */
|
|
3992
4199
|
async function fetchAllBondingCurve(rpc, addresses, config) {
|
|
3993
4200
|
const maybeAccounts = await fetchAllMaybeBondingCurve(rpc, addresses, config);
|
|
3994
4201
|
assertAccountsExist(maybeAccounts);
|
|
3995
4202
|
return maybeAccounts;
|
|
3996
4203
|
}
|
|
4204
|
+
/**
|
|
4205
|
+
* Fetches `BondingCurve` accounts, with the non-existing variant for each address that holds
|
|
4206
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
4207
|
+
* {@link decodeBondingCurve} throws for a lamports-only account instead.
|
|
4208
|
+
*/
|
|
3997
4209
|
async function fetchAllMaybeBondingCurve(rpc, addresses, config) {
|
|
3998
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeBondingCurve(maybeAccount)
|
|
4210
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeBondingCurve(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4211
|
+
address: maybeAccount.address,
|
|
4212
|
+
exists: false
|
|
4213
|
+
}));
|
|
3999
4214
|
}
|
|
4000
4215
|
function getBondingCurveSize() {
|
|
4001
|
-
return
|
|
4216
|
+
return 618;
|
|
4002
4217
|
}
|
|
4003
4218
|
//#endregion
|
|
4004
4219
|
//#region src/launchpad/generated/accounts/globalConfig.ts
|
|
@@ -4078,21 +4293,40 @@ function decodeGlobalConfig$1(encodedAccount) {
|
|
|
4078
4293
|
}
|
|
4079
4294
|
return decodeAccount(encodedAccount, getGlobalConfigDecoder$1());
|
|
4080
4295
|
}
|
|
4296
|
+
/** Fetches a `GlobalConfig` account, throwing when it does not exist or only holds lamports. */
|
|
4081
4297
|
async function fetchGlobalConfig$1(rpc, address, config) {
|
|
4082
4298
|
const maybeAccount = await fetchMaybeGlobalConfig$1(rpc, address, config);
|
|
4083
4299
|
assertAccountExists(maybeAccount);
|
|
4084
4300
|
return maybeAccount;
|
|
4085
4301
|
}
|
|
4302
|
+
/**
|
|
4303
|
+
* Fetches a `GlobalConfig` account, or the non-existing variant when the address holds no
|
|
4304
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
4305
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
4306
|
+
*/
|
|
4086
4307
|
async function fetchMaybeGlobalConfig$1(rpc, address, config) {
|
|
4087
|
-
|
|
4308
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
4309
|
+
return decodeGlobalConfig$1(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4310
|
+
address,
|
|
4311
|
+
exists: false
|
|
4312
|
+
});
|
|
4088
4313
|
}
|
|
4314
|
+
/** Fetches `GlobalConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
4089
4315
|
async function fetchAllGlobalConfig$1(rpc, addresses, config) {
|
|
4090
4316
|
const maybeAccounts = await fetchAllMaybeGlobalConfig$1(rpc, addresses, config);
|
|
4091
4317
|
assertAccountsExist(maybeAccounts);
|
|
4092
4318
|
return maybeAccounts;
|
|
4093
4319
|
}
|
|
4320
|
+
/**
|
|
4321
|
+
* Fetches `GlobalConfig` accounts, with the non-existing variant for each address that holds
|
|
4322
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
4323
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
4324
|
+
*/
|
|
4094
4325
|
async function fetchAllMaybeGlobalConfig$1(rpc, addresses, config) {
|
|
4095
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig$1(maybeAccount)
|
|
4326
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig$1(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4327
|
+
address: maybeAccount.address,
|
|
4328
|
+
exists: false
|
|
4329
|
+
}));
|
|
4096
4330
|
}
|
|
4097
4331
|
function getGlobalConfigSize() {
|
|
4098
4332
|
return 179;
|
|
@@ -4165,21 +4399,40 @@ function decodeRewardAccrual(encodedAccount) {
|
|
|
4165
4399
|
}
|
|
4166
4400
|
return decodeAccount(encodedAccount, getRewardAccrualDecoder());
|
|
4167
4401
|
}
|
|
4402
|
+
/** Fetches a `RewardAccrual` account, throwing when it does not exist or only holds lamports. */
|
|
4168
4403
|
async function fetchRewardAccrual(rpc, address, config) {
|
|
4169
4404
|
const maybeAccount = await fetchMaybeRewardAccrual(rpc, address, config);
|
|
4170
4405
|
assertAccountExists(maybeAccount);
|
|
4171
4406
|
return maybeAccount;
|
|
4172
4407
|
}
|
|
4408
|
+
/**
|
|
4409
|
+
* Fetches a `RewardAccrual` account, or the non-existing variant when the address holds no
|
|
4410
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
4411
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
4412
|
+
*/
|
|
4173
4413
|
async function fetchMaybeRewardAccrual(rpc, address, config) {
|
|
4174
|
-
|
|
4414
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
4415
|
+
return decodeRewardAccrual(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4416
|
+
address,
|
|
4417
|
+
exists: false
|
|
4418
|
+
});
|
|
4175
4419
|
}
|
|
4420
|
+
/** Fetches `RewardAccrual` accounts, throwing when any does not exist or only holds lamports. */
|
|
4176
4421
|
async function fetchAllRewardAccrual(rpc, addresses, config) {
|
|
4177
4422
|
const maybeAccounts = await fetchAllMaybeRewardAccrual(rpc, addresses, config);
|
|
4178
4423
|
assertAccountsExist(maybeAccounts);
|
|
4179
4424
|
return maybeAccounts;
|
|
4180
4425
|
}
|
|
4426
|
+
/**
|
|
4427
|
+
* Fetches `RewardAccrual` accounts, with the non-existing variant for each address that holds
|
|
4428
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
4429
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
4430
|
+
*/
|
|
4181
4431
|
async function fetchAllMaybeRewardAccrual(rpc, addresses, config) {
|
|
4182
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeRewardAccrual(maybeAccount)
|
|
4432
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeRewardAccrual(accountIsCreated$1(maybeAccount) ? maybeAccount : {
|
|
4433
|
+
address: maybeAccount.address,
|
|
4434
|
+
exists: false
|
|
4435
|
+
}));
|
|
4183
4436
|
}
|
|
4184
4437
|
function getRewardAccrualSize() {
|
|
4185
4438
|
return 130;
|
|
@@ -4308,12 +4561,16 @@ const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 7009;
|
|
|
4308
4561
|
const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 7010;
|
|
4309
4562
|
/** NothingToClaim: Nothing to claim */
|
|
4310
4563
|
const SEND_LAUNCHPAD_ERROR__NOTHING_TO_CLAIM = 7011;
|
|
4311
|
-
/**
|
|
4312
|
-
const
|
|
4564
|
+
/** Unused7012: Unused */
|
|
4565
|
+
const SEND_LAUNCHPAD_ERROR__UNUSED7012 = 7012;
|
|
4313
4566
|
/** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
|
|
4314
4567
|
const SEND_LAUNCHPAD_ERROR__QUOTE_MINT_PRICE_UNSET = 7013;
|
|
4315
4568
|
/** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
|
|
4316
4569
|
const SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 7014;
|
|
4570
|
+
/** CreatorFeeTooHigh: Creator fee exceeds the partner's maximum */
|
|
4571
|
+
const SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH = 7015;
|
|
4572
|
+
/** CreatorFeeModeNotAllowed: Creator fee mode is not allowed by the partner config */
|
|
4573
|
+
const SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED = 7016;
|
|
4317
4574
|
/** InsufficientLiquidity: Insufficient liquidity */
|
|
4318
4575
|
const SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY = 7100;
|
|
4319
4576
|
/** InvalidAmount: Invalid amount */
|
|
@@ -4323,6 +4580,8 @@ const sendLaunchpadErrorMessages = {
|
|
|
4323
4580
|
[SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
4324
4581
|
[SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND]: `Base mint not found`,
|
|
4325
4582
|
[SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY]: `Blocked by held supply`,
|
|
4583
|
+
[SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED]: `Creator fee mode is not allowed by the partner config`,
|
|
4584
|
+
[SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH]: `Creator fee exceeds the partner's maximum`,
|
|
4326
4585
|
[SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE]: `Curve is live`,
|
|
4327
4586
|
[SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance in source account`,
|
|
4328
4587
|
[SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
@@ -4330,7 +4589,6 @@ const sendLaunchpadErrorMessages = {
|
|
|
4330
4589
|
[SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
|
|
4331
4590
|
[SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT]: `Invalid base mint`,
|
|
4332
4591
|
[SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR]: `Invalid coin creator`,
|
|
4333
|
-
[SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID]: `Creator identity is not a decodable wallet address`,
|
|
4334
4592
|
[SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT]: `Invalid Pyth price account`,
|
|
4335
4593
|
[SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED]: `Invalid Pyth feed ID`,
|
|
4336
4594
|
[SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT]: `Invalid quote mint`,
|
|
@@ -4348,6 +4606,7 @@ const sendLaunchpadErrorMessages = {
|
|
|
4348
4606
|
[SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED]: `Token creation is disabled`,
|
|
4349
4607
|
[SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
|
|
4350
4608
|
[SEND_LAUNCHPAD_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
4609
|
+
[SEND_LAUNCHPAD_ERROR__UNUSED7012]: `Unused`,
|
|
4351
4610
|
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
|
|
4352
4611
|
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
|
|
4353
4612
|
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT]: `User token account mint does not match the trade`,
|
|
@@ -4366,6 +4625,8 @@ var errors_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4366
4625
|
SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW: () => SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW,
|
|
4367
4626
|
SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND: () => SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND,
|
|
4368
4627
|
SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY: () => SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY,
|
|
4628
|
+
SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED: () => SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED,
|
|
4629
|
+
SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH: () => SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH,
|
|
4369
4630
|
SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE: () => SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE,
|
|
4370
4631
|
SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE: () => SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE,
|
|
4371
4632
|
SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY: () => SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY,
|
|
@@ -4373,7 +4634,6 @@ var errors_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4373
4634
|
SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY: () => SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY,
|
|
4374
4635
|
SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT: () => SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT,
|
|
4375
4636
|
SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR: () => SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR,
|
|
4376
|
-
SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID: () => SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID,
|
|
4377
4637
|
SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT: () => SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT,
|
|
4378
4638
|
SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED: () => SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED,
|
|
4379
4639
|
SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT: () => SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT,
|
|
@@ -4391,6 +4651,7 @@ var errors_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4391
4651
|
SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED: () => SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED,
|
|
4392
4652
|
SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE: () => SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE,
|
|
4393
4653
|
SEND_LAUNCHPAD_ERROR__UNAUTHORIZED: () => SEND_LAUNCHPAD_ERROR__UNAUTHORIZED,
|
|
4654
|
+
SEND_LAUNCHPAD_ERROR__UNUSED7012: () => SEND_LAUNCHPAD_ERROR__UNUSED7012,
|
|
4394
4655
|
SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID: () => SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID,
|
|
4395
4656
|
SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY: () => SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY,
|
|
4396
4657
|
SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT: () => SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT,
|
|
@@ -4433,6 +4694,44 @@ async function findBondingCurvePda(seeds) {
|
|
|
4433
4694
|
});
|
|
4434
4695
|
}
|
|
4435
4696
|
//#endregion
|
|
4697
|
+
//#region src/launchpad/generated/pdas/creatorFeeConfig.ts
|
|
4698
|
+
/**
|
|
4699
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
4700
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4701
|
+
* to add features, then rerun Codama to update it.
|
|
4702
|
+
*
|
|
4703
|
+
* @see https://github.com/codama-idl/codama
|
|
4704
|
+
*/
|
|
4705
|
+
async function findCreatorFeeConfigPda(seeds) {
|
|
4706
|
+
return await getProgramDerivedAddress({
|
|
4707
|
+
programAddress: SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
4708
|
+
seeds: [
|
|
4709
|
+
getBytesEncoder().encode(new Uint8Array([
|
|
4710
|
+
99,
|
|
4711
|
+
114,
|
|
4712
|
+
101,
|
|
4713
|
+
97,
|
|
4714
|
+
116,
|
|
4715
|
+
111,
|
|
4716
|
+
114,
|
|
4717
|
+
95,
|
|
4718
|
+
102,
|
|
4719
|
+
101,
|
|
4720
|
+
101,
|
|
4721
|
+
95,
|
|
4722
|
+
99,
|
|
4723
|
+
111,
|
|
4724
|
+
110,
|
|
4725
|
+
102,
|
|
4726
|
+
105,
|
|
4727
|
+
103
|
|
4728
|
+
])),
|
|
4729
|
+
getAddressEncoder().encode(seeds.baseMint),
|
|
4730
|
+
getAddressEncoder().encode(seeds.quoteMint)
|
|
4731
|
+
]
|
|
4732
|
+
});
|
|
4733
|
+
}
|
|
4734
|
+
//#endregion
|
|
4436
4735
|
//#region src/launchpad/generated/pdas/eventAuthority.ts
|
|
4437
4736
|
const EVENT_AUTHORITY_PDA_ADDRESS$1 = "FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T";
|
|
4438
4737
|
function findEventAuthorityPda$1() {
|
|
@@ -4494,6 +4793,7 @@ var pdas_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4494
4793
|
MIGRATION_AUTHORITY_PDA_ADDRESS: () => MIGRATION_AUTHORITY_PDA_ADDRESS,
|
|
4495
4794
|
WSOL_REWARD_ACCRUAL_PDA_ADDRESS: () => WSOL_REWARD_ACCRUAL_PDA_ADDRESS,
|
|
4496
4795
|
findBondingCurvePda: () => findBondingCurvePda,
|
|
4796
|
+
findCreatorFeeConfigPda: () => findCreatorFeeConfigPda,
|
|
4497
4797
|
findEventAuthorityPda: () => findEventAuthorityPda$1,
|
|
4498
4798
|
findGlobalConfigPda: () => findGlobalConfigPda$1,
|
|
4499
4799
|
findMigrationAuthorityPda: () => findMigrationAuthorityPda,
|
|
@@ -4501,80 +4801,6 @@ var pdas_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
4501
4801
|
findWsolRewardAccrualPda: () => findWsolRewardAccrualPda
|
|
4502
4802
|
});
|
|
4503
4803
|
//#endregion
|
|
4504
|
-
//#region src/utils/creator-hash.ts
|
|
4505
|
-
const MAX_CREATOR_PLATFORM_LEN = 32;
|
|
4506
|
-
/** SHA-256 of the LE-u32-length-prefixed platform and id. Frozen: it seeds live PDAs. */
|
|
4507
|
-
async function creatorHashFromId(creatorPlatform, creatorId) {
|
|
4508
|
-
const encoder = new TextEncoder();
|
|
4509
|
-
const platformBuf = encoder.encode(creatorPlatform);
|
|
4510
|
-
const idBuf = encoder.encode(creatorId);
|
|
4511
|
-
if (platformBuf.length > MAX_CREATOR_PLATFORM_LEN) throw new RangeError(`creatorPlatform exceeds ${MAX_CREATOR_PLATFORM_LEN} bytes (got ${platformBuf.length})`);
|
|
4512
|
-
const platformLength = /* @__PURE__ */ new Uint8Array(4);
|
|
4513
|
-
new DataView(platformLength.buffer).setUint32(0, platformBuf.length, true);
|
|
4514
|
-
const idLength = /* @__PURE__ */ new Uint8Array(4);
|
|
4515
|
-
new DataView(idLength.buffer).setUint32(0, idBuf.length, true);
|
|
4516
|
-
const buf = new Uint8Array(4 + platformBuf.length + 4 + idBuf.length);
|
|
4517
|
-
buf.set(platformLength, 0);
|
|
4518
|
-
buf.set(platformBuf, 4);
|
|
4519
|
-
buf.set(idLength, 4 + platformBuf.length);
|
|
4520
|
-
buf.set(idBuf, 4 + platformBuf.length + 4);
|
|
4521
|
-
const hash = new Uint8Array(await crypto.subtle.digest("SHA-256", buf));
|
|
4522
|
-
return getAddressDecoder().decode(hash);
|
|
4523
|
-
}
|
|
4524
|
-
/** NUL-pads `text` to `length` bytes, the on-chain `CreatorFeeConfig.platformId` form; throws RangeError if longer. */
|
|
4525
|
-
function encodeCreatorId(text, length) {
|
|
4526
|
-
const bytes = new TextEncoder().encode(text);
|
|
4527
|
-
if (bytes.length > length) throw new RangeError(`text exceeds ${length} bytes (got ${bytes.length})`);
|
|
4528
|
-
const out = new Uint8Array(length);
|
|
4529
|
-
out.set(bytes, 0);
|
|
4530
|
-
return out;
|
|
4531
|
-
}
|
|
4532
|
-
/** Strips NUL padding. Pass this, never the padded array, to {@link creatorHashFromId}: the hash is length-prefixed. */
|
|
4533
|
-
function decodeCreatorId(bytes) {
|
|
4534
|
-
let end = bytes.length;
|
|
4535
|
-
while (end > 0 && bytes[end - 1] === 0) end -= 1;
|
|
4536
|
-
return new TextDecoder().decode(bytes.slice(0, end));
|
|
4537
|
-
}
|
|
4538
|
-
//#endregion
|
|
4539
|
-
//#region src/nexus/generated/pdas/creatorFeeConfig.ts
|
|
4540
|
-
/**
|
|
4541
|
-
* This code was AUTOGENERATED using the Codama library.
|
|
4542
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4543
|
-
* to add features, then rerun Codama to update it.
|
|
4544
|
-
*
|
|
4545
|
-
* @see https://github.com/codama-idl/codama
|
|
4546
|
-
*/
|
|
4547
|
-
async function findCreatorFeeConfigPda(seeds) {
|
|
4548
|
-
return await getProgramDerivedAddress({
|
|
4549
|
-
programAddress: SEND_NEXUS_PROGRAM_ADDRESS,
|
|
4550
|
-
seeds: [
|
|
4551
|
-
getBytesEncoder().encode(new Uint8Array([
|
|
4552
|
-
99,
|
|
4553
|
-
114,
|
|
4554
|
-
101,
|
|
4555
|
-
97,
|
|
4556
|
-
116,
|
|
4557
|
-
111,
|
|
4558
|
-
114,
|
|
4559
|
-
95,
|
|
4560
|
-
102,
|
|
4561
|
-
101,
|
|
4562
|
-
101,
|
|
4563
|
-
95,
|
|
4564
|
-
98,
|
|
4565
|
-
97,
|
|
4566
|
-
108,
|
|
4567
|
-
97,
|
|
4568
|
-
110,
|
|
4569
|
-
99,
|
|
4570
|
-
101
|
|
4571
|
-
])),
|
|
4572
|
-
getAddressEncoder().encode(seeds.creatorHash),
|
|
4573
|
-
getAddressEncoder().encode(seeds.quoteMint)
|
|
4574
|
-
]
|
|
4575
|
-
});
|
|
4576
|
-
}
|
|
4577
|
-
//#endregion
|
|
4578
4804
|
//#region src/launchpad/generated/instructions/createToken.ts
|
|
4579
4805
|
/**
|
|
4580
4806
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -4600,12 +4826,12 @@ function getCreateTokenInstructionDataEncoder() {
|
|
|
4600
4826
|
return transformEncoder(getStructEncoder([
|
|
4601
4827
|
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
4602
4828
|
["platformConfig", getAddressEncoder()],
|
|
4603
|
-
["creatorPlatform", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
4604
|
-
["creatorId", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
4605
|
-
["creatorHash", getAddressEncoder()],
|
|
4606
4829
|
["name", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
4607
4830
|
["symbol", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
4608
|
-
["uri", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())]
|
|
4831
|
+
["uri", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
4832
|
+
["creatorFeeMode", getU8Encoder()],
|
|
4833
|
+
["creatorFeeBps", getU16Encoder()],
|
|
4834
|
+
["dexCreatorFeeBps", getU16Encoder()]
|
|
4609
4835
|
]), (value) => ({
|
|
4610
4836
|
...value,
|
|
4611
4837
|
discriminator: CREATE_TOKEN_DISCRIMINATOR
|
|
@@ -4615,12 +4841,12 @@ function getCreateTokenInstructionDataDecoder() {
|
|
|
4615
4841
|
return getStructDecoder([
|
|
4616
4842
|
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
4617
4843
|
["platformConfig", getAddressDecoder()],
|
|
4618
|
-
["creatorPlatform", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
4619
|
-
["creatorId", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
4620
|
-
["creatorHash", getAddressDecoder()],
|
|
4621
4844
|
["name", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
4622
4845
|
["symbol", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
4623
|
-
["uri", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())]
|
|
4846
|
+
["uri", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
4847
|
+
["creatorFeeMode", getU8Decoder()],
|
|
4848
|
+
["creatorFeeBps", getU16Decoder()],
|
|
4849
|
+
["dexCreatorFeeBps", getU16Decoder()]
|
|
4624
4850
|
]);
|
|
4625
4851
|
}
|
|
4626
4852
|
function getCreateTokenInstructionDataCodec() {
|
|
@@ -4764,33 +4990,9 @@ async function getCreateTokenInstructionAsync(input) {
|
|
|
4764
4990
|
getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("quoteMint", accounts.quoteMint.value))
|
|
4765
4991
|
]
|
|
4766
4992
|
});
|
|
4767
|
-
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
getBytesEncoder().encode(new Uint8Array([
|
|
4771
|
-
99,
|
|
4772
|
-
114,
|
|
4773
|
-
101,
|
|
4774
|
-
97,
|
|
4775
|
-
116,
|
|
4776
|
-
111,
|
|
4777
|
-
114,
|
|
4778
|
-
95,
|
|
4779
|
-
102,
|
|
4780
|
-
101,
|
|
4781
|
-
101,
|
|
4782
|
-
95,
|
|
4783
|
-
98,
|
|
4784
|
-
97,
|
|
4785
|
-
108,
|
|
4786
|
-
97,
|
|
4787
|
-
110,
|
|
4788
|
-
99,
|
|
4789
|
-
101
|
|
4790
|
-
])),
|
|
4791
|
-
getAddressEncoder().encode(getNonNullResolvedInstructionInput("creatorHash", args.creatorHash)),
|
|
4792
|
-
getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("quoteMint", accounts.quoteMint.value))
|
|
4793
|
-
]
|
|
4993
|
+
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda({
|
|
4994
|
+
baseMint: getAddressFromResolvedInstructionAccount("baseMint", accounts.baseMint.value),
|
|
4995
|
+
quoteMint: getAddressFromResolvedInstructionAccount("quoteMint", accounts.quoteMint.value)
|
|
4794
4996
|
});
|
|
4795
4997
|
if (!accounts.nexusProgram.value) accounts.nexusProgram.value = "7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX";
|
|
4796
4998
|
if (!accounts.nexusGlobalConfig.value) accounts.nexusGlobalConfig.value = "3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr";
|
|
@@ -6475,7 +6677,8 @@ var trade_exports = /* @__PURE__ */ __exportAll({
|
|
|
6475
6677
|
sellExactIn: () => sellExactIn,
|
|
6476
6678
|
sellExactOut: () => sellExactOut
|
|
6477
6679
|
});
|
|
6478
|
-
/** `baseAmountOut` is
|
|
6680
|
+
/** `baseAmountOut` is the base the buyer receives, after the base mint's transfer fee.
|
|
6681
|
+
* The buy is capped at the curve's supply left. Read the result from `quote.baseToUser`. */
|
|
6479
6682
|
async function buyExactOut(params) {
|
|
6480
6683
|
const quote = buyExactOut$2({
|
|
6481
6684
|
reserveQuote: params.virtualQuoteReserves,
|
|
@@ -6535,7 +6738,7 @@ async function sellExactIn(params) {
|
|
|
6535
6738
|
quote
|
|
6536
6739
|
};
|
|
6537
6740
|
}
|
|
6538
|
-
/** `quoteAmountOut` is
|
|
6741
|
+
/** `quoteAmountOut` is the quote the seller receives, after the quote mint's transfer fee. */
|
|
6539
6742
|
async function sellExactOut(params) {
|
|
6540
6743
|
const quote = sellExactOut$2({
|
|
6541
6744
|
reserveQuote: params.virtualQuoteReserves,
|
|
@@ -6583,7 +6786,7 @@ async function buildSellExactOutInstruction(params) {
|
|
|
6583
6786
|
maxAmountIn: params.maxAmountIn
|
|
6584
6787
|
});
|
|
6585
6788
|
}
|
|
6586
|
-
/**
|
|
6789
|
+
/** Returns the percent of the curve's real base sold, from 0 to 100. At 100 the curve can migrate. */
|
|
6587
6790
|
function calculateBondingCurveProgress(params) {
|
|
6588
6791
|
const { realBaseReserves, initialRealBase } = params;
|
|
6589
6792
|
if (initialRealBase === 0n) return 100;
|
|
@@ -6610,33 +6813,25 @@ var create_exports = /* @__PURE__ */ __exportAll({
|
|
|
6610
6813
|
buildCreateTokenInstruction: () => buildCreateTokenInstruction
|
|
6611
6814
|
});
|
|
6612
6815
|
async function buildCreateTokenInstruction(params) {
|
|
6613
|
-
return buildCreateTokenInstructionWithHash(params, await creatorHashFromId(params.creatorPlatform, params.creatorId));
|
|
6614
|
-
}
|
|
6615
|
-
async function buildCreateTokenInstructionWithHash(params, creatorHash) {
|
|
6616
|
-
const [creatorFeeConfig] = await findCreatorFeeConfigPda({
|
|
6617
|
-
creatorHash,
|
|
6618
|
-
quoteMint: params.quoteMint
|
|
6619
|
-
});
|
|
6620
6816
|
return getCreateTokenInstructionAsync({
|
|
6621
6817
|
user: params.user,
|
|
6622
6818
|
payer: params.payer ?? params.user,
|
|
6623
6819
|
coinCreator: params.coinCreator,
|
|
6624
6820
|
baseMint: params.baseMint,
|
|
6625
6821
|
quoteMint: params.quoteMint,
|
|
6626
|
-
creatorFeeConfig,
|
|
6627
6822
|
partner: params.partner,
|
|
6628
6823
|
platformConfig: params.platformConfig,
|
|
6629
6824
|
quoteTokenProgram: params.quoteTokenProgram,
|
|
6630
|
-
creatorPlatform: params.creatorPlatform,
|
|
6631
|
-
creatorId: params.creatorId,
|
|
6632
|
-
creatorHash,
|
|
6633
6825
|
name: params.name,
|
|
6634
6826
|
symbol: params.symbol,
|
|
6635
|
-
uri: params.uri
|
|
6827
|
+
uri: params.uri,
|
|
6828
|
+
creatorFeeMode: params.creatorFeeMode,
|
|
6829
|
+
creatorFeeBps: params.creatorFeeBps,
|
|
6830
|
+
dexCreatorFeeBps: params.dexCreatorFeeBps
|
|
6636
6831
|
});
|
|
6637
6832
|
}
|
|
6638
6833
|
async function buildCreateAndBuyInstructions(params) {
|
|
6639
|
-
const instructions = [await
|
|
6834
|
+
const instructions = [await buildCreateTokenInstruction(params)];
|
|
6640
6835
|
let quote;
|
|
6641
6836
|
if (params.buyQuoteAmount > 0n) {
|
|
6642
6837
|
const buyResult = await buyExactIn({
|
|
@@ -6720,7 +6915,7 @@ function getCompleteEventDecoder() {
|
|
|
6720
6915
|
["baseMint", getAddressDecoder()],
|
|
6721
6916
|
["quoteMint", getAddressDecoder()],
|
|
6722
6917
|
["coinCreator", getAddressDecoder()],
|
|
6723
|
-
["
|
|
6918
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
6724
6919
|
["platformConfig", getAddressDecoder()],
|
|
6725
6920
|
["curvePartner", getAddressDecoder()],
|
|
6726
6921
|
["isPartner", getBooleanDecoder()],
|
|
@@ -6792,7 +6987,7 @@ function getCreatorClaimEventDecoder() {
|
|
|
6792
6987
|
["quoteMint", getAddressDecoder()],
|
|
6793
6988
|
["platformConfig", getAddressDecoder()],
|
|
6794
6989
|
["coinCreator", getAddressDecoder()],
|
|
6795
|
-
["
|
|
6990
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
6796
6991
|
["claimer", getAddressDecoder()],
|
|
6797
6992
|
["destinationOwner", getAddressDecoder()],
|
|
6798
6993
|
["amount", getU64Decoder()],
|
|
@@ -6864,7 +7059,7 @@ function getMigrateEventDecoder() {
|
|
|
6864
7059
|
["quoteMint", getAddressDecoder()],
|
|
6865
7060
|
["pool", getAddressDecoder()],
|
|
6866
7061
|
["coinCreator", getAddressDecoder()],
|
|
6867
|
-
["
|
|
7062
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
6868
7063
|
["platformConfig", getAddressDecoder()],
|
|
6869
7064
|
["baseAmount", getU64Decoder()],
|
|
6870
7065
|
["quoteAmount", getU64Decoder()],
|
|
@@ -7077,9 +7272,7 @@ function getTokenCreateEventDecoder() {
|
|
|
7077
7272
|
["quoteMint", getAddressDecoder()],
|
|
7078
7273
|
["quoteDecimals", getU8Decoder()],
|
|
7079
7274
|
["coinCreator", getAddressDecoder()],
|
|
7080
|
-
["
|
|
7081
|
-
["creatorId", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
7082
|
-
["creatorFeeConfig", getAddressDecoder()],
|
|
7275
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 5 })],
|
|
7083
7276
|
["platformConfig", getAddressDecoder()],
|
|
7084
7277
|
["name", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
7085
7278
|
["symbol", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
@@ -7091,7 +7284,10 @@ function getTokenCreateEventDecoder() {
|
|
|
7091
7284
|
["virtualQuoteReserves", getU64Decoder()],
|
|
7092
7285
|
["realBaseReserves", getU64Decoder()],
|
|
7093
7286
|
["realQuoteReserves", getU64Decoder()],
|
|
7094
|
-
["timestamp", getI64Decoder()]
|
|
7287
|
+
["timestamp", getI64Decoder()],
|
|
7288
|
+
["creatorFeeMode", getU8Decoder()],
|
|
7289
|
+
["creatorFeeBps", getU16Decoder()],
|
|
7290
|
+
["dexCreatorFeeBps", getU16Decoder()]
|
|
7095
7291
|
]);
|
|
7096
7292
|
}
|
|
7097
7293
|
/**
|
|
@@ -7158,7 +7354,7 @@ function getTradeEventDecoder() {
|
|
|
7158
7354
|
["quoteMint", getAddressDecoder()],
|
|
7159
7355
|
["user", getAddressDecoder()],
|
|
7160
7356
|
["coinCreator", getAddressDecoder()],
|
|
7161
|
-
["
|
|
7357
|
+
["padding0", getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
7162
7358
|
["platformConfig", getAddressDecoder()],
|
|
7163
7359
|
["baseAmount", getU64Decoder()],
|
|
7164
7360
|
["quoteAmountGross", getU64Decoder()],
|
|
@@ -7174,7 +7370,9 @@ function getTradeEventDecoder() {
|
|
|
7174
7370
|
["virtualQuoteReserves", getU64Decoder()],
|
|
7175
7371
|
["realBaseReserves", getU64Decoder()],
|
|
7176
7372
|
["realQuoteReserves", getU64Decoder()],
|
|
7177
|
-
["timestamp", getI64Decoder()]
|
|
7373
|
+
["timestamp", getI64Decoder()],
|
|
7374
|
+
["creatorFeeMode", getU8Decoder()],
|
|
7375
|
+
["creatorFeeBps", getU16Decoder()]
|
|
7178
7376
|
]);
|
|
7179
7377
|
}
|
|
7180
7378
|
/**
|
|
@@ -7381,7 +7579,7 @@ async function getClaimCreatorFeesInstructionAsync(input) {
|
|
|
7381
7579
|
},
|
|
7382
7580
|
creatorFeeConfig: {
|
|
7383
7581
|
value: input.creatorFeeConfig ?? null,
|
|
7384
|
-
isWritable:
|
|
7582
|
+
isWritable: true
|
|
7385
7583
|
},
|
|
7386
7584
|
nexusGlobalConfig: {
|
|
7387
7585
|
value: null,
|
|
@@ -7432,6 +7630,10 @@ async function getClaimCreatorFeesInstructionAsync(input) {
|
|
|
7432
7630
|
baseMint: getAddressFromResolvedInstructionAccount("baseMint", accounts.baseMint.value),
|
|
7433
7631
|
quoteMint: getAddressFromResolvedInstructionAccount("quoteMint", accounts.quoteMint.value)
|
|
7434
7632
|
});
|
|
7633
|
+
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda({
|
|
7634
|
+
baseMint: getAddressFromResolvedInstructionAccount("baseMint", accounts.baseMint.value),
|
|
7635
|
+
quoteMint: getAddressFromResolvedInstructionAccount("quoteMint", accounts.quoteMint.value)
|
|
7636
|
+
});
|
|
7435
7637
|
if (!accounts.nexusGlobalConfig.value) accounts.nexusGlobalConfig.value = "3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr";
|
|
7436
7638
|
if (!accounts.quoteVault.value) accounts.quoteVault.value = await getProgramDerivedAddress({
|
|
7437
7639
|
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
@@ -7493,7 +7695,7 @@ function getClaimCreatorFeesInstruction(input) {
|
|
|
7493
7695
|
},
|
|
7494
7696
|
creatorFeeConfig: {
|
|
7495
7697
|
value: input.creatorFeeConfig ?? null,
|
|
7496
|
-
isWritable:
|
|
7698
|
+
isWritable: true
|
|
7497
7699
|
},
|
|
7498
7700
|
nexusGlobalConfig: {
|
|
7499
7701
|
value: null,
|
|
@@ -7975,7 +8177,7 @@ async function getMigrateInstructionAsync(input) {
|
|
|
7975
8177
|
},
|
|
7976
8178
|
creatorFeeConfig: {
|
|
7977
8179
|
value: input.creatorFeeConfig ?? null,
|
|
7978
|
-
isWritable:
|
|
8180
|
+
isWritable: true
|
|
7979
8181
|
},
|
|
7980
8182
|
baseTokenProgram: {
|
|
7981
8183
|
value: null,
|
|
@@ -8000,6 +8202,10 @@ async function getMigrateInstructionAsync(input) {
|
|
|
8000
8202
|
program: {
|
|
8001
8203
|
value: null,
|
|
8002
8204
|
isWritable: false
|
|
8205
|
+
},
|
|
8206
|
+
dexCreatorFeeConfig: {
|
|
8207
|
+
value: input.dexCreatorFeeConfig ?? null,
|
|
8208
|
+
isWritable: true
|
|
8003
8209
|
}
|
|
8004
8210
|
};
|
|
8005
8211
|
if (!accounts.bondingCurve.value) accounts.bondingCurve.value = await findBondingCurvePda({
|
|
@@ -8055,11 +8261,42 @@ async function getMigrateInstructionAsync(input) {
|
|
|
8055
8261
|
});
|
|
8056
8262
|
if (!accounts.dexEventAuthority.value) accounts.dexEventAuthority.value = "4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t";
|
|
8057
8263
|
if (!accounts.nexusProgram.value) accounts.nexusProgram.value = "7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX";
|
|
8264
|
+
if (!accounts.creatorFeeConfig.value) accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda({
|
|
8265
|
+
baseMint: getAddressFromResolvedInstructionAccount("baseMint", accounts.baseMint.value),
|
|
8266
|
+
quoteMint: getAddressFromResolvedInstructionAccount("quoteMint", accounts.quoteMint.value)
|
|
8267
|
+
});
|
|
8058
8268
|
if (!accounts.baseTokenProgram.value) accounts.baseTokenProgram.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
8059
8269
|
if (!accounts.associatedTokenProgram.value) accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
8060
8270
|
if (!accounts.systemProgram.value) accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
8061
8271
|
if (!accounts.eventAuthority.value) accounts.eventAuthority.value = EVENT_AUTHORITY_PDA_ADDRESS$1;
|
|
8062
8272
|
if (!accounts.program.value) accounts.program.value = "5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP";
|
|
8273
|
+
if (!accounts.dexCreatorFeeConfig.value) accounts.dexCreatorFeeConfig.value = await getProgramDerivedAddress({
|
|
8274
|
+
programAddress: "84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX",
|
|
8275
|
+
seeds: [
|
|
8276
|
+
getBytesEncoder().encode(new Uint8Array([
|
|
8277
|
+
99,
|
|
8278
|
+
114,
|
|
8279
|
+
101,
|
|
8280
|
+
97,
|
|
8281
|
+
116,
|
|
8282
|
+
111,
|
|
8283
|
+
114,
|
|
8284
|
+
95,
|
|
8285
|
+
102,
|
|
8286
|
+
101,
|
|
8287
|
+
101,
|
|
8288
|
+
95,
|
|
8289
|
+
99,
|
|
8290
|
+
111,
|
|
8291
|
+
110,
|
|
8292
|
+
102,
|
|
8293
|
+
105,
|
|
8294
|
+
103
|
|
8295
|
+
])),
|
|
8296
|
+
getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("baseMint", accounts.baseMint.value)),
|
|
8297
|
+
getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("quoteMint", accounts.quoteMint.value))
|
|
8298
|
+
]
|
|
8299
|
+
});
|
|
8063
8300
|
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
8064
8301
|
return Object.freeze({
|
|
8065
8302
|
accounts: [
|
|
@@ -8084,7 +8321,8 @@ async function getMigrateInstructionAsync(input) {
|
|
|
8084
8321
|
getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram),
|
|
8085
8322
|
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
8086
8323
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
8087
|
-
getAccountMeta("program", accounts.program)
|
|
8324
|
+
getAccountMeta("program", accounts.program),
|
|
8325
|
+
getAccountMeta("dexCreatorFeeConfig", accounts.dexCreatorFeeConfig)
|
|
8088
8326
|
],
|
|
8089
8327
|
data: getMigrateInstructionDataEncoder().encode({}),
|
|
8090
8328
|
programAddress
|
|
@@ -8155,7 +8393,7 @@ function getMigrateInstruction(input) {
|
|
|
8155
8393
|
},
|
|
8156
8394
|
creatorFeeConfig: {
|
|
8157
8395
|
value: input.creatorFeeConfig ?? null,
|
|
8158
|
-
isWritable:
|
|
8396
|
+
isWritable: true
|
|
8159
8397
|
},
|
|
8160
8398
|
baseTokenProgram: {
|
|
8161
8399
|
value: null,
|
|
@@ -8180,6 +8418,10 @@ function getMigrateInstruction(input) {
|
|
|
8180
8418
|
program: {
|
|
8181
8419
|
value: null,
|
|
8182
8420
|
isWritable: false
|
|
8421
|
+
},
|
|
8422
|
+
dexCreatorFeeConfig: {
|
|
8423
|
+
value: input.dexCreatorFeeConfig ?? null,
|
|
8424
|
+
isWritable: true
|
|
8183
8425
|
}
|
|
8184
8426
|
};
|
|
8185
8427
|
if (!accounts.dexProgram.value) accounts.dexProgram.value = "84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX";
|
|
@@ -8215,7 +8457,8 @@ function getMigrateInstruction(input) {
|
|
|
8215
8457
|
getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram),
|
|
8216
8458
|
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
8217
8459
|
getAccountMeta("eventAuthority", accounts.eventAuthority),
|
|
8218
|
-
getAccountMeta("program", accounts.program)
|
|
8460
|
+
getAccountMeta("program", accounts.program),
|
|
8461
|
+
getAccountMeta("dexCreatorFeeConfig", accounts.dexCreatorFeeConfig)
|
|
8219
8462
|
],
|
|
8220
8463
|
data: getMigrateInstructionDataEncoder().encode({}),
|
|
8221
8464
|
programAddress
|
|
@@ -8228,9 +8471,9 @@ function parseMigrateInstruction(instruction) {
|
|
|
8228
8471
|
error.name = "InstructionDiscriminatorMismatchError";
|
|
8229
8472
|
throw error;
|
|
8230
8473
|
}
|
|
8231
|
-
if (instruction.accounts.length <
|
|
8474
|
+
if (instruction.accounts.length < 23) throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
8232
8475
|
actualAccountMetas: instruction.accounts.length,
|
|
8233
|
-
expectedAccountMetas:
|
|
8476
|
+
expectedAccountMetas: 23
|
|
8234
8477
|
});
|
|
8235
8478
|
let accountIndex = 0;
|
|
8236
8479
|
const getNextAccount = () => {
|
|
@@ -8262,7 +8505,8 @@ function parseMigrateInstruction(instruction) {
|
|
|
8262
8505
|
associatedTokenProgram: getNextAccount(),
|
|
8263
8506
|
systemProgram: getNextAccount(),
|
|
8264
8507
|
eventAuthority: getNextAccount(),
|
|
8265
|
-
program: getNextAccount()
|
|
8508
|
+
program: getNextAccount(),
|
|
8509
|
+
dexCreatorFeeConfig: getNextAccount()
|
|
8266
8510
|
},
|
|
8267
8511
|
data: getMigrateInstructionDataDecoder().decode(instruction.data)
|
|
8268
8512
|
};
|
|
@@ -8501,6 +8745,7 @@ function sendLaunchpadProgram() {
|
|
|
8501
8745
|
pdas: {
|
|
8502
8746
|
bondingCurve: findBondingCurvePda,
|
|
8503
8747
|
eventAuthority: findEventAuthorityPda$1,
|
|
8748
|
+
creatorFeeConfig: findCreatorFeeConfigPda,
|
|
8504
8749
|
rewardAccrual: findRewardAccrualPda,
|
|
8505
8750
|
globalConfig: findGlobalConfigPda$1,
|
|
8506
8751
|
wsolRewardAccrual: findWsolRewardAccrualPda,
|
|
@@ -8518,7 +8763,7 @@ var plugins_exports$1 = /* @__PURE__ */ __exportAll({ sendLaunchpadProgram: () =
|
|
|
8518
8763
|
//#endregion
|
|
8519
8764
|
//#region src/utils/pda.ts
|
|
8520
8765
|
const addressEncoder = getAddressEncoder();
|
|
8521
|
-
/**
|
|
8766
|
+
/** Derives the associated token account of `wallet` for `mint` under `tokenProgram`. */
|
|
8522
8767
|
async function findAssociatedTokenPda(wallet, mint, tokenProgram = TOKEN_PROGRAM_ADDRESS) {
|
|
8523
8768
|
return await getProgramDerivedAddress({
|
|
8524
8769
|
programAddress: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
@@ -8534,13 +8779,20 @@ async function findAssociatedTokenPda(wallet, mint, tokenProgram = TOKEN_PROGRAM
|
|
|
8534
8779
|
var migrate_exports = /* @__PURE__ */ __exportAll({ buildMigrateInstruction: () => buildMigrateInstruction });
|
|
8535
8780
|
async function buildMigrateInstruction(params) {
|
|
8536
8781
|
const { quoteTokenProgram } = params;
|
|
8537
|
-
const [[pool], [lpMint]] = await Promise.all([
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8782
|
+
const [[pool], [lpMint], [dexCreatorFeeConfig]] = await Promise.all([
|
|
8783
|
+
findPoolPda({
|
|
8784
|
+
baseMint: params.baseMint,
|
|
8785
|
+
quoteMint: params.quoteMint
|
|
8786
|
+
}),
|
|
8787
|
+
findLpMintPda({
|
|
8788
|
+
baseMint: params.baseMint,
|
|
8789
|
+
quoteMint: params.quoteMint
|
|
8790
|
+
}),
|
|
8791
|
+
findCreatorFeeConfigPda$1({
|
|
8792
|
+
baseMint: params.baseMint,
|
|
8793
|
+
quoteMint: params.quoteMint
|
|
8794
|
+
})
|
|
8795
|
+
]);
|
|
8544
8796
|
const [[poolBaseVault], [poolQuoteVault], [poolLpAccount]] = await Promise.all([
|
|
8545
8797
|
findAssociatedTokenPda(pool, params.baseMint, TOKEN_2022_PROGRAM_ADDRESS),
|
|
8546
8798
|
findAssociatedTokenPda(pool, params.quoteMint, quoteTokenProgram),
|
|
@@ -8550,7 +8802,7 @@ async function buildMigrateInstruction(params) {
|
|
|
8550
8802
|
caller: params.caller,
|
|
8551
8803
|
baseMint: params.baseMint,
|
|
8552
8804
|
quoteMint: params.quoteMint,
|
|
8553
|
-
|
|
8805
|
+
dexCreatorFeeConfig,
|
|
8554
8806
|
poolBaseVault,
|
|
8555
8807
|
poolQuoteVault,
|
|
8556
8808
|
poolLpAccount,
|
|
@@ -8574,7 +8826,8 @@ var launchpad_exports = /* @__PURE__ */ __exportAll({
|
|
|
8574
8826
|
//#endregion
|
|
8575
8827
|
//#region src/math/fee-decay.ts
|
|
8576
8828
|
var fee_decay_exports = /* @__PURE__ */ __exportAll({ calculateFeeDecayPremium: () => calculateFeeDecayPremium });
|
|
8577
|
-
/**
|
|
8829
|
+
/** Returns the fee decay premium in bps, rounded up. The premium falls quadratically from
|
|
8830
|
+
* `decayStartBps - standardFeeBps` at creation to 0 after `decaySeconds`. */
|
|
8578
8831
|
function calculateFeeDecayPremium(params) {
|
|
8579
8832
|
const { currentTimestamp, createdAtTimestamp, decaySeconds, decayStartBps, standardFeeBps } = params;
|
|
8580
8833
|
if (decaySeconds === 0) return 0n;
|
|
@@ -8595,7 +8848,9 @@ function calculateFeeDecayPremium(params) {
|
|
|
8595
8848
|
//#endregion
|
|
8596
8849
|
//#region src/math/fees.ts
|
|
8597
8850
|
var fees_exports = /* @__PURE__ */ __exportAll({ splitFeeAmount: () => splitFeeAmount });
|
|
8598
|
-
/**
|
|
8851
|
+
/** Splits `feeAmount` into protocol, LP and creator shares. LP and creator round down. Protocol gets
|
|
8852
|
+
* the decay premium and all remainders. Throws `RangeError` on a negative or non-integer input,
|
|
8853
|
+
* a zero total bps, or `protocolBps + lpBps` above `baseTotalBps`. */
|
|
8599
8854
|
function splitFeeAmount(args) {
|
|
8600
8855
|
const { feeAmount } = args;
|
|
8601
8856
|
const protocolBps = toBps(args.protocolBps, "protocolBps");
|
|
@@ -8641,6 +8896,39 @@ var math_exports = /* @__PURE__ */ __exportAll({
|
|
|
8641
8896
|
fees: () => fees_exports
|
|
8642
8897
|
});
|
|
8643
8898
|
//#endregion
|
|
8899
|
+
//#region src/nexus/generated/shared/index.ts
|
|
8900
|
+
/** The System Program, which owns every address nobody has created an account at yet. */
|
|
8901
|
+
const SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
8902
|
+
/**
|
|
8903
|
+
* Whether an encoded account was created on-chain, rather than merely sent lamports.
|
|
8904
|
+
*
|
|
8905
|
+
* Anyone can send lamports to an address before its account is created, which leaves it on-chain,
|
|
8906
|
+
* owned by the System Program, with no data. This returns `false` for that shape, as it does for an
|
|
8907
|
+
* account that does not exist. Any other existing account counts as created, whoever owns it; the
|
|
8908
|
+
* `decode*` functions still check the owner.
|
|
8909
|
+
*
|
|
8910
|
+
* The generated `fetchMaybe*` and `fetchAllMaybe*` helpers apply this rule themselves. Apply it to
|
|
8911
|
+
* accounts you fetch or receive another way (subscriptions, batch loaders, caches) before passing
|
|
8912
|
+
* them to a `decode*` function, which throws for a lamports-only account: an account passed to it as
|
|
8913
|
+
* existing must never come back as the non-existing variant typed as an `Account`.
|
|
8914
|
+
*
|
|
8915
|
+
* Only a `true` result narrows the type. A lamports-only account is still `exists: true` at runtime,
|
|
8916
|
+
* so a `false` result leaves the type unchanged instead of narrowing it to the non-existing variant.
|
|
8917
|
+
* The `uncreated` property in the narrowed type is never present; it exists only to prevent that.
|
|
8918
|
+
*
|
|
8919
|
+
* @example
|
|
8920
|
+
* ```ts
|
|
8921
|
+
* const maybeAccount = decodeMyAccount(
|
|
8922
|
+
* accountIsCreated(encodedAccount) ? encodedAccount : { address: encodedAccount.address, exists: false },
|
|
8923
|
+
* );
|
|
8924
|
+
* ```
|
|
8925
|
+
*/
|
|
8926
|
+
function accountIsCreated(account) {
|
|
8927
|
+
const maybeAccount = account;
|
|
8928
|
+
if ("exists" in maybeAccount && !maybeAccount.exists) return false;
|
|
8929
|
+
return !(maybeAccount.programAddress === SYSTEM_PROGRAM_ADDRESS && maybeAccount.data.length === 0);
|
|
8930
|
+
}
|
|
8931
|
+
//#endregion
|
|
8644
8932
|
//#region src/nexus/generated/accounts/altRegistry.ts
|
|
8645
8933
|
/**
|
|
8646
8934
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -8704,111 +8992,43 @@ function decodeAltRegistry(encodedAccount) {
|
|
|
8704
8992
|
}
|
|
8705
8993
|
return decodeAccount(encodedAccount, getAltRegistryDecoder());
|
|
8706
8994
|
}
|
|
8995
|
+
/** Fetches a `AltRegistry` account, throwing when it does not exist or only holds lamports. */
|
|
8707
8996
|
async function fetchAltRegistry(rpc, address, config) {
|
|
8708
8997
|
const maybeAccount = await fetchMaybeAltRegistry(rpc, address, config);
|
|
8709
8998
|
assertAccountExists(maybeAccount);
|
|
8710
8999
|
return maybeAccount;
|
|
8711
9000
|
}
|
|
9001
|
+
/**
|
|
9002
|
+
* Fetches a `AltRegistry` account, or the non-existing variant when the address holds no
|
|
9003
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9004
|
+
* {@link decodeAltRegistry} throws for a lamports-only account instead.
|
|
9005
|
+
*/
|
|
8712
9006
|
async function fetchMaybeAltRegistry(rpc, address, config) {
|
|
8713
|
-
|
|
9007
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
9008
|
+
return decodeAltRegistry(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9009
|
+
address,
|
|
9010
|
+
exists: false
|
|
9011
|
+
});
|
|
8714
9012
|
}
|
|
9013
|
+
/** Fetches `AltRegistry` accounts, throwing when any does not exist or only holds lamports. */
|
|
8715
9014
|
async function fetchAllAltRegistry(rpc, addresses, config) {
|
|
8716
9015
|
const maybeAccounts = await fetchAllMaybeAltRegistry(rpc, addresses, config);
|
|
8717
9016
|
assertAccountsExist(maybeAccounts);
|
|
8718
9017
|
return maybeAccounts;
|
|
8719
9018
|
}
|
|
8720
|
-
async function fetchAllMaybeAltRegistry(rpc, addresses, config) {
|
|
8721
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeAltRegistry(maybeAccount));
|
|
8722
|
-
}
|
|
8723
|
-
function getAltRegistrySize() {
|
|
8724
|
-
return 74;
|
|
8725
|
-
}
|
|
8726
|
-
//#endregion
|
|
8727
|
-
//#region src/nexus/generated/accounts/creatorFeeConfig.ts
|
|
8728
9019
|
/**
|
|
8729
|
-
*
|
|
8730
|
-
*
|
|
8731
|
-
*
|
|
8732
|
-
*
|
|
8733
|
-
* @see https://github.com/codama-idl/codama
|
|
9020
|
+
* Fetches `AltRegistry` accounts, with the non-existing variant for each address that holds
|
|
9021
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9022
|
+
* {@link decodeAltRegistry} throws for a lamports-only account instead.
|
|
8734
9023
|
*/
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
74,
|
|
8740
|
-
215,
|
|
8741
|
-
196,
|
|
8742
|
-
130,
|
|
8743
|
-
32
|
|
8744
|
-
]);
|
|
8745
|
-
function getCreatorFeeConfigDiscriminatorBytes() {
|
|
8746
|
-
return fixEncoderSize(getBytesEncoder(), 8).encode(CREATOR_FEE_CONFIG_DISCRIMINATOR);
|
|
8747
|
-
}
|
|
8748
|
-
/** Gets the encoder for {@link CreatorFeeConfigArgs} account data. */
|
|
8749
|
-
function getCreatorFeeConfigEncoder() {
|
|
8750
|
-
return transformEncoder(getStructEncoder([
|
|
8751
|
-
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
8752
|
-
["version", getU8Encoder()],
|
|
8753
|
-
["bump", getU8Encoder()],
|
|
8754
|
-
["platformIndex", getU8Encoder()],
|
|
8755
|
-
["platformId", fixEncoderSize(getBytesEncoder(), 44)],
|
|
8756
|
-
["quoteMint", getAddressEncoder()],
|
|
8757
|
-
["reserved", fixEncoderSize(getBytesEncoder(), 64)]
|
|
8758
|
-
]), (value) => ({
|
|
8759
|
-
...value,
|
|
8760
|
-
discriminator: CREATOR_FEE_CONFIG_DISCRIMINATOR
|
|
9024
|
+
async function fetchAllMaybeAltRegistry(rpc, addresses, config) {
|
|
9025
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeAltRegistry(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9026
|
+
address: maybeAccount.address,
|
|
9027
|
+
exists: false
|
|
8761
9028
|
}));
|
|
8762
9029
|
}
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
return getStructDecoder([
|
|
8766
|
-
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
8767
|
-
["version", getU8Decoder()],
|
|
8768
|
-
["bump", getU8Decoder()],
|
|
8769
|
-
["platformIndex", getU8Decoder()],
|
|
8770
|
-
["platformId", fixDecoderSize(getBytesDecoder(), 44)],
|
|
8771
|
-
["quoteMint", getAddressDecoder()],
|
|
8772
|
-
["reserved", fixDecoderSize(getBytesDecoder(), 64)]
|
|
8773
|
-
]);
|
|
8774
|
-
}
|
|
8775
|
-
/** Gets the codec for {@link CreatorFeeConfig} account data. */
|
|
8776
|
-
function getCreatorFeeConfigCodec() {
|
|
8777
|
-
return combineCodec(getCreatorFeeConfigEncoder(), getCreatorFeeConfigDecoder());
|
|
8778
|
-
}
|
|
8779
|
-
function decodeCreatorFeeConfig(encodedAccount) {
|
|
8780
|
-
if (!("exists" in encodedAccount) || encodedAccount.exists) {
|
|
8781
|
-
if (encodedAccount.programAddress !== "7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX") {
|
|
8782
|
-
const error = /* @__PURE__ */ new Error(`decodeCreatorFeeConfig: account ${encodedAccount.address} is owned by ${encodedAccount.programAddress}, expected ${SEND_NEXUS_PROGRAM_ADDRESS}`);
|
|
8783
|
-
error.name = "AccountOwnerMismatchError";
|
|
8784
|
-
throw error;
|
|
8785
|
-
}
|
|
8786
|
-
if (!containsBytes(encodedAccount.data, CREATOR_FEE_CONFIG_DISCRIMINATOR, 0)) {
|
|
8787
|
-
const error = /* @__PURE__ */ new Error(`decodeCreatorFeeConfig: account ${encodedAccount.address} does not match the CreatorFeeConfig discriminator`);
|
|
8788
|
-
error.name = "AccountDiscriminatorMismatchError";
|
|
8789
|
-
throw error;
|
|
8790
|
-
}
|
|
8791
|
-
}
|
|
8792
|
-
return decodeAccount(encodedAccount, getCreatorFeeConfigDecoder());
|
|
8793
|
-
}
|
|
8794
|
-
async function fetchCreatorFeeConfig(rpc, address, config) {
|
|
8795
|
-
const maybeAccount = await fetchMaybeCreatorFeeConfig(rpc, address, config);
|
|
8796
|
-
assertAccountExists(maybeAccount);
|
|
8797
|
-
return maybeAccount;
|
|
8798
|
-
}
|
|
8799
|
-
async function fetchMaybeCreatorFeeConfig(rpc, address, config) {
|
|
8800
|
-
return decodeCreatorFeeConfig(await fetchEncodedAccount(rpc, address, config));
|
|
8801
|
-
}
|
|
8802
|
-
async function fetchAllCreatorFeeConfig(rpc, addresses, config) {
|
|
8803
|
-
const maybeAccounts = await fetchAllMaybeCreatorFeeConfig(rpc, addresses, config);
|
|
8804
|
-
assertAccountsExist(maybeAccounts);
|
|
8805
|
-
return maybeAccounts;
|
|
8806
|
-
}
|
|
8807
|
-
async function fetchAllMaybeCreatorFeeConfig(rpc, addresses, config) {
|
|
8808
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeCreatorFeeConfig(maybeAccount));
|
|
8809
|
-
}
|
|
8810
|
-
function getCreatorFeeConfigSize() {
|
|
8811
|
-
return 151;
|
|
9030
|
+
function getAltRegistrySize() {
|
|
9031
|
+
return 74;
|
|
8812
9032
|
}
|
|
8813
9033
|
//#endregion
|
|
8814
9034
|
//#region src/nexus/generated/types/authPlatformEntry.ts
|
|
@@ -8829,29 +9049,6 @@ function getAuthPlatformEntryCodec() {
|
|
|
8829
9049
|
return combineCodec(getAuthPlatformEntryEncoder(), getAuthPlatformEntryDecoder());
|
|
8830
9050
|
}
|
|
8831
9051
|
//#endregion
|
|
8832
|
-
//#region src/nexus/generated/types/callerType.ts
|
|
8833
|
-
/**
|
|
8834
|
-
* This code was AUTOGENERATED using the Codama library.
|
|
8835
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
8836
|
-
* to add features, then rerun Codama to update it.
|
|
8837
|
-
*
|
|
8838
|
-
* @see https://github.com/codama-idl/codama
|
|
8839
|
-
*/
|
|
8840
|
-
let CallerType = /* @__PURE__ */ function(CallerType) {
|
|
8841
|
-
CallerType[CallerType["PlatformBondingCurve"] = 0] = "PlatformBondingCurve";
|
|
8842
|
-
CallerType[CallerType["PlatformPool"] = 1] = "PlatformPool";
|
|
8843
|
-
return CallerType;
|
|
8844
|
-
}({});
|
|
8845
|
-
function getCallerTypeEncoder() {
|
|
8846
|
-
return getEnumEncoder(CallerType);
|
|
8847
|
-
}
|
|
8848
|
-
function getCallerTypeDecoder() {
|
|
8849
|
-
return getEnumDecoder(CallerType);
|
|
8850
|
-
}
|
|
8851
|
-
function getCallerTypeCodec() {
|
|
8852
|
-
return combineCodec(getCallerTypeEncoder(), getCallerTypeDecoder());
|
|
8853
|
-
}
|
|
8854
|
-
//#endregion
|
|
8855
9052
|
//#region src/nexus/generated/types/dexFees.ts
|
|
8856
9053
|
/**
|
|
8857
9054
|
* This code was AUTOGENERATED using the Codama library.
|
|
@@ -8865,7 +9062,7 @@ function getDexFeesEncoder() {
|
|
|
8865
9062
|
["creationFeeCents", getU64Encoder()],
|
|
8866
9063
|
["protocolFeeBps", getU16Encoder()],
|
|
8867
9064
|
["lpFeeBps", getU16Encoder()],
|
|
8868
|
-
["
|
|
9065
|
+
["maxCreatorFeeBps", getU16Encoder()],
|
|
8869
9066
|
["feeDecaySeconds", getU16Encoder()],
|
|
8870
9067
|
["feeDecayStartBps", getU16Encoder()]
|
|
8871
9068
|
]);
|
|
@@ -8875,7 +9072,7 @@ function getDexFeesDecoder() {
|
|
|
8875
9072
|
["creationFeeCents", getU64Decoder()],
|
|
8876
9073
|
["protocolFeeBps", getU16Decoder()],
|
|
8877
9074
|
["lpFeeBps", getU16Decoder()],
|
|
8878
|
-
["
|
|
9075
|
+
["maxCreatorFeeBps", getU16Decoder()],
|
|
8879
9076
|
["feeDecaySeconds", getU16Decoder()],
|
|
8880
9077
|
["feeDecayStartBps", getU16Decoder()]
|
|
8881
9078
|
]);
|
|
@@ -8924,7 +9121,7 @@ function getLaunchpadFeesEncoder() {
|
|
|
8924
9121
|
return getStructEncoder([
|
|
8925
9122
|
["creationFeeCents", getU64Encoder()],
|
|
8926
9123
|
["protocolFeeBps", getU16Encoder()],
|
|
8927
|
-
["
|
|
9124
|
+
["maxCreatorFeeBps", getU16Encoder()],
|
|
8928
9125
|
["feeDecaySeconds", getU16Encoder()],
|
|
8929
9126
|
["feeDecayStartBps", getU16Encoder()]
|
|
8930
9127
|
]);
|
|
@@ -8933,7 +9130,7 @@ function getLaunchpadFeesDecoder() {
|
|
|
8933
9130
|
return getStructDecoder([
|
|
8934
9131
|
["creationFeeCents", getU64Decoder()],
|
|
8935
9132
|
["protocolFeeBps", getU16Decoder()],
|
|
8936
|
-
["
|
|
9133
|
+
["maxCreatorFeeBps", getU16Decoder()],
|
|
8937
9134
|
["feeDecaySeconds", getU16Decoder()],
|
|
8938
9135
|
["feeDecayStartBps", getU16Decoder()]
|
|
8939
9136
|
]);
|
|
@@ -8944,13 +9141,9 @@ function getLaunchpadFeesCodec() {
|
|
|
8944
9141
|
//#endregion
|
|
8945
9142
|
//#region src/nexus/generated/types/index.ts
|
|
8946
9143
|
var types_exports = /* @__PURE__ */ __exportAll({
|
|
8947
|
-
CallerType: () => CallerType,
|
|
8948
9144
|
getAuthPlatformEntryCodec: () => getAuthPlatformEntryCodec,
|
|
8949
9145
|
getAuthPlatformEntryDecoder: () => getAuthPlatformEntryDecoder,
|
|
8950
9146
|
getAuthPlatformEntryEncoder: () => getAuthPlatformEntryEncoder,
|
|
8951
|
-
getCallerTypeCodec: () => getCallerTypeCodec,
|
|
8952
|
-
getCallerTypeDecoder: () => getCallerTypeDecoder,
|
|
8953
|
-
getCallerTypeEncoder: () => getCallerTypeEncoder,
|
|
8954
9147
|
getDexFeesCodec: () => getDexFeesCodec,
|
|
8955
9148
|
getDexFeesDecoder: () => getDexFeesDecoder,
|
|
8956
9149
|
getDexFeesEncoder: () => getDexFeesEncoder,
|
|
@@ -8994,7 +9187,7 @@ function getFeePresetEncoder() {
|
|
|
8994
9187
|
["launchpad", getLaunchpadFeesEncoder()],
|
|
8995
9188
|
["dex", getDexFeesEncoder()],
|
|
8996
9189
|
["platformConfig", getAddressEncoder()],
|
|
8997
|
-
["reserved", fixEncoderSize(getBytesEncoder(),
|
|
9190
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 64)]
|
|
8998
9191
|
]), (value) => ({
|
|
8999
9192
|
...value,
|
|
9000
9193
|
discriminator: FEE_PRESET_DISCRIMINATOR
|
|
@@ -9011,7 +9204,7 @@ function getFeePresetDecoder() {
|
|
|
9011
9204
|
["launchpad", getLaunchpadFeesDecoder()],
|
|
9012
9205
|
["dex", getDexFeesDecoder()],
|
|
9013
9206
|
["platformConfig", getAddressDecoder()],
|
|
9014
|
-
["reserved", fixDecoderSize(getBytesDecoder(),
|
|
9207
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 64)]
|
|
9015
9208
|
]);
|
|
9016
9209
|
}
|
|
9017
9210
|
/** Gets the codec for {@link FeePreset} account data. */
|
|
@@ -9033,21 +9226,40 @@ function decodeFeePreset(encodedAccount) {
|
|
|
9033
9226
|
}
|
|
9034
9227
|
return decodeAccount(encodedAccount, getFeePresetDecoder());
|
|
9035
9228
|
}
|
|
9229
|
+
/** Fetches a `FeePreset` account, throwing when it does not exist or only holds lamports. */
|
|
9036
9230
|
async function fetchFeePreset(rpc, address, config) {
|
|
9037
9231
|
const maybeAccount = await fetchMaybeFeePreset(rpc, address, config);
|
|
9038
9232
|
assertAccountExists(maybeAccount);
|
|
9039
9233
|
return maybeAccount;
|
|
9040
9234
|
}
|
|
9235
|
+
/**
|
|
9236
|
+
* Fetches a `FeePreset` account, or the non-existing variant when the address holds no
|
|
9237
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9238
|
+
* {@link decodeFeePreset} throws for a lamports-only account instead.
|
|
9239
|
+
*/
|
|
9041
9240
|
async function fetchMaybeFeePreset(rpc, address, config) {
|
|
9042
|
-
|
|
9241
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
9242
|
+
return decodeFeePreset(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9243
|
+
address,
|
|
9244
|
+
exists: false
|
|
9245
|
+
});
|
|
9043
9246
|
}
|
|
9247
|
+
/** Fetches `FeePreset` accounts, throwing when any does not exist or only holds lamports. */
|
|
9044
9248
|
async function fetchAllFeePreset(rpc, addresses, config) {
|
|
9045
9249
|
const maybeAccounts = await fetchAllMaybeFeePreset(rpc, addresses, config);
|
|
9046
9250
|
assertAccountsExist(maybeAccounts);
|
|
9047
9251
|
return maybeAccounts;
|
|
9048
9252
|
}
|
|
9253
|
+
/**
|
|
9254
|
+
* Fetches `FeePreset` accounts, with the non-existing variant for each address that holds
|
|
9255
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9256
|
+
* {@link decodeFeePreset} throws for a lamports-only account instead.
|
|
9257
|
+
*/
|
|
9049
9258
|
async function fetchAllMaybeFeePreset(rpc, addresses, config) {
|
|
9050
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeFeePreset(maybeAccount)
|
|
9259
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeFeePreset(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9260
|
+
address: maybeAccount.address,
|
|
9261
|
+
exists: false
|
|
9262
|
+
}));
|
|
9051
9263
|
}
|
|
9052
9264
|
//#endregion
|
|
9053
9265
|
//#region src/nexus/generated/accounts/globalConfig.ts
|
|
@@ -9117,21 +9329,40 @@ function decodeGlobalConfig(encodedAccount) {
|
|
|
9117
9329
|
}
|
|
9118
9330
|
return decodeAccount(encodedAccount, getGlobalConfigDecoder());
|
|
9119
9331
|
}
|
|
9332
|
+
/** Fetches a `GlobalConfig` account, throwing when it does not exist or only holds lamports. */
|
|
9120
9333
|
async function fetchGlobalConfig(rpc, address, config) {
|
|
9121
9334
|
const maybeAccount = await fetchMaybeGlobalConfig(rpc, address, config);
|
|
9122
9335
|
assertAccountExists(maybeAccount);
|
|
9123
9336
|
return maybeAccount;
|
|
9124
9337
|
}
|
|
9338
|
+
/**
|
|
9339
|
+
* Fetches a `GlobalConfig` account, or the non-existing variant when the address holds no
|
|
9340
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9341
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
9342
|
+
*/
|
|
9125
9343
|
async function fetchMaybeGlobalConfig(rpc, address, config) {
|
|
9126
|
-
|
|
9344
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
9345
|
+
return decodeGlobalConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9346
|
+
address,
|
|
9347
|
+
exists: false
|
|
9348
|
+
});
|
|
9127
9349
|
}
|
|
9350
|
+
/** Fetches `GlobalConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
9128
9351
|
async function fetchAllGlobalConfig(rpc, addresses, config) {
|
|
9129
9352
|
const maybeAccounts = await fetchAllMaybeGlobalConfig(rpc, addresses, config);
|
|
9130
9353
|
assertAccountsExist(maybeAccounts);
|
|
9131
9354
|
return maybeAccounts;
|
|
9132
9355
|
}
|
|
9356
|
+
/**
|
|
9357
|
+
* Fetches `GlobalConfig` accounts, with the non-existing variant for each address that holds
|
|
9358
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9359
|
+
* {@link decodeGlobalConfig} throws for a lamports-only account instead.
|
|
9360
|
+
*/
|
|
9133
9361
|
async function fetchAllMaybeGlobalConfig(rpc, addresses, config) {
|
|
9134
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig(maybeAccount)
|
|
9362
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeGlobalConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9363
|
+
address: maybeAccount.address,
|
|
9364
|
+
exists: false
|
|
9365
|
+
}));
|
|
9135
9366
|
}
|
|
9136
9367
|
//#endregion
|
|
9137
9368
|
//#region src/nexus/generated/accounts/partnerConfig.ts
|
|
@@ -9167,7 +9398,8 @@ function getPartnerConfigEncoder() {
|
|
|
9167
9398
|
["launchpad", getLaunchpadFeesEncoder()],
|
|
9168
9399
|
["dex", getDexFeesEncoder()],
|
|
9169
9400
|
["platformConfig", getAddressEncoder()],
|
|
9170
|
-
["
|
|
9401
|
+
["allowedCreatorFeeModes", getU16Encoder()],
|
|
9402
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 256)]
|
|
9171
9403
|
]), (value) => ({
|
|
9172
9404
|
...value,
|
|
9173
9405
|
discriminator: PARTNER_CONFIG_DISCRIMINATOR
|
|
@@ -9185,7 +9417,8 @@ function getPartnerConfigDecoder() {
|
|
|
9185
9417
|
["launchpad", getLaunchpadFeesDecoder()],
|
|
9186
9418
|
["dex", getDexFeesDecoder()],
|
|
9187
9419
|
["platformConfig", getAddressDecoder()],
|
|
9188
|
-
["
|
|
9420
|
+
["allowedCreatorFeeModes", getU16Decoder()],
|
|
9421
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 256)]
|
|
9189
9422
|
]);
|
|
9190
9423
|
}
|
|
9191
9424
|
/** Gets the codec for {@link PartnerConfig} account data. */
|
|
@@ -9207,24 +9440,43 @@ function decodePartnerConfig(encodedAccount) {
|
|
|
9207
9440
|
}
|
|
9208
9441
|
return decodeAccount(encodedAccount, getPartnerConfigDecoder());
|
|
9209
9442
|
}
|
|
9443
|
+
/** Fetches a `PartnerConfig` account, throwing when it does not exist or only holds lamports. */
|
|
9210
9444
|
async function fetchPartnerConfig(rpc, address, config) {
|
|
9211
9445
|
const maybeAccount = await fetchMaybePartnerConfig(rpc, address, config);
|
|
9212
9446
|
assertAccountExists(maybeAccount);
|
|
9213
9447
|
return maybeAccount;
|
|
9214
9448
|
}
|
|
9449
|
+
/**
|
|
9450
|
+
* Fetches a `PartnerConfig` account, or the non-existing variant when the address holds no
|
|
9451
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9452
|
+
* {@link decodePartnerConfig} throws for a lamports-only account instead.
|
|
9453
|
+
*/
|
|
9215
9454
|
async function fetchMaybePartnerConfig(rpc, address, config) {
|
|
9216
|
-
|
|
9455
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
9456
|
+
return decodePartnerConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9457
|
+
address,
|
|
9458
|
+
exists: false
|
|
9459
|
+
});
|
|
9217
9460
|
}
|
|
9461
|
+
/** Fetches `PartnerConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
9218
9462
|
async function fetchAllPartnerConfig(rpc, addresses, config) {
|
|
9219
9463
|
const maybeAccounts = await fetchAllMaybePartnerConfig(rpc, addresses, config);
|
|
9220
9464
|
assertAccountsExist(maybeAccounts);
|
|
9221
9465
|
return maybeAccounts;
|
|
9222
9466
|
}
|
|
9467
|
+
/**
|
|
9468
|
+
* Fetches `PartnerConfig` accounts, with the non-existing variant for each address that holds
|
|
9469
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9470
|
+
* {@link decodePartnerConfig} throws for a lamports-only account instead.
|
|
9471
|
+
*/
|
|
9223
9472
|
async function fetchAllMaybePartnerConfig(rpc, addresses, config) {
|
|
9224
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodePartnerConfig(maybeAccount)
|
|
9473
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodePartnerConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9474
|
+
address: maybeAccount.address,
|
|
9475
|
+
exists: false
|
|
9476
|
+
}));
|
|
9225
9477
|
}
|
|
9226
9478
|
function getPartnerConfigSize() {
|
|
9227
|
-
return
|
|
9479
|
+
return 399;
|
|
9228
9480
|
}
|
|
9229
9481
|
//#endregion
|
|
9230
9482
|
//#region src/nexus/generated/accounts/partnerMetadata.ts
|
|
@@ -9300,21 +9552,40 @@ function decodePartnerMetadata(encodedAccount) {
|
|
|
9300
9552
|
}
|
|
9301
9553
|
return decodeAccount(encodedAccount, getPartnerMetadataDecoder());
|
|
9302
9554
|
}
|
|
9555
|
+
/** Fetches a `PartnerMetadata` account, throwing when it does not exist or only holds lamports. */
|
|
9303
9556
|
async function fetchPartnerMetadata(rpc, address, config) {
|
|
9304
9557
|
const maybeAccount = await fetchMaybePartnerMetadata(rpc, address, config);
|
|
9305
9558
|
assertAccountExists(maybeAccount);
|
|
9306
9559
|
return maybeAccount;
|
|
9307
9560
|
}
|
|
9561
|
+
/**
|
|
9562
|
+
* Fetches a `PartnerMetadata` account, or the non-existing variant when the address holds no
|
|
9563
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9564
|
+
* {@link decodePartnerMetadata} throws for a lamports-only account instead.
|
|
9565
|
+
*/
|
|
9308
9566
|
async function fetchMaybePartnerMetadata(rpc, address, config) {
|
|
9309
|
-
|
|
9567
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
9568
|
+
return decodePartnerMetadata(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9569
|
+
address,
|
|
9570
|
+
exists: false
|
|
9571
|
+
});
|
|
9310
9572
|
}
|
|
9573
|
+
/** Fetches `PartnerMetadata` accounts, throwing when any does not exist or only holds lamports. */
|
|
9311
9574
|
async function fetchAllPartnerMetadata(rpc, addresses, config) {
|
|
9312
9575
|
const maybeAccounts = await fetchAllMaybePartnerMetadata(rpc, addresses, config);
|
|
9313
9576
|
assertAccountsExist(maybeAccounts);
|
|
9314
9577
|
return maybeAccounts;
|
|
9315
9578
|
}
|
|
9579
|
+
/**
|
|
9580
|
+
* Fetches `PartnerMetadata` accounts, with the non-existing variant for each address that holds
|
|
9581
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9582
|
+
* {@link decodePartnerMetadata} throws for a lamports-only account instead.
|
|
9583
|
+
*/
|
|
9316
9584
|
async function fetchAllMaybePartnerMetadata(rpc, addresses, config) {
|
|
9317
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodePartnerMetadata(maybeAccount)
|
|
9585
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodePartnerMetadata(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9586
|
+
address: maybeAccount.address,
|
|
9587
|
+
exists: false
|
|
9588
|
+
}));
|
|
9318
9589
|
}
|
|
9319
9590
|
//#endregion
|
|
9320
9591
|
//#region src/nexus/generated/accounts/rewardState.ts
|
|
@@ -9394,21 +9665,40 @@ function decodeRewardState(encodedAccount) {
|
|
|
9394
9665
|
}
|
|
9395
9666
|
return decodeAccount(encodedAccount, getRewardStateDecoder());
|
|
9396
9667
|
}
|
|
9668
|
+
/** Fetches a `RewardState` account, throwing when it does not exist or only holds lamports. */
|
|
9397
9669
|
async function fetchRewardState(rpc, address, config) {
|
|
9398
9670
|
const maybeAccount = await fetchMaybeRewardState(rpc, address, config);
|
|
9399
9671
|
assertAccountExists(maybeAccount);
|
|
9400
9672
|
return maybeAccount;
|
|
9401
9673
|
}
|
|
9674
|
+
/**
|
|
9675
|
+
* Fetches a `RewardState` account, or the non-existing variant when the address holds no
|
|
9676
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9677
|
+
* {@link decodeRewardState} throws for a lamports-only account instead.
|
|
9678
|
+
*/
|
|
9402
9679
|
async function fetchMaybeRewardState(rpc, address, config) {
|
|
9403
|
-
|
|
9680
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
9681
|
+
return decodeRewardState(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9682
|
+
address,
|
|
9683
|
+
exists: false
|
|
9684
|
+
});
|
|
9404
9685
|
}
|
|
9686
|
+
/** Fetches `RewardState` accounts, throwing when any does not exist or only holds lamports. */
|
|
9405
9687
|
async function fetchAllRewardState(rpc, addresses, config) {
|
|
9406
9688
|
const maybeAccounts = await fetchAllMaybeRewardState(rpc, addresses, config);
|
|
9407
9689
|
assertAccountsExist(maybeAccounts);
|
|
9408
9690
|
return maybeAccounts;
|
|
9409
9691
|
}
|
|
9692
|
+
/**
|
|
9693
|
+
* Fetches `RewardState` accounts, with the non-existing variant for each address that holds
|
|
9694
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9695
|
+
* {@link decodeRewardState} throws for a lamports-only account instead.
|
|
9696
|
+
*/
|
|
9410
9697
|
async function fetchAllMaybeRewardState(rpc, addresses, config) {
|
|
9411
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeRewardState(maybeAccount)
|
|
9698
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeRewardState(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9699
|
+
address: maybeAccount.address,
|
|
9700
|
+
exists: false
|
|
9701
|
+
}));
|
|
9412
9702
|
}
|
|
9413
9703
|
function getRewardStateSize() {
|
|
9414
9704
|
return 196;
|
|
@@ -9483,21 +9773,40 @@ function decodeStakingConfig(encodedAccount) {
|
|
|
9483
9773
|
}
|
|
9484
9774
|
return decodeAccount(encodedAccount, getStakingConfigDecoder());
|
|
9485
9775
|
}
|
|
9776
|
+
/** Fetches a `StakingConfig` account, throwing when it does not exist or only holds lamports. */
|
|
9486
9777
|
async function fetchStakingConfig(rpc, address, config) {
|
|
9487
9778
|
const maybeAccount = await fetchMaybeStakingConfig(rpc, address, config);
|
|
9488
9779
|
assertAccountExists(maybeAccount);
|
|
9489
9780
|
return maybeAccount;
|
|
9490
9781
|
}
|
|
9782
|
+
/**
|
|
9783
|
+
* Fetches a `StakingConfig` account, or the non-existing variant when the address holds no
|
|
9784
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9785
|
+
* {@link decodeStakingConfig} throws for a lamports-only account instead.
|
|
9786
|
+
*/
|
|
9491
9787
|
async function fetchMaybeStakingConfig(rpc, address, config) {
|
|
9492
|
-
|
|
9788
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
9789
|
+
return decodeStakingConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9790
|
+
address,
|
|
9791
|
+
exists: false
|
|
9792
|
+
});
|
|
9493
9793
|
}
|
|
9794
|
+
/** Fetches `StakingConfig` accounts, throwing when any does not exist or only holds lamports. */
|
|
9494
9795
|
async function fetchAllStakingConfig(rpc, addresses, config) {
|
|
9495
9796
|
const maybeAccounts = await fetchAllMaybeStakingConfig(rpc, addresses, config);
|
|
9496
9797
|
assertAccountsExist(maybeAccounts);
|
|
9497
9798
|
return maybeAccounts;
|
|
9498
9799
|
}
|
|
9800
|
+
/**
|
|
9801
|
+
* Fetches `StakingConfig` accounts, with the non-existing variant for each address that holds
|
|
9802
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9803
|
+
* {@link decodeStakingConfig} throws for a lamports-only account instead.
|
|
9804
|
+
*/
|
|
9499
9805
|
async function fetchAllMaybeStakingConfig(rpc, addresses, config) {
|
|
9500
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeStakingConfig(maybeAccount)
|
|
9806
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeStakingConfig(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9807
|
+
address: maybeAccount.address,
|
|
9808
|
+
exists: false
|
|
9809
|
+
}));
|
|
9501
9810
|
}
|
|
9502
9811
|
function getStakingConfigSize() {
|
|
9503
9812
|
return 117;
|
|
@@ -9538,7 +9847,7 @@ function getUserRewardDebtEncoder() {
|
|
|
9538
9847
|
["amountSnapshot", getU64Encoder()],
|
|
9539
9848
|
["settledVersion", getU32Encoder()],
|
|
9540
9849
|
["owed", getU64Encoder()],
|
|
9541
|
-
["reserved", fixEncoderSize(getBytesEncoder(),
|
|
9850
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 64)]
|
|
9542
9851
|
]), (value) => ({
|
|
9543
9852
|
...value,
|
|
9544
9853
|
discriminator: USER_REWARD_DEBT_DISCRIMINATOR
|
|
@@ -9558,7 +9867,7 @@ function getUserRewardDebtDecoder() {
|
|
|
9558
9867
|
["amountSnapshot", getU64Decoder()],
|
|
9559
9868
|
["settledVersion", getU32Decoder()],
|
|
9560
9869
|
["owed", getU64Decoder()],
|
|
9561
|
-
["reserved", fixDecoderSize(getBytesDecoder(),
|
|
9870
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 64)]
|
|
9562
9871
|
]);
|
|
9563
9872
|
}
|
|
9564
9873
|
/** Gets the codec for {@link UserRewardDebt} account data. */
|
|
@@ -9580,24 +9889,43 @@ function decodeUserRewardDebt(encodedAccount) {
|
|
|
9580
9889
|
}
|
|
9581
9890
|
return decodeAccount(encodedAccount, getUserRewardDebtDecoder());
|
|
9582
9891
|
}
|
|
9892
|
+
/** Fetches a `UserRewardDebt` account, throwing when it does not exist or only holds lamports. */
|
|
9583
9893
|
async function fetchUserRewardDebt(rpc, address, config) {
|
|
9584
9894
|
const maybeAccount = await fetchMaybeUserRewardDebt(rpc, address, config);
|
|
9585
9895
|
assertAccountExists(maybeAccount);
|
|
9586
9896
|
return maybeAccount;
|
|
9587
9897
|
}
|
|
9898
|
+
/**
|
|
9899
|
+
* Fetches a `UserRewardDebt` account, or the non-existing variant when the address holds no
|
|
9900
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
9901
|
+
* {@link decodeUserRewardDebt} throws for a lamports-only account instead.
|
|
9902
|
+
*/
|
|
9588
9903
|
async function fetchMaybeUserRewardDebt(rpc, address, config) {
|
|
9589
|
-
|
|
9904
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
9905
|
+
return decodeUserRewardDebt(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9906
|
+
address,
|
|
9907
|
+
exists: false
|
|
9908
|
+
});
|
|
9590
9909
|
}
|
|
9910
|
+
/** Fetches `UserRewardDebt` accounts, throwing when any does not exist or only holds lamports. */
|
|
9591
9911
|
async function fetchAllUserRewardDebt(rpc, addresses, config) {
|
|
9592
9912
|
const maybeAccounts = await fetchAllMaybeUserRewardDebt(rpc, addresses, config);
|
|
9593
9913
|
assertAccountsExist(maybeAccounts);
|
|
9594
9914
|
return maybeAccounts;
|
|
9595
9915
|
}
|
|
9916
|
+
/**
|
|
9917
|
+
* Fetches `UserRewardDebt` accounts, with the non-existing variant for each address that holds
|
|
9918
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
9919
|
+
* {@link decodeUserRewardDebt} throws for a lamports-only account instead.
|
|
9920
|
+
*/
|
|
9596
9921
|
async function fetchAllMaybeUserRewardDebt(rpc, addresses, config) {
|
|
9597
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeUserRewardDebt(maybeAccount)
|
|
9922
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeUserRewardDebt(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
9923
|
+
address: maybeAccount.address,
|
|
9924
|
+
exists: false
|
|
9925
|
+
}));
|
|
9598
9926
|
}
|
|
9599
9927
|
function getUserRewardDebtSize() {
|
|
9600
|
-
return
|
|
9928
|
+
return 214;
|
|
9601
9929
|
}
|
|
9602
9930
|
//#endregion
|
|
9603
9931
|
//#region src/nexus/generated/accounts/userStakePosition.ts
|
|
@@ -9632,7 +9960,7 @@ function getUserStakePositionEncoder() {
|
|
|
9632
9960
|
["amount", getU64Encoder()],
|
|
9633
9961
|
["stakeVersion", getU32Encoder()],
|
|
9634
9962
|
["settledCount", getU16Encoder()],
|
|
9635
|
-
["reserved", fixEncoderSize(getBytesEncoder(),
|
|
9963
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 128)]
|
|
9636
9964
|
]), (value) => ({
|
|
9637
9965
|
...value,
|
|
9638
9966
|
discriminator: USER_STAKE_POSITION_DISCRIMINATOR
|
|
@@ -9649,7 +9977,7 @@ function getUserStakePositionDecoder() {
|
|
|
9649
9977
|
["amount", getU64Decoder()],
|
|
9650
9978
|
["stakeVersion", getU32Decoder()],
|
|
9651
9979
|
["settledCount", getU16Decoder()],
|
|
9652
|
-
["reserved", fixDecoderSize(getBytesDecoder(),
|
|
9980
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 128)]
|
|
9653
9981
|
]);
|
|
9654
9982
|
}
|
|
9655
9983
|
/** Gets the codec for {@link UserStakePosition} account data. */
|
|
@@ -9671,24 +9999,43 @@ function decodeUserStakePosition(encodedAccount) {
|
|
|
9671
9999
|
}
|
|
9672
10000
|
return decodeAccount(encodedAccount, getUserStakePositionDecoder());
|
|
9673
10001
|
}
|
|
10002
|
+
/** Fetches a `UserStakePosition` account, throwing when it does not exist or only holds lamports. */
|
|
9674
10003
|
async function fetchUserStakePosition(rpc, address, config) {
|
|
9675
10004
|
const maybeAccount = await fetchMaybeUserStakePosition(rpc, address, config);
|
|
9676
10005
|
assertAccountExists(maybeAccount);
|
|
9677
10006
|
return maybeAccount;
|
|
9678
10007
|
}
|
|
10008
|
+
/**
|
|
10009
|
+
* Fetches a `UserStakePosition` account, or the non-existing variant when the address holds no
|
|
10010
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
10011
|
+
* {@link decodeUserStakePosition} throws for a lamports-only account instead.
|
|
10012
|
+
*/
|
|
9679
10013
|
async function fetchMaybeUserStakePosition(rpc, address, config) {
|
|
9680
|
-
|
|
10014
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
10015
|
+
return decodeUserStakePosition(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
10016
|
+
address,
|
|
10017
|
+
exists: false
|
|
10018
|
+
});
|
|
9681
10019
|
}
|
|
10020
|
+
/** Fetches `UserStakePosition` accounts, throwing when any does not exist or only holds lamports. */
|
|
9682
10021
|
async function fetchAllUserStakePosition(rpc, addresses, config) {
|
|
9683
10022
|
const maybeAccounts = await fetchAllMaybeUserStakePosition(rpc, addresses, config);
|
|
9684
10023
|
assertAccountsExist(maybeAccounts);
|
|
9685
10024
|
return maybeAccounts;
|
|
9686
10025
|
}
|
|
10026
|
+
/**
|
|
10027
|
+
* Fetches `UserStakePosition` accounts, with the non-existing variant for each address that holds
|
|
10028
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
10029
|
+
* {@link decodeUserStakePosition} throws for a lamports-only account instead.
|
|
10030
|
+
*/
|
|
9687
10031
|
async function fetchAllMaybeUserStakePosition(rpc, addresses, config) {
|
|
9688
|
-
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeUserStakePosition(maybeAccount)
|
|
10032
|
+
return (await fetchEncodedAccounts(rpc, addresses, config)).map((maybeAccount) => decodeUserStakePosition(accountIsCreated(maybeAccount) ? maybeAccount : {
|
|
10033
|
+
address: maybeAccount.address,
|
|
10034
|
+
exists: false
|
|
10035
|
+
}));
|
|
9689
10036
|
}
|
|
9690
10037
|
function getUserStakePositionSize() {
|
|
9691
|
-
return
|
|
10038
|
+
return 216;
|
|
9692
10039
|
}
|
|
9693
10040
|
//#endregion
|
|
9694
10041
|
//#region src/nexus/generated/accounts/sendNexus.accounts.ts
|
|
@@ -9707,7 +10054,6 @@ function identifySendNexusAccount(account) {
|
|
|
9707
10054
|
if ("data" in account && account.programAddress !== "7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX") return null;
|
|
9708
10055
|
const data = "data" in account ? account.data : account;
|
|
9709
10056
|
if (containsBytes(data, ALT_REGISTRY_DISCRIMINATOR, 0)) return "altRegistry";
|
|
9710
|
-
if (containsBytes(data, CREATOR_FEE_CONFIG_DISCRIMINATOR, 0)) return "creatorFeeConfig";
|
|
9711
10057
|
if (containsBytes(data, FEE_PRESET_DISCRIMINATOR, 0)) return "feePreset";
|
|
9712
10058
|
if (containsBytes(data, GLOBAL_CONFIG_DISCRIMINATOR, 0)) return "globalConfig";
|
|
9713
10059
|
if (containsBytes(data, PARTNER_CONFIG_DISCRIMINATOR, 0)) return "partnerConfig";
|
|
@@ -9722,7 +10068,6 @@ function identifySendNexusAccount(account) {
|
|
|
9722
10068
|
//#region src/nexus/generated/accounts/index.ts
|
|
9723
10069
|
var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
9724
10070
|
ALT_REGISTRY_DISCRIMINATOR: () => ALT_REGISTRY_DISCRIMINATOR,
|
|
9725
|
-
CREATOR_FEE_CONFIG_DISCRIMINATOR: () => CREATOR_FEE_CONFIG_DISCRIMINATOR,
|
|
9726
10071
|
FEE_PRESET_DISCRIMINATOR: () => FEE_PRESET_DISCRIMINATOR,
|
|
9727
10072
|
GLOBAL_CONFIG_DISCRIMINATOR: () => GLOBAL_CONFIG_DISCRIMINATOR,
|
|
9728
10073
|
PARTNER_CONFIG_DISCRIMINATOR: () => PARTNER_CONFIG_DISCRIMINATOR,
|
|
@@ -9732,7 +10077,6 @@ var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
|
9732
10077
|
USER_REWARD_DEBT_DISCRIMINATOR: () => USER_REWARD_DEBT_DISCRIMINATOR,
|
|
9733
10078
|
USER_STAKE_POSITION_DISCRIMINATOR: () => USER_STAKE_POSITION_DISCRIMINATOR,
|
|
9734
10079
|
decodeAltRegistry: () => decodeAltRegistry,
|
|
9735
|
-
decodeCreatorFeeConfig: () => decodeCreatorFeeConfig,
|
|
9736
10080
|
decodeFeePreset: () => decodeFeePreset,
|
|
9737
10081
|
decodeGlobalConfig: () => decodeGlobalConfig,
|
|
9738
10082
|
decodePartnerConfig: () => decodePartnerConfig,
|
|
@@ -9742,11 +10086,9 @@ var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
|
9742
10086
|
decodeUserRewardDebt: () => decodeUserRewardDebt,
|
|
9743
10087
|
decodeUserStakePosition: () => decodeUserStakePosition,
|
|
9744
10088
|
fetchAllAltRegistry: () => fetchAllAltRegistry,
|
|
9745
|
-
fetchAllCreatorFeeConfig: () => fetchAllCreatorFeeConfig,
|
|
9746
10089
|
fetchAllFeePreset: () => fetchAllFeePreset,
|
|
9747
10090
|
fetchAllGlobalConfig: () => fetchAllGlobalConfig,
|
|
9748
10091
|
fetchAllMaybeAltRegistry: () => fetchAllMaybeAltRegistry,
|
|
9749
|
-
fetchAllMaybeCreatorFeeConfig: () => fetchAllMaybeCreatorFeeConfig,
|
|
9750
10092
|
fetchAllMaybeFeePreset: () => fetchAllMaybeFeePreset,
|
|
9751
10093
|
fetchAllMaybeGlobalConfig: () => fetchAllMaybeGlobalConfig,
|
|
9752
10094
|
fetchAllMaybePartnerConfig: () => fetchAllMaybePartnerConfig,
|
|
@@ -9762,11 +10104,9 @@ var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
|
9762
10104
|
fetchAllUserRewardDebt: () => fetchAllUserRewardDebt,
|
|
9763
10105
|
fetchAllUserStakePosition: () => fetchAllUserStakePosition,
|
|
9764
10106
|
fetchAltRegistry: () => fetchAltRegistry,
|
|
9765
|
-
fetchCreatorFeeConfig: () => fetchCreatorFeeConfig,
|
|
9766
10107
|
fetchFeePreset: () => fetchFeePreset,
|
|
9767
10108
|
fetchGlobalConfig: () => fetchGlobalConfig,
|
|
9768
10109
|
fetchMaybeAltRegistry: () => fetchMaybeAltRegistry,
|
|
9769
|
-
fetchMaybeCreatorFeeConfig: () => fetchMaybeCreatorFeeConfig,
|
|
9770
10110
|
fetchMaybeFeePreset: () => fetchMaybeFeePreset,
|
|
9771
10111
|
fetchMaybeGlobalConfig: () => fetchMaybeGlobalConfig,
|
|
9772
10112
|
fetchMaybePartnerConfig: () => fetchMaybePartnerConfig,
|
|
@@ -9786,11 +10126,6 @@ var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
|
9786
10126
|
getAltRegistryDiscriminatorBytes: () => getAltRegistryDiscriminatorBytes,
|
|
9787
10127
|
getAltRegistryEncoder: () => getAltRegistryEncoder,
|
|
9788
10128
|
getAltRegistrySize: () => getAltRegistrySize,
|
|
9789
|
-
getCreatorFeeConfigCodec: () => getCreatorFeeConfigCodec,
|
|
9790
|
-
getCreatorFeeConfigDecoder: () => getCreatorFeeConfigDecoder,
|
|
9791
|
-
getCreatorFeeConfigDiscriminatorBytes: () => getCreatorFeeConfigDiscriminatorBytes,
|
|
9792
|
-
getCreatorFeeConfigEncoder: () => getCreatorFeeConfigEncoder,
|
|
9793
|
-
getCreatorFeeConfigSize: () => getCreatorFeeConfigSize,
|
|
9794
10129
|
getFeePresetCodec: () => getFeePresetCodec,
|
|
9795
10130
|
getFeePresetDecoder: () => getFeePresetDecoder,
|
|
9796
10131
|
getFeePresetDiscriminatorBytes: () => getFeePresetDiscriminatorBytes,
|
|
@@ -10228,12 +10563,16 @@ const SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 7009;
|
|
|
10228
10563
|
const SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 7010;
|
|
10229
10564
|
/** NothingToClaim: Nothing to claim */
|
|
10230
10565
|
const SEND_NEXUS_ERROR__NOTHING_TO_CLAIM = 7011;
|
|
10231
|
-
/**
|
|
10232
|
-
const
|
|
10566
|
+
/** Unused7012: Unused */
|
|
10567
|
+
const SEND_NEXUS_ERROR__UNUSED7012 = 7012;
|
|
10233
10568
|
/** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
|
|
10234
10569
|
const SEND_NEXUS_ERROR__QUOTE_MINT_PRICE_UNSET = 7013;
|
|
10235
10570
|
/** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
|
|
10236
10571
|
const SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 7014;
|
|
10572
|
+
/** CreatorFeeTooHigh: Creator fee exceeds the partner's maximum */
|
|
10573
|
+
const SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH = 7015;
|
|
10574
|
+
/** CreatorFeeModeNotAllowed: Creator fee mode is not allowed by the partner config */
|
|
10575
|
+
const SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED = 7016;
|
|
10237
10576
|
/** InsufficientLiquidity: Insufficient liquidity */
|
|
10238
10577
|
const SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY = 7100;
|
|
10239
10578
|
/** InvalidAmount: Invalid amount */
|
|
@@ -10241,6 +10580,8 @@ const SEND_NEXUS_ERROR__INVALID_AMOUNT = 7101;
|
|
|
10241
10580
|
const sendNexusErrorMessages = {
|
|
10242
10581
|
[SEND_NEXUS_ERROR__AMBIGUOUS_FEE_SOURCE]: `Cannot specify both fee_preset and custom_fees`,
|
|
10243
10582
|
[SEND_NEXUS_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
10583
|
+
[SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED]: `Creator fee mode is not allowed by the partner config`,
|
|
10584
|
+
[SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH]: `Creator fee exceeds the partner's maximum`,
|
|
10244
10585
|
[SEND_NEXUS_ERROR__DUPLICATE_AUTH_PLATFORM_NAME]: `Duplicate auth platform name`,
|
|
10245
10586
|
[SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
10246
10587
|
[SEND_NEXUS_ERROR__INSUFFICIENT_STAKE]: `Insufficient stake balance`,
|
|
@@ -10248,7 +10589,6 @@ const sendNexusErrorMessages = {
|
|
|
10248
10589
|
[SEND_NEXUS_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
|
|
10249
10590
|
[SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_INDEX]: `Invalid auth platform index`,
|
|
10250
10591
|
[SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_NAME]: `Invalid auth platform name`,
|
|
10251
|
-
[SEND_NEXUS_ERROR__INVALID_CREATOR_ID]: `Creator identity is not a decodable wallet address`,
|
|
10252
10592
|
[SEND_NEXUS_ERROR__INVALID_DESTINATION]: `Invalid destination account`,
|
|
10253
10593
|
[SEND_NEXUS_ERROR__INVALID_FEE_PRESET]: `Invalid fee configuration`,
|
|
10254
10594
|
[SEND_NEXUS_ERROR__INVALID_MINT]: `Invalid mint`,
|
|
@@ -10282,6 +10622,7 @@ const sendNexusErrorMessages = {
|
|
|
10282
10622
|
[SEND_NEXUS_ERROR__TOO_MANY_AUTH_PLATFORMS]: `Too many auth platforms (max 255)`,
|
|
10283
10623
|
[SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
|
|
10284
10624
|
[SEND_NEXUS_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
10625
|
+
[SEND_NEXUS_ERROR__UNUSED7012]: `Unused`,
|
|
10285
10626
|
[SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
|
|
10286
10627
|
[SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
|
|
10287
10628
|
[SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT]: `User token account mint does not match the trade`,
|
|
@@ -10298,6 +10639,8 @@ function isSendNexusError(error, transactionMessage, code) {
|
|
|
10298
10639
|
var errors_exports = /* @__PURE__ */ __exportAll({
|
|
10299
10640
|
SEND_NEXUS_ERROR__AMBIGUOUS_FEE_SOURCE: () => SEND_NEXUS_ERROR__AMBIGUOUS_FEE_SOURCE,
|
|
10300
10641
|
SEND_NEXUS_ERROR__ARITHMETIC_OVERFLOW: () => SEND_NEXUS_ERROR__ARITHMETIC_OVERFLOW,
|
|
10642
|
+
SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED: () => SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED,
|
|
10643
|
+
SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH: () => SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH,
|
|
10301
10644
|
SEND_NEXUS_ERROR__DUPLICATE_AUTH_PLATFORM_NAME: () => SEND_NEXUS_ERROR__DUPLICATE_AUTH_PLATFORM_NAME,
|
|
10302
10645
|
SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY: () => SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY,
|
|
10303
10646
|
SEND_NEXUS_ERROR__INSUFFICIENT_STAKE: () => SEND_NEXUS_ERROR__INSUFFICIENT_STAKE,
|
|
@@ -10305,7 +10648,6 @@ var errors_exports = /* @__PURE__ */ __exportAll({
|
|
|
10305
10648
|
SEND_NEXUS_ERROR__INVALID_AUTHORITY: () => SEND_NEXUS_ERROR__INVALID_AUTHORITY,
|
|
10306
10649
|
SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_INDEX: () => SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_INDEX,
|
|
10307
10650
|
SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_NAME: () => SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_NAME,
|
|
10308
|
-
SEND_NEXUS_ERROR__INVALID_CREATOR_ID: () => SEND_NEXUS_ERROR__INVALID_CREATOR_ID,
|
|
10309
10651
|
SEND_NEXUS_ERROR__INVALID_DESTINATION: () => SEND_NEXUS_ERROR__INVALID_DESTINATION,
|
|
10310
10652
|
SEND_NEXUS_ERROR__INVALID_FEE_PRESET: () => SEND_NEXUS_ERROR__INVALID_FEE_PRESET,
|
|
10311
10653
|
SEND_NEXUS_ERROR__INVALID_MINT: () => SEND_NEXUS_ERROR__INVALID_MINT,
|
|
@@ -10339,6 +10681,7 @@ var errors_exports = /* @__PURE__ */ __exportAll({
|
|
|
10339
10681
|
SEND_NEXUS_ERROR__TOO_MANY_AUTH_PLATFORMS: () => SEND_NEXUS_ERROR__TOO_MANY_AUTH_PLATFORMS,
|
|
10340
10682
|
SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE: () => SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE,
|
|
10341
10683
|
SEND_NEXUS_ERROR__UNAUTHORIZED: () => SEND_NEXUS_ERROR__UNAUTHORIZED,
|
|
10684
|
+
SEND_NEXUS_ERROR__UNUSED7012: () => SEND_NEXUS_ERROR__UNUSED7012,
|
|
10342
10685
|
SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_INVALID: () => SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_INVALID,
|
|
10343
10686
|
SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY: () => SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY,
|
|
10344
10687
|
SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT: () => SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT,
|
|
@@ -10725,7 +11068,6 @@ var pdas_exports = /* @__PURE__ */ __exportAll({
|
|
|
10725
11068
|
GLOBAL_CONFIG_PDA_ADDRESS: () => GLOBAL_CONFIG_PDA_ADDRESS,
|
|
10726
11069
|
STAKING_CONFIG_PDA_ADDRESS: () => STAKING_CONFIG_PDA_ADDRESS,
|
|
10727
11070
|
findAltRegistryPda: () => findAltRegistryPda,
|
|
10728
|
-
findCreatorFeeConfigPda: () => findCreatorFeeConfigPda,
|
|
10729
11071
|
findDefaultFeePresetPda: () => findDefaultFeePresetPda,
|
|
10730
11072
|
findDefaultPartnerMetadataPda: () => findDefaultPartnerMetadataPda,
|
|
10731
11073
|
findDefaultPartnerPda: () => findDefaultPartnerPda,
|
|
@@ -12139,13 +12481,6 @@ function sendNexusProgram() {
|
|
|
12139
12481
|
fetchAllMaybe: (addresses, config) => fetchAllMaybeAltRegistry(client.rpc, addresses, config),
|
|
12140
12482
|
fetchMaybe: (address, config) => fetchMaybeAltRegistry(client.rpc, address, config)
|
|
12141
12483
|
}),
|
|
12142
|
-
creatorFeeConfig: Object.freeze({
|
|
12143
|
-
...getCreatorFeeConfigCodec(),
|
|
12144
|
-
fetch: (address, config) => fetchCreatorFeeConfig(client.rpc, address, config),
|
|
12145
|
-
fetchAll: (addresses, config) => fetchAllCreatorFeeConfig(client.rpc, addresses, config),
|
|
12146
|
-
fetchAllMaybe: (addresses, config) => fetchAllMaybeCreatorFeeConfig(client.rpc, addresses, config),
|
|
12147
|
-
fetchMaybe: (address, config) => fetchMaybeCreatorFeeConfig(client.rpc, address, config)
|
|
12148
|
-
}),
|
|
12149
12484
|
feePreset: Object.freeze({
|
|
12150
12485
|
...getFeePresetCodec(),
|
|
12151
12486
|
fetch: (address, config) => fetchFeePreset(client.rpc, address, config),
|
|
@@ -12243,7 +12578,6 @@ function sendNexusProgram() {
|
|
|
12243
12578
|
userStakePosition: findUserStakePositionPda,
|
|
12244
12579
|
userRewardDebt: findUserRewardDebtPda,
|
|
12245
12580
|
eventAuthority: findEventAuthorityPda,
|
|
12246
|
-
creatorFeeConfig: findCreatorFeeConfigPda,
|
|
12247
12581
|
altRegistry: findAltRegistryPda
|
|
12248
12582
|
},
|
|
12249
12583
|
identifyAccount: identifySendNexusAccount,
|
|
@@ -12261,7 +12595,8 @@ var fee_helpers_exports = /* @__PURE__ */ __exportAll({
|
|
|
12261
12595
|
effectiveFeeBps: () => effectiveFeeBps,
|
|
12262
12596
|
fetchPartnerFees: () => fetchPartnerFees
|
|
12263
12597
|
});
|
|
12264
|
-
/**
|
|
12598
|
+
/** Fetches the `PartnerConfig` of `partner` on `platformConfig`. Throws if it does not exist.
|
|
12599
|
+
* Use the `platformConfig` of the market you price. A partner's fees differ per platform. */
|
|
12265
12600
|
async function fetchPartnerFees(rpc, partner, platformConfig) {
|
|
12266
12601
|
const [partnerPda] = await findPartnerConfigPda({
|
|
12267
12602
|
partner,
|
|
@@ -12271,10 +12606,13 @@ async function fetchPartnerFees(rpc, partner, platformConfig) {
|
|
|
12271
12606
|
if (!maybeAccount.exists) throw new Error(`No fee config for partner ${partner} on platform ${platformConfig}`);
|
|
12272
12607
|
return maybeAccount.data;
|
|
12273
12608
|
}
|
|
12274
|
-
/**
|
|
12275
|
-
*
|
|
12276
|
-
|
|
12277
|
-
|
|
12609
|
+
/** Returns the `feeBps` a trade pays: the standard rate plus the decay premium. The standard rate
|
|
12610
|
+
* is the protocol and LP rates of `schedule` plus `creatorFeeBps`. `schedule` is the
|
|
12611
|
+
* `PartnerConfig`'s `launchpad` for a curve or `dex` for a pool. `creatorFeeBps` and `createdAt`
|
|
12612
|
+
* are the curve's or pool's. `schedule.maxCreatorFeeBps` has no effect. `createdAt` and `now`
|
|
12613
|
+
* are in unix seconds. */
|
|
12614
|
+
function effectiveFeeBps(schedule, createdAt, now, creatorFeeBps) {
|
|
12615
|
+
const standardFeeBps = schedule.protocolFeeBps + ("lpFeeBps" in schedule ? schedule.lpFeeBps : 0) + creatorFeeBps;
|
|
12278
12616
|
const premium = calculateFeeDecayPremium({
|
|
12279
12617
|
currentTimestamp: now,
|
|
12280
12618
|
createdAtTimestamp: createdAt,
|
|
@@ -12288,7 +12626,7 @@ function effectiveFeeBps(schedule, createdAt, now) {
|
|
|
12288
12626
|
//#region src/utils/chunk.ts
|
|
12289
12627
|
/** RPCs reject a `getMultipleAccounts` call past this many addresses. */
|
|
12290
12628
|
const MAX_ACCOUNTS_PER_REQUEST = 100;
|
|
12291
|
-
/**
|
|
12629
|
+
/** Calls `read` once per 100 addresses. Results follow `addresses` order. */
|
|
12292
12630
|
async function fetchInChunks(addresses, read) {
|
|
12293
12631
|
const chunks = [];
|
|
12294
12632
|
for (let start = 0; start < addresses.length; start += MAX_ACCOUNTS_PER_REQUEST) chunks.push(addresses.slice(start, start + MAX_ACCOUNTS_PER_REQUEST));
|
|
@@ -12323,9 +12661,8 @@ function compareAddresses(a, b) {
|
|
|
12323
12661
|
if (a > b) return 1;
|
|
12324
12662
|
return 0;
|
|
12325
12663
|
}
|
|
12326
|
-
/**
|
|
12327
|
-
*
|
|
12328
|
-
* `StakingConfig.rewardCount` rather than settle a short list. */
|
|
12664
|
+
/** Returns every registered reward mint, disabled mints included, sorted by address.
|
|
12665
|
+
* Throws if the count differs from `StakingConfig.rewardCount`. */
|
|
12329
12666
|
async function getRewardMints(rpc) {
|
|
12330
12667
|
const [stakingConfig] = findStakingConfigPda();
|
|
12331
12668
|
const [accounts, config] = await Promise.all([rpc.getProgramAccounts(SEND_NEXUS_PROGRAM_ADDRESS, {
|
|
@@ -12355,7 +12692,8 @@ async function resolveRewardMints(rpc, rewardMints) {
|
|
|
12355
12692
|
if (!hasProgramAccounts(rpc)) throw new Error("This RPC has no getProgramAccounts, so the reward registry cannot be read from chain. Pass rewardMints explicitly.");
|
|
12356
12693
|
return await getRewardMints(rpc);
|
|
12357
12694
|
}
|
|
12358
|
-
/**
|
|
12695
|
+
/** Builds one `settle` per reward mint. `source` is the mint list, or an RPC to read it from.
|
|
12696
|
+
* `settle` is idempotent. With a partial list, `stake` and `unstake` fail with `RewardsNotSettled`. */
|
|
12359
12697
|
async function buildSettleInstructions(source, params) {
|
|
12360
12698
|
const rewardMints = isRewardMintList(source) ? source : await resolveRewardMints(source, void 0);
|
|
12361
12699
|
return Promise.all(rewardMints.map((rewardMint) => getSettleInstructionAsync({
|
|
@@ -12376,10 +12714,11 @@ async function fetchMissingUserRewardDebts(rpc, user, stakingMint, knownRewardMi
|
|
|
12376
12714
|
return addr;
|
|
12377
12715
|
})), (chunk) => fetchEncodedAccounts(rpc, chunk));
|
|
12378
12716
|
const missingMints = [];
|
|
12379
|
-
for (const [index, rewardMint] of rewardMints.entries()) if (!encodedAccounts[index]
|
|
12717
|
+
for (const [index, rewardMint] of rewardMints.entries()) if (!accountIsCreated(encodedAccounts[index])) missingMints.push(rewardMint);
|
|
12380
12718
|
return missingMints;
|
|
12381
12719
|
}
|
|
12382
|
-
/**
|
|
12720
|
+
/** Builds a `create_user_reward_debt` for each missing `UserRewardDebt`, then a `settle` for every
|
|
12721
|
+
* reward mint. The user does not sign these instructions. */
|
|
12383
12722
|
async function buildStakingPreflightInstructions(rpc, params) {
|
|
12384
12723
|
const rewardMints = await resolveRewardMints(rpc, params.rewardMints);
|
|
12385
12724
|
const missingMints = await fetchMissingUserRewardDebts(rpc, params.user, params.stakingMint, rewardMints);
|
|
@@ -12392,13 +12731,14 @@ async function buildStakingPreflightInstructions(rpc, params) {
|
|
|
12392
12731
|
const settleIxs = await buildSettleInstructions(rewardMints, params);
|
|
12393
12732
|
return [...createIxs, ...settleIxs];
|
|
12394
12733
|
}
|
|
12395
|
-
/**
|
|
12734
|
+
/** Returns true if `stake` and `unstake` pass the `settledCount == rewardCount` check. */
|
|
12396
12735
|
async function isFullySettled(rpc, user, stakingMint) {
|
|
12397
12736
|
const [config, position] = await Promise.all([fetchStakingConfigData(rpc), fetchUserStakePositionData(rpc, user, stakingMint)]);
|
|
12398
12737
|
if (position === null) return config.rewardCount === 0;
|
|
12399
12738
|
return position.settledCount === config.rewardCount;
|
|
12400
12739
|
}
|
|
12401
|
-
/**
|
|
12740
|
+
/** The instruction fails with `RewardsNotSettled` until every mint is settled at the current
|
|
12741
|
+
* `stakeVersion`. Run `buildStakingPreflightInstructions` first. */
|
|
12402
12742
|
async function buildStakeInstruction(params) {
|
|
12403
12743
|
return getStakeInstructionAsync({
|
|
12404
12744
|
user: params.user,
|
|
@@ -12407,8 +12747,9 @@ async function buildStakeInstruction(params) {
|
|
|
12407
12747
|
amount: params.amount
|
|
12408
12748
|
});
|
|
12409
12749
|
}
|
|
12410
|
-
/**
|
|
12411
|
-
*
|
|
12750
|
+
/** Run `buildStakingPreflightInstructions` immediately before. The check also passes on an older
|
|
12751
|
+
* settle. Rewards since that settle then accrue on the smaller post-unstake amount, and the
|
|
12752
|
+
* difference is lost. */
|
|
12412
12753
|
async function buildUnstakeInstruction(params) {
|
|
12413
12754
|
return getUnstakeInstructionAsync({
|
|
12414
12755
|
user: params.user,
|
|
@@ -12417,8 +12758,8 @@ async function buildUnstakeInstruction(params) {
|
|
|
12417
12758
|
amount: params.amount
|
|
12418
12759
|
});
|
|
12419
12760
|
}
|
|
12420
|
-
/**
|
|
12421
|
-
* `
|
|
12761
|
+
/** Builds one `claim` per reward mint. A `create_user_reward_debt` comes before each `claim` whose
|
|
12762
|
+
* `UserRewardDebt` is missing: `claim` fails without it. Throws if a mint has no `RewardState`. */
|
|
12422
12763
|
async function buildClaimRewardsInstructions(rpc, params) {
|
|
12423
12764
|
const [stakingConfigAddr] = findStakingConfigPda();
|
|
12424
12765
|
const rewardMints = await resolveRewardMints(rpc, params.rewardMints);
|
|
@@ -12446,13 +12787,13 @@ async function buildClaimRewardsInstructions(rpc, params) {
|
|
|
12446
12787
|
const payer = params.payer ?? params.user;
|
|
12447
12788
|
return (await Promise.all(rewardMints.map(async (rewardMint, index) => {
|
|
12448
12789
|
const encodedRewardState = fetched[index];
|
|
12449
|
-
if (!encodedRewardState
|
|
12790
|
+
if (!accountIsCreated(encodedRewardState)) throw new Error(`RewardState not found for mint ${rewardMint}`);
|
|
12450
12791
|
const { vault } = rewardStateDecoder.decode(encodedRewardState.data);
|
|
12451
12792
|
const encodedMint = fetched[rewardMints.length + index];
|
|
12452
12793
|
const tokenProgram = encodedMint.exists ? encodedMint.programAddress : void 0;
|
|
12453
12794
|
const [destination] = await findAssociatedTokenPda(params.user.address, rewardMint, tokenProgram);
|
|
12454
12795
|
const instructions = [];
|
|
12455
|
-
if (!fetched[rewardMints.length * 2 + index]
|
|
12796
|
+
if (!accountIsCreated(fetched[rewardMints.length * 2 + index])) instructions.push(await getCreateUserRewardDebtInstructionAsync({
|
|
12456
12797
|
user: params.user.address,
|
|
12457
12798
|
payer,
|
|
12458
12799
|
stakingMint: params.stakingMint,
|
|
@@ -12470,7 +12811,8 @@ async function buildClaimRewardsInstructions(rpc, params) {
|
|
|
12470
12811
|
return instructions;
|
|
12471
12812
|
}))).flat();
|
|
12472
12813
|
}
|
|
12473
|
-
/**
|
|
12814
|
+
/** Returns the accounts of `withdraw_fees` for one reward mint. Without `tokenProgram`, reads it
|
|
12815
|
+
* from the mint account. Throws if that account does not exist. */
|
|
12474
12816
|
async function buildWithdrawFeesAccounts(rpc, params) {
|
|
12475
12817
|
const [stakingConfigAddr] = findStakingConfigPda();
|
|
12476
12818
|
const tokenProgram = params.tokenProgram ?? (await rpc.getAccountInfo(params.rewardMint, { encoding: "base64" }).send()).value?.owner;
|
|
@@ -12503,19 +12845,19 @@ async function fetchUserStakePositionData(rpc, user, stakingMint) {
|
|
|
12503
12845
|
const maybePosition = await fetchMaybeUserStakePosition(rpc, positionAddr);
|
|
12504
12846
|
return maybePosition.exists ? maybePosition.data : null;
|
|
12505
12847
|
}
|
|
12506
|
-
/**
|
|
12507
|
-
* can never store: it requires a token mint. */
|
|
12848
|
+
/** Returns false for the system program address, the value of an unbound staking mint. */
|
|
12508
12849
|
function isStakingMintBound(stakingMint) {
|
|
12509
|
-
return stakingMint !== SYSTEM_PROGRAM_ADDRESS;
|
|
12850
|
+
return stakingMint !== SYSTEM_PROGRAM_ADDRESS$3;
|
|
12510
12851
|
}
|
|
12511
|
-
/**
|
|
12852
|
+
/** Returns the staking mint. Throws if no staking mint is bound. A bound staking mint cannot change. */
|
|
12512
12853
|
async function fetchSendMint(rpc) {
|
|
12513
12854
|
const { stakingMint } = await fetchStakingConfigData(rpc);
|
|
12514
12855
|
if (!isStakingMintBound(stakingMint)) throw new Error("Staking mint not yet bound -- nexus not fully initialized");
|
|
12515
12856
|
return stakingMint;
|
|
12516
12857
|
}
|
|
12517
|
-
/**
|
|
12518
|
-
* its own mint
|
|
12858
|
+
/** Returns one entry per reward mint, in `knownRewardMints` order, else sorted by address. Each amount
|
|
12859
|
+
* is in the raw units of its own mint. Do not add them together. Each amount is what the vault sends,
|
|
12860
|
+
* before the mint's transfer fee. */
|
|
12519
12861
|
async function fetchPendingRewards(rpc, user, stakingMint, knownRewardMints) {
|
|
12520
12862
|
const rewardMints = await resolveRewardMints(rpc, knownRewardMints);
|
|
12521
12863
|
if (rewardMints.length === 0) return [];
|
|
@@ -12556,15 +12898,15 @@ async function fetchPendingRewards(rpc, user, stakingMint, knownRewardMints) {
|
|
|
12556
12898
|
return pdas.map(({ rewardMint }, index) => {
|
|
12557
12899
|
const base = index * 3;
|
|
12558
12900
|
const encodedDebt = encodedAccounts[base];
|
|
12559
|
-
const debt = encodedDebt
|
|
12901
|
+
const debt = accountIsCreated(encodedDebt) ? userRewardDebtDecoder.decode(encodedDebt.data) : {
|
|
12560
12902
|
owed: 0n,
|
|
12561
12903
|
accSnapshot: 0n,
|
|
12562
12904
|
amountSnapshot: stakeAmount
|
|
12563
12905
|
};
|
|
12564
12906
|
const encodedLaunchpadAccrual = encodedAccounts[base + 1];
|
|
12565
|
-
const launchpadAcc = encodedLaunchpadAccrual
|
|
12907
|
+
const launchpadAcc = accountIsCreated(encodedLaunchpadAccrual) ? rewardAccrualDecoder.decode(encodedLaunchpadAccrual.data).accPerToken : 0n;
|
|
12566
12908
|
const encodedDexAccrual = encodedAccounts[base + 2];
|
|
12567
|
-
const dexAcc = encodedDexAccrual
|
|
12909
|
+
const dexAcc = accountIsCreated(encodedDexAccrual) ? rewardAccrualDecoder.decode(encodedDexAccrual.data).accPerToken : 0n;
|
|
12568
12910
|
const basis = debt.amountSnapshot < stakeAmount ? debt.amountSnapshot : stakeAmount;
|
|
12569
12911
|
const combined = launchpadAcc + dexAcc;
|
|
12570
12912
|
const accrued = basis * (combined > debt.accSnapshot ? combined - debt.accSnapshot : 0n) / PRECISION;
|
|
@@ -12593,9 +12935,9 @@ var platform_exports = /* @__PURE__ */ __exportAll({
|
|
|
12593
12935
|
PLATFORM_SEED: () => PLATFORM_SEED,
|
|
12594
12936
|
findPlatformAddress: () => findPlatformAddress
|
|
12595
12937
|
});
|
|
12596
|
-
/**
|
|
12938
|
+
/** Seed of the platform PDA. A platform has no on-chain account. */
|
|
12597
12939
|
const PLATFORM_SEED = "platform";
|
|
12598
|
-
/**
|
|
12940
|
+
/** Derives the platform key for `name` under the nexus program. Each name gives a different platform. */
|
|
12599
12941
|
async function findPlatformAddress(name) {
|
|
12600
12942
|
return await getProgramDerivedAddress({
|
|
12601
12943
|
programAddress: SEND_NEXUS_PROGRAM_ADDRESS,
|
|
@@ -12637,8 +12979,9 @@ function readEntry(view, start) {
|
|
|
12637
12979
|
basisPoints: view.getUint16(start + FEE_BASIS_POINTS, true)
|
|
12638
12980
|
};
|
|
12639
12981
|
}
|
|
12640
|
-
/** `
|
|
12641
|
-
*
|
|
12982
|
+
/** Decodes the `TransferFeeConfig` extension of a mint. `owner` is the program that owns the account.
|
|
12983
|
+
* Returns `undefined` if the mint has no such extension. Throws `RangeError` if `owner` is not a
|
|
12984
|
+
* token program or `data` is not a valid mint. */
|
|
12642
12985
|
function decodeTransferFeeConfig(data, owner) {
|
|
12643
12986
|
if (owner === TOKEN_PROGRAM_ADDRESS) return void 0;
|
|
12644
12987
|
if (owner !== TOKEN_2022_PROGRAM_ADDRESS) throw new RangeError(`decodeTransferFeeConfig: ${owner} is not a token program`);
|
|
@@ -12667,7 +13010,7 @@ function decodeTransferFeeConfig(data, owner) {
|
|
|
12667
13010
|
offset = next;
|
|
12668
13011
|
}
|
|
12669
13012
|
}
|
|
12670
|
-
/**
|
|
13013
|
+
/** Returns the fee for `epoch`, as SPL `get_epoch_fee` does. The newer entry applies from its own epoch on. */
|
|
12671
13014
|
function transferFeeAtEpoch(config, epoch) {
|
|
12672
13015
|
const entry = epoch >= config.newer.epoch ? config.newer : config.older;
|
|
12673
13016
|
return {
|
|
@@ -12682,8 +13025,9 @@ function mintFeeAtEpoch(data, owner, epoch) {
|
|
|
12682
13025
|
function currentEpoch(rpc, commitment) {
|
|
12683
13026
|
return rpc.getEpochInfo(commitment === void 0 ? void 0 : { commitment }).send().then((info) => info.epoch);
|
|
12684
13027
|
}
|
|
12685
|
-
/**
|
|
12686
|
-
* the cluster
|
|
13028
|
+
/** Reads the transfer fee of each mint for `epoch`. The result is valid only for that epoch.
|
|
13029
|
+
* `epoch` defaults to the current cluster epoch, read with `getEpochInfo`. A mint without a
|
|
13030
|
+
* transfer fee maps to `undefined`. Throws if a mint account is missing or does not decode. */
|
|
12687
13031
|
async function fetchMintFees(rpc, mints, options) {
|
|
12688
13032
|
const commitment = options?.commitment;
|
|
12689
13033
|
const [epoch, accounts] = await Promise.all([options?.epoch ?? currentEpoch(rpc, commitment), fetchInChunks(mints, (chunk) => rpc.getMultipleAccounts(chunk, commitment === void 0 ? { encoding: "base64" } : {
|
|
@@ -12712,7 +13056,8 @@ function decodeMintInfo(mint, data, owner) {
|
|
|
12712
13056
|
tokenProgram: owner
|
|
12713
13057
|
};
|
|
12714
13058
|
}
|
|
12715
|
-
/**
|
|
13059
|
+
/** Reads the decimals and token program of `mint`. Throws if the account does not exist, a token
|
|
13060
|
+
* program does not own it, or it is too short for a mint. */
|
|
12716
13061
|
async function fetchQuoteMintInfo(rpc, mint, commitment) {
|
|
12717
13062
|
const { value } = await rpc.getAccountInfo(mint, commitment === void 0 ? { encoding: "base64" } : {
|
|
12718
13063
|
commitment,
|
|
@@ -12721,7 +13066,8 @@ async function fetchQuoteMintInfo(rpc, mint, commitment) {
|
|
|
12721
13066
|
if (!value) throw new Error(`fetchQuoteMintInfo: no account at ${mint}`);
|
|
12722
13067
|
return decodeMintInfo(mint, new Uint8Array(getBase64Encoder().encode(value.data[0])), value.owner);
|
|
12723
13068
|
}
|
|
12724
|
-
/**
|
|
13069
|
+
/** Reads the decimals and token program of each mint. Results follow `mints` order. Throws as
|
|
13070
|
+
* {@link fetchQuoteMintInfo} does. */
|
|
12725
13071
|
async function fetchQuoteMintInfos(rpc, mints, commitment) {
|
|
12726
13072
|
if (mints.length === 0) return [];
|
|
12727
13073
|
const value = await fetchInChunks(mints, (chunk) => rpc.getMultipleAccounts(chunk, commitment === void 0 ? { encoding: "base64" } : {
|
|
@@ -12738,9 +13084,7 @@ async function fetchQuoteMintInfos(rpc, mints, commitment) {
|
|
|
12738
13084
|
//#endregion
|
|
12739
13085
|
//#region src/utils/index.ts
|
|
12740
13086
|
var utils_exports = /* @__PURE__ */ __exportAll({
|
|
12741
|
-
|
|
12742
|
-
decodeCreatorId: () => decodeCreatorId,
|
|
12743
|
-
encodeCreatorId: () => encodeCreatorId,
|
|
13087
|
+
accountIsCreated: () => accountIsCreated,
|
|
12744
13088
|
fetchQuoteMintInfo: () => fetchQuoteMintInfo,
|
|
12745
13089
|
fetchQuoteMintInfos: () => fetchQuoteMintInfos,
|
|
12746
13090
|
findAssociatedTokenPda: () => findAssociatedTokenPda
|