@pump-fun/pump-sdk 1.28.0 → 1.30.0-devnet.1
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 +46 -0
- package/dist/esm/index.js +217 -4
- package/dist/index.d.mts +93 -3
- package/dist/index.d.ts +93 -3
- package/dist/index.js +217 -4
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/pda.ts +15 -0
- package/src/sdk.ts +236 -3
- package/src/state.ts +36 -0
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(
|
|
@@ -20378,7 +20407,13 @@ var PumpSdk = class {
|
|
|
20378
20407
|
user,
|
|
20379
20408
|
creatorVault: creatorVaultPda(creator),
|
|
20380
20409
|
tokenProgram
|
|
20381
|
-
}).
|
|
20410
|
+
}).remainingAccounts([
|
|
20411
|
+
{
|
|
20412
|
+
pubkey: bondingCurveV2Pda(mint),
|
|
20413
|
+
isWritable: false,
|
|
20414
|
+
isSigner: false
|
|
20415
|
+
}
|
|
20416
|
+
]).instruction();
|
|
20382
20417
|
}
|
|
20383
20418
|
async getSellInstructionRaw({
|
|
20384
20419
|
user,
|
|
@@ -20430,17 +20465,28 @@ var PumpSdk = class {
|
|
|
20430
20465
|
pubkey: userVolumeAccumulator,
|
|
20431
20466
|
isWritable: true,
|
|
20432
20467
|
isSigner: false
|
|
20468
|
+
},
|
|
20469
|
+
{
|
|
20470
|
+
pubkey: bondingCurveV2Pda(mint),
|
|
20471
|
+
isWritable: false,
|
|
20472
|
+
isSigner: false
|
|
20473
|
+
}
|
|
20474
|
+
] : [
|
|
20475
|
+
{
|
|
20476
|
+
pubkey: bondingCurveV2Pda(mint),
|
|
20477
|
+
isWritable: false,
|
|
20478
|
+
isSigner: false
|
|
20433
20479
|
}
|
|
20434
|
-
]
|
|
20480
|
+
]
|
|
20435
20481
|
).instruction();
|
|
20436
20482
|
}
|
|
20437
20483
|
/**
|
|
20438
20484
|
* Creates a fee sharing configuration for a token.
|
|
20439
20485
|
*
|
|
20440
20486
|
* @param params - Parameters for creating a fee sharing configuration
|
|
20441
|
-
* @param params.creator - The creator of the token
|
|
20487
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
20442
20488
|
* @param params.mint - The mint address of the token
|
|
20443
|
-
* @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.
|
|
20444
20490
|
*/
|
|
20445
20491
|
async createFeeSharingConfig({
|
|
20446
20492
|
creator,
|
|
@@ -20591,6 +20637,154 @@ var PumpSdk = class {
|
|
|
20591
20637
|
user
|
|
20592
20638
|
}).instruction();
|
|
20593
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
|
+
}
|
|
20594
20788
|
};
|
|
20595
20789
|
var PUMP_SDK = new PumpSdk();
|
|
20596
20790
|
function isCreatorUsingSharingConfig({
|
|
@@ -20628,6 +20822,12 @@ function bondingCurvePda(mint) {
|
|
|
20628
20822
|
new PublicKey5(mint).toBuffer()
|
|
20629
20823
|
]);
|
|
20630
20824
|
}
|
|
20825
|
+
function bondingCurveV2Pda(mint) {
|
|
20826
|
+
return pumpPda([
|
|
20827
|
+
import_buffer.Buffer.from("bonding-curve-v2"),
|
|
20828
|
+
new PublicKey5(mint).toBuffer()
|
|
20829
|
+
]);
|
|
20830
|
+
}
|
|
20631
20831
|
function creatorVaultPda(creator) {
|
|
20632
20832
|
return pumpPda([import_buffer.Buffer.from("creator-vault"), creator.toBuffer()]);
|
|
20633
20833
|
}
|
|
@@ -20681,6 +20881,13 @@ var ammCreatorVaultPda = (creator) => {
|
|
|
20681
20881
|
PUMP_AMM_PROGRAM_ID
|
|
20682
20882
|
)[0];
|
|
20683
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
|
+
};
|
|
20684
20891
|
export {
|
|
20685
20892
|
AMM_GLOBAL_PDA,
|
|
20686
20893
|
AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA,
|
|
@@ -20701,14 +20908,17 @@ export {
|
|
|
20701
20908
|
PUMP_FEE_PROGRAM_ID,
|
|
20702
20909
|
PUMP_PROGRAM_ID,
|
|
20703
20910
|
PUMP_SDK,
|
|
20911
|
+
Platform,
|
|
20704
20912
|
PoolRequiredForGraduatedError,
|
|
20705
20913
|
PumpSdk,
|
|
20914
|
+
SUPPORTED_SOCIAL_PLATFORMS,
|
|
20706
20915
|
ShareCalculationOverflowError,
|
|
20707
20916
|
TooManyShareholdersError,
|
|
20708
20917
|
ZeroShareError,
|
|
20709
20918
|
ammCreatorVaultPda,
|
|
20710
20919
|
bondingCurveMarketCap,
|
|
20711
20920
|
bondingCurvePda,
|
|
20921
|
+
bondingCurveV2Pda,
|
|
20712
20922
|
canonicalPumpPoolPda,
|
|
20713
20923
|
creatorVaultPda,
|
|
20714
20924
|
currentDayTokens,
|
|
@@ -20726,8 +20936,11 @@ export {
|
|
|
20726
20936
|
getTokenVaultPda,
|
|
20727
20937
|
isCreatorUsingSharingConfig,
|
|
20728
20938
|
newBondingCurve,
|
|
20939
|
+
platformToString,
|
|
20729
20940
|
pump_default as pumpIdl,
|
|
20730
20941
|
pumpPoolAuthorityPda,
|
|
20942
|
+
socialFeePda,
|
|
20943
|
+
stringToPlatform,
|
|
20731
20944
|
totalUnclaimedTokens,
|
|
20732
20945
|
userVolumeAccumulatorPda
|
|
20733
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;
|
|
@@ -16944,6 +16955,7 @@ declare const PUMP_AMM_EVENT_AUTHORITY_PDA: PublicKey;
|
|
|
16944
16955
|
declare const PUMP_FEE_EVENT_AUTHORITY_PDA: PublicKey;
|
|
16945
16956
|
declare function getEventAuthorityPda(programId: PublicKey): PublicKey;
|
|
16946
16957
|
declare function bondingCurvePda(mint: PublicKeyInitData): PublicKey;
|
|
16958
|
+
declare function bondingCurveV2Pda(mint: PublicKeyInitData): PublicKey;
|
|
16947
16959
|
declare function creatorVaultPda(creator: PublicKey): PublicKey;
|
|
16948
16960
|
declare function pumpPoolAuthorityPda(mint: PublicKey): PublicKey;
|
|
16949
16961
|
declare const CANONICAL_POOL_INDEX = 0;
|
|
@@ -16955,6 +16967,7 @@ declare const getSolVaultPda: () => PublicKey;
|
|
|
16955
16967
|
declare const getTokenVaultPda: (mintPubkey: PublicKey) => PublicKey;
|
|
16956
16968
|
declare const feeSharingConfigPda: (mint: PublicKey) => PublicKey;
|
|
16957
16969
|
declare const ammCreatorVaultPda: (creator: PublicKey) => PublicKey;
|
|
16970
|
+
declare const socialFeePda: (userId: string, platform: number) => PublicKey;
|
|
16958
16971
|
|
|
16959
16972
|
/**
|
|
16960
16973
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
@@ -22727,9 +22740,9 @@ declare class PumpSdk {
|
|
|
22727
22740
|
* Creates a fee sharing configuration for a token.
|
|
22728
22741
|
*
|
|
22729
22742
|
* @param params - Parameters for creating a fee sharing configuration
|
|
22730
|
-
* @param params.creator - The creator of the token
|
|
22743
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
22731
22744
|
* @param params.mint - The mint address of the token
|
|
22732
|
-
* @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.
|
|
22733
22746
|
*/
|
|
22734
22747
|
createFeeSharingConfig({ creator, mint, pool, }: {
|
|
22735
22748
|
creator: PublicKey;
|
|
@@ -22791,6 +22804,83 @@ declare class PumpSdk {
|
|
|
22791
22804
|
claimCashbackInstruction({ user, }: {
|
|
22792
22805
|
user: PublicKey;
|
|
22793
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;
|
|
22794
22884
|
}
|
|
22795
22885
|
declare const PUMP_SDK: PumpSdk;
|
|
22796
22886
|
/**
|
|
@@ -22937,4 +23027,4 @@ declare class PoolRequiredForGraduatedError extends Error {
|
|
|
22937
23027
|
constructor();
|
|
22938
23028
|
}
|
|
22939
23029
|
|
|
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 };
|
|
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;
|
|
@@ -16944,6 +16955,7 @@ declare const PUMP_AMM_EVENT_AUTHORITY_PDA: PublicKey;
|
|
|
16944
16955
|
declare const PUMP_FEE_EVENT_AUTHORITY_PDA: PublicKey;
|
|
16945
16956
|
declare function getEventAuthorityPda(programId: PublicKey): PublicKey;
|
|
16946
16957
|
declare function bondingCurvePda(mint: PublicKeyInitData): PublicKey;
|
|
16958
|
+
declare function bondingCurveV2Pda(mint: PublicKeyInitData): PublicKey;
|
|
16947
16959
|
declare function creatorVaultPda(creator: PublicKey): PublicKey;
|
|
16948
16960
|
declare function pumpPoolAuthorityPda(mint: PublicKey): PublicKey;
|
|
16949
16961
|
declare const CANONICAL_POOL_INDEX = 0;
|
|
@@ -16955,6 +16967,7 @@ declare const getSolVaultPda: () => PublicKey;
|
|
|
16955
16967
|
declare const getTokenVaultPda: (mintPubkey: PublicKey) => PublicKey;
|
|
16956
16968
|
declare const feeSharingConfigPda: (mint: PublicKey) => PublicKey;
|
|
16957
16969
|
declare const ammCreatorVaultPda: (creator: PublicKey) => PublicKey;
|
|
16970
|
+
declare const socialFeePda: (userId: string, platform: number) => PublicKey;
|
|
16958
16971
|
|
|
16959
16972
|
/**
|
|
16960
16973
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
@@ -22727,9 +22740,9 @@ declare class PumpSdk {
|
|
|
22727
22740
|
* Creates a fee sharing configuration for a token.
|
|
22728
22741
|
*
|
|
22729
22742
|
* @param params - Parameters for creating a fee sharing configuration
|
|
22730
|
-
* @param params.creator - The creator of the token
|
|
22743
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
22731
22744
|
* @param params.mint - The mint address of the token
|
|
22732
|
-
* @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.
|
|
22733
22746
|
*/
|
|
22734
22747
|
createFeeSharingConfig({ creator, mint, pool, }: {
|
|
22735
22748
|
creator: PublicKey;
|
|
@@ -22791,6 +22804,83 @@ declare class PumpSdk {
|
|
|
22791
22804
|
claimCashbackInstruction({ user, }: {
|
|
22792
22805
|
user: PublicKey;
|
|
22793
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;
|
|
22794
22884
|
}
|
|
22795
22885
|
declare const PUMP_SDK: PumpSdk;
|
|
22796
22886
|
/**
|
|
@@ -22937,4 +23027,4 @@ declare class PoolRequiredForGraduatedError extends Error {
|
|
|
22937
23027
|
constructor();
|
|
22938
23028
|
}
|
|
22939
23029
|
|
|
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 };
|
|
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,14 +1829,17 @@ __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,
|
|
1837
1839
|
ammCreatorVaultPda: () => ammCreatorVaultPda,
|
|
1838
1840
|
bondingCurveMarketCap: () => bondingCurveMarketCap,
|
|
1839
1841
|
bondingCurvePda: () => bondingCurvePda,
|
|
1842
|
+
bondingCurveV2Pda: () => bondingCurveV2Pda,
|
|
1840
1843
|
canonicalPumpPoolPda: () => canonicalPumpPoolPda,
|
|
1841
1844
|
creatorVaultPda: () => creatorVaultPda,
|
|
1842
1845
|
currentDayTokens: () => currentDayTokens,
|
|
@@ -1854,8 +1857,11 @@ __export(index_exports, {
|
|
|
1854
1857
|
getTokenVaultPda: () => getTokenVaultPda,
|
|
1855
1858
|
isCreatorUsingSharingConfig: () => isCreatorUsingSharingConfig,
|
|
1856
1859
|
newBondingCurve: () => newBondingCurve,
|
|
1860
|
+
platformToString: () => platformToString,
|
|
1857
1861
|
pumpIdl: () => pump_default,
|
|
1858
1862
|
pumpPoolAuthorityPda: () => pumpPoolAuthorityPda,
|
|
1863
|
+
socialFeePda: () => socialFeePda,
|
|
1864
|
+
stringToPlatform: () => stringToPlatform,
|
|
1859
1865
|
totalUnclaimedTokens: () => totalUnclaimedTokens,
|
|
1860
1866
|
userVolumeAccumulatorPda: () => userVolumeAccumulatorPda
|
|
1861
1867
|
});
|
|
@@ -19935,6 +19941,35 @@ var OnlinePumpSdk = class {
|
|
|
19935
19941
|
}
|
|
19936
19942
|
};
|
|
19937
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
|
+
|
|
19938
19973
|
// src/sdk.ts
|
|
19939
19974
|
function getPumpProgram(connection) {
|
|
19940
19975
|
return new import_anchor.Program(
|
|
@@ -20403,7 +20438,13 @@ var PumpSdk = class {
|
|
|
20403
20438
|
user,
|
|
20404
20439
|
creatorVault: creatorVaultPda(creator),
|
|
20405
20440
|
tokenProgram
|
|
20406
|
-
}).
|
|
20441
|
+
}).remainingAccounts([
|
|
20442
|
+
{
|
|
20443
|
+
pubkey: bondingCurveV2Pda(mint),
|
|
20444
|
+
isWritable: false,
|
|
20445
|
+
isSigner: false
|
|
20446
|
+
}
|
|
20447
|
+
]).instruction();
|
|
20407
20448
|
}
|
|
20408
20449
|
async getSellInstructionRaw({
|
|
20409
20450
|
user,
|
|
@@ -20455,17 +20496,28 @@ var PumpSdk = class {
|
|
|
20455
20496
|
pubkey: userVolumeAccumulator,
|
|
20456
20497
|
isWritable: true,
|
|
20457
20498
|
isSigner: false
|
|
20499
|
+
},
|
|
20500
|
+
{
|
|
20501
|
+
pubkey: bondingCurveV2Pda(mint),
|
|
20502
|
+
isWritable: false,
|
|
20503
|
+
isSigner: false
|
|
20504
|
+
}
|
|
20505
|
+
] : [
|
|
20506
|
+
{
|
|
20507
|
+
pubkey: bondingCurveV2Pda(mint),
|
|
20508
|
+
isWritable: false,
|
|
20509
|
+
isSigner: false
|
|
20458
20510
|
}
|
|
20459
|
-
]
|
|
20511
|
+
]
|
|
20460
20512
|
).instruction();
|
|
20461
20513
|
}
|
|
20462
20514
|
/**
|
|
20463
20515
|
* Creates a fee sharing configuration for a token.
|
|
20464
20516
|
*
|
|
20465
20517
|
* @param params - Parameters for creating a fee sharing configuration
|
|
20466
|
-
* @param params.creator - The creator of the token
|
|
20518
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
20467
20519
|
* @param params.mint - The mint address of the token
|
|
20468
|
-
* @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.
|
|
20469
20521
|
*/
|
|
20470
20522
|
async createFeeSharingConfig({
|
|
20471
20523
|
creator,
|
|
@@ -20616,6 +20668,154 @@ var PumpSdk = class {
|
|
|
20616
20668
|
user
|
|
20617
20669
|
}).instruction();
|
|
20618
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
|
+
}
|
|
20619
20819
|
};
|
|
20620
20820
|
var PUMP_SDK = new PumpSdk();
|
|
20621
20821
|
function isCreatorUsingSharingConfig({
|
|
@@ -20653,6 +20853,12 @@ function bondingCurvePda(mint) {
|
|
|
20653
20853
|
new import_web35.PublicKey(mint).toBuffer()
|
|
20654
20854
|
]);
|
|
20655
20855
|
}
|
|
20856
|
+
function bondingCurveV2Pda(mint) {
|
|
20857
|
+
return (0, import_pump_swap_sdk3.pumpPda)([
|
|
20858
|
+
import_buffer.Buffer.from("bonding-curve-v2"),
|
|
20859
|
+
new import_web35.PublicKey(mint).toBuffer()
|
|
20860
|
+
]);
|
|
20861
|
+
}
|
|
20656
20862
|
function creatorVaultPda(creator) {
|
|
20657
20863
|
return (0, import_pump_swap_sdk3.pumpPda)([import_buffer.Buffer.from("creator-vault"), creator.toBuffer()]);
|
|
20658
20864
|
}
|
|
@@ -20706,6 +20912,13 @@ var ammCreatorVaultPda = (creator) => {
|
|
|
20706
20912
|
PUMP_AMM_PROGRAM_ID
|
|
20707
20913
|
)[0];
|
|
20708
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
|
+
};
|
|
20709
20922
|
/*! Bundled license information:
|
|
20710
20923
|
|
|
20711
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
|
@@ -56,6 +56,13 @@ export function bondingCurvePda(mint: PublicKeyInitData): PublicKey {
|
|
|
56
56
|
]);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
export function bondingCurveV2Pda(mint: PublicKeyInitData): PublicKey {
|
|
60
|
+
return pumpPda([
|
|
61
|
+
Buffer.from("bonding-curve-v2"),
|
|
62
|
+
new PublicKey(mint).toBuffer(),
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
|
|
59
66
|
export function creatorVaultPda(creator: PublicKey) {
|
|
60
67
|
return pumpPda([Buffer.from("creator-vault"), creator.toBuffer()]);
|
|
61
68
|
}
|
|
@@ -121,3 +128,11 @@ export const ammCreatorVaultPda = (creator: PublicKey): PublicKey => {
|
|
|
121
128
|
PUMP_AMM_PROGRAM_ID,
|
|
122
129
|
)[0];
|
|
123
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
|
@@ -45,6 +45,8 @@ import {
|
|
|
45
45
|
pumpPoolAuthorityPda,
|
|
46
46
|
feeSharingConfigPda,
|
|
47
47
|
userVolumeAccumulatorPda,
|
|
48
|
+
socialFeePda,
|
|
49
|
+
bondingCurveV2Pda,
|
|
48
50
|
} from "./pda";
|
|
49
51
|
import {
|
|
50
52
|
BondingCurve,
|
|
@@ -56,6 +58,9 @@ import {
|
|
|
56
58
|
SharingConfig,
|
|
57
59
|
DistributeCreatorFeesEvent,
|
|
58
60
|
MinimumDistributableFeeEvent,
|
|
61
|
+
Platform,
|
|
62
|
+
SUPPORTED_SOCIAL_PLATFORMS,
|
|
63
|
+
platformToString,
|
|
59
64
|
} from "./state";
|
|
60
65
|
|
|
61
66
|
export function getPumpProgram(connection: Connection): Program<Pump> {
|
|
@@ -718,6 +723,13 @@ export class PumpSdk {
|
|
|
718
723
|
creatorVault: creatorVaultPda(creator),
|
|
719
724
|
tokenProgram,
|
|
720
725
|
})
|
|
726
|
+
.remainingAccounts([
|
|
727
|
+
{
|
|
728
|
+
pubkey: bondingCurveV2Pda(mint),
|
|
729
|
+
isWritable: false,
|
|
730
|
+
isSigner: false,
|
|
731
|
+
},
|
|
732
|
+
])
|
|
721
733
|
.instruction();
|
|
722
734
|
}
|
|
723
735
|
|
|
@@ -795,8 +807,19 @@ export class PumpSdk {
|
|
|
795
807
|
isWritable: true,
|
|
796
808
|
isSigner: false,
|
|
797
809
|
},
|
|
810
|
+
{
|
|
811
|
+
pubkey: bondingCurveV2Pda(mint),
|
|
812
|
+
isWritable: false,
|
|
813
|
+
isSigner: false,
|
|
814
|
+
},
|
|
798
815
|
]
|
|
799
|
-
: [
|
|
816
|
+
: [
|
|
817
|
+
{
|
|
818
|
+
pubkey: bondingCurveV2Pda(mint),
|
|
819
|
+
isWritable: false,
|
|
820
|
+
isSigner: false,
|
|
821
|
+
},
|
|
822
|
+
],
|
|
800
823
|
)
|
|
801
824
|
.instruction();
|
|
802
825
|
}
|
|
@@ -805,9 +828,9 @@ export class PumpSdk {
|
|
|
805
828
|
* Creates a fee sharing configuration for a token.
|
|
806
829
|
*
|
|
807
830
|
* @param params - Parameters for creating a fee sharing configuration
|
|
808
|
-
* @param params.creator - The creator of the token
|
|
831
|
+
* @param params.creator - The creator of the token. Must sign the transaction.
|
|
809
832
|
* @param params.mint - The mint address of the token
|
|
810
|
-
* @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.
|
|
811
834
|
*/
|
|
812
835
|
async createFeeSharingConfig({
|
|
813
836
|
creator,
|
|
@@ -1010,8 +1033,218 @@ export class PumpSdk {
|
|
|
1010
1033
|
})
|
|
1011
1034
|
.instruction();
|
|
1012
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
|
+
}
|
|
1013
1245
|
}
|
|
1014
1246
|
|
|
1247
|
+
|
|
1015
1248
|
export const PUMP_SDK = new PumpSdk();
|
|
1016
1249
|
|
|
1017
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;
|