@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/sdk.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { AnchorProvider, Program } from "@coral-xyz/anchor";
|
|
2
|
+
import {
|
|
3
|
+
coinCreatorVaultAtaPda,
|
|
4
|
+
coinCreatorVaultAuthorityPda,
|
|
5
|
+
} from "@pump-fun/pump-swap-sdk";
|
|
2
6
|
import {
|
|
3
7
|
createAssociatedTokenAccountIdempotentInstruction,
|
|
4
|
-
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
5
8
|
getAssociatedTokenAddressSync,
|
|
6
9
|
NATIVE_MINT,
|
|
7
10
|
TOKEN_2022_PROGRAM_ID,
|
|
@@ -13,20 +16,36 @@ import {
|
|
|
13
16
|
PublicKey,
|
|
14
17
|
TransactionInstruction,
|
|
15
18
|
} from "@solana/web3.js";
|
|
16
|
-
import pumpIdl from "./idl/pump.json";
|
|
17
|
-
import { Pump } from "./idl/pump";
|
|
18
19
|
import BN from "bn.js";
|
|
20
|
+
|
|
21
|
+
import { getStaticRandomFeeRecipient } from "./bondingCurve";
|
|
19
22
|
import {
|
|
20
23
|
NoShareholdersError,
|
|
21
24
|
TooManyShareholdersError,
|
|
22
25
|
ZeroShareError,
|
|
23
|
-
ShareCalculationOverflowError,
|
|
24
26
|
InvalidShareTotalError,
|
|
25
27
|
DuplicateShareholderError,
|
|
26
|
-
PoolRequiredForGraduatedError,
|
|
27
28
|
} from "./errors";
|
|
28
|
-
|
|
29
|
-
import {
|
|
29
|
+
import { getFeeRecipient } from "./fees";
|
|
30
|
+
import { Pump } from "./idl/pump";
|
|
31
|
+
import pumpIdl from "./idl/pump.json";
|
|
32
|
+
import { PumpAmm } from "./idl/pump_amm";
|
|
33
|
+
import PumpAmmIdl from "./idl/pump_amm.json";
|
|
34
|
+
import { PumpFees } from "./idl/pump_fees";
|
|
35
|
+
import PumpFeesIdl from "./idl/pump_fees.json";
|
|
36
|
+
import { OFFLINE_PUMP_PROGRAM } from "./onlineSdk";
|
|
37
|
+
import {
|
|
38
|
+
bondingCurvePda,
|
|
39
|
+
canonicalPumpPoolPda,
|
|
40
|
+
creatorVaultPda,
|
|
41
|
+
getGlobalParamsPda,
|
|
42
|
+
getMayhemStatePda,
|
|
43
|
+
getSolVaultPda,
|
|
44
|
+
getTokenVaultPda,
|
|
45
|
+
pumpPoolAuthorityPda,
|
|
46
|
+
feeSharingConfigPda,
|
|
47
|
+
userVolumeAccumulatorPda,
|
|
48
|
+
} from "./pda";
|
|
30
49
|
import {
|
|
31
50
|
BondingCurve,
|
|
32
51
|
FeeConfig,
|
|
@@ -38,24 +57,16 @@ import {
|
|
|
38
57
|
DistributeCreatorFeesEvent,
|
|
39
58
|
MinimumDistributableFeeEvent,
|
|
40
59
|
} from "./state";
|
|
41
|
-
import { getStaticRandomFeeRecipient } from "./bondingCurve";
|
|
42
|
-
import { getFeeRecipient } from "./fees";
|
|
43
|
-
import { OFFLINE_PUMP_PROGRAM } from "./onlineSdk";
|
|
44
|
-
import PumpAmmIdl from "./idl/pump_amm.json";
|
|
45
|
-
import { PumpAmm } from "./idl/pump_amm";
|
|
46
|
-
import PumpFeesIdl from "./idl/pump_fees.json";
|
|
47
|
-
import { PumpFees } from "./idl/pump_fees";
|
|
48
|
-
import { coinCreatorVaultAtaPda, coinCreatorVaultAuthorityPda, PUMP_AMM_EVENT_AUTHORITY_PDA, pumpAmmPda } from "@pump-fun/pump-swap-sdk";
|
|
49
60
|
|
|
50
61
|
export function getPumpProgram(connection: Connection): Program<Pump> {
|
|
51
62
|
return new Program(
|
|
52
63
|
pumpIdl as Pump,
|
|
53
|
-
new AnchorProvider(connection, null as any, {})
|
|
64
|
+
new AnchorProvider(connection, null as any, {}),
|
|
54
65
|
);
|
|
55
66
|
}
|
|
56
67
|
|
|
57
68
|
export const PUMP_PROGRAM_ID = new PublicKey(
|
|
58
|
-
"6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"
|
|
69
|
+
"6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",
|
|
59
70
|
);
|
|
60
71
|
|
|
61
72
|
export function getPumpAmmProgram(connection: Connection): Program<PumpAmm> {
|
|
@@ -65,9 +76,7 @@ export function getPumpAmmProgram(connection: Connection): Program<PumpAmm> {
|
|
|
65
76
|
);
|
|
66
77
|
}
|
|
67
78
|
|
|
68
|
-
export function getPumpFeeProgram(
|
|
69
|
-
connection: Connection,
|
|
70
|
-
): Program<PumpFees> {
|
|
79
|
+
export function getPumpFeeProgram(connection: Connection): Program<PumpFees> {
|
|
71
80
|
return new Program(
|
|
72
81
|
PumpFeesIdl as PumpFees,
|
|
73
82
|
new AnchorProvider(connection, null as any, {}),
|
|
@@ -75,21 +84,21 @@ export function getPumpFeeProgram(
|
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
export const PUMP_AMM_PROGRAM_ID = new PublicKey(
|
|
78
|
-
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"
|
|
87
|
+
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",
|
|
79
88
|
);
|
|
80
89
|
|
|
81
90
|
export const MAYHEM_PROGRAM_ID = new PublicKey(
|
|
82
|
-
"MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e"
|
|
91
|
+
"MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e",
|
|
83
92
|
);
|
|
84
93
|
|
|
85
94
|
export const PUMP_FEE_PROGRAM_ID = new PublicKey(
|
|
86
|
-
"pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
95
|
+
"pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ",
|
|
87
96
|
);
|
|
88
97
|
|
|
89
98
|
export const BONDING_CURVE_NEW_SIZE = 151;
|
|
90
99
|
|
|
91
100
|
export const PUMP_TOKEN_MINT = new PublicKey(
|
|
92
|
-
"pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn"
|
|
101
|
+
"pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn",
|
|
93
102
|
);
|
|
94
103
|
|
|
95
104
|
export const MAX_SHAREHOLDERS = 10;
|
|
@@ -104,40 +113,40 @@ export class PumpSdk {
|
|
|
104
113
|
// Create offline programs for fee and AMM
|
|
105
114
|
this.offlinePumpFeeProgram = new Program(
|
|
106
115
|
PumpFeesIdl as PumpFees,
|
|
107
|
-
new AnchorProvider(null as any, null as any, {})
|
|
116
|
+
new AnchorProvider(null as any, null as any, {}),
|
|
108
117
|
);
|
|
109
118
|
this.offlinePumpAmmProgram = new Program(
|
|
110
119
|
PumpAmmIdl as PumpAmm,
|
|
111
|
-
new AnchorProvider(null as any, null as any, {})
|
|
120
|
+
new AnchorProvider(null as any, null as any, {}),
|
|
112
121
|
);
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
decodeGlobal(accountInfo: AccountInfo<Buffer>): Global {
|
|
116
125
|
return this.offlinePumpProgram.coder.accounts.decode<Global>(
|
|
117
126
|
"global",
|
|
118
|
-
accountInfo.data
|
|
127
|
+
accountInfo.data,
|
|
119
128
|
);
|
|
120
129
|
}
|
|
121
130
|
|
|
122
131
|
decodeFeeConfig(accountInfo: AccountInfo<Buffer>): FeeConfig {
|
|
123
132
|
return this.offlinePumpProgram.coder.accounts.decode<FeeConfig>(
|
|
124
133
|
"feeConfig",
|
|
125
|
-
accountInfo.data
|
|
134
|
+
accountInfo.data,
|
|
126
135
|
);
|
|
127
136
|
}
|
|
128
137
|
|
|
129
138
|
decodeBondingCurve(accountInfo: AccountInfo<Buffer>): BondingCurve {
|
|
130
139
|
return this.offlinePumpProgram.coder.accounts.decode<BondingCurve>(
|
|
131
140
|
"bondingCurve",
|
|
132
|
-
accountInfo.data
|
|
141
|
+
accountInfo.data,
|
|
133
142
|
);
|
|
134
143
|
}
|
|
135
144
|
|
|
136
145
|
decodeBondingCurveNullable(
|
|
137
|
-
accountInfo: AccountInfo<Buffer
|
|
146
|
+
accountInfo: AccountInfo<Buffer>,
|
|
138
147
|
): BondingCurve | null {
|
|
139
148
|
try {
|
|
140
|
-
|
|
149
|
+
const data = accountInfo.data;
|
|
141
150
|
// Ensure buffer is at least 82 bytes
|
|
142
151
|
if (data.length < 82) {
|
|
143
152
|
const padded = Buffer.alloc(82);
|
|
@@ -149,37 +158,37 @@ export class PumpSdk {
|
|
|
149
158
|
}
|
|
150
159
|
|
|
151
160
|
return this.decodeBondingCurve(accountInfo);
|
|
152
|
-
} catch (
|
|
153
|
-
console.warn("Failed to decode bonding curve",
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.warn("Failed to decode bonding curve", error);
|
|
154
163
|
return null;
|
|
155
164
|
}
|
|
156
165
|
}
|
|
157
166
|
|
|
158
167
|
decodeGlobalVolumeAccumulator(
|
|
159
|
-
accountInfo: AccountInfo<Buffer
|
|
168
|
+
accountInfo: AccountInfo<Buffer>,
|
|
160
169
|
): GlobalVolumeAccumulator {
|
|
161
170
|
return this.offlinePumpProgram.coder.accounts.decode<GlobalVolumeAccumulator>(
|
|
162
171
|
"globalVolumeAccumulator",
|
|
163
|
-
accountInfo.data
|
|
172
|
+
accountInfo.data,
|
|
164
173
|
);
|
|
165
174
|
}
|
|
166
175
|
|
|
167
176
|
decodeUserVolumeAccumulator(
|
|
168
|
-
accountInfo: AccountInfo<Buffer
|
|
177
|
+
accountInfo: AccountInfo<Buffer>,
|
|
169
178
|
): UserVolumeAccumulator {
|
|
170
179
|
return this.offlinePumpProgram.coder.accounts.decode<UserVolumeAccumulator>(
|
|
171
180
|
"userVolumeAccumulator",
|
|
172
|
-
accountInfo.data
|
|
181
|
+
accountInfo.data,
|
|
173
182
|
);
|
|
174
183
|
}
|
|
175
184
|
|
|
176
185
|
decodeUserVolumeAccumulatorNullable(
|
|
177
|
-
accountInfo: AccountInfo<Buffer
|
|
186
|
+
accountInfo: AccountInfo<Buffer>,
|
|
178
187
|
): UserVolumeAccumulator | null {
|
|
179
188
|
try {
|
|
180
189
|
return this.decodeUserVolumeAccumulator(accountInfo);
|
|
181
|
-
} catch (
|
|
182
|
-
console.warn("Failed to decode user volume accumulator",
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.warn("Failed to decode user volume accumulator", error);
|
|
183
192
|
return null;
|
|
184
193
|
}
|
|
185
194
|
}
|
|
@@ -227,6 +236,7 @@ export class PumpSdk {
|
|
|
227
236
|
creator,
|
|
228
237
|
user,
|
|
229
238
|
mayhemMode,
|
|
239
|
+
cashback = false,
|
|
230
240
|
}: {
|
|
231
241
|
mint: PublicKey;
|
|
232
242
|
name: string;
|
|
@@ -235,9 +245,10 @@ export class PumpSdk {
|
|
|
235
245
|
creator: PublicKey;
|
|
236
246
|
user: PublicKey;
|
|
237
247
|
mayhemMode: boolean;
|
|
248
|
+
cashback?: boolean;
|
|
238
249
|
}): Promise<TransactionInstruction> {
|
|
239
250
|
return await this.offlinePumpProgram.methods
|
|
240
|
-
.createV2(name, symbol, uri, creator, mayhemMode)
|
|
251
|
+
.createV2(name, symbol, uri, creator, mayhemMode, [cashback ?? false])
|
|
241
252
|
.accountsPartial({
|
|
242
253
|
mint,
|
|
243
254
|
user,
|
|
@@ -281,7 +292,7 @@ export class PumpSdk {
|
|
|
281
292
|
await this.extendAccountInstruction({
|
|
282
293
|
account: bondingCurvePda(mint),
|
|
283
294
|
user,
|
|
284
|
-
})
|
|
295
|
+
}),
|
|
285
296
|
);
|
|
286
297
|
}
|
|
287
298
|
|
|
@@ -289,7 +300,7 @@ export class PumpSdk {
|
|
|
289
300
|
mint,
|
|
290
301
|
user,
|
|
291
302
|
true,
|
|
292
|
-
tokenProgram
|
|
303
|
+
tokenProgram,
|
|
293
304
|
);
|
|
294
305
|
|
|
295
306
|
if (!associatedUserAccountInfo) {
|
|
@@ -299,8 +310,8 @@ export class PumpSdk {
|
|
|
299
310
|
associatedUser,
|
|
300
311
|
user,
|
|
301
312
|
mint,
|
|
302
|
-
tokenProgram
|
|
303
|
-
)
|
|
313
|
+
tokenProgram,
|
|
314
|
+
),
|
|
304
315
|
);
|
|
305
316
|
}
|
|
306
317
|
|
|
@@ -316,7 +327,7 @@ export class PumpSdk {
|
|
|
316
327
|
slippage,
|
|
317
328
|
tokenProgram,
|
|
318
329
|
mayhemMode: bondingCurve.isMayhemMode,
|
|
319
|
-
})
|
|
330
|
+
}),
|
|
320
331
|
);
|
|
321
332
|
|
|
322
333
|
return instructions;
|
|
@@ -333,6 +344,7 @@ export class PumpSdk {
|
|
|
333
344
|
amount,
|
|
334
345
|
solAmount,
|
|
335
346
|
mayhemMode,
|
|
347
|
+
cashback = false,
|
|
336
348
|
}: {
|
|
337
349
|
global: Global;
|
|
338
350
|
mint: PublicKey;
|
|
@@ -344,12 +356,13 @@ export class PumpSdk {
|
|
|
344
356
|
amount: BN;
|
|
345
357
|
solAmount: BN;
|
|
346
358
|
mayhemMode: boolean;
|
|
359
|
+
cashback?: boolean;
|
|
347
360
|
}): Promise<TransactionInstruction[]> {
|
|
348
361
|
const associatedUser = getAssociatedTokenAddressSync(
|
|
349
362
|
mint,
|
|
350
363
|
user,
|
|
351
364
|
true,
|
|
352
|
-
TOKEN_2022_PROGRAM_ID
|
|
365
|
+
TOKEN_2022_PROGRAM_ID,
|
|
353
366
|
);
|
|
354
367
|
return [
|
|
355
368
|
await this.createV2Instruction({
|
|
@@ -360,6 +373,7 @@ export class PumpSdk {
|
|
|
360
373
|
creator,
|
|
361
374
|
user,
|
|
362
375
|
mayhemMode,
|
|
376
|
+
cashback,
|
|
363
377
|
}),
|
|
364
378
|
await this.extendAccountInstruction({
|
|
365
379
|
account: bondingCurvePda(mint),
|
|
@@ -370,7 +384,7 @@ export class PumpSdk {
|
|
|
370
384
|
associatedUser,
|
|
371
385
|
user,
|
|
372
386
|
mint,
|
|
373
|
-
TOKEN_2022_PROGRAM_ID
|
|
387
|
+
TOKEN_2022_PROGRAM_ID,
|
|
374
388
|
),
|
|
375
389
|
await this.buyInstruction({
|
|
376
390
|
global,
|
|
@@ -422,7 +436,7 @@ export class PumpSdk {
|
|
|
422
436
|
user,
|
|
423
437
|
associatedUser,
|
|
424
438
|
user,
|
|
425
|
-
mint
|
|
439
|
+
mint,
|
|
426
440
|
),
|
|
427
441
|
await this.buyInstruction({
|
|
428
442
|
global,
|
|
@@ -470,7 +484,7 @@ export class PumpSdk {
|
|
|
470
484
|
feeRecipient: getFeeRecipient(global, mayhemMode),
|
|
471
485
|
amount,
|
|
472
486
|
solAmount: solAmount.add(
|
|
473
|
-
solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000))
|
|
487
|
+
solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000)),
|
|
474
488
|
),
|
|
475
489
|
tokenProgram,
|
|
476
490
|
});
|
|
@@ -487,6 +501,7 @@ export class PumpSdk {
|
|
|
487
501
|
slippage,
|
|
488
502
|
tokenProgram = TOKEN_PROGRAM_ID,
|
|
489
503
|
mayhemMode = false,
|
|
504
|
+
cashback = false,
|
|
490
505
|
}: {
|
|
491
506
|
global: Global;
|
|
492
507
|
bondingCurveAccountInfo: AccountInfo<Buffer>;
|
|
@@ -498,6 +513,7 @@ export class PumpSdk {
|
|
|
498
513
|
slippage: number;
|
|
499
514
|
tokenProgram: PublicKey;
|
|
500
515
|
mayhemMode: boolean;
|
|
516
|
+
cashback?: boolean;
|
|
501
517
|
}): Promise<TransactionInstruction[]> {
|
|
502
518
|
const instructions: TransactionInstruction[] = [];
|
|
503
519
|
|
|
@@ -506,7 +522,7 @@ export class PumpSdk {
|
|
|
506
522
|
await this.extendAccountInstruction({
|
|
507
523
|
account: bondingCurvePda(mint),
|
|
508
524
|
user,
|
|
509
|
-
})
|
|
525
|
+
}),
|
|
510
526
|
);
|
|
511
527
|
}
|
|
512
528
|
|
|
@@ -518,10 +534,11 @@ export class PumpSdk {
|
|
|
518
534
|
feeRecipient: getFeeRecipient(global, mayhemMode),
|
|
519
535
|
amount,
|
|
520
536
|
solAmount: solAmount.sub(
|
|
521
|
-
solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000))
|
|
537
|
+
solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000)),
|
|
522
538
|
),
|
|
523
539
|
tokenProgram,
|
|
524
|
-
|
|
540
|
+
cashback,
|
|
541
|
+
}),
|
|
525
542
|
);
|
|
526
543
|
|
|
527
544
|
return instructions;
|
|
@@ -559,7 +576,7 @@ export class PumpSdk {
|
|
|
559
576
|
mint,
|
|
560
577
|
bondingCurve,
|
|
561
578
|
true,
|
|
562
|
-
tokenProgram
|
|
579
|
+
tokenProgram,
|
|
563
580
|
);
|
|
564
581
|
|
|
565
582
|
const poolAuthority = pumpPoolAuthorityPda(mint);
|
|
@@ -567,7 +584,7 @@ export class PumpSdk {
|
|
|
567
584
|
mint,
|
|
568
585
|
poolAuthority,
|
|
569
586
|
true,
|
|
570
|
-
tokenProgram
|
|
587
|
+
tokenProgram,
|
|
571
588
|
);
|
|
572
589
|
|
|
573
590
|
const pool = canonicalPumpPoolPda(mint);
|
|
@@ -575,7 +592,7 @@ export class PumpSdk {
|
|
|
575
592
|
mint,
|
|
576
593
|
pool,
|
|
577
594
|
true,
|
|
578
|
-
tokenProgram
|
|
595
|
+
tokenProgram,
|
|
579
596
|
);
|
|
580
597
|
return this.offlinePumpProgram.methods
|
|
581
598
|
.migrate()
|
|
@@ -591,7 +608,7 @@ export class PumpSdk {
|
|
|
591
608
|
}
|
|
592
609
|
|
|
593
610
|
async syncUserVolumeAccumulator(
|
|
594
|
-
user: PublicKey
|
|
611
|
+
user: PublicKey,
|
|
595
612
|
): Promise<TransactionInstruction> {
|
|
596
613
|
return await this.offlinePumpProgram.methods
|
|
597
614
|
.syncUserVolumeAccumulator()
|
|
@@ -631,7 +648,7 @@ export class PumpSdk {
|
|
|
631
648
|
}
|
|
632
649
|
|
|
633
650
|
async closeUserVolumeAccumulator(
|
|
634
|
-
user: PublicKey
|
|
651
|
+
user: PublicKey,
|
|
635
652
|
): Promise<TransactionInstruction> {
|
|
636
653
|
return await this.offlinePumpProgram.methods
|
|
637
654
|
.closeUserVolumeAccumulator()
|
|
@@ -662,7 +679,7 @@ export class PumpSdk {
|
|
|
662
679
|
mint,
|
|
663
680
|
user,
|
|
664
681
|
true,
|
|
665
|
-
tokenProgram
|
|
682
|
+
tokenProgram,
|
|
666
683
|
),
|
|
667
684
|
mint,
|
|
668
685
|
creator,
|
|
@@ -699,7 +716,7 @@ export class PumpSdk {
|
|
|
699
716
|
associatedUser,
|
|
700
717
|
user,
|
|
701
718
|
creatorVault: creatorVaultPda(creator),
|
|
702
|
-
tokenProgram
|
|
719
|
+
tokenProgram,
|
|
703
720
|
})
|
|
704
721
|
.instruction();
|
|
705
722
|
}
|
|
@@ -712,6 +729,7 @@ export class PumpSdk {
|
|
|
712
729
|
solAmount,
|
|
713
730
|
feeRecipient = getStaticRandomFeeRecipient(),
|
|
714
731
|
tokenProgram = TOKEN_PROGRAM_ID,
|
|
732
|
+
cashback = false,
|
|
715
733
|
}: {
|
|
716
734
|
user: PublicKey;
|
|
717
735
|
mint: PublicKey;
|
|
@@ -720,6 +738,7 @@ export class PumpSdk {
|
|
|
720
738
|
solAmount: BN;
|
|
721
739
|
feeRecipient: PublicKey;
|
|
722
740
|
tokenProgram: PublicKey;
|
|
741
|
+
cashback?: boolean;
|
|
723
742
|
}): Promise<TransactionInstruction> {
|
|
724
743
|
return await this.getSellInstructionInternal({
|
|
725
744
|
user,
|
|
@@ -729,6 +748,7 @@ export class PumpSdk {
|
|
|
729
748
|
amount,
|
|
730
749
|
solAmount,
|
|
731
750
|
tokenProgram,
|
|
751
|
+
cashback,
|
|
732
752
|
});
|
|
733
753
|
}
|
|
734
754
|
|
|
@@ -740,6 +760,7 @@ export class PumpSdk {
|
|
|
740
760
|
amount,
|
|
741
761
|
solAmount,
|
|
742
762
|
tokenProgram,
|
|
763
|
+
cashback = false,
|
|
743
764
|
}: {
|
|
744
765
|
user: PublicKey;
|
|
745
766
|
mint: PublicKey;
|
|
@@ -748,7 +769,9 @@ export class PumpSdk {
|
|
|
748
769
|
amount: BN;
|
|
749
770
|
solAmount: BN;
|
|
750
771
|
tokenProgram: PublicKey;
|
|
772
|
+
cashback?: boolean;
|
|
751
773
|
}): Promise<TransactionInstruction> {
|
|
774
|
+
const userVolumeAccumulator = userVolumeAccumulatorPda(user);
|
|
752
775
|
return await this.offlinePumpProgram.methods
|
|
753
776
|
.sell(amount, solAmount)
|
|
754
777
|
.accountsPartial({
|
|
@@ -758,12 +781,23 @@ export class PumpSdk {
|
|
|
758
781
|
mint,
|
|
759
782
|
user,
|
|
760
783
|
true,
|
|
761
|
-
tokenProgram
|
|
784
|
+
tokenProgram,
|
|
762
785
|
),
|
|
763
786
|
user,
|
|
764
787
|
creatorVault: creatorVaultPda(creator),
|
|
765
|
-
tokenProgram
|
|
788
|
+
tokenProgram,
|
|
766
789
|
})
|
|
790
|
+
.remainingAccounts(
|
|
791
|
+
cashback
|
|
792
|
+
? [
|
|
793
|
+
{
|
|
794
|
+
pubkey: userVolumeAccumulator,
|
|
795
|
+
isWritable: true,
|
|
796
|
+
isSigner: false,
|
|
797
|
+
},
|
|
798
|
+
]
|
|
799
|
+
: [],
|
|
800
|
+
)
|
|
767
801
|
.instruction();
|
|
768
802
|
}
|
|
769
803
|
|
|
@@ -794,7 +828,6 @@ export class PumpSdk {
|
|
|
794
828
|
.instruction();
|
|
795
829
|
}
|
|
796
830
|
|
|
797
|
-
|
|
798
831
|
/**
|
|
799
832
|
* Updates the fee shares for a token's creator fee distribution.
|
|
800
833
|
*
|
|
@@ -803,7 +836,6 @@ export class PumpSdk {
|
|
|
803
836
|
* @param params.mint - The mint address of the token
|
|
804
837
|
* @param params.curShareholders - Array of current shareholders
|
|
805
838
|
* @param params.newShareholders - Array of new shareholders and their share percentages
|
|
806
|
-
*
|
|
807
839
|
* @requirements for newShareholders:
|
|
808
840
|
* - Must contain at least 1 shareholder (cannot be empty)
|
|
809
841
|
* - Maximum of 10 shareholders allowed
|
|
@@ -811,13 +843,11 @@ export class PumpSdk {
|
|
|
811
843
|
* - Total shares must equal exactly 10,000 basis points (100%)
|
|
812
844
|
* - No duplicate addresses allowed
|
|
813
845
|
* - shareBps is in basis points where 1 bps = 0.01% (e.g., 1500 = 15%)
|
|
814
|
-
*
|
|
815
846
|
* @throws {NoShareholdersError} If shareholders array is empty
|
|
816
847
|
* @throws {TooManyShareholdersError} If more than 10 shareholders
|
|
817
848
|
* @throws {ZeroShareError} If any shareholder has zero or negative shares
|
|
818
849
|
* @throws {InvalidShareTotalError} If total shares don't equal 10,000 basis points
|
|
819
850
|
* @throws {DuplicateShareholderError} If duplicate addresses are found
|
|
820
|
-
*
|
|
821
851
|
* @example
|
|
822
852
|
* ```typescript
|
|
823
853
|
* const instruction = await PUMP_SDK.updateFeeShares({
|
|
@@ -848,7 +878,10 @@ export class PumpSdk {
|
|
|
848
878
|
}
|
|
849
879
|
|
|
850
880
|
if (newShareholders.length > MAX_SHAREHOLDERS) {
|
|
851
|
-
throw new TooManyShareholdersError(
|
|
881
|
+
throw new TooManyShareholdersError(
|
|
882
|
+
newShareholders.length,
|
|
883
|
+
MAX_SHAREHOLDERS,
|
|
884
|
+
);
|
|
852
885
|
}
|
|
853
886
|
|
|
854
887
|
let totalShares = 0;
|
|
@@ -872,26 +905,31 @@ export class PumpSdk {
|
|
|
872
905
|
}
|
|
873
906
|
|
|
874
907
|
const sharingConfigPda = feeSharingConfigPda(mint);
|
|
875
|
-
const coinCreatorVaultAuthority =
|
|
908
|
+
const coinCreatorVaultAuthority =
|
|
909
|
+
coinCreatorVaultAuthorityPda(sharingConfigPda);
|
|
876
910
|
|
|
877
911
|
return await this.offlinePumpFeeProgram.methods
|
|
878
912
|
.updateFeeShares(
|
|
879
|
-
newShareholders.map(sh => ({
|
|
913
|
+
newShareholders.map((sh) => ({
|
|
880
914
|
address: sh.address,
|
|
881
915
|
shareBps: sh.shareBps,
|
|
882
|
-
}))
|
|
916
|
+
})),
|
|
883
917
|
)
|
|
884
918
|
.accountsPartial({
|
|
885
919
|
authority,
|
|
886
920
|
mint,
|
|
887
|
-
coinCreatorVaultAta: coinCreatorVaultAtaPda(
|
|
921
|
+
coinCreatorVaultAta: coinCreatorVaultAtaPda(
|
|
922
|
+
coinCreatorVaultAuthority,
|
|
923
|
+
NATIVE_MINT,
|
|
924
|
+
TOKEN_PROGRAM_ID,
|
|
925
|
+
),
|
|
888
926
|
})
|
|
889
927
|
.remainingAccounts(
|
|
890
928
|
currentShareholders.map((pubkey) => ({
|
|
891
929
|
pubkey,
|
|
892
930
|
isWritable: true,
|
|
893
931
|
isSigner: false,
|
|
894
|
-
}))
|
|
932
|
+
})),
|
|
895
933
|
)
|
|
896
934
|
.instruction();
|
|
897
935
|
}
|
|
@@ -899,7 +937,7 @@ export class PumpSdk {
|
|
|
899
937
|
decodeDistributeCreatorFeesEvent(data: Buffer): DistributeCreatorFeesEvent {
|
|
900
938
|
return this.offlinePumpProgram.coder.types.decode<DistributeCreatorFeesEvent>(
|
|
901
939
|
"distributeCreatorFeesEvent",
|
|
902
|
-
data
|
|
940
|
+
data,
|
|
903
941
|
);
|
|
904
942
|
}
|
|
905
943
|
|
|
@@ -923,7 +961,7 @@ export class PumpSdk {
|
|
|
923
961
|
pubkey: shareholder.address,
|
|
924
962
|
isWritable: true,
|
|
925
963
|
isSigner: false,
|
|
926
|
-
}))
|
|
964
|
+
})),
|
|
927
965
|
)
|
|
928
966
|
.instruction();
|
|
929
967
|
}
|
|
@@ -931,7 +969,7 @@ export class PumpSdk {
|
|
|
931
969
|
decodeMinimumDistributableFee(data: Buffer): MinimumDistributableFeeEvent {
|
|
932
970
|
return this.offlinePumpProgram.coder.types.decode<MinimumDistributableFeeEvent>(
|
|
933
971
|
"minimumDistributableFeeEvent",
|
|
934
|
-
data
|
|
972
|
+
data,
|
|
935
973
|
);
|
|
936
974
|
}
|
|
937
975
|
|
|
@@ -955,10 +993,23 @@ export class PumpSdk {
|
|
|
955
993
|
pubkey: shareholder.address,
|
|
956
994
|
isWritable: true,
|
|
957
995
|
isSigner: false,
|
|
958
|
-
}))
|
|
996
|
+
})),
|
|
959
997
|
)
|
|
960
998
|
.instruction();
|
|
961
999
|
}
|
|
1000
|
+
|
|
1001
|
+
async claimCashbackInstruction({
|
|
1002
|
+
user,
|
|
1003
|
+
}: {
|
|
1004
|
+
user: PublicKey;
|
|
1005
|
+
}): Promise<TransactionInstruction> {
|
|
1006
|
+
return await this.offlinePumpProgram.methods
|
|
1007
|
+
.claimCashback()
|
|
1008
|
+
.accountsPartial({
|
|
1009
|
+
user,
|
|
1010
|
+
})
|
|
1011
|
+
.instruction();
|
|
1012
|
+
}
|
|
962
1013
|
}
|
|
963
1014
|
|
|
964
1015
|
export const PUMP_SDK = new PumpSdk();
|
|
@@ -975,9 +1026,7 @@ export const PUMP_SDK = new PumpSdk();
|
|
|
975
1026
|
* @param params.creator - The creator address to check
|
|
976
1027
|
* - For ungraduated coins: use BondingCurve.creator
|
|
977
1028
|
* - For graduated coins: use Pool.coinCreator (from AMM pool)
|
|
978
|
-
*
|
|
979
1029
|
* @returns true if the creator has migrated to fee sharing config, false otherwise
|
|
980
|
-
*
|
|
981
1030
|
* @example
|
|
982
1031
|
* ```typescript
|
|
983
1032
|
* import { isCreatorUsingSharingConfig } from "@pump-fun/sdk";
|
package/src/state.ts
CHANGED
package/src/tokenIncentives.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
|
+
|
|
2
3
|
import { GlobalVolumeAccumulator, UserVolumeAccumulator } from "./state";
|
|
3
4
|
|
|
4
5
|
export function totalUnclaimedTokens(
|
|
@@ -17,7 +18,7 @@ export function totalUnclaimedTokens(
|
|
|
17
18
|
return result;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
const currentTimestampBn = new BN(currentTimestamp);
|
|
21
22
|
|
|
22
23
|
if (currentTimestampBn.lt(startTime)) {
|
|
23
24
|
return result;
|
|
@@ -74,7 +75,7 @@ export function currentDayTokens(
|
|
|
74
75
|
return new BN(0);
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
const currentTimestampBn = new BN(currentTimestamp);
|
|
78
79
|
|
|
79
80
|
if (currentTimestampBn.lt(startTime) || currentTimestampBn.gt(endTime)) {
|
|
80
81
|
return new BN(0);
|