@pump-fun/pump-sdk 1.27.0-devnet.2 → 1.28.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/dist/esm/index.js +3599 -1738
- package/dist/index.d.mts +6741 -6653
- package/dist/index.d.ts +6741 -6653
- package/dist/index.js +3066 -1217
- package/package.json +18 -3
- package/src/bondingCurve.ts +3 -2
- package/src/errors.ts +11 -4
- package/src/fees.ts +16 -9
- package/src/idl/pump.json +263 -1
- package/src/idl/pump.ts +3271 -3815
- package/src/idl/pump_amm.json +391 -1
- package/src/idl/pump_amm.ts +2899 -3154
- package/src/idl/pump_fees.json +1271 -114
- package/src/idl/pump_fees.ts +2208 -1586
- package/src/index.ts +5 -1
- package/src/onlineSdk.ts +52 -27
- package/src/pda.ts +29 -16
- package/src/sdk.ts +127 -78
- package/src/state.ts +1 -1
- package/src/tokenIncentives.ts +3 -2
package/src/index.ts
CHANGED
|
@@ -22,7 +22,11 @@ export {
|
|
|
22
22
|
PUMP_SDK,
|
|
23
23
|
isCreatorUsingSharingConfig,
|
|
24
24
|
} from "./sdk";
|
|
25
|
-
export {
|
|
25
|
+
export {
|
|
26
|
+
OnlinePumpSdk,
|
|
27
|
+
MinimumDistributableFeeResult,
|
|
28
|
+
DistributeCreatorFeeResult,
|
|
29
|
+
} from "./onlineSdk";
|
|
26
30
|
export {
|
|
27
31
|
FeeConfig,
|
|
28
32
|
Global,
|
package/src/onlineSdk.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Program } from "@coral-xyz/anchor";
|
|
2
2
|
import {
|
|
3
3
|
coinCreatorVaultAtaPda,
|
|
4
4
|
coinCreatorVaultAuthorityPda,
|
|
@@ -20,10 +20,10 @@ import {
|
|
|
20
20
|
TransactionMessage,
|
|
21
21
|
VersionedTransaction,
|
|
22
22
|
} from "@solana/web3.js";
|
|
23
|
-
import { Pump } from "./idl/pump";
|
|
24
|
-
import { PumpAmm } from "./idl/pump_amm";
|
|
25
23
|
import BN from "bn.js";
|
|
26
24
|
|
|
25
|
+
import { Pump } from "./idl/pump";
|
|
26
|
+
import { PumpAmm } from "./idl/pump_amm";
|
|
27
27
|
import {
|
|
28
28
|
bondingCurvePda,
|
|
29
29
|
canonicalPumpPoolPda,
|
|
@@ -34,6 +34,12 @@ import {
|
|
|
34
34
|
PUMP_FEE_CONFIG_PDA,
|
|
35
35
|
userVolumeAccumulatorPda,
|
|
36
36
|
} from "./pda";
|
|
37
|
+
import {
|
|
38
|
+
getPumpAmmProgram,
|
|
39
|
+
getPumpProgram,
|
|
40
|
+
PUMP_SDK,
|
|
41
|
+
PUMP_TOKEN_MINT,
|
|
42
|
+
} from "./sdk";
|
|
37
43
|
import {
|
|
38
44
|
BondingCurve,
|
|
39
45
|
FeeConfig,
|
|
@@ -44,7 +50,6 @@ import {
|
|
|
44
50
|
UserVolumeAccumulatorTotalStats,
|
|
45
51
|
} from "./state";
|
|
46
52
|
import { currentDayTokens, totalUnclaimedTokens } from "./tokenIncentives";
|
|
47
|
-
import { getPumpAmmProgram, getPumpProgram, PUMP_SDK, PUMP_TOKEN_MINT } from "./sdk";
|
|
48
53
|
|
|
49
54
|
export const OFFLINE_PUMP_PROGRAM = getPumpProgram(null as any as Connection);
|
|
50
55
|
|
|
@@ -81,7 +86,11 @@ export class OnlinePumpSdk {
|
|
|
81
86
|
);
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
async fetchBuyState(
|
|
89
|
+
async fetchBuyState(
|
|
90
|
+
mint: PublicKey,
|
|
91
|
+
user: PublicKey,
|
|
92
|
+
tokenProgram: PublicKey = TOKEN_PROGRAM_ID,
|
|
93
|
+
) {
|
|
85
94
|
const [bondingCurveAccountInfo, associatedUserAccountInfo] =
|
|
86
95
|
await this.connection.getMultipleAccountsInfo([
|
|
87
96
|
bondingCurvePda(mint),
|
|
@@ -98,7 +107,11 @@ export class OnlinePumpSdk {
|
|
|
98
107
|
return { bondingCurveAccountInfo, bondingCurve, associatedUserAccountInfo };
|
|
99
108
|
}
|
|
100
109
|
|
|
101
|
-
async fetchSellState(
|
|
110
|
+
async fetchSellState(
|
|
111
|
+
mint: PublicKey,
|
|
112
|
+
user: PublicKey,
|
|
113
|
+
tokenProgram: PublicKey = TOKEN_PROGRAM_ID,
|
|
114
|
+
) {
|
|
102
115
|
const [bondingCurveAccountInfo, associatedUserAccountInfo] =
|
|
103
116
|
await this.connection.getMultipleAccountsInfo([
|
|
104
117
|
bondingCurvePda(mint),
|
|
@@ -170,17 +183,17 @@ export class OnlinePumpSdk {
|
|
|
170
183
|
coinCreator: PublicKey,
|
|
171
184
|
feePayer?: PublicKey,
|
|
172
185
|
): Promise<TransactionInstruction[]> {
|
|
173
|
-
|
|
174
|
-
|
|
186
|
+
const quoteMint = NATIVE_MINT;
|
|
187
|
+
const quoteTokenProgram = TOKEN_PROGRAM_ID;
|
|
175
188
|
|
|
176
|
-
|
|
177
|
-
|
|
189
|
+
const coinCreatorVaultAuthority = coinCreatorVaultAuthorityPda(coinCreator);
|
|
190
|
+
const coinCreatorVaultAta = coinCreatorVaultAtaPda(
|
|
178
191
|
coinCreatorVaultAuthority,
|
|
179
192
|
quoteMint,
|
|
180
193
|
quoteTokenProgram,
|
|
181
194
|
);
|
|
182
195
|
|
|
183
|
-
|
|
196
|
+
const coinCreatorTokenAccount = getAssociatedTokenAddressSync(
|
|
184
197
|
quoteMint,
|
|
185
198
|
coinCreator,
|
|
186
199
|
true,
|
|
@@ -199,16 +212,19 @@ export class OnlinePumpSdk {
|
|
|
199
212
|
creator: coinCreator,
|
|
200
213
|
})
|
|
201
214
|
.instruction(),
|
|
202
|
-
...(await PUMP_AMM_SDK.collectCoinCreatorFee(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
...(await PUMP_AMM_SDK.collectCoinCreatorFee(
|
|
216
|
+
{
|
|
217
|
+
coinCreator,
|
|
218
|
+
quoteMint,
|
|
219
|
+
quoteTokenProgram,
|
|
220
|
+
coinCreatorVaultAuthority,
|
|
221
|
+
coinCreatorVaultAta,
|
|
222
|
+
coinCreatorTokenAccount,
|
|
223
|
+
coinCreatorVaultAtaAccountInfo,
|
|
224
|
+
coinCreatorTokenAccountInfo,
|
|
225
|
+
},
|
|
226
|
+
feePayer,
|
|
227
|
+
)),
|
|
212
228
|
];
|
|
213
229
|
}
|
|
214
230
|
|
|
@@ -449,11 +465,14 @@ export class OnlinePumpSdk {
|
|
|
449
465
|
*/
|
|
450
466
|
async getMinimumDistributableFee(
|
|
451
467
|
mint: PublicKey,
|
|
452
|
-
simulationSigner: PublicKey = new PublicKey(
|
|
468
|
+
simulationSigner: PublicKey = new PublicKey(
|
|
469
|
+
"UqN2p5bAzBqYdHXcgB6WLtuVrdvmy9JSAtgqZb3CMKw",
|
|
470
|
+
),
|
|
453
471
|
): Promise<MinimumDistributableFeeResult> {
|
|
454
472
|
const sharingConfigPubkey = feeSharingConfigPda(mint);
|
|
455
473
|
const poolAddress = canonicalPumpPoolPda(mint);
|
|
456
|
-
const coinCreatorVaultAuthority =
|
|
474
|
+
const coinCreatorVaultAuthority =
|
|
475
|
+
coinCreatorVaultAuthorityPda(sharingConfigPubkey);
|
|
457
476
|
const ammVaultAta = coinCreatorVaultAtaPda(
|
|
458
477
|
coinCreatorVaultAuthority,
|
|
459
478
|
NATIVE_MINT,
|
|
@@ -471,7 +490,9 @@ export class OnlinePumpSdk {
|
|
|
471
490
|
throw new Error(`Sharing config not found for mint: ${mint.toBase58()}`);
|
|
472
491
|
}
|
|
473
492
|
|
|
474
|
-
const sharingConfig = PUMP_SDK.decodeSharingConfig(
|
|
493
|
+
const sharingConfig = PUMP_SDK.decodeSharingConfig(
|
|
494
|
+
sharingConfigAccountInfo,
|
|
495
|
+
);
|
|
475
496
|
|
|
476
497
|
const instructions: TransactionInstruction[] = [];
|
|
477
498
|
|
|
@@ -518,7 +539,8 @@ export class OnlinePumpSdk {
|
|
|
518
539
|
const [data, encoding] = result.value.returnData?.data ?? [];
|
|
519
540
|
if (data) {
|
|
520
541
|
const buffer = Buffer.from(data, encoding as BufferEncoding);
|
|
521
|
-
minimumDistributableFee =
|
|
542
|
+
minimumDistributableFee =
|
|
543
|
+
PUMP_SDK.decodeMinimumDistributableFee(buffer);
|
|
522
544
|
}
|
|
523
545
|
}
|
|
524
546
|
|
|
@@ -543,7 +565,8 @@ export class OnlinePumpSdk {
|
|
|
543
565
|
): Promise<DistributeCreatorFeeResult> {
|
|
544
566
|
const sharingConfigPubkey = feeSharingConfigPda(mint);
|
|
545
567
|
const poolAddress = canonicalPumpPoolPda(mint);
|
|
546
|
-
const coinCreatorVaultAuthority =
|
|
568
|
+
const coinCreatorVaultAuthority =
|
|
569
|
+
coinCreatorVaultAuthorityPda(sharingConfigPubkey);
|
|
547
570
|
const ammVaultAta = coinCreatorVaultAtaPda(
|
|
548
571
|
coinCreatorVaultAuthority,
|
|
549
572
|
NATIVE_MINT,
|
|
@@ -561,7 +584,9 @@ export class OnlinePumpSdk {
|
|
|
561
584
|
throw new Error(`Sharing config not found for mint: ${mint.toBase58()}`);
|
|
562
585
|
}
|
|
563
586
|
|
|
564
|
-
const sharingConfig = PUMP_SDK.decodeSharingConfig(
|
|
587
|
+
const sharingConfig = PUMP_SDK.decodeSharingConfig(
|
|
588
|
+
sharingConfigAccountInfo,
|
|
589
|
+
);
|
|
565
590
|
|
|
566
591
|
const instructions: TransactionInstruction[] = [];
|
|
567
592
|
|
package/src/pda.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
poolPda,
|
|
3
|
+
pumpFeePda,
|
|
4
|
+
pumpPda,
|
|
5
|
+
pumpAmmPda,
|
|
6
|
+
} from "@pump-fun/pump-swap-sdk";
|
|
7
|
+
import {
|
|
8
|
+
getAssociatedTokenAddressSync,
|
|
9
|
+
NATIVE_MINT,
|
|
10
|
+
TOKEN_2022_PROGRAM_ID,
|
|
11
|
+
} from "@solana/spl-token";
|
|
1
12
|
import { PublicKey, PublicKeyInitData } from "@solana/web3.js";
|
|
2
|
-
import { getAssociatedTokenAddressSync, NATIVE_MINT, TOKEN_2022_PROGRAM_ID } from "@solana/spl-token";
|
|
3
|
-
import { poolPda, pumpFeePda, pumpPda, pumpAmmPda } from "@pump-fun/pump-swap-sdk";
|
|
4
|
-
import { MAYHEM_PROGRAM_ID, PUMP_PROGRAM_ID, PUMP_AMM_PROGRAM_ID, PUMP_FEE_PROGRAM_ID } from "./sdk";
|
|
5
13
|
import { Buffer } from "buffer";
|
|
6
14
|
|
|
15
|
+
import {
|
|
16
|
+
MAYHEM_PROGRAM_ID,
|
|
17
|
+
PUMP_PROGRAM_ID,
|
|
18
|
+
PUMP_AMM_PROGRAM_ID,
|
|
19
|
+
PUMP_FEE_PROGRAM_ID,
|
|
20
|
+
} from "./sdk";
|
|
21
|
+
|
|
7
22
|
export const GLOBAL_PDA = pumpPda([Buffer.from("global")]);
|
|
8
23
|
|
|
9
24
|
export const AMM_GLOBAL_PDA = pumpAmmPda([Buffer.from("amm_global")]);
|
|
@@ -21,15 +36,16 @@ export const AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA = pumpAmmPda([
|
|
|
21
36
|
Buffer.from("global_volume_accumulator"),
|
|
22
37
|
]);
|
|
23
38
|
|
|
24
|
-
|
|
25
39
|
export const PUMP_EVENT_AUTHORITY_PDA = getEventAuthorityPda(PUMP_PROGRAM_ID);
|
|
26
|
-
export const PUMP_AMM_EVENT_AUTHORITY_PDA =
|
|
27
|
-
|
|
40
|
+
export const PUMP_AMM_EVENT_AUTHORITY_PDA =
|
|
41
|
+
getEventAuthorityPda(PUMP_AMM_PROGRAM_ID);
|
|
42
|
+
export const PUMP_FEE_EVENT_AUTHORITY_PDA =
|
|
43
|
+
getEventAuthorityPda(PUMP_FEE_PROGRAM_ID);
|
|
28
44
|
|
|
29
45
|
export function getEventAuthorityPda(programId: PublicKey): PublicKey {
|
|
30
46
|
return PublicKey.findProgramAddressSync(
|
|
31
47
|
[Buffer.from("__event_authority")],
|
|
32
|
-
programId
|
|
48
|
+
programId,
|
|
33
49
|
)[0];
|
|
34
50
|
}
|
|
35
51
|
|
|
@@ -68,21 +84,21 @@ export function userVolumeAccumulatorPda(user: PublicKey): PublicKey {
|
|
|
68
84
|
export const getGlobalParamsPda = (): PublicKey => {
|
|
69
85
|
return PublicKey.findProgramAddressSync(
|
|
70
86
|
[Buffer.from("global-params")],
|
|
71
|
-
MAYHEM_PROGRAM_ID
|
|
87
|
+
MAYHEM_PROGRAM_ID,
|
|
72
88
|
)[0];
|
|
73
89
|
};
|
|
74
90
|
|
|
75
91
|
export const getMayhemStatePda = (mint: PublicKey): PublicKey => {
|
|
76
92
|
return PublicKey.findProgramAddressSync(
|
|
77
93
|
[Buffer.from("mayhem-state"), mint.toBuffer()],
|
|
78
|
-
MAYHEM_PROGRAM_ID
|
|
94
|
+
MAYHEM_PROGRAM_ID,
|
|
79
95
|
)[0];
|
|
80
96
|
};
|
|
81
97
|
|
|
82
98
|
export const getSolVaultPda = (): PublicKey => {
|
|
83
99
|
return PublicKey.findProgramAddressSync(
|
|
84
100
|
[Buffer.from("sol-vault")],
|
|
85
|
-
MAYHEM_PROGRAM_ID
|
|
101
|
+
MAYHEM_PROGRAM_ID,
|
|
86
102
|
)[0];
|
|
87
103
|
};
|
|
88
104
|
|
|
@@ -91,20 +107,17 @@ export const getTokenVaultPda = (mintPubkey: PublicKey): PublicKey => {
|
|
|
91
107
|
mintPubkey,
|
|
92
108
|
getSolVaultPda(),
|
|
93
109
|
true,
|
|
94
|
-
TOKEN_2022_PROGRAM_ID
|
|
110
|
+
TOKEN_2022_PROGRAM_ID,
|
|
95
111
|
);
|
|
96
112
|
};
|
|
97
113
|
|
|
98
114
|
export const feeSharingConfigPda = (mint: PublicKey): PublicKey => {
|
|
99
|
-
return pumpFeePda([
|
|
100
|
-
Buffer.from("sharing-config"),
|
|
101
|
-
mint.toBuffer(),
|
|
102
|
-
]);
|
|
115
|
+
return pumpFeePda([Buffer.from("sharing-config"), mint.toBuffer()]);
|
|
103
116
|
};
|
|
104
117
|
|
|
105
118
|
export const ammCreatorVaultPda = (creator: PublicKey): PublicKey => {
|
|
106
119
|
return PublicKey.findProgramAddressSync(
|
|
107
120
|
[Buffer.from("creator_vault"), creator.toBuffer()],
|
|
108
|
-
PUMP_AMM_PROGRAM_ID
|
|
121
|
+
PUMP_AMM_PROGRAM_ID,
|
|
109
122
|
)[0];
|
|
110
123
|
};
|