@send-fun/sdk 1.2.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.
Files changed (51) hide show
  1. package/dist/index.cjs +281 -365
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +125 -166
  4. package/dist/index.d.cts.map +1 -1
  5. package/dist/index.d.mts +125 -166
  6. package/dist/index.d.mts.map +1 -1
  7. package/dist/index.mjs +281 -365
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +7 -7
  10. package/src/dex/generated/accounts/pool.ts +19 -7
  11. package/src/dex/generated/errors/sendDex.ts +16 -8
  12. package/src/dex/generated/events/creatorClaimEvent.ts +3 -2
  13. package/src/dex/generated/events/poolCreateEvent.ts +8 -2
  14. package/src/dex/generated/events/tokenCreateEvent.ts +8 -9
  15. package/src/dex/generated/events/tradeEvent.ts +9 -2
  16. package/src/dex/generated/instructions/claimCreatorFees.ts +21 -5
  17. package/src/{nexus → dex}/generated/pdas/creatorFeeConfig.ts +6 -6
  18. package/src/dex/generated/pdas/index.ts +1 -0
  19. package/src/dex/generated/plugins/sendDex.ts +3 -0
  20. package/src/launchpad/create.ts +9 -34
  21. package/src/launchpad/generated/accounts/bondingCurve.ts +23 -7
  22. package/src/launchpad/generated/errors/sendLaunchpad.ts +12 -4
  23. package/src/launchpad/generated/events/completeEvent.ts +3 -2
  24. package/src/launchpad/generated/events/creatorClaimEvent.ts +3 -2
  25. package/src/launchpad/generated/events/migrateEvent.ts +3 -2
  26. package/src/launchpad/generated/events/tokenCreateEvent.ts +10 -9
  27. package/src/launchpad/generated/events/tradeEvent.ts +9 -2
  28. package/src/launchpad/generated/instructions/claimCreatorFees.ts +17 -4
  29. package/src/launchpad/generated/instructions/createToken.ts +32 -50
  30. package/src/launchpad/generated/instructions/migrate.ts +79 -12
  31. package/src/launchpad/generated/pdas/creatorFeeConfig.ts +39 -0
  32. package/src/launchpad/generated/pdas/index.ts +1 -0
  33. package/src/launchpad/generated/plugins/sendLaunchpad.ts +3 -0
  34. package/src/launchpad/migrate.ts +7 -4
  35. package/src/nexus/fee-helpers.ts +8 -5
  36. package/src/nexus/generated/accounts/feePreset.ts +2 -2
  37. package/src/nexus/generated/accounts/index.ts +0 -1
  38. package/src/nexus/generated/accounts/partnerConfig.ts +9 -3
  39. package/src/nexus/generated/accounts/sendNexus.accounts.ts +0 -5
  40. package/src/nexus/generated/accounts/userRewardDebt.ts +3 -3
  41. package/src/nexus/generated/accounts/userStakePosition.ts +3 -3
  42. package/src/nexus/generated/errors/sendNexus.ts +12 -4
  43. package/src/nexus/generated/pdas/index.ts +0 -1
  44. package/src/nexus/generated/plugins/sendNexus.ts +0 -35
  45. package/src/nexus/generated/types/dexFees.ts +4 -4
  46. package/src/nexus/generated/types/index.ts +0 -1
  47. package/src/nexus/generated/types/launchpadFees.ts +4 -4
  48. package/src/utils/index.ts +0 -5
  49. package/src/nexus/generated/accounts/creatorFeeConfig.ts +0 -237
  50. package/src/nexus/generated/types/callerType.ts +0 -38
  51. package/src/utils/creator-hash.ts +0 -60
@@ -45,6 +45,7 @@ import {
45
45
  import {
46
46
  EVENT_AUTHORITY_PDA_ADDRESS,
47
47
  findBondingCurvePda,
48
+ findCreatorFeeConfigPda,
48
49
  MIGRATION_AUTHORITY_PDA_ADDRESS,
49
50
  } from '../pdas/index.js';
50
51
  import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
@@ -90,6 +91,7 @@ export type MigrateInstruction<
90
91
  'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
91
92
  TAccountProgram extends string | AccountMeta<string> =
92
93
  '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP',
94
+ TAccountDexCreatorFeeConfig extends string | AccountMeta<string> = string,
93
95
  TRemainingAccounts extends readonly AccountMeta<string>[] = [],
94
96
  > = Instruction<TProgram> &
95
97
  InstructionWithData<ReadonlyUint8Array> &
@@ -142,7 +144,7 @@ export type MigrateInstruction<
142
144
  ? ReadonlyAccount<TAccountNexusProgram>
143
145
  : TAccountNexusProgram,
144
146
  TAccountCreatorFeeConfig extends string
145
- ? ReadonlyAccount<TAccountCreatorFeeConfig>
147
+ ? WritableAccount<TAccountCreatorFeeConfig>
146
148
  : TAccountCreatorFeeConfig,
147
149
  TAccountBaseTokenProgram extends string
148
150
  ? ReadonlyAccount<TAccountBaseTokenProgram>
@@ -162,6 +164,9 @@ export type MigrateInstruction<
162
164
  TAccountProgram extends string
163
165
  ? ReadonlyAccount<TAccountProgram>
164
166
  : TAccountProgram,
167
+ TAccountDexCreatorFeeConfig extends string
168
+ ? WritableAccount<TAccountDexCreatorFeeConfig>
169
+ : TAccountDexCreatorFeeConfig,
165
170
  ...TRemainingAccounts,
166
171
  ]
167
172
  >;
@@ -209,6 +214,7 @@ export type MigrateAsyncInput<
209
214
  TAccountPoolLpAccount extends string = string,
210
215
  TAccountCreatorFeeConfig extends string = string,
211
216
  TAccountQuoteTokenProgram extends string = string,
217
+ TAccountDexCreatorFeeConfig extends string = string,
212
218
  > = {
213
219
  caller: TransactionSigner<TAccountCaller>;
214
220
  bondingCurve?: Address<TAccountBondingCurve>;
@@ -221,8 +227,9 @@ export type MigrateAsyncInput<
221
227
  poolBaseVault: Address<TAccountPoolBaseVault>;
222
228
  poolQuoteVault: Address<TAccountPoolQuoteVault>;
223
229
  poolLpAccount: Address<TAccountPoolLpAccount>;
224
- creatorFeeConfig: Address<TAccountCreatorFeeConfig>;
230
+ creatorFeeConfig?: Address<TAccountCreatorFeeConfig>;
225
231
  quoteTokenProgram: Address<TAccountQuoteTokenProgram>;
232
+ dexCreatorFeeConfig?: Address<TAccountDexCreatorFeeConfig>;
226
233
  };
227
234
 
228
235
  export async function getMigrateInstructionAsync<
@@ -239,6 +246,7 @@ export async function getMigrateInstructionAsync<
239
246
  TAccountPoolLpAccount extends string,
240
247
  TAccountCreatorFeeConfig extends string,
241
248
  TAccountQuoteTokenProgram extends string,
249
+ TAccountDexCreatorFeeConfig extends string,
242
250
  >(
243
251
  input: MigrateAsyncInput<
244
252
  TAccountCaller,
@@ -253,7 +261,8 @@ export async function getMigrateInstructionAsync<
253
261
  TAccountPoolQuoteVault,
254
262
  TAccountPoolLpAccount,
255
263
  TAccountCreatorFeeConfig,
256
- TAccountQuoteTokenProgram
264
+ TAccountQuoteTokenProgram,
265
+ TAccountDexCreatorFeeConfig
257
266
  >,
258
267
  ): Promise<
259
268
  MigrateInstruction<
@@ -279,7 +288,8 @@ export async function getMigrateInstructionAsync<
279
288
  'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
280
289
  '11111111111111111111111111111111',
281
290
  'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
282
- '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
291
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP',
292
+ TAccountDexCreatorFeeConfig
283
293
  >
284
294
  > {
285
295
  // Program address.
@@ -307,7 +317,7 @@ export async function getMigrateInstructionAsync<
307
317
  nexusProgram: { value: null, isWritable: false },
308
318
  creatorFeeConfig: {
309
319
  value: input.creatorFeeConfig ?? null,
310
- isWritable: false,
320
+ isWritable: true,
311
321
  },
312
322
  baseTokenProgram: { value: null, isWritable: false },
313
323
  quoteTokenProgram: {
@@ -318,6 +328,10 @@ export async function getMigrateInstructionAsync<
318
328
  systemProgram: { value: null, isWritable: false },
319
329
  eventAuthority: { value: null, isWritable: false },
320
330
  program: { value: null, isWritable: false },
331
+ dexCreatorFeeConfig: {
332
+ value: input.dexCreatorFeeConfig ?? null,
333
+ isWritable: true,
334
+ },
321
335
  };
322
336
  const accounts = originalAccounts as Record<
323
337
  keyof typeof originalAccounts,
@@ -445,6 +459,18 @@ export async function getMigrateInstructionAsync<
445
459
  accounts.nexusProgram.value =
446
460
  '7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX' as Address<'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX'>;
447
461
  }
462
+ if (!accounts.creatorFeeConfig.value) {
463
+ accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda({
464
+ baseMint: getAddressFromResolvedInstructionAccount(
465
+ 'baseMint',
466
+ accounts.baseMint.value,
467
+ ),
468
+ quoteMint: getAddressFromResolvedInstructionAccount(
469
+ 'quoteMint',
470
+ accounts.quoteMint.value,
471
+ ),
472
+ });
473
+ }
448
474
  if (!accounts.baseTokenProgram.value) {
449
475
  accounts.baseTokenProgram.value =
450
476
  'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb' as Address<'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'>;
@@ -464,6 +490,32 @@ export async function getMigrateInstructionAsync<
464
490
  accounts.program.value =
465
491
  '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP' as Address<'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'>;
466
492
  }
493
+ if (!accounts.dexCreatorFeeConfig.value) {
494
+ accounts.dexCreatorFeeConfig.value = await getProgramDerivedAddress({
495
+ programAddress:
496
+ '84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX' as Address<'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX'>,
497
+ seeds: [
498
+ getBytesEncoder().encode(
499
+ new Uint8Array([
500
+ 99, 114, 101, 97, 116, 111, 114, 95, 102, 101, 101, 95,
501
+ 99, 111, 110, 102, 105, 103,
502
+ ]),
503
+ ),
504
+ getAddressEncoder().encode(
505
+ getAddressFromResolvedInstructionAccount(
506
+ 'baseMint',
507
+ accounts.baseMint.value,
508
+ ),
509
+ ),
510
+ getAddressEncoder().encode(
511
+ getAddressFromResolvedInstructionAccount(
512
+ 'quoteMint',
513
+ accounts.quoteMint.value,
514
+ ),
515
+ ),
516
+ ],
517
+ });
518
+ }
467
519
 
468
520
  const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
469
521
  return Object.freeze({
@@ -493,6 +545,7 @@ export async function getMigrateInstructionAsync<
493
545
  getAccountMeta('systemProgram', accounts.systemProgram),
494
546
  getAccountMeta('eventAuthority', accounts.eventAuthority),
495
547
  getAccountMeta('program', accounts.program),
548
+ getAccountMeta('dexCreatorFeeConfig', accounts.dexCreatorFeeConfig),
496
549
  ],
497
550
  data: getMigrateInstructionDataEncoder().encode({}),
498
551
  programAddress,
@@ -519,7 +572,8 @@ export async function getMigrateInstructionAsync<
519
572
  'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
520
573
  '11111111111111111111111111111111',
521
574
  'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
522
- '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
575
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP',
576
+ TAccountDexCreatorFeeConfig
523
577
  >);
524
578
  }
525
579
 
@@ -537,6 +591,7 @@ export type MigrateInput<
537
591
  TAccountPoolLpAccount extends string = string,
538
592
  TAccountCreatorFeeConfig extends string = string,
539
593
  TAccountQuoteTokenProgram extends string = string,
594
+ TAccountDexCreatorFeeConfig extends string = string,
540
595
  > = {
541
596
  caller: TransactionSigner<TAccountCaller>;
542
597
  bondingCurve: Address<TAccountBondingCurve>;
@@ -551,6 +606,7 @@ export type MigrateInput<
551
606
  poolLpAccount: Address<TAccountPoolLpAccount>;
552
607
  creatorFeeConfig: Address<TAccountCreatorFeeConfig>;
553
608
  quoteTokenProgram: Address<TAccountQuoteTokenProgram>;
609
+ dexCreatorFeeConfig: Address<TAccountDexCreatorFeeConfig>;
554
610
  };
555
611
 
556
612
  export function getMigrateInstruction<
@@ -567,6 +623,7 @@ export function getMigrateInstruction<
567
623
  TAccountPoolLpAccount extends string,
568
624
  TAccountCreatorFeeConfig extends string,
569
625
  TAccountQuoteTokenProgram extends string,
626
+ TAccountDexCreatorFeeConfig extends string,
570
627
  >(
571
628
  input: MigrateInput<
572
629
  TAccountCaller,
@@ -581,7 +638,8 @@ export function getMigrateInstruction<
581
638
  TAccountPoolQuoteVault,
582
639
  TAccountPoolLpAccount,
583
640
  TAccountCreatorFeeConfig,
584
- TAccountQuoteTokenProgram
641
+ TAccountQuoteTokenProgram,
642
+ TAccountDexCreatorFeeConfig
585
643
  >,
586
644
  ): MigrateInstruction<
587
645
  typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
@@ -606,7 +664,8 @@ export function getMigrateInstruction<
606
664
  'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
607
665
  '11111111111111111111111111111111',
608
666
  'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
609
- '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
667
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP',
668
+ TAccountDexCreatorFeeConfig
610
669
  > {
611
670
  // Program address.
612
671
  const programAddress = SEND_LAUNCHPAD_PROGRAM_ADDRESS;
@@ -633,7 +692,7 @@ export function getMigrateInstruction<
633
692
  nexusProgram: { value: null, isWritable: false },
634
693
  creatorFeeConfig: {
635
694
  value: input.creatorFeeConfig ?? null,
636
- isWritable: false,
695
+ isWritable: true,
637
696
  },
638
697
  baseTokenProgram: { value: null, isWritable: false },
639
698
  quoteTokenProgram: {
@@ -644,6 +703,10 @@ export function getMigrateInstruction<
644
703
  systemProgram: { value: null, isWritable: false },
645
704
  eventAuthority: { value: null, isWritable: false },
646
705
  program: { value: null, isWritable: false },
706
+ dexCreatorFeeConfig: {
707
+ value: input.dexCreatorFeeConfig ?? null,
708
+ isWritable: true,
709
+ },
647
710
  };
648
711
  const accounts = originalAccounts as Record<
649
712
  keyof typeof originalAccounts,
@@ -714,6 +777,7 @@ export function getMigrateInstruction<
714
777
  getAccountMeta('systemProgram', accounts.systemProgram),
715
778
  getAccountMeta('eventAuthority', accounts.eventAuthority),
716
779
  getAccountMeta('program', accounts.program),
780
+ getAccountMeta('dexCreatorFeeConfig', accounts.dexCreatorFeeConfig),
717
781
  ],
718
782
  data: getMigrateInstructionDataEncoder().encode({}),
719
783
  programAddress,
@@ -740,7 +804,8 @@ export function getMigrateInstruction<
740
804
  'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
741
805
  '11111111111111111111111111111111',
742
806
  'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
743
- '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
807
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP',
808
+ TAccountDexCreatorFeeConfig
744
809
  >);
745
810
  }
746
811
 
@@ -772,6 +837,7 @@ export type ParsedMigrateInstruction<
772
837
  systemProgram: TAccountMetas[19];
773
838
  eventAuthority: TAccountMetas[20];
774
839
  program: TAccountMetas[21];
840
+ dexCreatorFeeConfig: TAccountMetas[22];
775
841
  };
776
842
  data: MigrateInstructionData;
777
843
  };
@@ -792,12 +858,12 @@ export function parseMigrateInstruction<
792
858
  error.name = 'InstructionDiscriminatorMismatchError';
793
859
  throw error;
794
860
  }
795
- if (instruction.accounts.length < 22) {
861
+ if (instruction.accounts.length < 23) {
796
862
  throw new SolanaError(
797
863
  SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
798
864
  {
799
865
  actualAccountMetas: instruction.accounts.length,
800
- expectedAccountMetas: 22,
866
+ expectedAccountMetas: 23,
801
867
  },
802
868
  );
803
869
  }
@@ -834,6 +900,7 @@ export function parseMigrateInstruction<
834
900
  systemProgram: getNextAccount(),
835
901
  eventAuthority: getNextAccount(),
836
902
  program: getNextAccount(),
903
+ dexCreatorFeeConfig: getNextAccount(),
837
904
  },
838
905
  data: getMigrateInstructionDataDecoder().decode(instruction.data),
839
906
  };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ getAddressEncoder,
11
+ getBytesEncoder,
12
+ getProgramDerivedAddress,
13
+ type Address,
14
+ type ProgramDerivedAddress,
15
+ } from '@solana/kit';
16
+ import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
17
+
18
+ export type CreatorFeeConfigSeeds = {
19
+ baseMint: Address;
20
+ quoteMint: Address;
21
+ };
22
+
23
+ export async function findCreatorFeeConfigPda(
24
+ seeds: CreatorFeeConfigSeeds,
25
+ ): Promise<ProgramDerivedAddress> {
26
+ return await getProgramDerivedAddress({
27
+ programAddress: SEND_LAUNCHPAD_PROGRAM_ADDRESS,
28
+ seeds: [
29
+ getBytesEncoder().encode(
30
+ new Uint8Array([
31
+ 99, 114, 101, 97, 116, 111, 114, 95, 102, 101, 101, 95, 99,
32
+ 111, 110, 102, 105, 103,
33
+ ]),
34
+ ),
35
+ getAddressEncoder().encode(seeds.baseMint),
36
+ getAddressEncoder().encode(seeds.quoteMint),
37
+ ],
38
+ });
39
+ }
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  export * from './bondingCurve.js';
10
+ export * from './creatorFeeConfig.js';
10
11
  export * from './eventAuthority.js';
11
12
  export * from './globalConfig.js';
12
13
  export * from './migrationAuthority.js';
@@ -76,6 +76,7 @@ import {
76
76
  } from '../instructions/index.js';
77
77
  import {
78
78
  findBondingCurvePda,
79
+ findCreatorFeeConfigPda,
79
80
  findEventAuthorityPda,
80
81
  findGlobalConfigPda,
81
82
  findMigrationAuthorityPda,
@@ -150,6 +151,7 @@ export type SendLaunchpadPluginInstructions = {
150
151
  export type SendLaunchpadPluginPdas = {
151
152
  bondingCurve: typeof findBondingCurvePda;
152
153
  eventAuthority: typeof findEventAuthorityPda;
154
+ creatorFeeConfig: typeof findCreatorFeeConfigPda;
153
155
  rewardAccrual: typeof findRewardAccrualPda;
154
156
  globalConfig: typeof findGlobalConfigPda;
155
157
  wsolRewardAccrual: typeof findWsolRewardAccrualPda;
@@ -299,6 +301,7 @@ export function sendLaunchpadProgram() {
299
301
  pdas: {
300
302
  bondingCurve: findBondingCurvePda,
301
303
  eventAuthority: findEventAuthorityPda,
304
+ creatorFeeConfig: findCreatorFeeConfigPda,
302
305
  rewardAccrual: findRewardAccrualPda,
303
306
  globalConfig: findGlobalConfigPda,
304
307
  wsolRewardAccrual: findWsolRewardAccrualPda,
@@ -1,6 +1,7 @@
1
1
  import type { Address, Instruction, TransactionSigner } from '@solana/kit';
2
2
  import { TOKEN_2022_PROGRAM_ADDRESS } from '../constants.js';
3
3
  import { findAssociatedTokenPda } from '../utils/pda.js';
4
+ import { findCreatorFeeConfigPda as findDexCreatorFeeConfigPda } from '../dex/generated/pdas/creatorFeeConfig.js';
4
5
  import { findPoolPda } from '../dex/generated/pdas/pool.js';
5
6
  import { findLpMintPda } from '../dex/generated/pdas/lpMint.js';
6
7
  import { getMigrateInstructionAsync } from './generated/instructions/migrate.js';
@@ -9,8 +10,6 @@ export interface MigrateParams {
9
10
  caller: TransactionSigner;
10
11
  baseMint: Address;
11
12
  quoteMint: Address;
12
- /** `bondingCurve.creatorFeeConfig`. `migrate` rejects any other address. */
13
- creatorFeeConfig: Address;
14
13
  quoteTokenProgram: Address;
15
14
  }
16
15
 
@@ -19,7 +18,7 @@ export async function buildMigrateInstruction(
19
18
  ): Promise<Instruction> {
20
19
  const { quoteTokenProgram } = params;
21
20
 
22
- const [[pool], [lpMint]] = await Promise.all([
21
+ const [[pool], [lpMint], [dexCreatorFeeConfig]] = await Promise.all([
23
22
  findPoolPda({
24
23
  baseMint: params.baseMint,
25
24
  quoteMint: params.quoteMint,
@@ -28,6 +27,10 @@ export async function buildMigrateInstruction(
28
27
  baseMint: params.baseMint,
29
28
  quoteMint: params.quoteMint,
30
29
  }),
30
+ findDexCreatorFeeConfigPda({
31
+ baseMint: params.baseMint,
32
+ quoteMint: params.quoteMint,
33
+ }),
31
34
  ]);
32
35
 
33
36
  const [[poolBaseVault], [poolQuoteVault], [poolLpAccount]] =
@@ -45,7 +48,7 @@ export async function buildMigrateInstruction(
45
48
  caller: params.caller,
46
49
  baseMint: params.baseMint,
47
50
  quoteMint: params.quoteMint,
48
- creatorFeeConfig: params.creatorFeeConfig,
51
+ dexCreatorFeeConfig,
49
52
  poolBaseVault,
50
53
  poolQuoteVault,
51
54
  poolLpAccount,
@@ -28,18 +28,21 @@ export async function fetchPartnerFees(
28
28
  return maybeAccount.data;
29
29
  }
30
30
 
31
- /** Returns the `feeBps` a trade pays: the standard rate plus the decay premium. `schedule` is the
32
- * `PartnerConfig`'s `launchpad` for a curve or `dex` for a pool. `createdAt` is the curve's or
33
- * pool's `createdAt`. Both times are in unix seconds. */
31
+ /** Returns the `feeBps` a trade pays: the standard rate plus the decay premium. The standard rate
32
+ * is the protocol and LP rates of `schedule` plus `creatorFeeBps`. `schedule` is the
33
+ * `PartnerConfig`'s `launchpad` for a curve or `dex` for a pool. `creatorFeeBps` and `createdAt`
34
+ * are the curve's or pool's. `schedule.maxCreatorFeeBps` has no effect. `createdAt` and `now`
35
+ * are in unix seconds. */
34
36
  export function effectiveFeeBps(
35
37
  schedule: LaunchpadFees | DexFees,
36
38
  createdAt: bigint,
37
39
  now: bigint,
40
+ creatorFeeBps: number,
38
41
  ): number {
39
42
  const standardFeeBps =
40
43
  schedule.protocolFeeBps +
41
- schedule.creatorFeeBps +
42
- ('lpFeeBps' in schedule ? schedule.lpFeeBps : 0);
44
+ ('lpFeeBps' in schedule ? schedule.lpFeeBps : 0) +
45
+ creatorFeeBps;
43
46
  const premium = calculateFeeDecayPremium({
44
47
  currentTimestamp: now,
45
48
  createdAtTimestamp: createdAt,
@@ -101,7 +101,7 @@ export function getFeePresetEncoder(): Encoder<FeePresetArgs> {
101
101
  ['launchpad', getLaunchpadFeesEncoder()],
102
102
  ['dex', getDexFeesEncoder()],
103
103
  ['platformConfig', getAddressEncoder()],
104
- ['reserved', fixEncoderSize(getBytesEncoder(), 32)],
104
+ ['reserved', fixEncoderSize(getBytesEncoder(), 64)],
105
105
  ]),
106
106
  (value) => ({ ...value, discriminator: FEE_PRESET_DISCRIMINATOR }),
107
107
  );
@@ -118,7 +118,7 @@ export function getFeePresetDecoder(): Decoder<FeePreset> {
118
118
  ['launchpad', getLaunchpadFeesDecoder()],
119
119
  ['dex', getDexFeesDecoder()],
120
120
  ['platformConfig', getAddressDecoder()],
121
- ['reserved', fixDecoderSize(getBytesDecoder(), 32)],
121
+ ['reserved', fixDecoderSize(getBytesDecoder(), 64)],
122
122
  ]);
123
123
  }
124
124
 
@@ -7,7 +7,6 @@
7
7
  */
8
8
 
9
9
  export * from './altRegistry.js';
10
- export * from './creatorFeeConfig.js';
11
10
  export * from './feePreset.js';
12
11
  export * from './globalConfig.js';
13
12
  export * from './partnerConfig.js';
@@ -22,6 +22,8 @@ import {
22
22
  getBytesEncoder,
23
23
  getStructDecoder,
24
24
  getStructEncoder,
25
+ getU16Decoder,
26
+ getU16Encoder,
25
27
  getU8Decoder,
26
28
  getU8Encoder,
27
29
  transformEncoder,
@@ -70,6 +72,7 @@ export type PartnerConfig = {
70
72
  launchpad: LaunchpadFees;
71
73
  dex: DexFees;
72
74
  platformConfig: Address;
75
+ allowedCreatorFeeModes: number;
73
76
  reserved: ReadonlyUint8Array;
74
77
  };
75
78
 
@@ -82,6 +85,7 @@ export type PartnerConfigArgs = {
82
85
  launchpad: LaunchpadFeesArgs;
83
86
  dex: DexFeesArgs;
84
87
  platformConfig: Address;
88
+ allowedCreatorFeeModes: number;
85
89
  reserved: ReadonlyUint8Array;
86
90
  };
87
91
 
@@ -98,7 +102,8 @@ export function getPartnerConfigEncoder(): FixedSizeEncoder<PartnerConfigArgs> {
98
102
  ['launchpad', getLaunchpadFeesEncoder()],
99
103
  ['dex', getDexFeesEncoder()],
100
104
  ['platformConfig', getAddressEncoder()],
101
- ['reserved', fixEncoderSize(getBytesEncoder(), 32)],
105
+ ['allowedCreatorFeeModes', getU16Encoder()],
106
+ ['reserved', fixEncoderSize(getBytesEncoder(), 256)],
102
107
  ]),
103
108
  (value) => ({ ...value, discriminator: PARTNER_CONFIG_DISCRIMINATOR }),
104
109
  );
@@ -116,7 +121,8 @@ export function getPartnerConfigDecoder(): FixedSizeDecoder<PartnerConfig> {
116
121
  ['launchpad', getLaunchpadFeesDecoder()],
117
122
  ['dex', getDexFeesDecoder()],
118
123
  ['platformConfig', getAddressDecoder()],
119
- ['reserved', fixDecoderSize(getBytesDecoder(), 32)],
124
+ ['allowedCreatorFeeModes', getU16Decoder()],
125
+ ['reserved', fixDecoderSize(getBytesDecoder(), 256)],
120
126
  ]);
121
127
  }
122
128
 
@@ -242,5 +248,5 @@ export async function fetchAllMaybePartnerConfig(
242
248
  }
243
249
 
244
250
  export function getPartnerConfigSize(): number {
245
- return 173;
251
+ return 399;
246
252
  }
@@ -13,7 +13,6 @@ import {
13
13
  } from '@solana/kit';
14
14
  import { SEND_NEXUS_PROGRAM_ADDRESS } from '../programs/index.js';
15
15
  import { ALT_REGISTRY_DISCRIMINATOR } from './altRegistry.js';
16
- import { CREATOR_FEE_CONFIG_DISCRIMINATOR } from './creatorFeeConfig.js';
17
16
  import { FEE_PRESET_DISCRIMINATOR } from './feePreset.js';
18
17
  import { GLOBAL_CONFIG_DISCRIMINATOR } from './globalConfig.js';
19
18
  import { PARTNER_CONFIG_DISCRIMINATOR } from './partnerConfig.js';
@@ -26,7 +25,6 @@ import { USER_STAKE_POSITION_DISCRIMINATOR } from './userStakePosition.js';
26
25
  /** Account kinds of the sendNexus program. */
27
26
  export type SendNexusAccountType =
28
27
  | 'altRegistry'
29
- | 'creatorFeeConfig'
30
28
  | 'feePreset'
31
29
  | 'globalConfig'
32
30
  | 'partnerConfig'
@@ -54,9 +52,6 @@ export function identifySendNexusAccount(
54
52
  if (containsBytes(data, ALT_REGISTRY_DISCRIMINATOR, 0)) {
55
53
  return 'altRegistry';
56
54
  }
57
- if (containsBytes(data, CREATOR_FEE_CONFIG_DISCRIMINATOR, 0)) {
58
- return 'creatorFeeConfig';
59
- }
60
55
  if (containsBytes(data, FEE_PRESET_DISCRIMINATOR, 0)) {
61
56
  return 'feePreset';
62
57
  }
@@ -99,7 +99,7 @@ export function getUserRewardDebtEncoder(): FixedSizeEncoder<UserRewardDebtArgs>
99
99
  ['amountSnapshot', getU64Encoder()],
100
100
  ['settledVersion', getU32Encoder()],
101
101
  ['owed', getU64Encoder()],
102
- ['reserved', fixEncoderSize(getBytesEncoder(), 32)],
102
+ ['reserved', fixEncoderSize(getBytesEncoder(), 64)],
103
103
  ]),
104
104
  (value) => ({
105
105
  ...value,
@@ -122,7 +122,7 @@ export function getUserRewardDebtDecoder(): FixedSizeDecoder<UserRewardDebt> {
122
122
  ['amountSnapshot', getU64Decoder()],
123
123
  ['settledVersion', getU32Decoder()],
124
124
  ['owed', getU64Decoder()],
125
- ['reserved', fixDecoderSize(getBytesDecoder(), 32)],
125
+ ['reserved', fixDecoderSize(getBytesDecoder(), 64)],
126
126
  ]);
127
127
  }
128
128
 
@@ -254,5 +254,5 @@ export async function fetchAllMaybeUserRewardDebt(
254
254
  }
255
255
 
256
256
  export function getUserRewardDebtSize(): number {
257
- return 182;
257
+ return 214;
258
258
  }
@@ -90,7 +90,7 @@ export function getUserStakePositionEncoder(): FixedSizeEncoder<UserStakePositio
90
90
  ['amount', getU64Encoder()],
91
91
  ['stakeVersion', getU32Encoder()],
92
92
  ['settledCount', getU16Encoder()],
93
- ['reserved', fixEncoderSize(getBytesEncoder(), 32)],
93
+ ['reserved', fixEncoderSize(getBytesEncoder(), 128)],
94
94
  ]),
95
95
  (value) => ({
96
96
  ...value,
@@ -110,7 +110,7 @@ export function getUserStakePositionDecoder(): FixedSizeDecoder<UserStakePositio
110
110
  ['amount', getU64Decoder()],
111
111
  ['stakeVersion', getU32Decoder()],
112
112
  ['settledCount', getU16Decoder()],
113
- ['reserved', fixDecoderSize(getBytesDecoder(), 32)],
113
+ ['reserved', fixDecoderSize(getBytesDecoder(), 128)],
114
114
  ]);
115
115
  }
116
116
 
@@ -251,5 +251,5 @@ export async function fetchAllMaybeUserStakePosition(
251
251
  }
252
252
 
253
253
  export function getUserStakePositionSize(): number {
254
- return 120;
254
+ return 216;
255
255
  }
@@ -98,12 +98,16 @@ export const SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 0x1b61; // 7009
98
98
  export const SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 0x1b62; // 7010
99
99
  /** NothingToClaim: Nothing to claim */
100
100
  export const SEND_NEXUS_ERROR__NOTHING_TO_CLAIM = 0x1b63; // 7011
101
- /** InvalidCreatorId: Creator identity is not a decodable wallet address */
102
- export const SEND_NEXUS_ERROR__INVALID_CREATOR_ID = 0x1b64; // 7012
101
+ /** Unused7012: Unused */
102
+ export const SEND_NEXUS_ERROR__UNUSED7012 = 0x1b64; // 7012
103
103
  /** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
104
104
  export const SEND_NEXUS_ERROR__QUOTE_MINT_PRICE_UNSET = 0x1b65; // 7013
105
105
  /** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
106
106
  export const SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 0x1b66; // 7014
107
+ /** CreatorFeeTooHigh: Creator fee exceeds the partner's maximum */
108
+ export const SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH = 0x1b67; // 7015
109
+ /** CreatorFeeModeNotAllowed: Creator fee mode is not allowed by the partner config */
110
+ export const SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED = 0x1b68; // 7016
107
111
  /** InsufficientLiquidity: Insufficient liquidity */
108
112
  export const SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY = 0x1bbc; // 7100
109
113
  /** InvalidAmount: Invalid amount */
@@ -112,6 +116,8 @@ export const SEND_NEXUS_ERROR__INVALID_AMOUNT = 0x1bbd; // 7101
112
116
  export type SendNexusError =
113
117
  | typeof SEND_NEXUS_ERROR__AMBIGUOUS_FEE_SOURCE
114
118
  | typeof SEND_NEXUS_ERROR__ARITHMETIC_OVERFLOW
119
+ | typeof SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED
120
+ | typeof SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH
115
121
  | typeof SEND_NEXUS_ERROR__DUPLICATE_AUTH_PLATFORM_NAME
116
122
  | typeof SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY
117
123
  | typeof SEND_NEXUS_ERROR__INSUFFICIENT_STAKE
@@ -119,7 +125,6 @@ export type SendNexusError =
119
125
  | typeof SEND_NEXUS_ERROR__INVALID_AUTHORITY
120
126
  | typeof SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_INDEX
121
127
  | typeof SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_NAME
122
- | typeof SEND_NEXUS_ERROR__INVALID_CREATOR_ID
123
128
  | typeof SEND_NEXUS_ERROR__INVALID_DESTINATION
124
129
  | typeof SEND_NEXUS_ERROR__INVALID_FEE_PRESET
125
130
  | typeof SEND_NEXUS_ERROR__INVALID_MINT
@@ -153,6 +158,7 @@ export type SendNexusError =
153
158
  | typeof SEND_NEXUS_ERROR__TOO_MANY_AUTH_PLATFORMS
154
159
  | typeof SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE
155
160
  | typeof SEND_NEXUS_ERROR__UNAUTHORIZED
161
+ | typeof SEND_NEXUS_ERROR__UNUSED7012
156
162
  | typeof SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_INVALID
157
163
  | typeof SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY
158
164
  | typeof SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT
@@ -161,6 +167,8 @@ export type SendNexusError =
161
167
  export const sendNexusErrorMessages: Record<SendNexusError, string> = {
162
168
  [SEND_NEXUS_ERROR__AMBIGUOUS_FEE_SOURCE]: `Cannot specify both fee_preset and custom_fees`,
163
169
  [SEND_NEXUS_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
170
+ [SEND_NEXUS_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED]: `Creator fee mode is not allowed by the partner config`,
171
+ [SEND_NEXUS_ERROR__CREATOR_FEE_TOO_HIGH]: `Creator fee exceeds the partner's maximum`,
164
172
  [SEND_NEXUS_ERROR__DUPLICATE_AUTH_PLATFORM_NAME]: `Duplicate auth platform name`,
165
173
  [SEND_NEXUS_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
166
174
  [SEND_NEXUS_ERROR__INSUFFICIENT_STAKE]: `Insufficient stake balance`,
@@ -168,7 +176,6 @@ export const sendNexusErrorMessages: Record<SendNexusError, string> = {
168
176
  [SEND_NEXUS_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
169
177
  [SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_INDEX]: `Invalid auth platform index`,
170
178
  [SEND_NEXUS_ERROR__INVALID_AUTH_PLATFORM_NAME]: `Invalid auth platform name`,
171
- [SEND_NEXUS_ERROR__INVALID_CREATOR_ID]: `Creator identity is not a decodable wallet address`,
172
179
  [SEND_NEXUS_ERROR__INVALID_DESTINATION]: `Invalid destination account`,
173
180
  [SEND_NEXUS_ERROR__INVALID_FEE_PRESET]: `Invalid fee configuration`,
174
181
  [SEND_NEXUS_ERROR__INVALID_MINT]: `Invalid mint`,
@@ -202,6 +209,7 @@ export const sendNexusErrorMessages: Record<SendNexusError, string> = {
202
209
  [SEND_NEXUS_ERROR__TOO_MANY_AUTH_PLATFORMS]: `Too many auth platforms (max 255)`,
203
210
  [SEND_NEXUS_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
204
211
  [SEND_NEXUS_ERROR__UNAUTHORIZED]: `Unauthorized`,
212
+ [SEND_NEXUS_ERROR__UNUSED7012]: `Unused`,
205
213
  [SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
206
214
  [SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
207
215
  [SEND_NEXUS_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT]: `User token account mint does not match the trade`,
@@ -7,7 +7,6 @@
7
7
  */
8
8
 
9
9
  export * from './altRegistry.js';
10
- export * from './creatorFeeConfig.js';
11
10
  export * from './defaultFeePreset.js';
12
11
  export * from './defaultPartner.js';
13
12
  export * from './defaultPartnerMetadata.js';