@pump-fun/pump-sdk 1.8.0 → 1.9.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/idl/pump.json CHANGED
@@ -2715,6 +2715,134 @@
2715
2715
  }
2716
2716
  ]
2717
2717
  },
2718
+ {
2719
+ "name": "sync_user_volume_accumulator",
2720
+ "discriminator": [
2721
+ 86,
2722
+ 31,
2723
+ 192,
2724
+ 87,
2725
+ 163,
2726
+ 87,
2727
+ 79,
2728
+ 238
2729
+ ],
2730
+ "accounts": [
2731
+ {
2732
+ "name": "user"
2733
+ },
2734
+ {
2735
+ "name": "global_volume_accumulator",
2736
+ "pda": {
2737
+ "seeds": [
2738
+ {
2739
+ "kind": "const",
2740
+ "value": [
2741
+ 103,
2742
+ 108,
2743
+ 111,
2744
+ 98,
2745
+ 97,
2746
+ 108,
2747
+ 95,
2748
+ 118,
2749
+ 111,
2750
+ 108,
2751
+ 117,
2752
+ 109,
2753
+ 101,
2754
+ 95,
2755
+ 97,
2756
+ 99,
2757
+ 99,
2758
+ 117,
2759
+ 109,
2760
+ 117,
2761
+ 108,
2762
+ 97,
2763
+ 116,
2764
+ 111,
2765
+ 114
2766
+ ]
2767
+ }
2768
+ ]
2769
+ }
2770
+ },
2771
+ {
2772
+ "name": "user_volume_accumulator",
2773
+ "writable": true,
2774
+ "pda": {
2775
+ "seeds": [
2776
+ {
2777
+ "kind": "const",
2778
+ "value": [
2779
+ 117,
2780
+ 115,
2781
+ 101,
2782
+ 114,
2783
+ 95,
2784
+ 118,
2785
+ 111,
2786
+ 108,
2787
+ 117,
2788
+ 109,
2789
+ 101,
2790
+ 95,
2791
+ 97,
2792
+ 99,
2793
+ 99,
2794
+ 117,
2795
+ 109,
2796
+ 117,
2797
+ 108,
2798
+ 97,
2799
+ 116,
2800
+ 111,
2801
+ 114
2802
+ ]
2803
+ },
2804
+ {
2805
+ "kind": "account",
2806
+ "path": "user"
2807
+ }
2808
+ ]
2809
+ }
2810
+ },
2811
+ {
2812
+ "name": "event_authority",
2813
+ "pda": {
2814
+ "seeds": [
2815
+ {
2816
+ "kind": "const",
2817
+ "value": [
2818
+ 95,
2819
+ 95,
2820
+ 101,
2821
+ 118,
2822
+ 101,
2823
+ 110,
2824
+ 116,
2825
+ 95,
2826
+ 97,
2827
+ 117,
2828
+ 116,
2829
+ 104,
2830
+ 111,
2831
+ 114,
2832
+ 105,
2833
+ 116,
2834
+ 121
2835
+ ]
2836
+ }
2837
+ ]
2838
+ }
2839
+ },
2840
+ {
2841
+ "name": "program"
2842
+ }
2843
+ ],
2844
+ "args": []
2845
+ },
2718
2846
  {
2719
2847
  "name": "update_global_authority",
2720
2848
  "discriminator": [
@@ -2991,6 +3119,19 @@
2991
3119
  131
2992
3120
  ]
2993
3121
  },
3122
+ {
3123
+ "name": "SyncUserVolumeAccumulatorEvent",
3124
+ "discriminator": [
3125
+ 197,
3126
+ 122,
3127
+ 167,
3128
+ 124,
3129
+ 116,
3130
+ 81,
3131
+ 91,
3132
+ 255
3133
+ ]
3134
+ },
2994
3135
  {
2995
3136
  "name": "TradeEvent",
2996
3137
  "discriminator": [
@@ -3734,6 +3875,26 @@
3734
3875
  ]
3735
3876
  }
3736
3877
  },
3878
+ {
3879
+ "name": "SyncUserVolumeAccumulatorEvent",
3880
+ "type": {
3881
+ "kind": "struct",
3882
+ "fields": [
3883
+ {
3884
+ "name": "user",
3885
+ "type": "pubkey"
3886
+ },
3887
+ {
3888
+ "name": "total_claimed_tokens_before",
3889
+ "type": "u64"
3890
+ },
3891
+ {
3892
+ "name": "total_claimed_tokens_after",
3893
+ "type": "u64"
3894
+ }
3895
+ ]
3896
+ }
3897
+ },
3737
3898
  {
3738
3899
  "name": "TradeEvent",
3739
3900
  "type": {
@@ -3858,6 +4019,10 @@
3858
4019
  {
3859
4020
  "name": "last_update_timestamp",
3860
4021
  "type": "i64"
4022
+ },
4023
+ {
4024
+ "name": "has_total_claimed_tokens",
4025
+ "type": "bool"
3861
4026
  }
3862
4027
  ]
3863
4028
  }
package/src/idl/pump.ts CHANGED
@@ -2721,6 +2721,134 @@ export type Pump = {
2721
2721
  }
2722
2722
  ]
2723
2723
  },
2724
+ {
2725
+ "name": "syncUserVolumeAccumulator",
2726
+ "discriminator": [
2727
+ 86,
2728
+ 31,
2729
+ 192,
2730
+ 87,
2731
+ 163,
2732
+ 87,
2733
+ 79,
2734
+ 238
2735
+ ],
2736
+ "accounts": [
2737
+ {
2738
+ "name": "user"
2739
+ },
2740
+ {
2741
+ "name": "globalVolumeAccumulator",
2742
+ "pda": {
2743
+ "seeds": [
2744
+ {
2745
+ "kind": "const",
2746
+ "value": [
2747
+ 103,
2748
+ 108,
2749
+ 111,
2750
+ 98,
2751
+ 97,
2752
+ 108,
2753
+ 95,
2754
+ 118,
2755
+ 111,
2756
+ 108,
2757
+ 117,
2758
+ 109,
2759
+ 101,
2760
+ 95,
2761
+ 97,
2762
+ 99,
2763
+ 99,
2764
+ 117,
2765
+ 109,
2766
+ 117,
2767
+ 108,
2768
+ 97,
2769
+ 116,
2770
+ 111,
2771
+ 114
2772
+ ]
2773
+ }
2774
+ ]
2775
+ }
2776
+ },
2777
+ {
2778
+ "name": "userVolumeAccumulator",
2779
+ "writable": true,
2780
+ "pda": {
2781
+ "seeds": [
2782
+ {
2783
+ "kind": "const",
2784
+ "value": [
2785
+ 117,
2786
+ 115,
2787
+ 101,
2788
+ 114,
2789
+ 95,
2790
+ 118,
2791
+ 111,
2792
+ 108,
2793
+ 117,
2794
+ 109,
2795
+ 101,
2796
+ 95,
2797
+ 97,
2798
+ 99,
2799
+ 99,
2800
+ 117,
2801
+ 109,
2802
+ 117,
2803
+ 108,
2804
+ 97,
2805
+ 116,
2806
+ 111,
2807
+ 114
2808
+ ]
2809
+ },
2810
+ {
2811
+ "kind": "account",
2812
+ "path": "user"
2813
+ }
2814
+ ]
2815
+ }
2816
+ },
2817
+ {
2818
+ "name": "eventAuthority",
2819
+ "pda": {
2820
+ "seeds": [
2821
+ {
2822
+ "kind": "const",
2823
+ "value": [
2824
+ 95,
2825
+ 95,
2826
+ 101,
2827
+ 118,
2828
+ 101,
2829
+ 110,
2830
+ 116,
2831
+ 95,
2832
+ 97,
2833
+ 117,
2834
+ 116,
2835
+ 104,
2836
+ 111,
2837
+ 114,
2838
+ 105,
2839
+ 116,
2840
+ 121
2841
+ ]
2842
+ }
2843
+ ]
2844
+ }
2845
+ },
2846
+ {
2847
+ "name": "program"
2848
+ }
2849
+ ],
2850
+ "args": []
2851
+ },
2724
2852
  {
2725
2853
  "name": "updateGlobalAuthority",
2726
2854
  "discriminator": [
@@ -2997,6 +3125,19 @@ export type Pump = {
2997
3125
  131
2998
3126
  ]
2999
3127
  },
3128
+ {
3129
+ "name": "syncUserVolumeAccumulatorEvent",
3130
+ "discriminator": [
3131
+ 197,
3132
+ 122,
3133
+ 167,
3134
+ 124,
3135
+ 116,
3136
+ 81,
3137
+ 91,
3138
+ 255
3139
+ ]
3140
+ },
3000
3141
  {
3001
3142
  "name": "tradeEvent",
3002
3143
  "discriminator": [
@@ -3740,6 +3881,26 @@ export type Pump = {
3740
3881
  ]
3741
3882
  }
3742
3883
  },
3884
+ {
3885
+ "name": "syncUserVolumeAccumulatorEvent",
3886
+ "type": {
3887
+ "kind": "struct",
3888
+ "fields": [
3889
+ {
3890
+ "name": "user",
3891
+ "type": "pubkey"
3892
+ },
3893
+ {
3894
+ "name": "totalClaimedTokensBefore",
3895
+ "type": "u64"
3896
+ },
3897
+ {
3898
+ "name": "totalClaimedTokensAfter",
3899
+ "type": "u64"
3900
+ }
3901
+ ]
3902
+ }
3903
+ },
3743
3904
  {
3744
3905
  "name": "tradeEvent",
3745
3906
  "type": {
@@ -3864,6 +4025,10 @@ export type Pump = {
3864
4025
  {
3865
4026
  "name": "lastUpdateTimestamp",
3866
4027
  "type": "i64"
4028
+ },
4029
+ {
4030
+ "name": "hasTotalClaimedTokens",
4031
+ "type": "bool"
3867
4032
  }
3868
4033
  ]
3869
4034
  }
package/src/sdk.ts CHANGED
@@ -52,6 +52,7 @@ export function getPumpProgram(
52
52
  export const PUMP_PROGRAM_ID = new PublicKey(
53
53
  "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",
54
54
  );
55
+
55
56
  export const PUMP_AMM_PROGRAM_ID = new PublicKey(
56
57
  "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",
57
58
  );
@@ -564,28 +565,48 @@ export class PumpSdk {
564
565
  endTime: BN,
565
566
  dayNumber: BN,
566
567
  tokenSupplyPerDay: BN,
567
- secondsInADay: BN = new BN(86400),
568
+ secondsInADay: BN = new BN(86_400),
568
569
  mint: PublicKey = PUMP_TOKEN_MINT,
569
570
  tokenProgram: PublicKey = TOKEN_2022_PROGRAM_ID,
570
- ): Promise<TransactionInstruction[]> {
571
+ ): Promise<TransactionInstruction> {
571
572
  const { authority } = await this.fetchGlobal();
572
573
 
574
+ return await this.offlinePumpProgram.methods
575
+ .adminUpdateTokenIncentives(
576
+ startTime,
577
+ endTime,
578
+ secondsInADay,
579
+ dayNumber,
580
+ tokenSupplyPerDay,
581
+ )
582
+ .accountsPartial({
583
+ global: this.globalPda(),
584
+ authority,
585
+ mint,
586
+ tokenProgram,
587
+ })
588
+ .instruction();
589
+ }
590
+
591
+ async adminUpdateTokenIncentivesBothPrograms(
592
+ startTime: BN,
593
+ endTime: BN,
594
+ dayNumber: BN,
595
+ tokenSupplyPerDay: BN,
596
+ secondsInADay: BN = new BN(86_400),
597
+ mint: PublicKey = PUMP_TOKEN_MINT,
598
+ tokenProgram: PublicKey = TOKEN_2022_PROGRAM_ID,
599
+ ): Promise<TransactionInstruction[]> {
573
600
  return [
574
- await this.offlinePumpProgram.methods
575
- .adminUpdateTokenIncentives(
576
- startTime,
577
- endTime,
578
- secondsInADay,
579
- dayNumber,
580
- tokenSupplyPerDay,
581
- )
582
- .accountsPartial({
583
- global: this.globalPda(),
584
- authority,
585
- mint,
586
- tokenProgram,
587
- })
588
- .instruction(),
601
+ await this.adminUpdateTokenIncentives(
602
+ startTime,
603
+ endTime,
604
+ dayNumber,
605
+ tokenSupplyPerDay,
606
+ secondsInADay,
607
+ mint,
608
+ tokenProgram,
609
+ ),
589
610
  await this.pumpAmmAdminSdk.adminUpdateTokenIncentives(
590
611
  startTime,
591
612
  endTime,
@@ -603,23 +624,32 @@ export class PumpSdk {
603
624
  payer: PublicKey,
604
625
  mint: PublicKey = PUMP_TOKEN_MINT,
605
626
  tokenProgram: PublicKey = TOKEN_2022_PROGRAM_ID,
627
+ ): Promise<TransactionInstruction> {
628
+ return await this.offlinePumpProgram.methods
629
+ .claimTokenIncentives()
630
+ .accountsPartial({
631
+ user,
632
+ payer,
633
+ mint,
634
+ tokenProgram,
635
+ })
636
+ .instruction();
637
+ }
638
+
639
+ async claimTokenIncentivesBothPrograms(
640
+ user: PublicKey,
641
+ payer: PublicKey,
642
+ mint: PublicKey = PUMP_TOKEN_MINT,
643
+ tokenProgram: PublicKey = TOKEN_2022_PROGRAM_ID,
606
644
  ): Promise<TransactionInstruction[]> {
607
645
  return [
608
- await this.offlinePumpProgram.methods
609
- .claimTokenIncentives()
610
- .accountsPartial({
611
- user,
612
- payer,
613
- mint,
614
- tokenProgram,
615
- })
616
- .instruction(),
617
- ...(await this.pumpAmmSdk.claimTokenIncentives(
646
+ await this.claimTokenIncentives(user, payer, mint, tokenProgram),
647
+ await this.pumpAmmSdk.claimTokenIncentives(
618
648
  user,
619
649
  payer,
620
650
  mint,
621
651
  tokenProgram,
622
- )),
652
+ ),
623
653
  ];
624
654
  }
625
655
 
@@ -646,10 +676,13 @@ export class PumpSdk {
646
676
  userVolumeAccumulatorAccountInfo,
647
677
  );
648
678
 
649
- return totalUnclaimedTokens(
650
- globalVolumeAccumulator,
651
- userVolumeAccumulator,
652
- ).add(await this.pumpAmmSdk.getCurrentDayTokens(user));
679
+ return totalUnclaimedTokens(globalVolumeAccumulator, userVolumeAccumulator);
680
+ }
681
+
682
+ async getTotalUnclaimedTokensBothPrograms(user: PublicKey): Promise<BN> {
683
+ return (await this.getTotalUnclaimedTokens(user)).add(
684
+ await this.pumpAmmSdk.getTotalUnclaimedTokens(user),
685
+ );
653
686
  }
654
687
 
655
688
  async getCurrentDayTokens(user: PublicKey): Promise<BN> {
@@ -675,10 +708,32 @@ export class PumpSdk {
675
708
  userVolumeAccumulatorAccountInfo,
676
709
  );
677
710
 
678
- return currentDayTokens(globalVolumeAccumulator, userVolumeAccumulator).add(
711
+ return currentDayTokens(globalVolumeAccumulator, userVolumeAccumulator);
712
+ }
713
+
714
+ async getCurrentDayTokensBothPrograms(user: PublicKey): Promise<BN> {
715
+ return (await this.getCurrentDayTokens(user)).add(
679
716
  await this.pumpAmmSdk.getCurrentDayTokens(user),
680
717
  );
681
718
  }
719
+
720
+ async syncUserVolumeAccumulator(
721
+ user: PublicKey
722
+ ): Promise<TransactionInstruction> {
723
+ return await this.offlinePumpProgram.methods
724
+ .syncUserVolumeAccumulator()
725
+ .accountsPartial({ user })
726
+ .instruction();
727
+ }
728
+
729
+ async syncUserVolumeAccumulatorBothPrograms(
730
+ user: PublicKey,
731
+ ): Promise<TransactionInstruction[]> {
732
+ return [
733
+ await this.syncUserVolumeAccumulator(user),
734
+ await this.pumpAmmSdk.syncUserVolumeAccumulator(user),
735
+ ];
736
+ }
682
737
  }
683
738
 
684
739
  function getFeeRecipient(global: Global): PublicKey {