@pump-fun/pump-sdk 1.28.0-devnet.1 → 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/README.md CHANGED
@@ -163,3 +163,49 @@ const tx = new Transaction().add(...instructions);
163
163
  ```
164
164
 
165
165
  This method automatically handles graduated tokens by including the `transferCreatorFeesToPump` instruction to consolidate fees from the AMM vault before distributing.
166
+
167
+ ## GitHub Recipient and Social Fee PDA Requirements
168
+
169
+ If you are adding a **GitHub recipient** as a fee recipient in sharing config, make sure to initialize the social fee pda before adding it as a recipient. Use one of these methods:
170
+
171
+ ```ts
172
+ import {
173
+ Platform,
174
+ PUMP_SDK,
175
+ } from "@pump-fun/pump-sdk";
176
+
177
+ // 1) Update an existing sharing config
178
+ await PUMP_SDK.updateSharingConfigWithSocialRecipients({
179
+ authority,
180
+ mint,
181
+ currentShareholders,
182
+ newShareholders: [
183
+ { address: authority, shareBps: 7000 },
184
+ { userId: "1234567", platform: Platform.GitHub, shareBps: 3000 },
185
+ ],
186
+ });
187
+
188
+ // 2) Create sharing config + set social recipients in one flow
189
+ // - Use pool for graduated coins
190
+ // - Use null for ungraduated coins
191
+ await PUMP_SDK.createSharingConfigWithSocialRecipients({
192
+ creator,
193
+ mint,
194
+ pool,
195
+ newShareholders: [
196
+ { address: creator, shareBps: 7000 },
197
+ { userId: "1234567", platform: Platform.GitHub, shareBps: 3000 },
198
+ ],
199
+ });
200
+ ```
201
+
202
+ Method selection:
203
+ - `updateSharingConfigWithSocialRecipients`: use when sharing config already exists.
204
+ - `createSharingConfigWithSocialRecipients`: use for first-time setup (creates config, then updates shares).
205
+
206
+ ✅ Checklist
207
+
208
+ - [ ] The GitHub user must be able to log in to claim fees. **GitHub organizations are not supported** for social fee recipients; adding an organization account can result in fees being permanently lost.
209
+ - [ ] Only `Platform.GitHub` is supported. Any attempt to use a different platform value can result in the coin being banned or **fees lost**.
210
+ - [ ] Fees in a GitHub vault can only be claimed by the linked GitHub user, and only through Pump.fun (web or mobile). You are responsible for directing users to claim there; we do not support any claim flow outside our apps.
211
+ - [ ] You have initialized the social fee recipient pda by using one of the above helper or `createSocialFeePda`
package/dist/esm/index.js CHANGED
@@ -19910,6 +19910,35 @@ var OnlinePumpSdk = class {
19910
19910
  }
19911
19911
  };
19912
19912
 
19913
+ // src/state.ts
19914
+ var Platform = /* @__PURE__ */ ((Platform3) => {
19915
+ Platform3[Platform3["Pump"] = 0] = "Pump";
19916
+ Platform3[Platform3["X"] = 1] = "X";
19917
+ Platform3[Platform3["GitHub"] = 2] = "GitHub";
19918
+ return Platform3;
19919
+ })(Platform || {});
19920
+ var SUPPORTED_SOCIAL_PLATFORMS = [2 /* GitHub */];
19921
+ var stringToPlatform = (value) => {
19922
+ const normalized = value.trim().toUpperCase();
19923
+ const entry = Object.entries(Platform).find(
19924
+ ([key, val]) => typeof val === "number" && key.toUpperCase() === normalized
19925
+ );
19926
+ if (entry) {
19927
+ return entry[1];
19928
+ }
19929
+ const validNames = Object.entries(Platform).filter(([, val]) => typeof val === "number").map(([key]) => key.toUpperCase()).join(", ");
19930
+ throw new Error(
19931
+ `Unknown platform "${value}". Expected one of: ${validNames}`
19932
+ );
19933
+ };
19934
+ var platformToString = (platform) => {
19935
+ const name = Platform[platform];
19936
+ if (name !== void 0) {
19937
+ return name;
19938
+ }
19939
+ throw new Error(`Unknown platform value: ${platform}`);
19940
+ };
19941
+
19913
19942
  // src/sdk.ts
19914
19943
  function getPumpProgram(connection) {
19915
19944
  return new Program(
@@ -20438,9 +20467,9 @@ var PumpSdk = class {
20438
20467
  * Creates a fee sharing configuration for a token.
20439
20468
  *
20440
20469
  * @param params - Parameters for creating a fee sharing configuration
20441
- * @param params.creator - The creator of the token
20470
+ * @param params.creator - The creator of the token. Must sign the transaction.
20442
20471
  * @param params.mint - The mint address of the token
20443
- * @param params.pool - The pool address of the token (null for ungraduated coins)
20472
+ * @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
20444
20473
  */
20445
20474
  async createFeeSharingConfig({
20446
20475
  creator,
@@ -20591,6 +20620,154 @@ var PumpSdk = class {
20591
20620
  user
20592
20621
  }).instruction();
20593
20622
  }
20623
+ /**
20624
+ * Creates a social fee PDA that can accumulate fees for a social media user.
20625
+ *
20626
+ * @param params.payer - Any signer account that pays for the transaction.
20627
+ * @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
20628
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
20629
+ * @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
20630
+ * In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
20631
+ */
20632
+ async createSocialFeePda({
20633
+ payer,
20634
+ userId,
20635
+ platform
20636
+ }) {
20637
+ if (!SUPPORTED_SOCIAL_PLATFORMS.includes(platform)) {
20638
+ const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map(
20639
+ (supportedPlatform) => platformToString(supportedPlatform)
20640
+ ).join(", ");
20641
+ throw new Error(
20642
+ `Unsupported platform "${platform}" for userId "${userId}". Supported platforms: ${supportedPlatformNames}.`
20643
+ );
20644
+ }
20645
+ return await this.offlinePumpFeeProgram.methods.createSocialFeePda(userId, platform).accountsPartial({
20646
+ payer,
20647
+ socialFeePda: socialFeePda(userId, platform)
20648
+ }).instruction();
20649
+ }
20650
+ normalizeSocialShareholders({
20651
+ newShareholders
20652
+ }) {
20653
+ const socialRecipientsToCreate = /* @__PURE__ */ new Map();
20654
+ const normalizedShareholders = newShareholders.map(
20655
+ (shareholder) => {
20656
+ if (shareholder.address) {
20657
+ return {
20658
+ address: shareholder.address,
20659
+ shareBps: shareholder.shareBps
20660
+ };
20661
+ }
20662
+ if (typeof shareholder.userId === "string" && typeof shareholder.platform === "number") {
20663
+ if (!SUPPORTED_SOCIAL_PLATFORMS.includes(shareholder.platform)) {
20664
+ const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map(
20665
+ (platform) => platformToString(platform)
20666
+ ).join(", ");
20667
+ throw new Error(
20668
+ `Unsupported platform "${shareholder.platform}" for userId "${shareholder.userId}". Supported platforms: ${supportedPlatformNames}.`
20669
+ );
20670
+ }
20671
+ const recipientPda = socialFeePda(shareholder.userId, shareholder.platform);
20672
+ socialRecipientsToCreate.set(recipientPda.toBase58(), {
20673
+ userId: shareholder.userId,
20674
+ platform: shareholder.platform
20675
+ });
20676
+ return {
20677
+ address: recipientPda,
20678
+ shareBps: shareholder.shareBps
20679
+ };
20680
+ }
20681
+ throw new Error(
20682
+ "Each new shareholder must provide either an address or both userId and platform."
20683
+ );
20684
+ }
20685
+ );
20686
+ return {
20687
+ normalizedShareholders,
20688
+ socialRecipientsToCreate
20689
+ };
20690
+ }
20691
+ /**
20692
+ * Wrapper around `updateSharingConfig` that resolves social recipients and
20693
+ * initializes any missing social recipient PDAs before updating fee shares.
20694
+ *
20695
+ * Requirements:
20696
+ * - `authority` must sign the transaction.
20697
+ *
20698
+ * Warning:
20699
+ * - sharing config must exist for that mint
20700
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
20701
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
20702
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
20703
+ */
20704
+ async updateSharingConfigWithSocialRecipients({
20705
+ authority,
20706
+ mint,
20707
+ currentShareholders,
20708
+ newShareholders
20709
+ }) {
20710
+ const instructions = [];
20711
+ const { normalizedShareholders, socialRecipientsToCreate } = this.normalizeSocialShareholders({ newShareholders });
20712
+ for (const recipient of socialRecipientsToCreate.values()) {
20713
+ instructions.push(
20714
+ await this.createSocialFeePda({
20715
+ payer: authority,
20716
+ userId: recipient.userId,
20717
+ platform: recipient.platform
20718
+ })
20719
+ );
20720
+ }
20721
+ instructions.push(
20722
+ await this.updateFeeShares({
20723
+ authority,
20724
+ mint,
20725
+ currentShareholders,
20726
+ newShareholders: normalizedShareholders
20727
+ })
20728
+ );
20729
+ return instructions;
20730
+ }
20731
+ /**
20732
+ * Wrapper around `createFeeSharingConfig` that resolves social recipients and
20733
+ * initializes any missing social recipient PDAs before updating fee shares.
20734
+ *
20735
+ * Requirements:
20736
+ * - `creator` must sign the transaction.
20737
+ * - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
20738
+ *
20739
+ * Warning:
20740
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
20741
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
20742
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
20743
+ */
20744
+ async createSharingConfigWithSocialRecipients({
20745
+ creator,
20746
+ mint,
20747
+ pool,
20748
+ newShareholders
20749
+ }) {
20750
+ const instructions = [];
20751
+ instructions.push(
20752
+ await this.createFeeSharingConfig({
20753
+ creator,
20754
+ mint,
20755
+ pool
20756
+ })
20757
+ );
20758
+ instructions.push(
20759
+ ...await this.updateSharingConfigWithSocialRecipients({
20760
+ authority: creator,
20761
+ mint,
20762
+ currentShareholders: [creator],
20763
+ newShareholders
20764
+ })
20765
+ );
20766
+ return instructions;
20767
+ }
20768
+ claimSocialFeePda() {
20769
+ throw new Error("This function can only be called by pump and is not supported");
20770
+ }
20594
20771
  };
20595
20772
  var PUMP_SDK = new PumpSdk();
20596
20773
  function isCreatorUsingSharingConfig({
@@ -20681,6 +20858,13 @@ var ammCreatorVaultPda = (creator) => {
20681
20858
  PUMP_AMM_PROGRAM_ID
20682
20859
  )[0];
20683
20860
  };
20861
+ var socialFeePda = (userId, platform) => {
20862
+ return pumpFeePda([
20863
+ import_buffer.Buffer.from("social-fee-pda"),
20864
+ import_buffer.Buffer.from(userId),
20865
+ import_buffer.Buffer.from([platform])
20866
+ ]);
20867
+ };
20684
20868
  export {
20685
20869
  AMM_GLOBAL_PDA,
20686
20870
  AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA,
@@ -20701,8 +20885,10 @@ export {
20701
20885
  PUMP_FEE_PROGRAM_ID,
20702
20886
  PUMP_PROGRAM_ID,
20703
20887
  PUMP_SDK,
20888
+ Platform,
20704
20889
  PoolRequiredForGraduatedError,
20705
20890
  PumpSdk,
20891
+ SUPPORTED_SOCIAL_PLATFORMS,
20706
20892
  ShareCalculationOverflowError,
20707
20893
  TooManyShareholdersError,
20708
20894
  ZeroShareError,
@@ -20726,8 +20912,11 @@ export {
20726
20912
  getTokenVaultPda,
20727
20913
  isCreatorUsingSharingConfig,
20728
20914
  newBondingCurve,
20915
+ platformToString,
20729
20916
  pump_default as pumpIdl,
20730
20917
  pumpPoolAuthorityPda,
20918
+ socialFeePda,
20919
+ stringToPlatform,
20731
20920
  totalUnclaimedTokens,
20732
20921
  userVolumeAccumulatorPda
20733
20922
  };
package/dist/index.d.mts CHANGED
@@ -16814,6 +16814,17 @@ interface PumpFees {
16814
16814
  ];
16815
16815
  }
16816
16816
 
16817
+ /**
16818
+ * Platform identifiers for social handle mappings.
16819
+ */
16820
+ declare enum Platform {
16821
+ Pump = 0,
16822
+ X = 1,
16823
+ GitHub = 2
16824
+ }
16825
+ declare const SUPPORTED_SOCIAL_PLATFORMS: Platform[];
16826
+ declare const stringToPlatform: (value: string) => Platform;
16827
+ declare const platformToString: (platform: Platform) => string;
16817
16828
  interface Global {
16818
16829
  initialized: boolean;
16819
16830
  authority: PublicKey;
@@ -16955,6 +16966,7 @@ declare const getSolVaultPda: () => PublicKey;
16955
16966
  declare const getTokenVaultPda: (mintPubkey: PublicKey) => PublicKey;
16956
16967
  declare const feeSharingConfigPda: (mint: PublicKey) => PublicKey;
16957
16968
  declare const ammCreatorVaultPda: (creator: PublicKey) => PublicKey;
16969
+ declare const socialFeePda: (userId: string, platform: number) => PublicKey;
16958
16970
 
16959
16971
  /**
16960
16972
  * Program IDL in camelCase format in order to be used in JS/TS.
@@ -22727,9 +22739,9 @@ declare class PumpSdk {
22727
22739
  * Creates a fee sharing configuration for a token.
22728
22740
  *
22729
22741
  * @param params - Parameters for creating a fee sharing configuration
22730
- * @param params.creator - The creator of the token
22742
+ * @param params.creator - The creator of the token. Must sign the transaction.
22731
22743
  * @param params.mint - The mint address of the token
22732
- * @param params.pool - The pool address of the token (null for ungraduated coins)
22744
+ * @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
22733
22745
  */
22734
22746
  createFeeSharingConfig({ creator, mint, pool, }: {
22735
22747
  creator: PublicKey;
@@ -22791,6 +22803,83 @@ declare class PumpSdk {
22791
22803
  claimCashbackInstruction({ user, }: {
22792
22804
  user: PublicKey;
22793
22805
  }): Promise<TransactionInstruction>;
22806
+ /**
22807
+ * Creates a social fee PDA that can accumulate fees for a social media user.
22808
+ *
22809
+ * @param params.payer - Any signer account that pays for the transaction.
22810
+ * @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
22811
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
22812
+ * @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
22813
+ * In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
22814
+ */
22815
+ createSocialFeePda({ payer, userId, platform, }: {
22816
+ payer: PublicKey;
22817
+ userId: string;
22818
+ platform: Platform;
22819
+ }): Promise<TransactionInstruction>;
22820
+ normalizeSocialShareholders({ newShareholders, }: {
22821
+ newShareholders: Array<{
22822
+ shareBps: number;
22823
+ address?: PublicKey;
22824
+ userId?: string;
22825
+ platform?: Platform;
22826
+ }>;
22827
+ }): {
22828
+ normalizedShareholders: Shareholder[];
22829
+ socialRecipientsToCreate: Map<string, {
22830
+ userId: string;
22831
+ platform: Platform;
22832
+ }>;
22833
+ };
22834
+ /**
22835
+ * Wrapper around `updateSharingConfig` that resolves social recipients and
22836
+ * initializes any missing social recipient PDAs before updating fee shares.
22837
+ *
22838
+ * Requirements:
22839
+ * - `authority` must sign the transaction.
22840
+ *
22841
+ * Warning:
22842
+ * - sharing config must exist for that mint
22843
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
22844
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
22845
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
22846
+ */
22847
+ updateSharingConfigWithSocialRecipients({ authority, mint, currentShareholders, newShareholders, }: {
22848
+ authority: PublicKey;
22849
+ mint: PublicKey;
22850
+ currentShareholders: PublicKey[];
22851
+ newShareholders: Array<{
22852
+ shareBps: number;
22853
+ address?: PublicKey;
22854
+ userId?: string;
22855
+ platform?: Platform;
22856
+ }>;
22857
+ }): Promise<TransactionInstruction[]>;
22858
+ /**
22859
+ * Wrapper around `createFeeSharingConfig` that resolves social recipients and
22860
+ * initializes any missing social recipient PDAs before updating fee shares.
22861
+ *
22862
+ * Requirements:
22863
+ * - `creator` must sign the transaction.
22864
+ * - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
22865
+ *
22866
+ * Warning:
22867
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
22868
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
22869
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
22870
+ */
22871
+ createSharingConfigWithSocialRecipients({ creator, mint, pool, newShareholders, }: {
22872
+ creator: PublicKey;
22873
+ mint: PublicKey;
22874
+ pool: PublicKey | null;
22875
+ newShareholders: Array<{
22876
+ shareBps: number;
22877
+ address?: PublicKey;
22878
+ userId?: string;
22879
+ platform?: Platform;
22880
+ }>;
22881
+ }): Promise<TransactionInstruction[]>;
22882
+ claimSocialFeePda(): void;
22794
22883
  }
22795
22884
  declare const PUMP_SDK: PumpSdk;
22796
22885
  /**
@@ -22937,4 +23026,4 @@ declare class PoolRequiredForGraduatedError extends Error {
22937
23026
  constructor();
22938
23027
  }
22939
23028
 
22940
- export { AMM_GLOBAL_PDA, AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA, BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type DistributeCreatorFeeResult, type DistributeCreatorFeesEvent, DuplicateShareholderError, type FeeConfig, GLOBAL_PDA, GLOBAL_VOLUME_ACCUMULATOR_PDA, type Global, type GlobalVolumeAccumulator, InvalidShareTotalError, MAYHEM_PROGRAM_ID, type MinimumDistributableFeeEvent, type MinimumDistributableFeeResult, NoShareholdersError, OnlinePumpSdk, PUMP_AMM_EVENT_AUTHORITY_PDA, PUMP_AMM_PROGRAM_ID, PUMP_EVENT_AUTHORITY_PDA, PUMP_FEE_CONFIG_PDA, PUMP_FEE_EVENT_AUTHORITY_PDA, PUMP_FEE_PROGRAM_ID, PUMP_PROGRAM_ID, PUMP_SDK, PoolRequiredForGraduatedError, type Pump, type PumpFees, PumpSdk, ShareCalculationOverflowError, type Shareholder, type SharingConfig, TooManyShareholdersError, type UserVolumeAccumulator, type UserVolumeAccumulatorTotalStats, ZeroShareError, ammCreatorVaultPda, bondingCurveMarketCap, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, feeSharingConfigPda, getBuySolAmountFromTokenAmount, getBuyTokenAmountFromSolAmount, getEventAuthorityPda, getGlobalParamsPda, getMayhemStatePda, getPumpAmmProgram, getPumpFeeProgram, getPumpProgram, getSellSolAmountFromTokenAmount, getSolVaultPda, getTokenVaultPda, isCreatorUsingSharingConfig, newBondingCurve, pump as pumpIdl, pumpPoolAuthorityPda, totalUnclaimedTokens, userVolumeAccumulatorPda };
23029
+ export { AMM_GLOBAL_PDA, AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA, BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type DistributeCreatorFeeResult, type DistributeCreatorFeesEvent, DuplicateShareholderError, type FeeConfig, GLOBAL_PDA, GLOBAL_VOLUME_ACCUMULATOR_PDA, type Global, type GlobalVolumeAccumulator, InvalidShareTotalError, MAYHEM_PROGRAM_ID, type MinimumDistributableFeeEvent, type MinimumDistributableFeeResult, NoShareholdersError, OnlinePumpSdk, PUMP_AMM_EVENT_AUTHORITY_PDA, PUMP_AMM_PROGRAM_ID, PUMP_EVENT_AUTHORITY_PDA, PUMP_FEE_CONFIG_PDA, PUMP_FEE_EVENT_AUTHORITY_PDA, PUMP_FEE_PROGRAM_ID, PUMP_PROGRAM_ID, PUMP_SDK, Platform, PoolRequiredForGraduatedError, type Pump, type PumpFees, PumpSdk, SUPPORTED_SOCIAL_PLATFORMS, ShareCalculationOverflowError, type Shareholder, type SharingConfig, TooManyShareholdersError, type UserVolumeAccumulator, type UserVolumeAccumulatorTotalStats, ZeroShareError, ammCreatorVaultPda, bondingCurveMarketCap, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, feeSharingConfigPda, getBuySolAmountFromTokenAmount, getBuyTokenAmountFromSolAmount, getEventAuthorityPda, getGlobalParamsPda, getMayhemStatePda, getPumpAmmProgram, getPumpFeeProgram, getPumpProgram, getSellSolAmountFromTokenAmount, getSolVaultPda, getTokenVaultPda, isCreatorUsingSharingConfig, newBondingCurve, platformToString, pump as pumpIdl, pumpPoolAuthorityPda, socialFeePda, stringToPlatform, totalUnclaimedTokens, userVolumeAccumulatorPda };
package/dist/index.d.ts CHANGED
@@ -16814,6 +16814,17 @@ interface PumpFees {
16814
16814
  ];
16815
16815
  }
16816
16816
 
16817
+ /**
16818
+ * Platform identifiers for social handle mappings.
16819
+ */
16820
+ declare enum Platform {
16821
+ Pump = 0,
16822
+ X = 1,
16823
+ GitHub = 2
16824
+ }
16825
+ declare const SUPPORTED_SOCIAL_PLATFORMS: Platform[];
16826
+ declare const stringToPlatform: (value: string) => Platform;
16827
+ declare const platformToString: (platform: Platform) => string;
16817
16828
  interface Global {
16818
16829
  initialized: boolean;
16819
16830
  authority: PublicKey;
@@ -16955,6 +16966,7 @@ declare const getSolVaultPda: () => PublicKey;
16955
16966
  declare const getTokenVaultPda: (mintPubkey: PublicKey) => PublicKey;
16956
16967
  declare const feeSharingConfigPda: (mint: PublicKey) => PublicKey;
16957
16968
  declare const ammCreatorVaultPda: (creator: PublicKey) => PublicKey;
16969
+ declare const socialFeePda: (userId: string, platform: number) => PublicKey;
16958
16970
 
16959
16971
  /**
16960
16972
  * Program IDL in camelCase format in order to be used in JS/TS.
@@ -22727,9 +22739,9 @@ declare class PumpSdk {
22727
22739
  * Creates a fee sharing configuration for a token.
22728
22740
  *
22729
22741
  * @param params - Parameters for creating a fee sharing configuration
22730
- * @param params.creator - The creator of the token
22742
+ * @param params.creator - The creator of the token. Must sign the transaction.
22731
22743
  * @param params.mint - The mint address of the token
22732
- * @param params.pool - The pool address of the token (null for ungraduated coins)
22744
+ * @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
22733
22745
  */
22734
22746
  createFeeSharingConfig({ creator, mint, pool, }: {
22735
22747
  creator: PublicKey;
@@ -22791,6 +22803,83 @@ declare class PumpSdk {
22791
22803
  claimCashbackInstruction({ user, }: {
22792
22804
  user: PublicKey;
22793
22805
  }): Promise<TransactionInstruction>;
22806
+ /**
22807
+ * Creates a social fee PDA that can accumulate fees for a social media user.
22808
+ *
22809
+ * @param params.payer - Any signer account that pays for the transaction.
22810
+ * @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
22811
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
22812
+ * @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
22813
+ * In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
22814
+ */
22815
+ createSocialFeePda({ payer, userId, platform, }: {
22816
+ payer: PublicKey;
22817
+ userId: string;
22818
+ platform: Platform;
22819
+ }): Promise<TransactionInstruction>;
22820
+ normalizeSocialShareholders({ newShareholders, }: {
22821
+ newShareholders: Array<{
22822
+ shareBps: number;
22823
+ address?: PublicKey;
22824
+ userId?: string;
22825
+ platform?: Platform;
22826
+ }>;
22827
+ }): {
22828
+ normalizedShareholders: Shareholder[];
22829
+ socialRecipientsToCreate: Map<string, {
22830
+ userId: string;
22831
+ platform: Platform;
22832
+ }>;
22833
+ };
22834
+ /**
22835
+ * Wrapper around `updateSharingConfig` that resolves social recipients and
22836
+ * initializes any missing social recipient PDAs before updating fee shares.
22837
+ *
22838
+ * Requirements:
22839
+ * - `authority` must sign the transaction.
22840
+ *
22841
+ * Warning:
22842
+ * - sharing config must exist for that mint
22843
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
22844
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
22845
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
22846
+ */
22847
+ updateSharingConfigWithSocialRecipients({ authority, mint, currentShareholders, newShareholders, }: {
22848
+ authority: PublicKey;
22849
+ mint: PublicKey;
22850
+ currentShareholders: PublicKey[];
22851
+ newShareholders: Array<{
22852
+ shareBps: number;
22853
+ address?: PublicKey;
22854
+ userId?: string;
22855
+ platform?: Platform;
22856
+ }>;
22857
+ }): Promise<TransactionInstruction[]>;
22858
+ /**
22859
+ * Wrapper around `createFeeSharingConfig` that resolves social recipients and
22860
+ * initializes any missing social recipient PDAs before updating fee shares.
22861
+ *
22862
+ * Requirements:
22863
+ * - `creator` must sign the transaction.
22864
+ * - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
22865
+ *
22866
+ * Warning:
22867
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
22868
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
22869
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
22870
+ */
22871
+ createSharingConfigWithSocialRecipients({ creator, mint, pool, newShareholders, }: {
22872
+ creator: PublicKey;
22873
+ mint: PublicKey;
22874
+ pool: PublicKey | null;
22875
+ newShareholders: Array<{
22876
+ shareBps: number;
22877
+ address?: PublicKey;
22878
+ userId?: string;
22879
+ platform?: Platform;
22880
+ }>;
22881
+ }): Promise<TransactionInstruction[]>;
22882
+ claimSocialFeePda(): void;
22794
22883
  }
22795
22884
  declare const PUMP_SDK: PumpSdk;
22796
22885
  /**
@@ -22937,4 +23026,4 @@ declare class PoolRequiredForGraduatedError extends Error {
22937
23026
  constructor();
22938
23027
  }
22939
23028
 
22940
- export { AMM_GLOBAL_PDA, AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA, BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type DistributeCreatorFeeResult, type DistributeCreatorFeesEvent, DuplicateShareholderError, type FeeConfig, GLOBAL_PDA, GLOBAL_VOLUME_ACCUMULATOR_PDA, type Global, type GlobalVolumeAccumulator, InvalidShareTotalError, MAYHEM_PROGRAM_ID, type MinimumDistributableFeeEvent, type MinimumDistributableFeeResult, NoShareholdersError, OnlinePumpSdk, PUMP_AMM_EVENT_AUTHORITY_PDA, PUMP_AMM_PROGRAM_ID, PUMP_EVENT_AUTHORITY_PDA, PUMP_FEE_CONFIG_PDA, PUMP_FEE_EVENT_AUTHORITY_PDA, PUMP_FEE_PROGRAM_ID, PUMP_PROGRAM_ID, PUMP_SDK, PoolRequiredForGraduatedError, type Pump, type PumpFees, PumpSdk, ShareCalculationOverflowError, type Shareholder, type SharingConfig, TooManyShareholdersError, type UserVolumeAccumulator, type UserVolumeAccumulatorTotalStats, ZeroShareError, ammCreatorVaultPda, bondingCurveMarketCap, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, feeSharingConfigPda, getBuySolAmountFromTokenAmount, getBuyTokenAmountFromSolAmount, getEventAuthorityPda, getGlobalParamsPda, getMayhemStatePda, getPumpAmmProgram, getPumpFeeProgram, getPumpProgram, getSellSolAmountFromTokenAmount, getSolVaultPda, getTokenVaultPda, isCreatorUsingSharingConfig, newBondingCurve, pump as pumpIdl, pumpPoolAuthorityPda, totalUnclaimedTokens, userVolumeAccumulatorPda };
23029
+ export { AMM_GLOBAL_PDA, AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA, BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type DistributeCreatorFeeResult, type DistributeCreatorFeesEvent, DuplicateShareholderError, type FeeConfig, GLOBAL_PDA, GLOBAL_VOLUME_ACCUMULATOR_PDA, type Global, type GlobalVolumeAccumulator, InvalidShareTotalError, MAYHEM_PROGRAM_ID, type MinimumDistributableFeeEvent, type MinimumDistributableFeeResult, NoShareholdersError, OnlinePumpSdk, PUMP_AMM_EVENT_AUTHORITY_PDA, PUMP_AMM_PROGRAM_ID, PUMP_EVENT_AUTHORITY_PDA, PUMP_FEE_CONFIG_PDA, PUMP_FEE_EVENT_AUTHORITY_PDA, PUMP_FEE_PROGRAM_ID, PUMP_PROGRAM_ID, PUMP_SDK, Platform, PoolRequiredForGraduatedError, type Pump, type PumpFees, PumpSdk, SUPPORTED_SOCIAL_PLATFORMS, ShareCalculationOverflowError, type Shareholder, type SharingConfig, TooManyShareholdersError, type UserVolumeAccumulator, type UserVolumeAccumulatorTotalStats, ZeroShareError, ammCreatorVaultPda, bondingCurveMarketCap, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, feeSharingConfigPda, getBuySolAmountFromTokenAmount, getBuyTokenAmountFromSolAmount, getEventAuthorityPda, getGlobalParamsPda, getMayhemStatePda, getPumpAmmProgram, getPumpFeeProgram, getPumpProgram, getSellSolAmountFromTokenAmount, getSolVaultPda, getTokenVaultPda, isCreatorUsingSharingConfig, newBondingCurve, platformToString, pump as pumpIdl, pumpPoolAuthorityPda, socialFeePda, stringToPlatform, totalUnclaimedTokens, userVolumeAccumulatorPda };
package/dist/index.js CHANGED
@@ -1829,8 +1829,10 @@ __export(index_exports, {
1829
1829
  PUMP_FEE_PROGRAM_ID: () => PUMP_FEE_PROGRAM_ID,
1830
1830
  PUMP_PROGRAM_ID: () => PUMP_PROGRAM_ID,
1831
1831
  PUMP_SDK: () => PUMP_SDK,
1832
+ Platform: () => Platform,
1832
1833
  PoolRequiredForGraduatedError: () => PoolRequiredForGraduatedError,
1833
1834
  PumpSdk: () => PumpSdk,
1835
+ SUPPORTED_SOCIAL_PLATFORMS: () => SUPPORTED_SOCIAL_PLATFORMS,
1834
1836
  ShareCalculationOverflowError: () => ShareCalculationOverflowError,
1835
1837
  TooManyShareholdersError: () => TooManyShareholdersError,
1836
1838
  ZeroShareError: () => ZeroShareError,
@@ -1854,8 +1856,11 @@ __export(index_exports, {
1854
1856
  getTokenVaultPda: () => getTokenVaultPda,
1855
1857
  isCreatorUsingSharingConfig: () => isCreatorUsingSharingConfig,
1856
1858
  newBondingCurve: () => newBondingCurve,
1859
+ platformToString: () => platformToString,
1857
1860
  pumpIdl: () => pump_default,
1858
1861
  pumpPoolAuthorityPda: () => pumpPoolAuthorityPda,
1862
+ socialFeePda: () => socialFeePda,
1863
+ stringToPlatform: () => stringToPlatform,
1859
1864
  totalUnclaimedTokens: () => totalUnclaimedTokens,
1860
1865
  userVolumeAccumulatorPda: () => userVolumeAccumulatorPda
1861
1866
  });
@@ -19935,6 +19940,35 @@ var OnlinePumpSdk = class {
19935
19940
  }
19936
19941
  };
19937
19942
 
19943
+ // src/state.ts
19944
+ var Platform = /* @__PURE__ */ ((Platform3) => {
19945
+ Platform3[Platform3["Pump"] = 0] = "Pump";
19946
+ Platform3[Platform3["X"] = 1] = "X";
19947
+ Platform3[Platform3["GitHub"] = 2] = "GitHub";
19948
+ return Platform3;
19949
+ })(Platform || {});
19950
+ var SUPPORTED_SOCIAL_PLATFORMS = [2 /* GitHub */];
19951
+ var stringToPlatform = (value) => {
19952
+ const normalized = value.trim().toUpperCase();
19953
+ const entry = Object.entries(Platform).find(
19954
+ ([key, val]) => typeof val === "number" && key.toUpperCase() === normalized
19955
+ );
19956
+ if (entry) {
19957
+ return entry[1];
19958
+ }
19959
+ const validNames = Object.entries(Platform).filter(([, val]) => typeof val === "number").map(([key]) => key.toUpperCase()).join(", ");
19960
+ throw new Error(
19961
+ `Unknown platform "${value}". Expected one of: ${validNames}`
19962
+ );
19963
+ };
19964
+ var platformToString = (platform) => {
19965
+ const name = Platform[platform];
19966
+ if (name !== void 0) {
19967
+ return name;
19968
+ }
19969
+ throw new Error(`Unknown platform value: ${platform}`);
19970
+ };
19971
+
19938
19972
  // src/sdk.ts
19939
19973
  function getPumpProgram(connection) {
19940
19974
  return new import_anchor.Program(
@@ -20463,9 +20497,9 @@ var PumpSdk = class {
20463
20497
  * Creates a fee sharing configuration for a token.
20464
20498
  *
20465
20499
  * @param params - Parameters for creating a fee sharing configuration
20466
- * @param params.creator - The creator of the token
20500
+ * @param params.creator - The creator of the token. Must sign the transaction.
20467
20501
  * @param params.mint - The mint address of the token
20468
- * @param params.pool - The pool address of the token (null for ungraduated coins)
20502
+ * @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
20469
20503
  */
20470
20504
  async createFeeSharingConfig({
20471
20505
  creator,
@@ -20616,6 +20650,154 @@ var PumpSdk = class {
20616
20650
  user
20617
20651
  }).instruction();
20618
20652
  }
20653
+ /**
20654
+ * Creates a social fee PDA that can accumulate fees for a social media user.
20655
+ *
20656
+ * @param params.payer - Any signer account that pays for the transaction.
20657
+ * @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
20658
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
20659
+ * @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
20660
+ * In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
20661
+ */
20662
+ async createSocialFeePda({
20663
+ payer,
20664
+ userId,
20665
+ platform
20666
+ }) {
20667
+ if (!SUPPORTED_SOCIAL_PLATFORMS.includes(platform)) {
20668
+ const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map(
20669
+ (supportedPlatform) => platformToString(supportedPlatform)
20670
+ ).join(", ");
20671
+ throw new Error(
20672
+ `Unsupported platform "${platform}" for userId "${userId}". Supported platforms: ${supportedPlatformNames}.`
20673
+ );
20674
+ }
20675
+ return await this.offlinePumpFeeProgram.methods.createSocialFeePda(userId, platform).accountsPartial({
20676
+ payer,
20677
+ socialFeePda: socialFeePda(userId, platform)
20678
+ }).instruction();
20679
+ }
20680
+ normalizeSocialShareholders({
20681
+ newShareholders
20682
+ }) {
20683
+ const socialRecipientsToCreate = /* @__PURE__ */ new Map();
20684
+ const normalizedShareholders = newShareholders.map(
20685
+ (shareholder) => {
20686
+ if (shareholder.address) {
20687
+ return {
20688
+ address: shareholder.address,
20689
+ shareBps: shareholder.shareBps
20690
+ };
20691
+ }
20692
+ if (typeof shareholder.userId === "string" && typeof shareholder.platform === "number") {
20693
+ if (!SUPPORTED_SOCIAL_PLATFORMS.includes(shareholder.platform)) {
20694
+ const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map(
20695
+ (platform) => platformToString(platform)
20696
+ ).join(", ");
20697
+ throw new Error(
20698
+ `Unsupported platform "${shareholder.platform}" for userId "${shareholder.userId}". Supported platforms: ${supportedPlatformNames}.`
20699
+ );
20700
+ }
20701
+ const recipientPda = socialFeePda(shareholder.userId, shareholder.platform);
20702
+ socialRecipientsToCreate.set(recipientPda.toBase58(), {
20703
+ userId: shareholder.userId,
20704
+ platform: shareholder.platform
20705
+ });
20706
+ return {
20707
+ address: recipientPda,
20708
+ shareBps: shareholder.shareBps
20709
+ };
20710
+ }
20711
+ throw new Error(
20712
+ "Each new shareholder must provide either an address or both userId and platform."
20713
+ );
20714
+ }
20715
+ );
20716
+ return {
20717
+ normalizedShareholders,
20718
+ socialRecipientsToCreate
20719
+ };
20720
+ }
20721
+ /**
20722
+ * Wrapper around `updateSharingConfig` that resolves social recipients and
20723
+ * initializes any missing social recipient PDAs before updating fee shares.
20724
+ *
20725
+ * Requirements:
20726
+ * - `authority` must sign the transaction.
20727
+ *
20728
+ * Warning:
20729
+ * - sharing config must exist for that mint
20730
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
20731
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
20732
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
20733
+ */
20734
+ async updateSharingConfigWithSocialRecipients({
20735
+ authority,
20736
+ mint,
20737
+ currentShareholders,
20738
+ newShareholders
20739
+ }) {
20740
+ const instructions = [];
20741
+ const { normalizedShareholders, socialRecipientsToCreate } = this.normalizeSocialShareholders({ newShareholders });
20742
+ for (const recipient of socialRecipientsToCreate.values()) {
20743
+ instructions.push(
20744
+ await this.createSocialFeePda({
20745
+ payer: authority,
20746
+ userId: recipient.userId,
20747
+ platform: recipient.platform
20748
+ })
20749
+ );
20750
+ }
20751
+ instructions.push(
20752
+ await this.updateFeeShares({
20753
+ authority,
20754
+ mint,
20755
+ currentShareholders,
20756
+ newShareholders: normalizedShareholders
20757
+ })
20758
+ );
20759
+ return instructions;
20760
+ }
20761
+ /**
20762
+ * Wrapper around `createFeeSharingConfig` that resolves social recipients and
20763
+ * initializes any missing social recipient PDAs before updating fee shares.
20764
+ *
20765
+ * Requirements:
20766
+ * - `creator` must sign the transaction.
20767
+ * - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
20768
+ *
20769
+ * Warning:
20770
+ * - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
20771
+ * The target must be a real user account with a login. E.g: Organizations are not supported.
20772
+ * - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
20773
+ */
20774
+ async createSharingConfigWithSocialRecipients({
20775
+ creator,
20776
+ mint,
20777
+ pool,
20778
+ newShareholders
20779
+ }) {
20780
+ const instructions = [];
20781
+ instructions.push(
20782
+ await this.createFeeSharingConfig({
20783
+ creator,
20784
+ mint,
20785
+ pool
20786
+ })
20787
+ );
20788
+ instructions.push(
20789
+ ...await this.updateSharingConfigWithSocialRecipients({
20790
+ authority: creator,
20791
+ mint,
20792
+ currentShareholders: [creator],
20793
+ newShareholders
20794
+ })
20795
+ );
20796
+ return instructions;
20797
+ }
20798
+ claimSocialFeePda() {
20799
+ throw new Error("This function can only be called by pump and is not supported");
20800
+ }
20619
20801
  };
20620
20802
  var PUMP_SDK = new PumpSdk();
20621
20803
  function isCreatorUsingSharingConfig({
@@ -20706,6 +20888,13 @@ var ammCreatorVaultPda = (creator) => {
20706
20888
  PUMP_AMM_PROGRAM_ID
20707
20889
  )[0];
20708
20890
  };
20891
+ var socialFeePda = (userId, platform) => {
20892
+ return (0, import_pump_swap_sdk3.pumpFeePda)([
20893
+ import_buffer.Buffer.from("social-fee-pda"),
20894
+ import_buffer.Buffer.from(userId),
20895
+ import_buffer.Buffer.from([platform])
20896
+ ]);
20897
+ };
20709
20898
  /*! Bundled license information:
20710
20899
 
20711
20900
  ieee754/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pump-fun/pump-sdk",
3
- "version": "1.28.0-devnet.1",
3
+ "version": "1.28.0-devnet.2",
4
4
  "description": "Pump Bonding Curve SDK",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/pump-fun/pump-sdk#readme",
package/src/index.ts CHANGED
@@ -38,6 +38,10 @@ export {
38
38
  SharingConfig,
39
39
  DistributeCreatorFeesEvent,
40
40
  MinimumDistributableFeeEvent,
41
+ Platform,
42
+ SUPPORTED_SOCIAL_PLATFORMS,
43
+ platformToString,
44
+ stringToPlatform
41
45
  } from "./state";
42
46
  export { totalUnclaimedTokens, currentDayTokens } from "./tokenIncentives";
43
47
  export * from "./errors";
package/src/pda.ts CHANGED
@@ -121,3 +121,11 @@ export const ammCreatorVaultPda = (creator: PublicKey): PublicKey => {
121
121
  PUMP_AMM_PROGRAM_ID,
122
122
  )[0];
123
123
  };
124
+
125
+ export const socialFeePda = (userId: string, platform: number): PublicKey => {
126
+ return pumpFeePda([
127
+ Buffer.from("social-fee-pda"),
128
+ Buffer.from(userId),
129
+ Buffer.from([platform]),
130
+ ]);
131
+ };
package/src/sdk.ts CHANGED
@@ -45,6 +45,7 @@ import {
45
45
  pumpPoolAuthorityPda,
46
46
  feeSharingConfigPda,
47
47
  userVolumeAccumulatorPda,
48
+ socialFeePda,
48
49
  } from "./pda";
49
50
  import {
50
51
  BondingCurve,
@@ -56,6 +57,9 @@ import {
56
57
  SharingConfig,
57
58
  DistributeCreatorFeesEvent,
58
59
  MinimumDistributableFeeEvent,
60
+ Platform,
61
+ SUPPORTED_SOCIAL_PLATFORMS,
62
+ platformToString,
59
63
  } from "./state";
60
64
 
61
65
  export function getPumpProgram(connection: Connection): Program<Pump> {
@@ -805,9 +809,9 @@ export class PumpSdk {
805
809
  * Creates a fee sharing configuration for a token.
806
810
  *
807
811
  * @param params - Parameters for creating a fee sharing configuration
808
- * @param params.creator - The creator of the token
812
+ * @param params.creator - The creator of the token. Must sign the transaction.
809
813
  * @param params.mint - The mint address of the token
810
- * @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.
811
815
  */
812
816
  async createFeeSharingConfig({
813
817
  creator,
@@ -1010,8 +1014,218 @@ export class PumpSdk {
1010
1014
  })
1011
1015
  .instruction();
1012
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
+ }
1013
1226
  }
1014
1227
 
1228
+
1015
1229
  export const PUMP_SDK = new PumpSdk();
1016
1230
 
1017
1231
  /**
package/src/state.ts CHANGED
@@ -1,6 +1,42 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import BN from "bn.js";
3
3
 
4
+ /**
5
+ * Platform identifiers for social handle mappings.
6
+ */
7
+ export enum Platform {
8
+ Pump = 0,
9
+ X = 1,
10
+ GitHub = 2,
11
+ }
12
+
13
+ export const SUPPORTED_SOCIAL_PLATFORMS = [Platform.GitHub];
14
+
15
+ export const stringToPlatform = (value: string): Platform => {
16
+ const normalized = value.trim().toUpperCase();
17
+ const entry = Object.entries(Platform).find(
18
+ ([key, val]) => typeof val === "number" && key.toUpperCase() === normalized,
19
+ );
20
+ if (entry) {
21
+ return entry[1] as Platform;
22
+ }
23
+ const validNames = Object.entries(Platform)
24
+ .filter(([, val]) => typeof val === "number")
25
+ .map(([key]) => key.toUpperCase())
26
+ .join(", ");
27
+ throw new Error(
28
+ `Unknown platform "${value}". Expected one of: ${validNames}`,
29
+ );
30
+ };
31
+
32
+ export const platformToString = (platform: Platform): string => {
33
+ const name = Platform[platform];
34
+ if (name !== undefined) {
35
+ return name;
36
+ }
37
+ throw new Error(`Unknown platform value: ${platform}`);
38
+ };
39
+
4
40
  export interface Global {
5
41
  // unused
6
42
  initialized: boolean;