@pump-fun/pump-sdk 1.20.0-devnet.1 → 1.20.0-devnet.3

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.ts CHANGED
@@ -2122,6 +2122,26 @@ export type Pump = {
2122
2122
  "name": "associatedTokenProgram",
2123
2123
  "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
2124
2124
  },
2125
+ {
2126
+ "name": "mayhemProgramId",
2127
+ "writable": true
2128
+ },
2129
+ {
2130
+ "name": "globalParams",
2131
+ "writable": true
2132
+ },
2133
+ {
2134
+ "name": "solVault",
2135
+ "writable": true
2136
+ },
2137
+ {
2138
+ "name": "mayhemState",
2139
+ "writable": true
2140
+ },
2141
+ {
2142
+ "name": "mayhemTokenVault",
2143
+ "writable": true
2144
+ },
2125
2145
  {
2126
2146
  "name": "eventAuthority",
2127
2147
  "pda": {
@@ -2171,6 +2191,10 @@ export type Pump = {
2171
2191
  {
2172
2192
  "name": "creator",
2173
2193
  "type": "pubkey"
2194
+ },
2195
+ {
2196
+ "name": "isMayhemMode",
2197
+ "type": "bool"
2174
2198
  }
2175
2199
  ]
2176
2200
  },
@@ -3668,6 +3692,90 @@ export type Pump = {
3668
3692
  }
3669
3693
  ]
3670
3694
  },
3695
+ {
3696
+ "name": "setReservedFeeRecipient",
3697
+ "discriminator": [
3698
+ 207,
3699
+ 189,
3700
+ 178,
3701
+ 71,
3702
+ 167,
3703
+ 122,
3704
+ 68,
3705
+ 180
3706
+ ],
3707
+ "accounts": [
3708
+ {
3709
+ "name": "global",
3710
+ "writable": true,
3711
+ "pda": {
3712
+ "seeds": [
3713
+ {
3714
+ "kind": "const",
3715
+ "value": [
3716
+ 103,
3717
+ 108,
3718
+ 111,
3719
+ 98,
3720
+ 97,
3721
+ 108
3722
+ ]
3723
+ }
3724
+ ]
3725
+ }
3726
+ },
3727
+ {
3728
+ "name": "authority",
3729
+ "writable": true,
3730
+ "signer": true,
3731
+ "relations": [
3732
+ "global"
3733
+ ]
3734
+ },
3735
+ {
3736
+ "name": "eventAuthority",
3737
+ "pda": {
3738
+ "seeds": [
3739
+ {
3740
+ "kind": "const",
3741
+ "value": [
3742
+ 95,
3743
+ 95,
3744
+ 101,
3745
+ 118,
3746
+ 101,
3747
+ 110,
3748
+ 116,
3749
+ 95,
3750
+ 97,
3751
+ 117,
3752
+ 116,
3753
+ 104,
3754
+ 111,
3755
+ 114,
3756
+ 105,
3757
+ 116,
3758
+ 121
3759
+ ]
3760
+ }
3761
+ ]
3762
+ }
3763
+ },
3764
+ {
3765
+ "name": "program"
3766
+ }
3767
+ ],
3768
+ "args": [
3769
+ {
3770
+ "name": "reservedFeeRecipient",
3771
+ "type": "pubkey"
3772
+ },
3773
+ {
3774
+ "name": "whitelistPda",
3775
+ "type": "pubkey"
3776
+ }
3777
+ ]
3778
+ },
3671
3779
  {
3672
3780
  "name": "syncUserVolumeAccumulator",
3673
3781
  "discriminator": [
@@ -3876,6 +3984,86 @@ export type Pump = {
3876
3984
  }
3877
3985
  ]
3878
3986
  },
3987
+ {
3988
+ "name": "toggleMayhemMode",
3989
+ "discriminator": [
3990
+ 1,
3991
+ 9,
3992
+ 111,
3993
+ 208,
3994
+ 100,
3995
+ 31,
3996
+ 255,
3997
+ 163
3998
+ ],
3999
+ "accounts": [
4000
+ {
4001
+ "name": "global",
4002
+ "writable": true,
4003
+ "pda": {
4004
+ "seeds": [
4005
+ {
4006
+ "kind": "const",
4007
+ "value": [
4008
+ 103,
4009
+ 108,
4010
+ 111,
4011
+ 98,
4012
+ 97,
4013
+ 108
4014
+ ]
4015
+ }
4016
+ ]
4017
+ }
4018
+ },
4019
+ {
4020
+ "name": "authority",
4021
+ "writable": true,
4022
+ "signer": true,
4023
+ "relations": [
4024
+ "global"
4025
+ ]
4026
+ },
4027
+ {
4028
+ "name": "eventAuthority",
4029
+ "pda": {
4030
+ "seeds": [
4031
+ {
4032
+ "kind": "const",
4033
+ "value": [
4034
+ 95,
4035
+ 95,
4036
+ 101,
4037
+ 118,
4038
+ 101,
4039
+ 110,
4040
+ 116,
4041
+ 95,
4042
+ 97,
4043
+ 117,
4044
+ 116,
4045
+ 104,
4046
+ 111,
4047
+ 114,
4048
+ 105,
4049
+ 116,
4050
+ 121
4051
+ ]
4052
+ }
4053
+ ]
4054
+ }
4055
+ },
4056
+ {
4057
+ "name": "program"
4058
+ }
4059
+ ],
4060
+ "args": [
4061
+ {
4062
+ "name": "enabled",
4063
+ "type": "bool"
4064
+ }
4065
+ ]
4066
+ },
3879
4067
  {
3880
4068
  "name": "updateGlobalAuthority",
3881
4069
  "discriminator": [
@@ -4466,6 +4654,14 @@ export type Pump = {
4466
4654
  {
4467
4655
  "code": 6046,
4468
4656
  "name": "createV2Disabled"
4657
+ },
4658
+ {
4659
+ "code": 6047,
4660
+ "name": "cpitializeMayhemFailed"
4661
+ },
4662
+ {
4663
+ "code": 6048,
4664
+ "name": "mayhemModeDisabled"
4469
4665
  }
4470
4666
  ],
4471
4667
  "types": [
@@ -4581,6 +4777,10 @@ export type Pump = {
4581
4777
  {
4582
4778
  "name": "creator",
4583
4779
  "type": "pubkey"
4780
+ },
4781
+ {
4782
+ "name": "isMayhemMode",
4783
+ "type": "bool"
4584
4784
  }
4585
4785
  ]
4586
4786
  }
@@ -4789,6 +4989,10 @@ export type Pump = {
4789
4989
  {
4790
4990
  "name": "tokenProgram",
4791
4991
  "type": "pubkey"
4992
+ },
4993
+ {
4994
+ "name": "isMayhemMode",
4995
+ "type": "bool"
4792
4996
  }
4793
4997
  ]
4794
4998
  }
@@ -4974,6 +5178,18 @@ export type Pump = {
4974
5178
  {
4975
5179
  "name": "createV2Enabled",
4976
5180
  "type": "bool"
5181
+ },
5182
+ {
5183
+ "name": "whitelistPda",
5184
+ "type": "pubkey"
5185
+ },
5186
+ {
5187
+ "name": "reservedFeeRecipient",
5188
+ "type": "pubkey"
5189
+ },
5190
+ {
5191
+ "name": "mayhemModeEnabled",
5192
+ "type": "bool"
4977
5193
  }
4978
5194
  ]
4979
5195
  }
package/src/onlineSdk.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Program } from "@coral-xyz/anchor";
1
+ import { AnchorProvider, Program } from "@coral-xyz/anchor";
2
2
  import {
3
3
  coinCreatorVaultAtaPda,
4
4
  coinCreatorVaultAuthorityPda,
package/src/pda.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PublicKey, PublicKeyInitData } from "@solana/web3.js";
2
- import { NATIVE_MINT } from "@solana/spl-token";
2
+ import { getAssociatedTokenAddressSync, NATIVE_MINT, TOKEN_2022_PROGRAM_ID } from "@solana/spl-token";
3
3
  import { poolPda, pumpFeePda, pumpPda } from "@pump-fun/pump-swap-sdk";
4
- import { PUMP_PROGRAM_ID } from "./sdk";
4
+ import { MAYHEM_PROGRAM_ID, PUMP_PROGRAM_ID } from "./sdk";
5
5
  import { Buffer } from "buffer";
6
6
 
7
7
  export const GLOBAL_PDA = pumpPda([Buffer.from("global")]);
@@ -44,3 +44,35 @@ export function canonicalPumpPoolPda(mint: PublicKey): PublicKey {
44
44
  export function userVolumeAccumulatorPda(user: PublicKey): PublicKey {
45
45
  return pumpPda([Buffer.from("user_volume_accumulator"), user.toBuffer()]);
46
46
  }
47
+
48
+ /// Mayhem mode pdas
49
+
50
+ export const getGlobalParamsPda = (): PublicKey => {
51
+ return PublicKey.findProgramAddressSync(
52
+ [Buffer.from("global-params")],
53
+ MAYHEM_PROGRAM_ID
54
+ )[0];
55
+ };
56
+
57
+ export const getMayhemStatePda = (mint: PublicKey): PublicKey => {
58
+ return PublicKey.findProgramAddressSync(
59
+ [Buffer.from("mayhem-state"), mint.toBuffer()],
60
+ MAYHEM_PROGRAM_ID
61
+ )[0];
62
+ };
63
+
64
+ export const getSolVaultPda = (): PublicKey => {
65
+ return PublicKey.findProgramAddressSync(
66
+ [Buffer.from("sol-vault")],
67
+ MAYHEM_PROGRAM_ID
68
+ )[0];
69
+ };
70
+
71
+ export const getTokenVaultPda = (mintPubkey: PublicKey): PublicKey => {
72
+ return getAssociatedTokenAddressSync(
73
+ mintPubkey,
74
+ getSolVaultPda(),
75
+ true,
76
+ TOKEN_2022_PROGRAM_ID
77
+ );
78
+ };
package/src/sdk.ts CHANGED
@@ -16,7 +16,7 @@ import pumpIdl from "./idl/pump.json";
16
16
  import { Pump } from "./idl/pump";
17
17
  import BN from "bn.js";
18
18
 
19
- import { bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, pumpPoolAuthorityPda } from "./pda";
19
+ import { bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, getGlobalParamsPda, getMayhemStatePda, getSolVaultPda, getTokenVaultPda, pumpPoolAuthorityPda } from "./pda";
20
20
  import {
21
21
  BondingCurve,
22
22
  FeeConfig,
@@ -42,11 +42,15 @@ export const PUMP_AMM_PROGRAM_ID = new PublicKey(
42
42
  "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",
43
43
  );
44
44
 
45
+ export const MAYHEM_PROGRAM_ID = new PublicKey(
46
+ "MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e",
47
+ );
48
+
45
49
  export const PUMP_FEE_PROGRAM_ID = new PublicKey(
46
50
  "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ",
47
51
  );
48
52
 
49
- export const BONDING_CURVE_NEW_SIZE = 150;
53
+ export const BONDING_CURVE_NEW_SIZE = 151;
50
54
 
51
55
  export const PUMP_TOKEN_MINT = new PublicKey(
52
56
  "pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn",
@@ -155,6 +159,7 @@ export class PumpSdk {
155
159
  uri,
156
160
  creator,
157
161
  user,
162
+ mayhemMode
158
163
  }: {
159
164
  mint: PublicKey;
160
165
  name: string;
@@ -162,13 +167,19 @@ export class PumpSdk {
162
167
  uri: string;
163
168
  creator: PublicKey;
164
169
  user: PublicKey;
170
+ mayhemMode: boolean;
165
171
  }): Promise<TransactionInstruction> {
166
172
  return await this.offlinePumpProgram.methods
167
- .createV2(name, symbol, uri, creator)
173
+ .createV2(name, symbol, uri, creator, mayhemMode)
168
174
  .accountsPartial({
169
175
  mint,
170
176
  user,
171
177
  tokenProgram: TOKEN_2022_PROGRAM_ID,
178
+ mayhemProgramId: MAYHEM_PROGRAM_ID,
179
+ globalParams: getGlobalParamsPda(),
180
+ solVault: getSolVaultPda(),
181
+ mayhemState: getMayhemStatePda(mint),
182
+ mayhemTokenVault: getTokenVaultPda(mint),
172
183
  })
173
184
  .instruction();
174
185
  }
@@ -231,7 +242,8 @@ export class PumpSdk {
231
242
  amount,
232
243
  solAmount,
233
244
  slippage,
234
- tokenProgram
245
+ tokenProgram,
246
+ mayhemMode: bondingCurve.isMayhemMode
235
247
  }),
236
248
  );
237
249
 
@@ -248,6 +260,7 @@ export class PumpSdk {
248
260
  user,
249
261
  amount,
250
262
  solAmount,
263
+ mayhemMode,
251
264
  }: {
252
265
  global: Global;
253
266
  mint: PublicKey;
@@ -258,10 +271,11 @@ export class PumpSdk {
258
271
  user: PublicKey;
259
272
  amount: BN;
260
273
  solAmount: BN;
274
+ mayhemMode: boolean;
261
275
  }): Promise<TransactionInstruction[]> {
262
276
  const associatedUser = getAssociatedTokenAddressSync(mint, user, true, TOKEN_2022_PROGRAM_ID);
263
277
  return [
264
- await this.createV2Instruction({ mint, name, symbol, uri, creator, user }),
278
+ await this.createV2Instruction({ mint, name, symbol, uri, creator, user, mayhemMode }),
265
279
  await this.extendAccountInstruction({
266
280
  account: bondingCurvePda(mint),
267
281
  user,
@@ -347,6 +361,7 @@ export class PumpSdk {
347
361
  solAmount,
348
362
  slippage,
349
363
  tokenProgram,
364
+ mayhemMode = false,
350
365
  }: {
351
366
  global: Global;
352
367
  mint: PublicKey;
@@ -357,13 +372,14 @@ export class PumpSdk {
357
372
  solAmount: BN;
358
373
  slippage: number;
359
374
  tokenProgram?: PublicKey;
375
+ mayhemMode?: boolean;
360
376
  }) {
361
377
  return await this.getBuyInstructionInternal({
362
378
  user,
363
379
  associatedUser,
364
380
  mint,
365
381
  creator,
366
- feeRecipient: getFeeRecipient(global),
382
+ feeRecipient: getFeeRecipient(global, mayhemMode),
367
383
  amount,
368
384
  solAmount: solAmount.add(
369
385
  solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000)),
@@ -382,6 +398,7 @@ export class PumpSdk {
382
398
  solAmount,
383
399
  slippage,
384
400
  tokenProgram = TOKEN_PROGRAM_ID,
401
+ mayhemMode = false
385
402
  }: {
386
403
  global: Global;
387
404
  bondingCurveAccountInfo: AccountInfo<Buffer>;
@@ -392,6 +409,7 @@ export class PumpSdk {
392
409
  solAmount: BN;
393
410
  slippage: number;
394
411
  tokenProgram: PublicKey;
412
+ mayhemMode: boolean;
395
413
  }): Promise<TransactionInstruction[]> {
396
414
  const instructions: TransactionInstruction[] = [];
397
415
 
@@ -409,7 +427,7 @@ export class PumpSdk {
409
427
  user,
410
428
  mint,
411
429
  creator: bondingCurve.creator,
412
- feeRecipient: getFeeRecipient(global),
430
+ feeRecipient: getFeeRecipient(global, mayhemMode),
413
431
  amount,
414
432
  solAmount: solAmount.sub(
415
433
  solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000)),
@@ -648,7 +666,12 @@ export class PumpSdk {
648
666
 
649
667
  export const PUMP_SDK = new PumpSdk();
650
668
 
651
- export function getFeeRecipient(global: Global): PublicKey {
669
+ export function getFeeRecipient(global: Global, mayhemMode: boolean): PublicKey {
670
+ if (!mayhemMode){
652
671
  const feeRecipients = [global.feeRecipient, ...global.feeRecipients];
653
672
  return feeRecipients[Math.floor(Math.random() * feeRecipients.length)];
673
+ }
674
+ else {
675
+ return global.reservedFeeRecipient
676
+ }
654
677
  }
package/src/state.ts CHANGED
@@ -19,6 +19,10 @@ export interface Global {
19
19
  feeRecipients: PublicKey[];
20
20
  setCreatorAuthority: PublicKey;
21
21
  adminSetCreatorAuthority: PublicKey;
22
+ createV2Enabled: boolean;
23
+ whitelistPda: PublicKey;
24
+ reservedFeeRecipient: PublicKey;
25
+ mayhemModeEnabled: boolean;
22
26
  }
23
27
 
24
28
  export interface BondingCurve {
@@ -29,6 +33,7 @@ export interface BondingCurve {
29
33
  tokenTotalSupply: BN;
30
34
  complete: boolean;
31
35
  creator: PublicKey;
36
+ isMayhemMode: boolean;
32
37
  }
33
38
 
34
39
  export interface GlobalVolumeAccumulator {