@pump-fun/pump-sdk 1.5.0-devnet.1 → 1.6.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/src/index.ts CHANGED
@@ -13,6 +13,8 @@ export {
13
13
  pumpPoolAuthorityPda,
14
14
  CANONICAL_POOL_INDEX,
15
15
  canonicalPumpPoolPda,
16
+ globalVolumeAccumulatorPda,
17
+ userVolumeAccumulatorPda,
16
18
  } from "./pda";
17
19
  export {
18
20
  getPumpProgram,
package/src/pda.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { PublicKey, PublicKeyInitData } from "@solana/web3.js";
2
2
  import { NATIVE_MINT } from "@solana/spl-token";
3
3
  import { poolPda } from "@pump-fun/pump-swap-sdk";
4
+ import { PUMP_PROGRAM_ID } from "./sdk";
4
5
 
5
6
  export function globalPda(programId: PublicKey): PublicKey {
6
7
  const [globalPda] = PublicKey.findProgramAddressSync(
@@ -56,3 +57,22 @@ export function canonicalPumpPoolPda(
56
57
  pumpAmmProgramId,
57
58
  );
58
59
  }
60
+
61
+ export function globalVolumeAccumulatorPda(
62
+ programId: PublicKey = PUMP_PROGRAM_ID,
63
+ ): [PublicKey, number] {
64
+ return PublicKey.findProgramAddressSync(
65
+ [Buffer.from("global_volume_accumulator")],
66
+ programId,
67
+ );
68
+ }
69
+
70
+ export function userVolumeAccumulatorPda(
71
+ user: PublicKey,
72
+ programId: PublicKey = PUMP_PROGRAM_ID,
73
+ ): [PublicKey, number] {
74
+ return PublicKey.findProgramAddressSync(
75
+ [Buffer.from("user_volume_accumulator"), user.toBuffer()],
76
+ programId,
77
+ );
78
+ }
package/src/sdk.ts CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  createAssociatedTokenAccountIdempotentInstruction,
5
5
  getAssociatedTokenAddressSync,
6
6
  NATIVE_MINT,
7
+ TOKEN_2022_PROGRAM_ID,
7
8
  TOKEN_PROGRAM_ID,
8
9
  } from "@solana/spl-token";
9
10
  import {
@@ -23,8 +24,10 @@ import {
23
24
  creatorVaultPda,
24
25
  globalPda,
25
26
  pumpPoolAuthorityPda,
27
+ globalVolumeAccumulatorPda,
28
+ userVolumeAccumulatorPda,
26
29
  } from "./pda";
27
- import { BondingCurve, Global } from "./state";
30
+ import { BondingCurve, Global, GlobalVolumeAccumulator, UserVolumeAccumulator } from "./state";
28
31
 
29
32
  export function getPumpProgram(
30
33
  connection: Connection,
@@ -49,6 +52,10 @@ export const PUMP_AMM_PROGRAM_ID = new PublicKey(
49
52
 
50
53
  export const BONDING_CURVE_NEW_SIZE = 150;
51
54
 
55
+ export const PUMP_TOKEN_MINT = new PublicKey(
56
+ "pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn",
57
+ );
58
+
52
59
  export class PumpSdk {
53
60
  private readonly connection: Connection;
54
61
  private readonly pumpProgram: Program<Pump>;
@@ -104,6 +111,14 @@ export class PumpSdk {
104
111
  );
105
112
  }
106
113
 
114
+ globalVolumeAccumulatorPda(): [PublicKey, number] {
115
+ return globalVolumeAccumulatorPda(this.offlinePumpProgram.programId);
116
+ }
117
+
118
+ userVolumeAccumulatorPda(user: PublicKey): [PublicKey, number] {
119
+ return userVolumeAccumulatorPda(user, this.offlinePumpProgram.programId);
120
+ }
121
+
107
122
  decodeGlobal(accountInfo: AccountInfo<Buffer>): Global {
108
123
  return this.offlinePumpProgram.coder.accounts.decode<Global>(
109
124
  "global",
@@ -118,6 +133,19 @@ export class PumpSdk {
118
133
  );
119
134
  }
120
135
 
136
+ decodeGlobalVolumeAccumulator(accountInfo: AccountInfo<Buffer>): GlobalVolumeAccumulator {
137
+ return this.offlinePumpProgram.coder.accounts.decode<GlobalVolumeAccumulator>(
138
+ "globalVolumeAccumulator",
139
+ accountInfo.data,
140
+ );
141
+ }
142
+
143
+ decodeUserVolumeAccumulator(accountInfo: AccountInfo<Buffer>): UserVolumeAccumulator {
144
+ return this.offlinePumpProgram.coder.accounts.decode<UserVolumeAccumulator>(
145
+ "userVolumeAccumulator",
146
+ accountInfo.data,
147
+ );
148
+ }
121
149
  async fetchGlobal(): Promise<Global> {
122
150
  return await this.pumpProgram.account.global.fetch(this.globalPda());
123
151
  }
@@ -168,6 +196,18 @@ export class PumpSdk {
168
196
  return { bondingCurveAccountInfo, bondingCurve };
169
197
  }
170
198
 
199
+ async fetchGlobalVolumeAccumulator(): Promise<GlobalVolumeAccumulator> {
200
+ return await this.pumpProgram.account.globalVolumeAccumulator.fetch(
201
+ this.globalVolumeAccumulatorPda()[0],
202
+ );
203
+ }
204
+
205
+ async fetchUserVolumeAccumulator(user: PublicKey): Promise<UserVolumeAccumulator> {
206
+ return await this.pumpProgram.account.userVolumeAccumulator.fetch(
207
+ this.userVolumeAccumulatorPda(user)[0],
208
+ );
209
+ }
210
+
171
211
  async createInstruction({
172
212
  mint,
173
213
  name,
@@ -506,6 +546,66 @@ export class PumpSdk {
506
546
 
507
547
  return new BN(accountInfo.lamports - rentExemptionLamports);
508
548
  }
549
+
550
+ async adminUpdatePumpIncentives(
551
+ admin: PublicKey,
552
+ startTime: BN,
553
+ endTime: BN,
554
+ dayNumber: BN,
555
+ pumpTokenSupplyPerDay: BN,
556
+ mint: PublicKey = PUMP_TOKEN_MINT,
557
+ tokenProgram: PublicKey = TOKEN_2022_PROGRAM_ID,
558
+ ): Promise<TransactionInstruction> {
559
+ return await this.offlinePumpProgram.methods
560
+ .updatePumpIncentives(
561
+ startTime,
562
+ endTime,
563
+ dayNumber.toNumber(),
564
+ pumpTokenSupplyPerDay,
565
+ )
566
+ .accountsPartial({
567
+ admin,
568
+ globalVolumeAccumulator: this.globalVolumeAccumulatorPda()[0],
569
+ globalConfig: this.globalPda(),
570
+ mint,
571
+ tokenProgram,
572
+ })
573
+ .instruction();
574
+ }
575
+
576
+ async claimPumpIncentives(
577
+ user: PublicKey,
578
+ payer: PublicKey,
579
+ mint: PublicKey = PUMP_TOKEN_MINT,
580
+ tokenProgram: PublicKey = TOKEN_2022_PROGRAM_ID
581
+ ): Promise<TransactionInstruction[]> {
582
+ const userPumpAta = getAssociatedTokenAddressSync(
583
+ mint,
584
+ user,
585
+ true,
586
+ tokenProgram,
587
+ );
588
+
589
+ return [
590
+ createAssociatedTokenAccountIdempotentInstruction(
591
+ payer,
592
+ userPumpAta,
593
+ user,
594
+ mint,
595
+ tokenProgram,
596
+ ),
597
+ await this.offlinePumpProgram.methods
598
+ .claimPumpIncentives()
599
+ .accountsPartial({
600
+ user,
601
+ payer,
602
+ globalVolumeAccumulator: this.globalVolumeAccumulatorPda()[0],
603
+ mint,
604
+ tokenProgram,
605
+ })
606
+ .instruction(),
607
+ ];
608
+ }
509
609
  }
510
610
 
511
611
  function getFeeRecipient(global: Global): PublicKey {
package/src/state.ts CHANGED
@@ -30,3 +30,17 @@ export interface BondingCurve {
30
30
  complete: boolean;
31
31
  creator: PublicKey;
32
32
  }
33
+
34
+ export interface GlobalVolumeAccumulator {
35
+ startTime: BN;
36
+ endTime: BN;
37
+ totalPumpTokenSupply: BN[];
38
+ solVolumes: BN[];
39
+ }
40
+
41
+ export interface UserVolumeAccumulator {
42
+ lastUpdateTimestamp: BN;
43
+ currentSolVolume: BN;
44
+ totalUnclaimedPumpTokens: BN;
45
+ totalClaimedPumpTokens: BN;
46
+ }