@pump-fun/pump-sdk 1.27.0 → 1.28.0-devnet.2

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/src/sdk.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import { AnchorProvider, Program } from "@coral-xyz/anchor";
2
+ import {
3
+ coinCreatorVaultAtaPda,
4
+ coinCreatorVaultAuthorityPda,
5
+ } from "@pump-fun/pump-swap-sdk";
2
6
  import {
3
7
  createAssociatedTokenAccountIdempotentInstruction,
4
- ASSOCIATED_TOKEN_PROGRAM_ID,
5
8
  getAssociatedTokenAddressSync,
6
9
  NATIVE_MINT,
7
10
  TOKEN_2022_PROGRAM_ID,
@@ -13,20 +16,37 @@ import {
13
16
  PublicKey,
14
17
  TransactionInstruction,
15
18
  } from "@solana/web3.js";
16
- import pumpIdl from "./idl/pump.json";
17
- import { Pump } from "./idl/pump";
18
19
  import BN from "bn.js";
20
+
21
+ import { getStaticRandomFeeRecipient } from "./bondingCurve";
19
22
  import {
20
23
  NoShareholdersError,
21
24
  TooManyShareholdersError,
22
25
  ZeroShareError,
23
- ShareCalculationOverflowError,
24
26
  InvalidShareTotalError,
25
27
  DuplicateShareholderError,
26
- PoolRequiredForGraduatedError,
27
28
  } from "./errors";
28
-
29
- import { bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, getGlobalParamsPda, getMayhemStatePda, getSolVaultPda, getTokenVaultPda, pumpPoolAuthorityPda, ammCreatorVaultPda, feeSharingConfigPda } from "./pda";
29
+ import { getFeeRecipient } from "./fees";
30
+ import { Pump } from "./idl/pump";
31
+ import pumpIdl from "./idl/pump.json";
32
+ import { PumpAmm } from "./idl/pump_amm";
33
+ import PumpAmmIdl from "./idl/pump_amm.json";
34
+ import { PumpFees } from "./idl/pump_fees";
35
+ import PumpFeesIdl from "./idl/pump_fees.json";
36
+ import { OFFLINE_PUMP_PROGRAM } from "./onlineSdk";
37
+ import {
38
+ bondingCurvePda,
39
+ canonicalPumpPoolPda,
40
+ creatorVaultPda,
41
+ getGlobalParamsPda,
42
+ getMayhemStatePda,
43
+ getSolVaultPda,
44
+ getTokenVaultPda,
45
+ pumpPoolAuthorityPda,
46
+ feeSharingConfigPda,
47
+ userVolumeAccumulatorPda,
48
+ socialFeePda,
49
+ } from "./pda";
30
50
  import {
31
51
  BondingCurve,
32
52
  FeeConfig,
@@ -37,25 +57,20 @@ import {
37
57
  SharingConfig,
38
58
  DistributeCreatorFeesEvent,
39
59
  MinimumDistributableFeeEvent,
60
+ Platform,
61
+ SUPPORTED_SOCIAL_PLATFORMS,
62
+ platformToString,
40
63
  } from "./state";
41
- import { getStaticRandomFeeRecipient } from "./bondingCurve";
42
- import { getFeeRecipient } from "./fees";
43
- import { OFFLINE_PUMP_PROGRAM } from "./onlineSdk";
44
- import PumpAmmIdl from "./idl/pump_amm.json";
45
- import { PumpAmm } from "./idl/pump_amm";
46
- import PumpFeesIdl from "./idl/pump_fees.json";
47
- import { PumpFees } from "./idl/pump_fees";
48
- import { coinCreatorVaultAtaPda, coinCreatorVaultAuthorityPda, PUMP_AMM_EVENT_AUTHORITY_PDA, pumpAmmPda } from "@pump-fun/pump-swap-sdk";
49
64
 
50
65
  export function getPumpProgram(connection: Connection): Program<Pump> {
51
66
  return new Program(
52
67
  pumpIdl as Pump,
53
- new AnchorProvider(connection, null as any, {})
68
+ new AnchorProvider(connection, null as any, {}),
54
69
  );
55
70
  }
56
71
 
57
72
  export const PUMP_PROGRAM_ID = new PublicKey(
58
- "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"
73
+ "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",
59
74
  );
60
75
 
61
76
  export function getPumpAmmProgram(connection: Connection): Program<PumpAmm> {
@@ -65,9 +80,7 @@ export function getPumpAmmProgram(connection: Connection): Program<PumpAmm> {
65
80
  );
66
81
  }
67
82
 
68
- export function getPumpFeeProgram(
69
- connection: Connection,
70
- ): Program<PumpFees> {
83
+ export function getPumpFeeProgram(connection: Connection): Program<PumpFees> {
71
84
  return new Program(
72
85
  PumpFeesIdl as PumpFees,
73
86
  new AnchorProvider(connection, null as any, {}),
@@ -75,21 +88,21 @@ export function getPumpFeeProgram(
75
88
  }
76
89
 
77
90
  export const PUMP_AMM_PROGRAM_ID = new PublicKey(
78
- "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"
91
+ "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",
79
92
  );
80
93
 
81
94
  export const MAYHEM_PROGRAM_ID = new PublicKey(
82
- "MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e"
95
+ "MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e",
83
96
  );
84
97
 
85
98
  export const PUMP_FEE_PROGRAM_ID = new PublicKey(
86
- "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
99
+ "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ",
87
100
  );
88
101
 
89
102
  export const BONDING_CURVE_NEW_SIZE = 151;
90
103
 
91
104
  export const PUMP_TOKEN_MINT = new PublicKey(
92
- "pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn"
105
+ "pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn",
93
106
  );
94
107
 
95
108
  export const MAX_SHAREHOLDERS = 10;
@@ -104,40 +117,40 @@ export class PumpSdk {
104
117
  // Create offline programs for fee and AMM
105
118
  this.offlinePumpFeeProgram = new Program(
106
119
  PumpFeesIdl as PumpFees,
107
- new AnchorProvider(null as any, null as any, {})
120
+ new AnchorProvider(null as any, null as any, {}),
108
121
  );
109
122
  this.offlinePumpAmmProgram = new Program(
110
123
  PumpAmmIdl as PumpAmm,
111
- new AnchorProvider(null as any, null as any, {})
124
+ new AnchorProvider(null as any, null as any, {}),
112
125
  );
113
126
  }
114
127
 
115
128
  decodeGlobal(accountInfo: AccountInfo<Buffer>): Global {
116
129
  return this.offlinePumpProgram.coder.accounts.decode<Global>(
117
130
  "global",
118
- accountInfo.data
131
+ accountInfo.data,
119
132
  );
120
133
  }
121
134
 
122
135
  decodeFeeConfig(accountInfo: AccountInfo<Buffer>): FeeConfig {
123
136
  return this.offlinePumpProgram.coder.accounts.decode<FeeConfig>(
124
137
  "feeConfig",
125
- accountInfo.data
138
+ accountInfo.data,
126
139
  );
127
140
  }
128
141
 
129
142
  decodeBondingCurve(accountInfo: AccountInfo<Buffer>): BondingCurve {
130
143
  return this.offlinePumpProgram.coder.accounts.decode<BondingCurve>(
131
144
  "bondingCurve",
132
- accountInfo.data
145
+ accountInfo.data,
133
146
  );
134
147
  }
135
148
 
136
149
  decodeBondingCurveNullable(
137
- accountInfo: AccountInfo<Buffer>
150
+ accountInfo: AccountInfo<Buffer>,
138
151
  ): BondingCurve | null {
139
152
  try {
140
- let data = accountInfo.data;
153
+ const data = accountInfo.data;
141
154
  // Ensure buffer is at least 82 bytes
142
155
  if (data.length < 82) {
143
156
  const padded = Buffer.alloc(82);
@@ -149,37 +162,37 @@ export class PumpSdk {
149
162
  }
150
163
 
151
164
  return this.decodeBondingCurve(accountInfo);
152
- } catch (e) {
153
- console.warn("Failed to decode bonding curve", e);
165
+ } catch (error) {
166
+ console.warn("Failed to decode bonding curve", error);
154
167
  return null;
155
168
  }
156
169
  }
157
170
 
158
171
  decodeGlobalVolumeAccumulator(
159
- accountInfo: AccountInfo<Buffer>
172
+ accountInfo: AccountInfo<Buffer>,
160
173
  ): GlobalVolumeAccumulator {
161
174
  return this.offlinePumpProgram.coder.accounts.decode<GlobalVolumeAccumulator>(
162
175
  "globalVolumeAccumulator",
163
- accountInfo.data
176
+ accountInfo.data,
164
177
  );
165
178
  }
166
179
 
167
180
  decodeUserVolumeAccumulator(
168
- accountInfo: AccountInfo<Buffer>
181
+ accountInfo: AccountInfo<Buffer>,
169
182
  ): UserVolumeAccumulator {
170
183
  return this.offlinePumpProgram.coder.accounts.decode<UserVolumeAccumulator>(
171
184
  "userVolumeAccumulator",
172
- accountInfo.data
185
+ accountInfo.data,
173
186
  );
174
187
  }
175
188
 
176
189
  decodeUserVolumeAccumulatorNullable(
177
- accountInfo: AccountInfo<Buffer>
190
+ accountInfo: AccountInfo<Buffer>,
178
191
  ): UserVolumeAccumulator | null {
179
192
  try {
180
193
  return this.decodeUserVolumeAccumulator(accountInfo);
181
- } catch (e) {
182
- console.warn("Failed to decode user volume accumulator", e);
194
+ } catch (error) {
195
+ console.warn("Failed to decode user volume accumulator", error);
183
196
  return null;
184
197
  }
185
198
  }
@@ -227,6 +240,7 @@ export class PumpSdk {
227
240
  creator,
228
241
  user,
229
242
  mayhemMode,
243
+ cashback = false,
230
244
  }: {
231
245
  mint: PublicKey;
232
246
  name: string;
@@ -235,9 +249,10 @@ export class PumpSdk {
235
249
  creator: PublicKey;
236
250
  user: PublicKey;
237
251
  mayhemMode: boolean;
252
+ cashback?: boolean;
238
253
  }): Promise<TransactionInstruction> {
239
254
  return await this.offlinePumpProgram.methods
240
- .createV2(name, symbol, uri, creator, mayhemMode)
255
+ .createV2(name, symbol, uri, creator, mayhemMode, [cashback ?? false])
241
256
  .accountsPartial({
242
257
  mint,
243
258
  user,
@@ -281,7 +296,7 @@ export class PumpSdk {
281
296
  await this.extendAccountInstruction({
282
297
  account: bondingCurvePda(mint),
283
298
  user,
284
- })
299
+ }),
285
300
  );
286
301
  }
287
302
 
@@ -289,7 +304,7 @@ export class PumpSdk {
289
304
  mint,
290
305
  user,
291
306
  true,
292
- tokenProgram
307
+ tokenProgram,
293
308
  );
294
309
 
295
310
  if (!associatedUserAccountInfo) {
@@ -299,8 +314,8 @@ export class PumpSdk {
299
314
  associatedUser,
300
315
  user,
301
316
  mint,
302
- tokenProgram
303
- )
317
+ tokenProgram,
318
+ ),
304
319
  );
305
320
  }
306
321
 
@@ -316,7 +331,7 @@ export class PumpSdk {
316
331
  slippage,
317
332
  tokenProgram,
318
333
  mayhemMode: bondingCurve.isMayhemMode,
319
- })
334
+ }),
320
335
  );
321
336
 
322
337
  return instructions;
@@ -333,6 +348,7 @@ export class PumpSdk {
333
348
  amount,
334
349
  solAmount,
335
350
  mayhemMode,
351
+ cashback = false,
336
352
  }: {
337
353
  global: Global;
338
354
  mint: PublicKey;
@@ -344,12 +360,13 @@ export class PumpSdk {
344
360
  amount: BN;
345
361
  solAmount: BN;
346
362
  mayhemMode: boolean;
363
+ cashback?: boolean;
347
364
  }): Promise<TransactionInstruction[]> {
348
365
  const associatedUser = getAssociatedTokenAddressSync(
349
366
  mint,
350
367
  user,
351
368
  true,
352
- TOKEN_2022_PROGRAM_ID
369
+ TOKEN_2022_PROGRAM_ID,
353
370
  );
354
371
  return [
355
372
  await this.createV2Instruction({
@@ -360,6 +377,7 @@ export class PumpSdk {
360
377
  creator,
361
378
  user,
362
379
  mayhemMode,
380
+ cashback,
363
381
  }),
364
382
  await this.extendAccountInstruction({
365
383
  account: bondingCurvePda(mint),
@@ -370,7 +388,7 @@ export class PumpSdk {
370
388
  associatedUser,
371
389
  user,
372
390
  mint,
373
- TOKEN_2022_PROGRAM_ID
391
+ TOKEN_2022_PROGRAM_ID,
374
392
  ),
375
393
  await this.buyInstruction({
376
394
  global,
@@ -422,7 +440,7 @@ export class PumpSdk {
422
440
  user,
423
441
  associatedUser,
424
442
  user,
425
- mint
443
+ mint,
426
444
  ),
427
445
  await this.buyInstruction({
428
446
  global,
@@ -470,7 +488,7 @@ export class PumpSdk {
470
488
  feeRecipient: getFeeRecipient(global, mayhemMode),
471
489
  amount,
472
490
  solAmount: solAmount.add(
473
- solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000))
491
+ solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000)),
474
492
  ),
475
493
  tokenProgram,
476
494
  });
@@ -487,6 +505,7 @@ export class PumpSdk {
487
505
  slippage,
488
506
  tokenProgram = TOKEN_PROGRAM_ID,
489
507
  mayhemMode = false,
508
+ cashback = false,
490
509
  }: {
491
510
  global: Global;
492
511
  bondingCurveAccountInfo: AccountInfo<Buffer>;
@@ -498,6 +517,7 @@ export class PumpSdk {
498
517
  slippage: number;
499
518
  tokenProgram: PublicKey;
500
519
  mayhemMode: boolean;
520
+ cashback?: boolean;
501
521
  }): Promise<TransactionInstruction[]> {
502
522
  const instructions: TransactionInstruction[] = [];
503
523
 
@@ -506,7 +526,7 @@ export class PumpSdk {
506
526
  await this.extendAccountInstruction({
507
527
  account: bondingCurvePda(mint),
508
528
  user,
509
- })
529
+ }),
510
530
  );
511
531
  }
512
532
 
@@ -518,10 +538,11 @@ export class PumpSdk {
518
538
  feeRecipient: getFeeRecipient(global, mayhemMode),
519
539
  amount,
520
540
  solAmount: solAmount.sub(
521
- solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000))
541
+ solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000)),
522
542
  ),
523
543
  tokenProgram,
524
- })
544
+ cashback,
545
+ }),
525
546
  );
526
547
 
527
548
  return instructions;
@@ -559,7 +580,7 @@ export class PumpSdk {
559
580
  mint,
560
581
  bondingCurve,
561
582
  true,
562
- tokenProgram
583
+ tokenProgram,
563
584
  );
564
585
 
565
586
  const poolAuthority = pumpPoolAuthorityPda(mint);
@@ -567,7 +588,7 @@ export class PumpSdk {
567
588
  mint,
568
589
  poolAuthority,
569
590
  true,
570
- tokenProgram
591
+ tokenProgram,
571
592
  );
572
593
 
573
594
  const pool = canonicalPumpPoolPda(mint);
@@ -575,7 +596,7 @@ export class PumpSdk {
575
596
  mint,
576
597
  pool,
577
598
  true,
578
- tokenProgram
599
+ tokenProgram,
579
600
  );
580
601
  return this.offlinePumpProgram.methods
581
602
  .migrate()
@@ -591,7 +612,7 @@ export class PumpSdk {
591
612
  }
592
613
 
593
614
  async syncUserVolumeAccumulator(
594
- user: PublicKey
615
+ user: PublicKey,
595
616
  ): Promise<TransactionInstruction> {
596
617
  return await this.offlinePumpProgram.methods
597
618
  .syncUserVolumeAccumulator()
@@ -631,7 +652,7 @@ export class PumpSdk {
631
652
  }
632
653
 
633
654
  async closeUserVolumeAccumulator(
634
- user: PublicKey
655
+ user: PublicKey,
635
656
  ): Promise<TransactionInstruction> {
636
657
  return await this.offlinePumpProgram.methods
637
658
  .closeUserVolumeAccumulator()
@@ -662,7 +683,7 @@ export class PumpSdk {
662
683
  mint,
663
684
  user,
664
685
  true,
665
- tokenProgram
686
+ tokenProgram,
666
687
  ),
667
688
  mint,
668
689
  creator,
@@ -699,7 +720,7 @@ export class PumpSdk {
699
720
  associatedUser,
700
721
  user,
701
722
  creatorVault: creatorVaultPda(creator),
702
- tokenProgram: tokenProgram,
723
+ tokenProgram,
703
724
  })
704
725
  .instruction();
705
726
  }
@@ -712,6 +733,7 @@ export class PumpSdk {
712
733
  solAmount,
713
734
  feeRecipient = getStaticRandomFeeRecipient(),
714
735
  tokenProgram = TOKEN_PROGRAM_ID,
736
+ cashback = false,
715
737
  }: {
716
738
  user: PublicKey;
717
739
  mint: PublicKey;
@@ -720,6 +742,7 @@ export class PumpSdk {
720
742
  solAmount: BN;
721
743
  feeRecipient: PublicKey;
722
744
  tokenProgram: PublicKey;
745
+ cashback?: boolean;
723
746
  }): Promise<TransactionInstruction> {
724
747
  return await this.getSellInstructionInternal({
725
748
  user,
@@ -729,6 +752,7 @@ export class PumpSdk {
729
752
  amount,
730
753
  solAmount,
731
754
  tokenProgram,
755
+ cashback,
732
756
  });
733
757
  }
734
758
 
@@ -740,6 +764,7 @@ export class PumpSdk {
740
764
  amount,
741
765
  solAmount,
742
766
  tokenProgram,
767
+ cashback = false,
743
768
  }: {
744
769
  user: PublicKey;
745
770
  mint: PublicKey;
@@ -748,7 +773,9 @@ export class PumpSdk {
748
773
  amount: BN;
749
774
  solAmount: BN;
750
775
  tokenProgram: PublicKey;
776
+ cashback?: boolean;
751
777
  }): Promise<TransactionInstruction> {
778
+ const userVolumeAccumulator = userVolumeAccumulatorPda(user);
752
779
  return await this.offlinePumpProgram.methods
753
780
  .sell(amount, solAmount)
754
781
  .accountsPartial({
@@ -758,12 +785,23 @@ export class PumpSdk {
758
785
  mint,
759
786
  user,
760
787
  true,
761
- tokenProgram
788
+ tokenProgram,
762
789
  ),
763
790
  user,
764
791
  creatorVault: creatorVaultPda(creator),
765
- tokenProgram: tokenProgram,
792
+ tokenProgram,
766
793
  })
794
+ .remainingAccounts(
795
+ cashback
796
+ ? [
797
+ {
798
+ pubkey: userVolumeAccumulator,
799
+ isWritable: true,
800
+ isSigner: false,
801
+ },
802
+ ]
803
+ : [],
804
+ )
767
805
  .instruction();
768
806
  }
769
807
 
@@ -771,9 +809,9 @@ export class PumpSdk {
771
809
  * Creates a fee sharing configuration for a token.
772
810
  *
773
811
  * @param params - Parameters for creating a fee sharing configuration
774
- * @param params.creator - The creator of the token
812
+ * @param params.creator - The creator of the token. Must sign the transaction.
775
813
  * @param params.mint - The mint address of the token
776
- * @param params.pool - The pool address of the token (null for ungraduated coins)
814
+ * @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
777
815
  */
778
816
  async createFeeSharingConfig({
779
817
  creator,
@@ -794,7 +832,6 @@ export class PumpSdk {
794
832
  .instruction();
795
833
  }
796
834
 
797
-
798
835
  /**
799
836
  * Updates the fee shares for a token's creator fee distribution.
800
837
  *
@@ -803,7 +840,6 @@ export class PumpSdk {
803
840
  * @param params.mint - The mint address of the token
804
841
  * @param params.curShareholders - Array of current shareholders
805
842
  * @param params.newShareholders - Array of new shareholders and their share percentages
806
- *
807
843
  * @requirements for newShareholders:
808
844
  * - Must contain at least 1 shareholder (cannot be empty)
809
845
  * - Maximum of 10 shareholders allowed
@@ -811,13 +847,11 @@ export class PumpSdk {
811
847
  * - Total shares must equal exactly 10,000 basis points (100%)
812
848
  * - No duplicate addresses allowed
813
849
  * - shareBps is in basis points where 1 bps = 0.01% (e.g., 1500 = 15%)
814
- *
815
850
  * @throws {NoShareholdersError} If shareholders array is empty
816
851
  * @throws {TooManyShareholdersError} If more than 10 shareholders
817
852
  * @throws {ZeroShareError} If any shareholder has zero or negative shares
818
853
  * @throws {InvalidShareTotalError} If total shares don't equal 10,000 basis points
819
854
  * @throws {DuplicateShareholderError} If duplicate addresses are found
820
- *
821
855
  * @example
822
856
  * ```typescript
823
857
  * const instruction = await PUMP_SDK.updateFeeShares({
@@ -848,7 +882,10 @@ export class PumpSdk {
848
882
  }
849
883
 
850
884
  if (newShareholders.length > MAX_SHAREHOLDERS) {
851
- throw new TooManyShareholdersError(newShareholders.length, MAX_SHAREHOLDERS);
885
+ throw new TooManyShareholdersError(
886
+ newShareholders.length,
887
+ MAX_SHAREHOLDERS,
888
+ );
852
889
  }
853
890
 
854
891
  let totalShares = 0;
@@ -872,26 +909,31 @@ export class PumpSdk {
872
909
  }
873
910
 
874
911
  const sharingConfigPda = feeSharingConfigPda(mint);
875
- const coinCreatorVaultAuthority = coinCreatorVaultAuthorityPda(sharingConfigPda);
912
+ const coinCreatorVaultAuthority =
913
+ coinCreatorVaultAuthorityPda(sharingConfigPda);
876
914
 
877
915
  return await this.offlinePumpFeeProgram.methods
878
916
  .updateFeeShares(
879
- newShareholders.map(sh => ({
917
+ newShareholders.map((sh) => ({
880
918
  address: sh.address,
881
919
  shareBps: sh.shareBps,
882
- }))
920
+ })),
883
921
  )
884
922
  .accountsPartial({
885
923
  authority,
886
924
  mint,
887
- coinCreatorVaultAta: coinCreatorVaultAtaPda(coinCreatorVaultAuthority, NATIVE_MINT, TOKEN_PROGRAM_ID),
925
+ coinCreatorVaultAta: coinCreatorVaultAtaPda(
926
+ coinCreatorVaultAuthority,
927
+ NATIVE_MINT,
928
+ TOKEN_PROGRAM_ID,
929
+ ),
888
930
  })
889
931
  .remainingAccounts(
890
932
  currentShareholders.map((pubkey) => ({
891
933
  pubkey,
892
934
  isWritable: true,
893
935
  isSigner: false,
894
- }))
936
+ })),
895
937
  )
896
938
  .instruction();
897
939
  }
@@ -899,7 +941,7 @@ export class PumpSdk {
899
941
  decodeDistributeCreatorFeesEvent(data: Buffer): DistributeCreatorFeesEvent {
900
942
  return this.offlinePumpProgram.coder.types.decode<DistributeCreatorFeesEvent>(
901
943
  "distributeCreatorFeesEvent",
902
- data
944
+ data,
903
945
  );
904
946
  }
905
947
 
@@ -923,7 +965,7 @@ export class PumpSdk {
923
965
  pubkey: shareholder.address,
924
966
  isWritable: true,
925
967
  isSigner: false,
926
- }))
968
+ })),
927
969
  )
928
970
  .instruction();
929
971
  }
@@ -931,7 +973,7 @@ export class PumpSdk {
931
973
  decodeMinimumDistributableFee(data: Buffer): MinimumDistributableFeeEvent {
932
974
  return this.offlinePumpProgram.coder.types.decode<MinimumDistributableFeeEvent>(
933
975
  "minimumDistributableFeeEvent",
934
- data
976
+ data,
935
977
  );
936
978
  }
937
979
 
@@ -955,12 +997,235 @@ export class PumpSdk {
955
997
  pubkey: shareholder.address,
956
998
  isWritable: true,
957
999
  isSigner: false,
958
- }))
1000
+ })),
959
1001
  )
960
1002
  .instruction();
961
1003
  }
1004
+
1005
+ async claimCashbackInstruction({
1006
+ user,
1007
+ }: {
1008
+ user: PublicKey;
1009
+ }): Promise<TransactionInstruction> {
1010
+ return await this.offlinePumpProgram.methods
1011
+ .claimCashback()
1012
+ .accountsPartial({
1013
+ user,
1014
+ })
1015
+ .instruction();
1016
+ }
1017
+
1018
+ /**
1019
+ * Creates a social fee PDA that can accumulate fees for a social media user.
1020
+ *
1021
+ * @param params.payer - Any signer account that pays for the transaction.
1022
+ * @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
1023
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
1024
+ * @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
1025
+ * In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
1026
+ */
1027
+ async createSocialFeePda({
1028
+ payer,
1029
+ userId,
1030
+ platform,
1031
+ }: {
1032
+ payer: PublicKey;
1033
+ userId: string;
1034
+ platform: Platform;
1035
+ }): Promise<TransactionInstruction> {
1036
+ if (!SUPPORTED_SOCIAL_PLATFORMS.includes(platform)) {
1037
+ const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map((supportedPlatform) =>
1038
+ platformToString(supportedPlatform),
1039
+ ).join(", ");
1040
+ throw new Error(
1041
+ `Unsupported platform "${platform}" for userId "${userId}". Supported platforms: ${supportedPlatformNames}.`,
1042
+ );
1043
+ }
1044
+
1045
+ return await this.offlinePumpFeeProgram.methods
1046
+ .createSocialFeePda(userId, platform)
1047
+ .accountsPartial({
1048
+ payer,
1049
+ socialFeePda: socialFeePda(userId, platform),
1050
+ })
1051
+ .instruction();
1052
+ }
1053
+
1054
+ normalizeSocialShareholders({
1055
+ newShareholders,
1056
+ }: {
1057
+ newShareholders: Array<{
1058
+ shareBps: number;
1059
+ address?: PublicKey;
1060
+ userId?: string;
1061
+ platform?: Platform;
1062
+ }>;
1063
+ }): {
1064
+ normalizedShareholders: Shareholder[];
1065
+ socialRecipientsToCreate: Map<string, { userId: string; platform: Platform }>;
1066
+ } {
1067
+ const socialRecipientsToCreate = new Map<
1068
+ string,
1069
+ { userId: string; platform: Platform }
1070
+ >();
1071
+ const normalizedShareholders: Shareholder[] = newShareholders.map(
1072
+ (shareholder) => {
1073
+ if (shareholder.address) {
1074
+ return {
1075
+ address: shareholder.address,
1076
+ shareBps: shareholder.shareBps,
1077
+ };
1078
+ }
1079
+
1080
+ if (
1081
+ typeof shareholder.userId === "string" &&
1082
+ typeof shareholder.platform === "number"
1083
+ ) {
1084
+ if (!SUPPORTED_SOCIAL_PLATFORMS.includes(shareholder.platform)) {
1085
+ const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map((platform) =>
1086
+ platformToString(platform),
1087
+ ).join(", ");
1088
+ throw new Error(
1089
+ `Unsupported platform "${shareholder.platform}" for userId "${shareholder.userId}". Supported platforms: ${supportedPlatformNames}.`,
1090
+ );
1091
+ }
1092
+
1093
+ const recipientPda = socialFeePda(shareholder.userId, shareholder.platform);
1094
+ socialRecipientsToCreate.set(recipientPda.toBase58(), {
1095
+ userId: shareholder.userId,
1096
+ platform: shareholder.platform,
1097
+ });
1098
+
1099
+ return {
1100
+ address: recipientPda,
1101
+ shareBps: shareholder.shareBps,
1102
+ };
1103
+ }
1104
+
1105
+ throw new Error(
1106
+ "Each new shareholder must provide either an address or both userId and platform.",
1107
+ );
1108
+ },
1109
+ );
1110
+
1111
+ return {
1112
+ normalizedShareholders,
1113
+ socialRecipientsToCreate,
1114
+ };
1115
+ }
1116
+
1117
+ /**
1118
+ * Wrapper around `updateSharingConfig` that resolves social recipients and
1119
+ * initializes any missing social recipient PDAs before updating fee shares.
1120
+ *
1121
+ * Requirements:
1122
+ * - `authority` must sign the transaction.
1123
+ *
1124
+ * Warning:
1125
+ * - sharing config must exist for that mint
1126
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
1127
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
1128
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
1129
+ */
1130
+ async updateSharingConfigWithSocialRecipients({
1131
+ authority,
1132
+ mint,
1133
+ currentShareholders,
1134
+ newShareholders,
1135
+ }: {
1136
+ authority: PublicKey;
1137
+ mint: PublicKey;
1138
+ currentShareholders: PublicKey[];
1139
+ newShareholders: Array<{
1140
+ shareBps: number;
1141
+ address?: PublicKey;
1142
+ userId?: string;
1143
+ platform?: Platform;
1144
+ }>;
1145
+ }): Promise<TransactionInstruction[]> {
1146
+ const instructions: TransactionInstruction[] = [];
1147
+ const { normalizedShareholders, socialRecipientsToCreate } =
1148
+ this.normalizeSocialShareholders({ newShareholders });
1149
+
1150
+ for (const recipient of socialRecipientsToCreate.values()) {
1151
+ instructions.push(
1152
+ await this.createSocialFeePda({
1153
+ payer: authority,
1154
+ userId: recipient.userId,
1155
+ platform: recipient.platform,
1156
+ }),
1157
+ );
1158
+ }
1159
+
1160
+ instructions.push(
1161
+ await this.updateFeeShares({
1162
+ authority,
1163
+ mint,
1164
+ currentShareholders,
1165
+ newShareholders: normalizedShareholders,
1166
+ }),
1167
+ );
1168
+
1169
+ return instructions;
1170
+ }
1171
+
1172
+ /**
1173
+ * Wrapper around `createFeeSharingConfig` that resolves social recipients and
1174
+ * initializes any missing social recipient PDAs before updating fee shares.
1175
+ *
1176
+ * Requirements:
1177
+ * - `creator` must sign the transaction.
1178
+ * - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
1179
+ *
1180
+ * Warning:
1181
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
1182
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
1183
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
1184
+ */
1185
+ async createSharingConfigWithSocialRecipients({
1186
+ creator,
1187
+ mint,
1188
+ pool,
1189
+ newShareholders,
1190
+ }: {
1191
+ creator: PublicKey;
1192
+ mint: PublicKey;
1193
+ pool: PublicKey | null;
1194
+ newShareholders: Array<{
1195
+ shareBps: number;
1196
+ address?: PublicKey;
1197
+ userId?: string;
1198
+ platform?: Platform;
1199
+ }>;
1200
+ }): Promise<TransactionInstruction[]> {
1201
+ const instructions: TransactionInstruction[] = [];
1202
+
1203
+ instructions.push(
1204
+ await this.createFeeSharingConfig({
1205
+ creator,
1206
+ mint,
1207
+ pool,
1208
+ }),
1209
+ );
1210
+
1211
+ instructions.push(
1212
+ ...(await this.updateSharingConfigWithSocialRecipients({
1213
+ authority: creator,
1214
+ mint,
1215
+ currentShareholders: [creator],
1216
+ newShareholders,
1217
+ })),
1218
+ );
1219
+
1220
+ return instructions;
1221
+ }
1222
+
1223
+ claimSocialFeePda() {
1224
+ throw new Error("This function can only be called by pump and is not supported");
1225
+ }
962
1226
  }
963
1227
 
1228
+
964
1229
  export const PUMP_SDK = new PumpSdk();
965
1230
 
966
1231
  /**
@@ -975,9 +1240,7 @@ export const PUMP_SDK = new PumpSdk();
975
1240
  * @param params.creator - The creator address to check
976
1241
  * - For ungraduated coins: use BondingCurve.creator
977
1242
  * - For graduated coins: use Pool.coinCreator (from AMM pool)
978
- *
979
1243
  * @returns true if the creator has migrated to fee sharing config, false otherwise
980
- *
981
1244
  * @example
982
1245
  * ```typescript
983
1246
  * import { isCreatorUsingSharingConfig } from "@pump-fun/sdk";