@pump-fun/pump-sdk 1.29.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/dist/esm/index.js +191 -2
- package/dist/index.d.mts +92 -3
- package/dist/index.d.ts +92 -3
- package/dist/index.js +191 -2
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/pda.ts +8 -0
- package/src/sdk.ts +216 -2
- package/src/state.ts +36 -0
package/README.md
CHANGED
|
@@ -163,3 +163,48 @@ 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 or null for ungraduated
|
|
190
|
+
await PUMP_SDK.createSharingConfigWithSocialRecipients({
|
|
191
|
+
creator,
|
|
192
|
+
mint,
|
|
193
|
+
pool,
|
|
194
|
+
newShareholders: [
|
|
195
|
+
{ address: creator, shareBps: 7000 },
|
|
196
|
+
{ userId: "1234567", platform: Platform.GitHub, shareBps: 3000 },
|
|
197
|
+
],
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Method selection:
|
|
202
|
+
- `updateSharingConfigWithSocialRecipients`: use when sharing config already exists.
|
|
203
|
+
- `createSharingConfigWithSocialRecipients`: use for first-time setup (creates config, then updates shares).
|
|
204
|
+
|
|
205
|
+
✅ Checklist
|
|
206
|
+
|
|
207
|
+
- [ ] 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.
|
|
208
|
+
- [ ] Only `Platform.GitHub` is supported. Any attempt to use a different platform value can result in the coin being banned or **fees lost**.
|
|
209
|
+
- [ ] 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.
|
|
210
|
+
- [ ] 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(
|
|
@@ -20455,9 +20484,9 @@ var PumpSdk = class {
|
|
|
20455
20484
|
* Creates a fee sharing configuration for a token.
|
|
20456
20485
|
*
|
|
20457
20486
|
* @param params - Parameters for creating a fee sharing configuration
|
|
20458
|
-
* @param params.creator - The creator of the token
|
|
20487
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
20459
20488
|
* @param params.mint - The mint address of the token
|
|
20460
|
-
* @param params.pool - The pool address of the token
|
|
20489
|
+
* @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
|
|
20461
20490
|
*/
|
|
20462
20491
|
async createFeeSharingConfig({
|
|
20463
20492
|
creator,
|
|
@@ -20608,6 +20637,154 @@ var PumpSdk = class {
|
|
|
20608
20637
|
user
|
|
20609
20638
|
}).instruction();
|
|
20610
20639
|
}
|
|
20640
|
+
/**
|
|
20641
|
+
* Creates a social fee PDA that can accumulate fees for a social media user.
|
|
20642
|
+
*
|
|
20643
|
+
* @param params.payer - Any signer account that pays for the transaction.
|
|
20644
|
+
* @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
20645
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
20646
|
+
* @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
|
|
20647
|
+
* In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
20648
|
+
*/
|
|
20649
|
+
async createSocialFeePda({
|
|
20650
|
+
payer,
|
|
20651
|
+
userId,
|
|
20652
|
+
platform
|
|
20653
|
+
}) {
|
|
20654
|
+
if (!SUPPORTED_SOCIAL_PLATFORMS.includes(platform)) {
|
|
20655
|
+
const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map(
|
|
20656
|
+
(supportedPlatform) => platformToString(supportedPlatform)
|
|
20657
|
+
).join(", ");
|
|
20658
|
+
throw new Error(
|
|
20659
|
+
`Unsupported platform "${platform}" for userId "${userId}". Supported platforms: ${supportedPlatformNames}.`
|
|
20660
|
+
);
|
|
20661
|
+
}
|
|
20662
|
+
return await this.offlinePumpFeeProgram.methods.createSocialFeePda(userId, platform).accountsPartial({
|
|
20663
|
+
payer,
|
|
20664
|
+
socialFeePda: socialFeePda(userId, platform)
|
|
20665
|
+
}).instruction();
|
|
20666
|
+
}
|
|
20667
|
+
normalizeSocialShareholders({
|
|
20668
|
+
newShareholders
|
|
20669
|
+
}) {
|
|
20670
|
+
const socialRecipientsToCreate = /* @__PURE__ */ new Map();
|
|
20671
|
+
const normalizedShareholders = newShareholders.map(
|
|
20672
|
+
(shareholder) => {
|
|
20673
|
+
if (shareholder.address) {
|
|
20674
|
+
return {
|
|
20675
|
+
address: shareholder.address,
|
|
20676
|
+
shareBps: shareholder.shareBps
|
|
20677
|
+
};
|
|
20678
|
+
}
|
|
20679
|
+
if (typeof shareholder.userId === "string" && typeof shareholder.platform === "number") {
|
|
20680
|
+
if (!SUPPORTED_SOCIAL_PLATFORMS.includes(shareholder.platform)) {
|
|
20681
|
+
const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map(
|
|
20682
|
+
(platform) => platformToString(platform)
|
|
20683
|
+
).join(", ");
|
|
20684
|
+
throw new Error(
|
|
20685
|
+
`Unsupported platform "${shareholder.platform}" for userId "${shareholder.userId}". Supported platforms: ${supportedPlatformNames}.`
|
|
20686
|
+
);
|
|
20687
|
+
}
|
|
20688
|
+
const recipientPda = socialFeePda(shareholder.userId, shareholder.platform);
|
|
20689
|
+
socialRecipientsToCreate.set(recipientPda.toBase58(), {
|
|
20690
|
+
userId: shareholder.userId,
|
|
20691
|
+
platform: shareholder.platform
|
|
20692
|
+
});
|
|
20693
|
+
return {
|
|
20694
|
+
address: recipientPda,
|
|
20695
|
+
shareBps: shareholder.shareBps
|
|
20696
|
+
};
|
|
20697
|
+
}
|
|
20698
|
+
throw new Error(
|
|
20699
|
+
"Each new shareholder must provide either an address or both userId and platform."
|
|
20700
|
+
);
|
|
20701
|
+
}
|
|
20702
|
+
);
|
|
20703
|
+
return {
|
|
20704
|
+
normalizedShareholders,
|
|
20705
|
+
socialRecipientsToCreate
|
|
20706
|
+
};
|
|
20707
|
+
}
|
|
20708
|
+
/**
|
|
20709
|
+
* Wrapper around `updateSharingConfig` that resolves social recipients and
|
|
20710
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
20711
|
+
*
|
|
20712
|
+
* Requirements:
|
|
20713
|
+
* - `authority` must sign the transaction.
|
|
20714
|
+
*
|
|
20715
|
+
* Warning:
|
|
20716
|
+
* - sharing config must exist for that mint
|
|
20717
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
20718
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
20719
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
20720
|
+
*/
|
|
20721
|
+
async updateSharingConfigWithSocialRecipients({
|
|
20722
|
+
authority,
|
|
20723
|
+
mint,
|
|
20724
|
+
currentShareholders,
|
|
20725
|
+
newShareholders
|
|
20726
|
+
}) {
|
|
20727
|
+
const instructions = [];
|
|
20728
|
+
const { normalizedShareholders, socialRecipientsToCreate } = this.normalizeSocialShareholders({ newShareholders });
|
|
20729
|
+
for (const recipient of socialRecipientsToCreate.values()) {
|
|
20730
|
+
instructions.push(
|
|
20731
|
+
await this.createSocialFeePda({
|
|
20732
|
+
payer: authority,
|
|
20733
|
+
userId: recipient.userId,
|
|
20734
|
+
platform: recipient.platform
|
|
20735
|
+
})
|
|
20736
|
+
);
|
|
20737
|
+
}
|
|
20738
|
+
instructions.push(
|
|
20739
|
+
await this.updateFeeShares({
|
|
20740
|
+
authority,
|
|
20741
|
+
mint,
|
|
20742
|
+
currentShareholders,
|
|
20743
|
+
newShareholders: normalizedShareholders
|
|
20744
|
+
})
|
|
20745
|
+
);
|
|
20746
|
+
return instructions;
|
|
20747
|
+
}
|
|
20748
|
+
/**
|
|
20749
|
+
* Wrapper around `createFeeSharingConfig` that resolves social recipients and
|
|
20750
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
20751
|
+
*
|
|
20752
|
+
* Requirements:
|
|
20753
|
+
* - `creator` must sign the transaction.
|
|
20754
|
+
* - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
|
|
20755
|
+
*
|
|
20756
|
+
* Warning:
|
|
20757
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
20758
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
20759
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
20760
|
+
*/
|
|
20761
|
+
async createSharingConfigWithSocialRecipients({
|
|
20762
|
+
creator,
|
|
20763
|
+
mint,
|
|
20764
|
+
pool,
|
|
20765
|
+
newShareholders
|
|
20766
|
+
}) {
|
|
20767
|
+
const instructions = [];
|
|
20768
|
+
instructions.push(
|
|
20769
|
+
await this.createFeeSharingConfig({
|
|
20770
|
+
creator,
|
|
20771
|
+
mint,
|
|
20772
|
+
pool
|
|
20773
|
+
})
|
|
20774
|
+
);
|
|
20775
|
+
instructions.push(
|
|
20776
|
+
...await this.updateSharingConfigWithSocialRecipients({
|
|
20777
|
+
authority: creator,
|
|
20778
|
+
mint,
|
|
20779
|
+
currentShareholders: [creator],
|
|
20780
|
+
newShareholders
|
|
20781
|
+
})
|
|
20782
|
+
);
|
|
20783
|
+
return instructions;
|
|
20784
|
+
}
|
|
20785
|
+
claimSocialFeePda() {
|
|
20786
|
+
throw new Error("This function can only be called by pump and is not supported");
|
|
20787
|
+
}
|
|
20611
20788
|
};
|
|
20612
20789
|
var PUMP_SDK = new PumpSdk();
|
|
20613
20790
|
function isCreatorUsingSharingConfig({
|
|
@@ -20704,6 +20881,13 @@ var ammCreatorVaultPda = (creator) => {
|
|
|
20704
20881
|
PUMP_AMM_PROGRAM_ID
|
|
20705
20882
|
)[0];
|
|
20706
20883
|
};
|
|
20884
|
+
var socialFeePda = (userId, platform) => {
|
|
20885
|
+
return pumpFeePda([
|
|
20886
|
+
import_buffer.Buffer.from("social-fee-pda"),
|
|
20887
|
+
import_buffer.Buffer.from(userId),
|
|
20888
|
+
import_buffer.Buffer.from([platform])
|
|
20889
|
+
]);
|
|
20890
|
+
};
|
|
20707
20891
|
export {
|
|
20708
20892
|
AMM_GLOBAL_PDA,
|
|
20709
20893
|
AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA,
|
|
@@ -20724,8 +20908,10 @@ export {
|
|
|
20724
20908
|
PUMP_FEE_PROGRAM_ID,
|
|
20725
20909
|
PUMP_PROGRAM_ID,
|
|
20726
20910
|
PUMP_SDK,
|
|
20911
|
+
Platform,
|
|
20727
20912
|
PoolRequiredForGraduatedError,
|
|
20728
20913
|
PumpSdk,
|
|
20914
|
+
SUPPORTED_SOCIAL_PLATFORMS,
|
|
20729
20915
|
ShareCalculationOverflowError,
|
|
20730
20916
|
TooManyShareholdersError,
|
|
20731
20917
|
ZeroShareError,
|
|
@@ -20750,8 +20936,11 @@ export {
|
|
|
20750
20936
|
getTokenVaultPda,
|
|
20751
20937
|
isCreatorUsingSharingConfig,
|
|
20752
20938
|
newBondingCurve,
|
|
20939
|
+
platformToString,
|
|
20753
20940
|
pump_default as pumpIdl,
|
|
20754
20941
|
pumpPoolAuthorityPda,
|
|
20942
|
+
socialFeePda,
|
|
20943
|
+
stringToPlatform,
|
|
20755
20944
|
totalUnclaimedTokens,
|
|
20756
20945
|
userVolumeAccumulatorPda
|
|
20757
20946
|
};
|
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;
|
|
@@ -16956,6 +16967,7 @@ declare const getSolVaultPda: () => PublicKey;
|
|
|
16956
16967
|
declare const getTokenVaultPda: (mintPubkey: PublicKey) => PublicKey;
|
|
16957
16968
|
declare const feeSharingConfigPda: (mint: PublicKey) => PublicKey;
|
|
16958
16969
|
declare const ammCreatorVaultPda: (creator: PublicKey) => PublicKey;
|
|
16970
|
+
declare const socialFeePda: (userId: string, platform: number) => PublicKey;
|
|
16959
16971
|
|
|
16960
16972
|
/**
|
|
16961
16973
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
@@ -22728,9 +22740,9 @@ declare class PumpSdk {
|
|
|
22728
22740
|
* Creates a fee sharing configuration for a token.
|
|
22729
22741
|
*
|
|
22730
22742
|
* @param params - Parameters for creating a fee sharing configuration
|
|
22731
|
-
* @param params.creator - The creator of the token
|
|
22743
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
22732
22744
|
* @param params.mint - The mint address of the token
|
|
22733
|
-
* @param params.pool - The pool address of the token
|
|
22745
|
+
* @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
|
|
22734
22746
|
*/
|
|
22735
22747
|
createFeeSharingConfig({ creator, mint, pool, }: {
|
|
22736
22748
|
creator: PublicKey;
|
|
@@ -22792,6 +22804,83 @@ declare class PumpSdk {
|
|
|
22792
22804
|
claimCashbackInstruction({ user, }: {
|
|
22793
22805
|
user: PublicKey;
|
|
22794
22806
|
}): Promise<TransactionInstruction>;
|
|
22807
|
+
/**
|
|
22808
|
+
* Creates a social fee PDA that can accumulate fees for a social media user.
|
|
22809
|
+
*
|
|
22810
|
+
* @param params.payer - Any signer account that pays for the transaction.
|
|
22811
|
+
* @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
22812
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
22813
|
+
* @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
|
|
22814
|
+
* In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
22815
|
+
*/
|
|
22816
|
+
createSocialFeePda({ payer, userId, platform, }: {
|
|
22817
|
+
payer: PublicKey;
|
|
22818
|
+
userId: string;
|
|
22819
|
+
platform: Platform;
|
|
22820
|
+
}): Promise<TransactionInstruction>;
|
|
22821
|
+
normalizeSocialShareholders({ newShareholders, }: {
|
|
22822
|
+
newShareholders: Array<{
|
|
22823
|
+
shareBps: number;
|
|
22824
|
+
address?: PublicKey;
|
|
22825
|
+
userId?: string;
|
|
22826
|
+
platform?: Platform;
|
|
22827
|
+
}>;
|
|
22828
|
+
}): {
|
|
22829
|
+
normalizedShareholders: Shareholder[];
|
|
22830
|
+
socialRecipientsToCreate: Map<string, {
|
|
22831
|
+
userId: string;
|
|
22832
|
+
platform: Platform;
|
|
22833
|
+
}>;
|
|
22834
|
+
};
|
|
22835
|
+
/**
|
|
22836
|
+
* Wrapper around `updateSharingConfig` that resolves social recipients and
|
|
22837
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
22838
|
+
*
|
|
22839
|
+
* Requirements:
|
|
22840
|
+
* - `authority` must sign the transaction.
|
|
22841
|
+
*
|
|
22842
|
+
* Warning:
|
|
22843
|
+
* - sharing config must exist for that mint
|
|
22844
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
22845
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
22846
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
22847
|
+
*/
|
|
22848
|
+
updateSharingConfigWithSocialRecipients({ authority, mint, currentShareholders, newShareholders, }: {
|
|
22849
|
+
authority: PublicKey;
|
|
22850
|
+
mint: PublicKey;
|
|
22851
|
+
currentShareholders: PublicKey[];
|
|
22852
|
+
newShareholders: Array<{
|
|
22853
|
+
shareBps: number;
|
|
22854
|
+
address?: PublicKey;
|
|
22855
|
+
userId?: string;
|
|
22856
|
+
platform?: Platform;
|
|
22857
|
+
}>;
|
|
22858
|
+
}): Promise<TransactionInstruction[]>;
|
|
22859
|
+
/**
|
|
22860
|
+
* Wrapper around `createFeeSharingConfig` that resolves social recipients and
|
|
22861
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
22862
|
+
*
|
|
22863
|
+
* Requirements:
|
|
22864
|
+
* - `creator` must sign the transaction.
|
|
22865
|
+
* - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
|
|
22866
|
+
*
|
|
22867
|
+
* Warning:
|
|
22868
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
22869
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
22870
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
22871
|
+
*/
|
|
22872
|
+
createSharingConfigWithSocialRecipients({ creator, mint, pool, newShareholders, }: {
|
|
22873
|
+
creator: PublicKey;
|
|
22874
|
+
mint: PublicKey;
|
|
22875
|
+
pool: PublicKey | null;
|
|
22876
|
+
newShareholders: Array<{
|
|
22877
|
+
shareBps: number;
|
|
22878
|
+
address?: PublicKey;
|
|
22879
|
+
userId?: string;
|
|
22880
|
+
platform?: Platform;
|
|
22881
|
+
}>;
|
|
22882
|
+
}): Promise<TransactionInstruction[]>;
|
|
22883
|
+
claimSocialFeePda(): void;
|
|
22795
22884
|
}
|
|
22796
22885
|
declare const PUMP_SDK: PumpSdk;
|
|
22797
22886
|
/**
|
|
@@ -22938,4 +23027,4 @@ declare class PoolRequiredForGraduatedError extends Error {
|
|
|
22938
23027
|
constructor();
|
|
22939
23028
|
}
|
|
22940
23029
|
|
|
22941
|
-
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, bondingCurveV2Pda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, feeSharingConfigPda, getBuySolAmountFromTokenAmount, getBuyTokenAmountFromSolAmount, getEventAuthorityPda, getGlobalParamsPda, getMayhemStatePda, getPumpAmmProgram, getPumpFeeProgram, getPumpProgram, getSellSolAmountFromTokenAmount, getSolVaultPda, getTokenVaultPda, isCreatorUsingSharingConfig, newBondingCurve, pump as pumpIdl, pumpPoolAuthorityPda, totalUnclaimedTokens, userVolumeAccumulatorPda };
|
|
23030
|
+
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, bondingCurveV2Pda, 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;
|
|
@@ -16956,6 +16967,7 @@ declare const getSolVaultPda: () => PublicKey;
|
|
|
16956
16967
|
declare const getTokenVaultPda: (mintPubkey: PublicKey) => PublicKey;
|
|
16957
16968
|
declare const feeSharingConfigPda: (mint: PublicKey) => PublicKey;
|
|
16958
16969
|
declare const ammCreatorVaultPda: (creator: PublicKey) => PublicKey;
|
|
16970
|
+
declare const socialFeePda: (userId: string, platform: number) => PublicKey;
|
|
16959
16971
|
|
|
16960
16972
|
/**
|
|
16961
16973
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
@@ -22728,9 +22740,9 @@ declare class PumpSdk {
|
|
|
22728
22740
|
* Creates a fee sharing configuration for a token.
|
|
22729
22741
|
*
|
|
22730
22742
|
* @param params - Parameters for creating a fee sharing configuration
|
|
22731
|
-
* @param params.creator - The creator of the token
|
|
22743
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
22732
22744
|
* @param params.mint - The mint address of the token
|
|
22733
|
-
* @param params.pool - The pool address of the token
|
|
22745
|
+
* @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
|
|
22734
22746
|
*/
|
|
22735
22747
|
createFeeSharingConfig({ creator, mint, pool, }: {
|
|
22736
22748
|
creator: PublicKey;
|
|
@@ -22792,6 +22804,83 @@ declare class PumpSdk {
|
|
|
22792
22804
|
claimCashbackInstruction({ user, }: {
|
|
22793
22805
|
user: PublicKey;
|
|
22794
22806
|
}): Promise<TransactionInstruction>;
|
|
22807
|
+
/**
|
|
22808
|
+
* Creates a social fee PDA that can accumulate fees for a social media user.
|
|
22809
|
+
*
|
|
22810
|
+
* @param params.payer - Any signer account that pays for the transaction.
|
|
22811
|
+
* @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
22812
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
22813
|
+
* @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
|
|
22814
|
+
* In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
22815
|
+
*/
|
|
22816
|
+
createSocialFeePda({ payer, userId, platform, }: {
|
|
22817
|
+
payer: PublicKey;
|
|
22818
|
+
userId: string;
|
|
22819
|
+
platform: Platform;
|
|
22820
|
+
}): Promise<TransactionInstruction>;
|
|
22821
|
+
normalizeSocialShareholders({ newShareholders, }: {
|
|
22822
|
+
newShareholders: Array<{
|
|
22823
|
+
shareBps: number;
|
|
22824
|
+
address?: PublicKey;
|
|
22825
|
+
userId?: string;
|
|
22826
|
+
platform?: Platform;
|
|
22827
|
+
}>;
|
|
22828
|
+
}): {
|
|
22829
|
+
normalizedShareholders: Shareholder[];
|
|
22830
|
+
socialRecipientsToCreate: Map<string, {
|
|
22831
|
+
userId: string;
|
|
22832
|
+
platform: Platform;
|
|
22833
|
+
}>;
|
|
22834
|
+
};
|
|
22835
|
+
/**
|
|
22836
|
+
* Wrapper around `updateSharingConfig` that resolves social recipients and
|
|
22837
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
22838
|
+
*
|
|
22839
|
+
* Requirements:
|
|
22840
|
+
* - `authority` must sign the transaction.
|
|
22841
|
+
*
|
|
22842
|
+
* Warning:
|
|
22843
|
+
* - sharing config must exist for that mint
|
|
22844
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
22845
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
22846
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
22847
|
+
*/
|
|
22848
|
+
updateSharingConfigWithSocialRecipients({ authority, mint, currentShareholders, newShareholders, }: {
|
|
22849
|
+
authority: PublicKey;
|
|
22850
|
+
mint: PublicKey;
|
|
22851
|
+
currentShareholders: PublicKey[];
|
|
22852
|
+
newShareholders: Array<{
|
|
22853
|
+
shareBps: number;
|
|
22854
|
+
address?: PublicKey;
|
|
22855
|
+
userId?: string;
|
|
22856
|
+
platform?: Platform;
|
|
22857
|
+
}>;
|
|
22858
|
+
}): Promise<TransactionInstruction[]>;
|
|
22859
|
+
/**
|
|
22860
|
+
* Wrapper around `createFeeSharingConfig` that resolves social recipients and
|
|
22861
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
22862
|
+
*
|
|
22863
|
+
* Requirements:
|
|
22864
|
+
* - `creator` must sign the transaction.
|
|
22865
|
+
* - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
|
|
22866
|
+
*
|
|
22867
|
+
* Warning:
|
|
22868
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
22869
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
22870
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
22871
|
+
*/
|
|
22872
|
+
createSharingConfigWithSocialRecipients({ creator, mint, pool, newShareholders, }: {
|
|
22873
|
+
creator: PublicKey;
|
|
22874
|
+
mint: PublicKey;
|
|
22875
|
+
pool: PublicKey | null;
|
|
22876
|
+
newShareholders: Array<{
|
|
22877
|
+
shareBps: number;
|
|
22878
|
+
address?: PublicKey;
|
|
22879
|
+
userId?: string;
|
|
22880
|
+
platform?: Platform;
|
|
22881
|
+
}>;
|
|
22882
|
+
}): Promise<TransactionInstruction[]>;
|
|
22883
|
+
claimSocialFeePda(): void;
|
|
22795
22884
|
}
|
|
22796
22885
|
declare const PUMP_SDK: PumpSdk;
|
|
22797
22886
|
/**
|
|
@@ -22938,4 +23027,4 @@ declare class PoolRequiredForGraduatedError extends Error {
|
|
|
22938
23027
|
constructor();
|
|
22939
23028
|
}
|
|
22940
23029
|
|
|
22941
|
-
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, bondingCurveV2Pda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, feeSharingConfigPda, getBuySolAmountFromTokenAmount, getBuyTokenAmountFromSolAmount, getEventAuthorityPda, getGlobalParamsPda, getMayhemStatePda, getPumpAmmProgram, getPumpFeeProgram, getPumpProgram, getSellSolAmountFromTokenAmount, getSolVaultPda, getTokenVaultPda, isCreatorUsingSharingConfig, newBondingCurve, pump as pumpIdl, pumpPoolAuthorityPda, totalUnclaimedTokens, userVolumeAccumulatorPda };
|
|
23030
|
+
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, bondingCurveV2Pda, 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,
|
|
@@ -1855,8 +1857,11 @@ __export(index_exports, {
|
|
|
1855
1857
|
getTokenVaultPda: () => getTokenVaultPda,
|
|
1856
1858
|
isCreatorUsingSharingConfig: () => isCreatorUsingSharingConfig,
|
|
1857
1859
|
newBondingCurve: () => newBondingCurve,
|
|
1860
|
+
platformToString: () => platformToString,
|
|
1858
1861
|
pumpIdl: () => pump_default,
|
|
1859
1862
|
pumpPoolAuthorityPda: () => pumpPoolAuthorityPda,
|
|
1863
|
+
socialFeePda: () => socialFeePda,
|
|
1864
|
+
stringToPlatform: () => stringToPlatform,
|
|
1860
1865
|
totalUnclaimedTokens: () => totalUnclaimedTokens,
|
|
1861
1866
|
userVolumeAccumulatorPda: () => userVolumeAccumulatorPda
|
|
1862
1867
|
});
|
|
@@ -19936,6 +19941,35 @@ var OnlinePumpSdk = class {
|
|
|
19936
19941
|
}
|
|
19937
19942
|
};
|
|
19938
19943
|
|
|
19944
|
+
// src/state.ts
|
|
19945
|
+
var Platform = /* @__PURE__ */ ((Platform3) => {
|
|
19946
|
+
Platform3[Platform3["Pump"] = 0] = "Pump";
|
|
19947
|
+
Platform3[Platform3["X"] = 1] = "X";
|
|
19948
|
+
Platform3[Platform3["GitHub"] = 2] = "GitHub";
|
|
19949
|
+
return Platform3;
|
|
19950
|
+
})(Platform || {});
|
|
19951
|
+
var SUPPORTED_SOCIAL_PLATFORMS = [2 /* GitHub */];
|
|
19952
|
+
var stringToPlatform = (value) => {
|
|
19953
|
+
const normalized = value.trim().toUpperCase();
|
|
19954
|
+
const entry = Object.entries(Platform).find(
|
|
19955
|
+
([key, val]) => typeof val === "number" && key.toUpperCase() === normalized
|
|
19956
|
+
);
|
|
19957
|
+
if (entry) {
|
|
19958
|
+
return entry[1];
|
|
19959
|
+
}
|
|
19960
|
+
const validNames = Object.entries(Platform).filter(([, val]) => typeof val === "number").map(([key]) => key.toUpperCase()).join(", ");
|
|
19961
|
+
throw new Error(
|
|
19962
|
+
`Unknown platform "${value}". Expected one of: ${validNames}`
|
|
19963
|
+
);
|
|
19964
|
+
};
|
|
19965
|
+
var platformToString = (platform) => {
|
|
19966
|
+
const name = Platform[platform];
|
|
19967
|
+
if (name !== void 0) {
|
|
19968
|
+
return name;
|
|
19969
|
+
}
|
|
19970
|
+
throw new Error(`Unknown platform value: ${platform}`);
|
|
19971
|
+
};
|
|
19972
|
+
|
|
19939
19973
|
// src/sdk.ts
|
|
19940
19974
|
function getPumpProgram(connection) {
|
|
19941
19975
|
return new import_anchor.Program(
|
|
@@ -20481,9 +20515,9 @@ var PumpSdk = class {
|
|
|
20481
20515
|
* Creates a fee sharing configuration for a token.
|
|
20482
20516
|
*
|
|
20483
20517
|
* @param params - Parameters for creating a fee sharing configuration
|
|
20484
|
-
* @param params.creator - The creator of the token
|
|
20518
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
20485
20519
|
* @param params.mint - The mint address of the token
|
|
20486
|
-
* @param params.pool - The pool address of the token
|
|
20520
|
+
* @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
|
|
20487
20521
|
*/
|
|
20488
20522
|
async createFeeSharingConfig({
|
|
20489
20523
|
creator,
|
|
@@ -20634,6 +20668,154 @@ var PumpSdk = class {
|
|
|
20634
20668
|
user
|
|
20635
20669
|
}).instruction();
|
|
20636
20670
|
}
|
|
20671
|
+
/**
|
|
20672
|
+
* Creates a social fee PDA that can accumulate fees for a social media user.
|
|
20673
|
+
*
|
|
20674
|
+
* @param params.payer - Any signer account that pays for the transaction.
|
|
20675
|
+
* @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
20676
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
20677
|
+
* @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
|
|
20678
|
+
* In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
20679
|
+
*/
|
|
20680
|
+
async createSocialFeePda({
|
|
20681
|
+
payer,
|
|
20682
|
+
userId,
|
|
20683
|
+
platform
|
|
20684
|
+
}) {
|
|
20685
|
+
if (!SUPPORTED_SOCIAL_PLATFORMS.includes(platform)) {
|
|
20686
|
+
const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map(
|
|
20687
|
+
(supportedPlatform) => platformToString(supportedPlatform)
|
|
20688
|
+
).join(", ");
|
|
20689
|
+
throw new Error(
|
|
20690
|
+
`Unsupported platform "${platform}" for userId "${userId}". Supported platforms: ${supportedPlatformNames}.`
|
|
20691
|
+
);
|
|
20692
|
+
}
|
|
20693
|
+
return await this.offlinePumpFeeProgram.methods.createSocialFeePda(userId, platform).accountsPartial({
|
|
20694
|
+
payer,
|
|
20695
|
+
socialFeePda: socialFeePda(userId, platform)
|
|
20696
|
+
}).instruction();
|
|
20697
|
+
}
|
|
20698
|
+
normalizeSocialShareholders({
|
|
20699
|
+
newShareholders
|
|
20700
|
+
}) {
|
|
20701
|
+
const socialRecipientsToCreate = /* @__PURE__ */ new Map();
|
|
20702
|
+
const normalizedShareholders = newShareholders.map(
|
|
20703
|
+
(shareholder) => {
|
|
20704
|
+
if (shareholder.address) {
|
|
20705
|
+
return {
|
|
20706
|
+
address: shareholder.address,
|
|
20707
|
+
shareBps: shareholder.shareBps
|
|
20708
|
+
};
|
|
20709
|
+
}
|
|
20710
|
+
if (typeof shareholder.userId === "string" && typeof shareholder.platform === "number") {
|
|
20711
|
+
if (!SUPPORTED_SOCIAL_PLATFORMS.includes(shareholder.platform)) {
|
|
20712
|
+
const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map(
|
|
20713
|
+
(platform) => platformToString(platform)
|
|
20714
|
+
).join(", ");
|
|
20715
|
+
throw new Error(
|
|
20716
|
+
`Unsupported platform "${shareholder.platform}" for userId "${shareholder.userId}". Supported platforms: ${supportedPlatformNames}.`
|
|
20717
|
+
);
|
|
20718
|
+
}
|
|
20719
|
+
const recipientPda = socialFeePda(shareholder.userId, shareholder.platform);
|
|
20720
|
+
socialRecipientsToCreate.set(recipientPda.toBase58(), {
|
|
20721
|
+
userId: shareholder.userId,
|
|
20722
|
+
platform: shareholder.platform
|
|
20723
|
+
});
|
|
20724
|
+
return {
|
|
20725
|
+
address: recipientPda,
|
|
20726
|
+
shareBps: shareholder.shareBps
|
|
20727
|
+
};
|
|
20728
|
+
}
|
|
20729
|
+
throw new Error(
|
|
20730
|
+
"Each new shareholder must provide either an address or both userId and platform."
|
|
20731
|
+
);
|
|
20732
|
+
}
|
|
20733
|
+
);
|
|
20734
|
+
return {
|
|
20735
|
+
normalizedShareholders,
|
|
20736
|
+
socialRecipientsToCreate
|
|
20737
|
+
};
|
|
20738
|
+
}
|
|
20739
|
+
/**
|
|
20740
|
+
* Wrapper around `updateSharingConfig` that resolves social recipients and
|
|
20741
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
20742
|
+
*
|
|
20743
|
+
* Requirements:
|
|
20744
|
+
* - `authority` must sign the transaction.
|
|
20745
|
+
*
|
|
20746
|
+
* Warning:
|
|
20747
|
+
* - sharing config must exist for that mint
|
|
20748
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
20749
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
20750
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
20751
|
+
*/
|
|
20752
|
+
async updateSharingConfigWithSocialRecipients({
|
|
20753
|
+
authority,
|
|
20754
|
+
mint,
|
|
20755
|
+
currentShareholders,
|
|
20756
|
+
newShareholders
|
|
20757
|
+
}) {
|
|
20758
|
+
const instructions = [];
|
|
20759
|
+
const { normalizedShareholders, socialRecipientsToCreate } = this.normalizeSocialShareholders({ newShareholders });
|
|
20760
|
+
for (const recipient of socialRecipientsToCreate.values()) {
|
|
20761
|
+
instructions.push(
|
|
20762
|
+
await this.createSocialFeePda({
|
|
20763
|
+
payer: authority,
|
|
20764
|
+
userId: recipient.userId,
|
|
20765
|
+
platform: recipient.platform
|
|
20766
|
+
})
|
|
20767
|
+
);
|
|
20768
|
+
}
|
|
20769
|
+
instructions.push(
|
|
20770
|
+
await this.updateFeeShares({
|
|
20771
|
+
authority,
|
|
20772
|
+
mint,
|
|
20773
|
+
currentShareholders,
|
|
20774
|
+
newShareholders: normalizedShareholders
|
|
20775
|
+
})
|
|
20776
|
+
);
|
|
20777
|
+
return instructions;
|
|
20778
|
+
}
|
|
20779
|
+
/**
|
|
20780
|
+
* Wrapper around `createFeeSharingConfig` that resolves social recipients and
|
|
20781
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
20782
|
+
*
|
|
20783
|
+
* Requirements:
|
|
20784
|
+
* - `creator` must sign the transaction.
|
|
20785
|
+
* - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
|
|
20786
|
+
*
|
|
20787
|
+
* Warning:
|
|
20788
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
20789
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
20790
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
20791
|
+
*/
|
|
20792
|
+
async createSharingConfigWithSocialRecipients({
|
|
20793
|
+
creator,
|
|
20794
|
+
mint,
|
|
20795
|
+
pool,
|
|
20796
|
+
newShareholders
|
|
20797
|
+
}) {
|
|
20798
|
+
const instructions = [];
|
|
20799
|
+
instructions.push(
|
|
20800
|
+
await this.createFeeSharingConfig({
|
|
20801
|
+
creator,
|
|
20802
|
+
mint,
|
|
20803
|
+
pool
|
|
20804
|
+
})
|
|
20805
|
+
);
|
|
20806
|
+
instructions.push(
|
|
20807
|
+
...await this.updateSharingConfigWithSocialRecipients({
|
|
20808
|
+
authority: creator,
|
|
20809
|
+
mint,
|
|
20810
|
+
currentShareholders: [creator],
|
|
20811
|
+
newShareholders
|
|
20812
|
+
})
|
|
20813
|
+
);
|
|
20814
|
+
return instructions;
|
|
20815
|
+
}
|
|
20816
|
+
claimSocialFeePda() {
|
|
20817
|
+
throw new Error("This function can only be called by pump and is not supported");
|
|
20818
|
+
}
|
|
20637
20819
|
};
|
|
20638
20820
|
var PUMP_SDK = new PumpSdk();
|
|
20639
20821
|
function isCreatorUsingSharingConfig({
|
|
@@ -20730,6 +20912,13 @@ var ammCreatorVaultPda = (creator) => {
|
|
|
20730
20912
|
PUMP_AMM_PROGRAM_ID
|
|
20731
20913
|
)[0];
|
|
20732
20914
|
};
|
|
20915
|
+
var socialFeePda = (userId, platform) => {
|
|
20916
|
+
return (0, import_pump_swap_sdk3.pumpFeePda)([
|
|
20917
|
+
import_buffer.Buffer.from("social-fee-pda"),
|
|
20918
|
+
import_buffer.Buffer.from(userId),
|
|
20919
|
+
import_buffer.Buffer.from([platform])
|
|
20920
|
+
]);
|
|
20921
|
+
};
|
|
20733
20922
|
/*! Bundled license information:
|
|
20734
20923
|
|
|
20735
20924
|
ieee754/index.js:
|
package/package.json
CHANGED
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
|
@@ -128,3 +128,11 @@ export const ammCreatorVaultPda = (creator: PublicKey): PublicKey => {
|
|
|
128
128
|
PUMP_AMM_PROGRAM_ID,
|
|
129
129
|
)[0];
|
|
130
130
|
};
|
|
131
|
+
|
|
132
|
+
export const socialFeePda = (userId: string, platform: number): PublicKey => {
|
|
133
|
+
return pumpFeePda([
|
|
134
|
+
Buffer.from("social-fee-pda"),
|
|
135
|
+
Buffer.from(userId),
|
|
136
|
+
Buffer.from([platform]),
|
|
137
|
+
]);
|
|
138
|
+
};
|
package/src/sdk.ts
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
feeSharingConfigPda,
|
|
47
47
|
userVolumeAccumulatorPda,
|
|
48
48
|
bondingCurveV2Pda,
|
|
49
|
+
socialFeePda,
|
|
49
50
|
} from "./pda";
|
|
50
51
|
import {
|
|
51
52
|
BondingCurve,
|
|
@@ -57,6 +58,9 @@ import {
|
|
|
57
58
|
SharingConfig,
|
|
58
59
|
DistributeCreatorFeesEvent,
|
|
59
60
|
MinimumDistributableFeeEvent,
|
|
61
|
+
Platform,
|
|
62
|
+
SUPPORTED_SOCIAL_PLATFORMS,
|
|
63
|
+
platformToString,
|
|
60
64
|
} from "./state";
|
|
61
65
|
|
|
62
66
|
export function getPumpProgram(connection: Connection): Program<Pump> {
|
|
@@ -824,9 +828,9 @@ export class PumpSdk {
|
|
|
824
828
|
* Creates a fee sharing configuration for a token.
|
|
825
829
|
*
|
|
826
830
|
* @param params - Parameters for creating a fee sharing configuration
|
|
827
|
-
* @param params.creator - The creator of the token
|
|
831
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
828
832
|
* @param params.mint - The mint address of the token
|
|
829
|
-
* @param params.pool - The pool address of the token
|
|
833
|
+
* @param params.pool - The pool address of the token. Must be provided for graduated coins; use `null` for ungraduated coins.
|
|
830
834
|
*/
|
|
831
835
|
async createFeeSharingConfig({
|
|
832
836
|
creator,
|
|
@@ -1029,8 +1033,218 @@ export class PumpSdk {
|
|
|
1029
1033
|
})
|
|
1030
1034
|
.instruction();
|
|
1031
1035
|
}
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Creates a social fee PDA that can accumulate fees for a social media user.
|
|
1039
|
+
*
|
|
1040
|
+
* @param params.payer - Any signer account that pays for the transaction.
|
|
1041
|
+
* @param params.userId - Must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
1042
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
1043
|
+
* @param params.platform - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss.
|
|
1044
|
+
* In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
1045
|
+
*/
|
|
1046
|
+
async createSocialFeePda({
|
|
1047
|
+
payer,
|
|
1048
|
+
userId,
|
|
1049
|
+
platform,
|
|
1050
|
+
}: {
|
|
1051
|
+
payer: PublicKey;
|
|
1052
|
+
userId: string;
|
|
1053
|
+
platform: Platform;
|
|
1054
|
+
}): Promise<TransactionInstruction> {
|
|
1055
|
+
if (!SUPPORTED_SOCIAL_PLATFORMS.includes(platform)) {
|
|
1056
|
+
const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map((supportedPlatform) =>
|
|
1057
|
+
platformToString(supportedPlatform),
|
|
1058
|
+
).join(", ");
|
|
1059
|
+
throw new Error(
|
|
1060
|
+
`Unsupported platform "${platform}" for userId "${userId}". Supported platforms: ${supportedPlatformNames}.`,
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
return await this.offlinePumpFeeProgram.methods
|
|
1065
|
+
.createSocialFeePda(userId, platform)
|
|
1066
|
+
.accountsPartial({
|
|
1067
|
+
payer,
|
|
1068
|
+
socialFeePda: socialFeePda(userId, platform),
|
|
1069
|
+
})
|
|
1070
|
+
.instruction();
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
normalizeSocialShareholders({
|
|
1074
|
+
newShareholders,
|
|
1075
|
+
}: {
|
|
1076
|
+
newShareholders: Array<{
|
|
1077
|
+
shareBps: number;
|
|
1078
|
+
address?: PublicKey;
|
|
1079
|
+
userId?: string;
|
|
1080
|
+
platform?: Platform;
|
|
1081
|
+
}>;
|
|
1082
|
+
}): {
|
|
1083
|
+
normalizedShareholders: Shareholder[];
|
|
1084
|
+
socialRecipientsToCreate: Map<string, { userId: string; platform: Platform }>;
|
|
1085
|
+
} {
|
|
1086
|
+
const socialRecipientsToCreate = new Map<
|
|
1087
|
+
string,
|
|
1088
|
+
{ userId: string; platform: Platform }
|
|
1089
|
+
>();
|
|
1090
|
+
const normalizedShareholders: Shareholder[] = newShareholders.map(
|
|
1091
|
+
(shareholder) => {
|
|
1092
|
+
if (shareholder.address) {
|
|
1093
|
+
return {
|
|
1094
|
+
address: shareholder.address,
|
|
1095
|
+
shareBps: shareholder.shareBps,
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
if (
|
|
1100
|
+
typeof shareholder.userId === "string" &&
|
|
1101
|
+
typeof shareholder.platform === "number"
|
|
1102
|
+
) {
|
|
1103
|
+
if (!SUPPORTED_SOCIAL_PLATFORMS.includes(shareholder.platform)) {
|
|
1104
|
+
const supportedPlatformNames = SUPPORTED_SOCIAL_PLATFORMS.map((platform) =>
|
|
1105
|
+
platformToString(platform),
|
|
1106
|
+
).join(", ");
|
|
1107
|
+
throw new Error(
|
|
1108
|
+
`Unsupported platform "${shareholder.platform}" for userId "${shareholder.userId}". Supported platforms: ${supportedPlatformNames}.`,
|
|
1109
|
+
);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
const recipientPda = socialFeePda(shareholder.userId, shareholder.platform);
|
|
1113
|
+
socialRecipientsToCreate.set(recipientPda.toBase58(), {
|
|
1114
|
+
userId: shareholder.userId,
|
|
1115
|
+
platform: shareholder.platform,
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
return {
|
|
1119
|
+
address: recipientPda,
|
|
1120
|
+
shareBps: shareholder.shareBps,
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
throw new Error(
|
|
1125
|
+
"Each new shareholder must provide either an address or both userId and platform.",
|
|
1126
|
+
);
|
|
1127
|
+
},
|
|
1128
|
+
);
|
|
1129
|
+
|
|
1130
|
+
return {
|
|
1131
|
+
normalizedShareholders,
|
|
1132
|
+
socialRecipientsToCreate,
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Wrapper around `updateSharingConfig` that resolves social recipients and
|
|
1138
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
1139
|
+
*
|
|
1140
|
+
* Requirements:
|
|
1141
|
+
* - `authority` must sign the transaction.
|
|
1142
|
+
*
|
|
1143
|
+
* Warning:
|
|
1144
|
+
* - sharing config must exist for that mint
|
|
1145
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
1146
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
1147
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
1148
|
+
*/
|
|
1149
|
+
async updateSharingConfigWithSocialRecipients({
|
|
1150
|
+
authority,
|
|
1151
|
+
mint,
|
|
1152
|
+
currentShareholders,
|
|
1153
|
+
newShareholders,
|
|
1154
|
+
}: {
|
|
1155
|
+
authority: PublicKey;
|
|
1156
|
+
mint: PublicKey;
|
|
1157
|
+
currentShareholders: PublicKey[];
|
|
1158
|
+
newShareholders: Array<{
|
|
1159
|
+
shareBps: number;
|
|
1160
|
+
address?: PublicKey;
|
|
1161
|
+
userId?: string;
|
|
1162
|
+
platform?: Platform;
|
|
1163
|
+
}>;
|
|
1164
|
+
}): Promise<TransactionInstruction[]> {
|
|
1165
|
+
const instructions: TransactionInstruction[] = [];
|
|
1166
|
+
const { normalizedShareholders, socialRecipientsToCreate } =
|
|
1167
|
+
this.normalizeSocialShareholders({ newShareholders });
|
|
1168
|
+
|
|
1169
|
+
for (const recipient of socialRecipientsToCreate.values()) {
|
|
1170
|
+
instructions.push(
|
|
1171
|
+
await this.createSocialFeePda({
|
|
1172
|
+
payer: authority,
|
|
1173
|
+
userId: recipient.userId,
|
|
1174
|
+
platform: recipient.platform,
|
|
1175
|
+
}),
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
instructions.push(
|
|
1180
|
+
await this.updateFeeShares({
|
|
1181
|
+
authority,
|
|
1182
|
+
mint,
|
|
1183
|
+
currentShareholders,
|
|
1184
|
+
newShareholders: normalizedShareholders,
|
|
1185
|
+
}),
|
|
1186
|
+
);
|
|
1187
|
+
|
|
1188
|
+
return instructions;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* Wrapper around `createFeeSharingConfig` that resolves social recipients and
|
|
1193
|
+
* initializes any missing social recipient PDAs before updating fee shares.
|
|
1194
|
+
*
|
|
1195
|
+
* Requirements:
|
|
1196
|
+
* - `creator` must sign the transaction.
|
|
1197
|
+
* - `pool` must be provided for graduated coins; use `null` for ungraduated coins.
|
|
1198
|
+
*
|
|
1199
|
+
* Warning:
|
|
1200
|
+
* - `userId` must be the GitHub user id returned by `https://api.github.com/users/<github-username>`.
|
|
1201
|
+
* The target must be a real user account with a login. E.g: Organizations are not supported.
|
|
1202
|
+
* - Only `github` is supported at the moment, any attempt to use other platforms will result in fee loss. In doubt check `SUPPORTED_SOCIAL_PLATFORMS`
|
|
1203
|
+
*/
|
|
1204
|
+
async createSharingConfigWithSocialRecipients({
|
|
1205
|
+
creator,
|
|
1206
|
+
mint,
|
|
1207
|
+
pool,
|
|
1208
|
+
newShareholders,
|
|
1209
|
+
}: {
|
|
1210
|
+
creator: PublicKey;
|
|
1211
|
+
mint: PublicKey;
|
|
1212
|
+
pool: PublicKey | null;
|
|
1213
|
+
newShareholders: Array<{
|
|
1214
|
+
shareBps: number;
|
|
1215
|
+
address?: PublicKey;
|
|
1216
|
+
userId?: string;
|
|
1217
|
+
platform?: Platform;
|
|
1218
|
+
}>;
|
|
1219
|
+
}): Promise<TransactionInstruction[]> {
|
|
1220
|
+
const instructions: TransactionInstruction[] = [];
|
|
1221
|
+
|
|
1222
|
+
instructions.push(
|
|
1223
|
+
await this.createFeeSharingConfig({
|
|
1224
|
+
creator,
|
|
1225
|
+
mint,
|
|
1226
|
+
pool,
|
|
1227
|
+
}),
|
|
1228
|
+
);
|
|
1229
|
+
|
|
1230
|
+
instructions.push(
|
|
1231
|
+
...(await this.updateSharingConfigWithSocialRecipients({
|
|
1232
|
+
authority: creator,
|
|
1233
|
+
mint,
|
|
1234
|
+
currentShareholders: [creator],
|
|
1235
|
+
newShareholders,
|
|
1236
|
+
})),
|
|
1237
|
+
);
|
|
1238
|
+
|
|
1239
|
+
return instructions;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
claimSocialFeePda() {
|
|
1243
|
+
throw new Error("This function can only be called by pump and is not supported");
|
|
1244
|
+
}
|
|
1032
1245
|
}
|
|
1033
1246
|
|
|
1247
|
+
|
|
1034
1248
|
export const PUMP_SDK = new PumpSdk();
|
|
1035
1249
|
|
|
1036
1250
|
/**
|
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;
|