@pump-fun/pump-sdk 1.23.0 → 1.24.0

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 CHANGED
@@ -8519,6 +8519,15 @@ var PumpSdk = class {
8519
8519
  }
8520
8520
  decodeBondingCurveNullable(accountInfo) {
8521
8521
  try {
8522
+ let data = accountInfo.data;
8523
+ if (data.length < 82) {
8524
+ const padded = Buffer.alloc(82);
8525
+ data.copy(padded);
8526
+ accountInfo = {
8527
+ ...accountInfo,
8528
+ data: padded
8529
+ };
8530
+ }
8522
8531
  return this.decodeBondingCurve(accountInfo);
8523
8532
  } catch (e) {
8524
8533
  console.warn("Failed to decode bonding curve", e);
@@ -8603,7 +8612,12 @@ var PumpSdk = class {
8603
8612
  })
8604
8613
  );
8605
8614
  }
8606
- const associatedUser = getAssociatedTokenAddressSync2(mint, user, true, tokenProgram);
8615
+ const associatedUser = getAssociatedTokenAddressSync2(
8616
+ mint,
8617
+ user,
8618
+ true,
8619
+ tokenProgram
8620
+ );
8607
8621
  if (!associatedUserAccountInfo) {
8608
8622
  instructions.push(
8609
8623
  createAssociatedTokenAccountIdempotentInstruction(
@@ -8643,9 +8657,22 @@ var PumpSdk = class {
8643
8657
  solAmount,
8644
8658
  mayhemMode
8645
8659
  }) {
8646
- const associatedUser = getAssociatedTokenAddressSync2(mint, user, true, TOKEN_2022_PROGRAM_ID2);
8660
+ const associatedUser = getAssociatedTokenAddressSync2(
8661
+ mint,
8662
+ user,
8663
+ true,
8664
+ TOKEN_2022_PROGRAM_ID2
8665
+ );
8647
8666
  return [
8648
- await this.createV2Instruction({ mint, name, symbol, uri, creator, user, mayhemMode }),
8667
+ await this.createV2Instruction({
8668
+ mint,
8669
+ name,
8670
+ symbol,
8671
+ uri,
8672
+ creator,
8673
+ user,
8674
+ mayhemMode
8675
+ }),
8649
8676
  await this.extendAccountInstruction({
8650
8677
  account: bondingCurvePda(mint),
8651
8678
  user
@@ -8789,11 +8816,26 @@ var PumpSdk = class {
8789
8816
  tokenProgram = TOKEN_PROGRAM_ID2
8790
8817
  }) {
8791
8818
  const bondingCurve = bondingCurvePda(mint);
8792
- const associatedBondingCurve = getAssociatedTokenAddressSync2(mint, bondingCurve, true, tokenProgram);
8819
+ const associatedBondingCurve = getAssociatedTokenAddressSync2(
8820
+ mint,
8821
+ bondingCurve,
8822
+ true,
8823
+ tokenProgram
8824
+ );
8793
8825
  const poolAuthority = pumpPoolAuthorityPda(mint);
8794
- const poolAuthorityMintAccount = getAssociatedTokenAddressSync2(mint, poolAuthority, true, tokenProgram);
8826
+ const poolAuthorityMintAccount = getAssociatedTokenAddressSync2(
8827
+ mint,
8828
+ poolAuthority,
8829
+ true,
8830
+ tokenProgram
8831
+ );
8795
8832
  const pool = canonicalPumpPoolPda(mint);
8796
- const poolBaseTokenAccount = getAssociatedTokenAddressSync2(mint, pool, true, tokenProgram);
8833
+ const poolBaseTokenAccount = getAssociatedTokenAddressSync2(
8834
+ mint,
8835
+ pool,
8836
+ true,
8837
+ tokenProgram
8838
+ );
8797
8839
  return this.offlinePumpProgram.methods.migrate().accountsPartial({
8798
8840
  mint,
8799
8841
  user,
@@ -8842,7 +8884,12 @@ var PumpSdk = class {
8842
8884
  }) {
8843
8885
  return await this.getBuyInstructionInternal({
8844
8886
  user,
8845
- associatedUser: getAssociatedTokenAddressSync2(mint, user, true, tokenProgram),
8887
+ associatedUser: getAssociatedTokenAddressSync2(
8888
+ mint,
8889
+ user,
8890
+ true,
8891
+ tokenProgram
8892
+ ),
8846
8893
  mint,
8847
8894
  creator,
8848
8895
  feeRecipient,
@@ -8900,7 +8947,12 @@ var PumpSdk = class {
8900
8947
  return await this.offlinePumpProgram.methods.sell(amount, solAmount).accountsPartial({
8901
8948
  feeRecipient,
8902
8949
  mint,
8903
- associatedUser: getAssociatedTokenAddressSync2(mint, user, true, tokenProgram),
8950
+ associatedUser: getAssociatedTokenAddressSync2(
8951
+ mint,
8952
+ user,
8953
+ true,
8954
+ tokenProgram
8955
+ ),
8904
8956
  user,
8905
8957
  creatorVault: creatorVaultPda(creator),
8906
8958
  tokenProgram
@@ -8910,7 +8962,10 @@ var PumpSdk = class {
8910
8962
  var PUMP_SDK = new PumpSdk();
8911
8963
  function getFeeRecipient(global, mayhemMode) {
8912
8964
  if (mayhemMode) {
8913
- const feeRecipients = [global.reservedFeeRecipient, ...global.reservedFeeRecipients];
8965
+ const feeRecipients = [
8966
+ global.reservedFeeRecipient,
8967
+ ...global.reservedFeeRecipients
8968
+ ];
8914
8969
  return feeRecipients[Math.floor(Math.random() * feeRecipients.length)];
8915
8970
  } else {
8916
8971
  const feeRecipients = [global.feeRecipient, ...global.feeRecipients];
package/dist/index.d.mts CHANGED
@@ -12285,7 +12285,7 @@ declare class PumpSdk {
12285
12285
  creator: PublicKey;
12286
12286
  user: PublicKey;
12287
12287
  }): Promise<TransactionInstruction>;
12288
- createV2Instruction({ mint, name, symbol, uri, creator, user, mayhemMode }: {
12288
+ createV2Instruction({ mint, name, symbol, uri, creator, user, mayhemMode, }: {
12289
12289
  mint: PublicKey;
12290
12290
  name: string;
12291
12291
  symbol: string;
@@ -12333,7 +12333,7 @@ declare class PumpSdk {
12333
12333
  solAmount: BN;
12334
12334
  }): Promise<TransactionInstruction[]>;
12335
12335
  private buyInstruction;
12336
- sellInstructions({ global, bondingCurveAccountInfo, bondingCurve, mint, user, amount, solAmount, slippage, tokenProgram, mayhemMode }: {
12336
+ sellInstructions({ global, bondingCurveAccountInfo, bondingCurve, mint, user, amount, solAmount, slippage, tokenProgram, mayhemMode, }: {
12337
12337
  global: Global;
12338
12338
  bondingCurveAccountInfo: AccountInfo<Buffer>;
12339
12339
  bondingCurve: BondingCurve;
@@ -12349,7 +12349,7 @@ declare class PumpSdk {
12349
12349
  account: PublicKey;
12350
12350
  user: PublicKey;
12351
12351
  }): Promise<TransactionInstruction>;
12352
- migrateInstruction({ withdrawAuthority, mint, user, tokenProgram }: {
12352
+ migrateInstruction({ withdrawAuthority, mint, user, tokenProgram, }: {
12353
12353
  withdrawAuthority: PublicKey;
12354
12354
  mint: PublicKey;
12355
12355
  user: PublicKey;
package/dist/index.d.ts CHANGED
@@ -12285,7 +12285,7 @@ declare class PumpSdk {
12285
12285
  creator: PublicKey;
12286
12286
  user: PublicKey;
12287
12287
  }): Promise<TransactionInstruction>;
12288
- createV2Instruction({ mint, name, symbol, uri, creator, user, mayhemMode }: {
12288
+ createV2Instruction({ mint, name, symbol, uri, creator, user, mayhemMode, }: {
12289
12289
  mint: PublicKey;
12290
12290
  name: string;
12291
12291
  symbol: string;
@@ -12333,7 +12333,7 @@ declare class PumpSdk {
12333
12333
  solAmount: BN;
12334
12334
  }): Promise<TransactionInstruction[]>;
12335
12335
  private buyInstruction;
12336
- sellInstructions({ global, bondingCurveAccountInfo, bondingCurve, mint, user, amount, solAmount, slippage, tokenProgram, mayhemMode }: {
12336
+ sellInstructions({ global, bondingCurveAccountInfo, bondingCurve, mint, user, amount, solAmount, slippage, tokenProgram, mayhemMode, }: {
12337
12337
  global: Global;
12338
12338
  bondingCurveAccountInfo: AccountInfo<Buffer>;
12339
12339
  bondingCurve: BondingCurve;
@@ -12349,7 +12349,7 @@ declare class PumpSdk {
12349
12349
  account: PublicKey;
12350
12350
  user: PublicKey;
12351
12351
  }): Promise<TransactionInstruction>;
12352
- migrateInstruction({ withdrawAuthority, mint, user, tokenProgram }: {
12352
+ migrateInstruction({ withdrawAuthority, mint, user, tokenProgram, }: {
12353
12353
  withdrawAuthority: PublicKey;
12354
12354
  mint: PublicKey;
12355
12355
  user: PublicKey;
package/dist/index.js CHANGED
@@ -8539,6 +8539,15 @@ var PumpSdk = class {
8539
8539
  }
8540
8540
  decodeBondingCurveNullable(accountInfo) {
8541
8541
  try {
8542
+ let data = accountInfo.data;
8543
+ if (data.length < 82) {
8544
+ const padded = Buffer.alloc(82);
8545
+ data.copy(padded);
8546
+ accountInfo = {
8547
+ ...accountInfo,
8548
+ data: padded
8549
+ };
8550
+ }
8542
8551
  return this.decodeBondingCurve(accountInfo);
8543
8552
  } catch (e) {
8544
8553
  console.warn("Failed to decode bonding curve", e);
@@ -8623,7 +8632,12 @@ var PumpSdk = class {
8623
8632
  })
8624
8633
  );
8625
8634
  }
8626
- const associatedUser = (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, user, true, tokenProgram);
8635
+ const associatedUser = (0, import_spl_token2.getAssociatedTokenAddressSync)(
8636
+ mint,
8637
+ user,
8638
+ true,
8639
+ tokenProgram
8640
+ );
8627
8641
  if (!associatedUserAccountInfo) {
8628
8642
  instructions.push(
8629
8643
  (0, import_spl_token2.createAssociatedTokenAccountIdempotentInstruction)(
@@ -8663,9 +8677,22 @@ var PumpSdk = class {
8663
8677
  solAmount,
8664
8678
  mayhemMode
8665
8679
  }) {
8666
- const associatedUser = (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, user, true, import_spl_token2.TOKEN_2022_PROGRAM_ID);
8680
+ const associatedUser = (0, import_spl_token2.getAssociatedTokenAddressSync)(
8681
+ mint,
8682
+ user,
8683
+ true,
8684
+ import_spl_token2.TOKEN_2022_PROGRAM_ID
8685
+ );
8667
8686
  return [
8668
- await this.createV2Instruction({ mint, name, symbol, uri, creator, user, mayhemMode }),
8687
+ await this.createV2Instruction({
8688
+ mint,
8689
+ name,
8690
+ symbol,
8691
+ uri,
8692
+ creator,
8693
+ user,
8694
+ mayhemMode
8695
+ }),
8669
8696
  await this.extendAccountInstruction({
8670
8697
  account: bondingCurvePda(mint),
8671
8698
  user
@@ -8809,11 +8836,26 @@ var PumpSdk = class {
8809
8836
  tokenProgram = import_spl_token2.TOKEN_PROGRAM_ID
8810
8837
  }) {
8811
8838
  const bondingCurve = bondingCurvePda(mint);
8812
- const associatedBondingCurve = (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, bondingCurve, true, tokenProgram);
8839
+ const associatedBondingCurve = (0, import_spl_token2.getAssociatedTokenAddressSync)(
8840
+ mint,
8841
+ bondingCurve,
8842
+ true,
8843
+ tokenProgram
8844
+ );
8813
8845
  const poolAuthority = pumpPoolAuthorityPda(mint);
8814
- const poolAuthorityMintAccount = (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, poolAuthority, true, tokenProgram);
8846
+ const poolAuthorityMintAccount = (0, import_spl_token2.getAssociatedTokenAddressSync)(
8847
+ mint,
8848
+ poolAuthority,
8849
+ true,
8850
+ tokenProgram
8851
+ );
8815
8852
  const pool = canonicalPumpPoolPda(mint);
8816
- const poolBaseTokenAccount = (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, pool, true, tokenProgram);
8853
+ const poolBaseTokenAccount = (0, import_spl_token2.getAssociatedTokenAddressSync)(
8854
+ mint,
8855
+ pool,
8856
+ true,
8857
+ tokenProgram
8858
+ );
8817
8859
  return this.offlinePumpProgram.methods.migrate().accountsPartial({
8818
8860
  mint,
8819
8861
  user,
@@ -8862,7 +8904,12 @@ var PumpSdk = class {
8862
8904
  }) {
8863
8905
  return await this.getBuyInstructionInternal({
8864
8906
  user,
8865
- associatedUser: (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, user, true, tokenProgram),
8907
+ associatedUser: (0, import_spl_token2.getAssociatedTokenAddressSync)(
8908
+ mint,
8909
+ user,
8910
+ true,
8911
+ tokenProgram
8912
+ ),
8866
8913
  mint,
8867
8914
  creator,
8868
8915
  feeRecipient,
@@ -8920,7 +8967,12 @@ var PumpSdk = class {
8920
8967
  return await this.offlinePumpProgram.methods.sell(amount, solAmount).accountsPartial({
8921
8968
  feeRecipient,
8922
8969
  mint,
8923
- associatedUser: (0, import_spl_token2.getAssociatedTokenAddressSync)(mint, user, true, tokenProgram),
8970
+ associatedUser: (0, import_spl_token2.getAssociatedTokenAddressSync)(
8971
+ mint,
8972
+ user,
8973
+ true,
8974
+ tokenProgram
8975
+ ),
8924
8976
  user,
8925
8977
  creatorVault: creatorVaultPda(creator),
8926
8978
  tokenProgram
@@ -8930,7 +8982,10 @@ var PumpSdk = class {
8930
8982
  var PUMP_SDK = new PumpSdk();
8931
8983
  function getFeeRecipient(global, mayhemMode) {
8932
8984
  if (mayhemMode) {
8933
- const feeRecipients = [global.reservedFeeRecipient, ...global.reservedFeeRecipients];
8985
+ const feeRecipients = [
8986
+ global.reservedFeeRecipient,
8987
+ ...global.reservedFeeRecipients
8988
+ ];
8934
8989
  return feeRecipients[Math.floor(Math.random() * feeRecipients.length)];
8935
8990
  } else {
8936
8991
  const feeRecipients = [global.feeRecipient, ...global.feeRecipients];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pump-fun/pump-sdk",
3
- "version": "1.23.0",
3
+ "version": "1.24.0",
4
4
  "description": "Pump Bonding Curve SDK",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/pump-fun/pump-sdk#readme",
package/src/sdk.ts CHANGED
@@ -16,7 +16,16 @@ 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, getGlobalParamsPda, getMayhemStatePda, getSolVaultPda, getTokenVaultPda, pumpPoolAuthorityPda } from "./pda";
19
+ import {
20
+ bondingCurvePda,
21
+ canonicalPumpPoolPda,
22
+ creatorVaultPda,
23
+ getGlobalParamsPda,
24
+ getMayhemStatePda,
25
+ getSolVaultPda,
26
+ getTokenVaultPda,
27
+ pumpPoolAuthorityPda,
28
+ } from "./pda";
20
29
  import {
21
30
  BondingCurve,
22
31
  FeeConfig,
@@ -30,30 +39,30 @@ import { OFFLINE_PUMP_PROGRAM } from "./onlineSdk";
30
39
  export function getPumpProgram(connection: Connection): Program<Pump> {
31
40
  return new Program(
32
41
  pumpIdl as Pump,
33
- new AnchorProvider(connection, null as any, {}),
42
+ new AnchorProvider(connection, null as any, {})
34
43
  );
35
44
  }
36
45
 
37
46
  export const PUMP_PROGRAM_ID = new PublicKey(
38
- "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",
47
+ "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"
39
48
  );
40
49
 
41
50
  export const PUMP_AMM_PROGRAM_ID = new PublicKey(
42
- "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",
51
+ "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"
43
52
  );
44
53
 
45
54
  export const MAYHEM_PROGRAM_ID = new PublicKey(
46
- "MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e",
55
+ "MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e"
47
56
  );
48
57
 
49
58
  export const PUMP_FEE_PROGRAM_ID = new PublicKey(
50
- "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ",
59
+ "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
51
60
  );
52
61
 
53
62
  export const BONDING_CURVE_NEW_SIZE = 151;
54
63
 
55
64
  export const PUMP_TOKEN_MINT = new PublicKey(
56
- "pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn",
65
+ "pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn"
57
66
  );
58
67
 
59
68
  export class PumpSdk {
@@ -66,28 +75,39 @@ export class PumpSdk {
66
75
  decodeGlobal(accountInfo: AccountInfo<Buffer>): Global {
67
76
  return this.offlinePumpProgram.coder.accounts.decode<Global>(
68
77
  "global",
69
- accountInfo.data,
78
+ accountInfo.data
70
79
  );
71
80
  }
72
81
 
73
82
  decodeFeeConfig(accountInfo: AccountInfo<Buffer>): FeeConfig {
74
83
  return this.offlinePumpProgram.coder.accounts.decode<FeeConfig>(
75
84
  "feeConfig",
76
- accountInfo.data,
85
+ accountInfo.data
77
86
  );
78
87
  }
79
88
 
80
89
  decodeBondingCurve(accountInfo: AccountInfo<Buffer>): BondingCurve {
81
90
  return this.offlinePumpProgram.coder.accounts.decode<BondingCurve>(
82
91
  "bondingCurve",
83
- accountInfo.data,
92
+ accountInfo.data
84
93
  );
85
94
  }
86
95
 
87
96
  decodeBondingCurveNullable(
88
- accountInfo: AccountInfo<Buffer>,
97
+ accountInfo: AccountInfo<Buffer>
89
98
  ): BondingCurve | null {
90
99
  try {
100
+ let data = accountInfo.data;
101
+ // Ensure buffer is at least 82 bytes
102
+ if (data.length < 82) {
103
+ const padded = Buffer.alloc(82);
104
+ data.copy(padded);
105
+ accountInfo = {
106
+ ...accountInfo,
107
+ data: padded,
108
+ };
109
+ }
110
+
91
111
  return this.decodeBondingCurve(accountInfo);
92
112
  } catch (e) {
93
113
  console.warn("Failed to decode bonding curve", e);
@@ -96,25 +116,25 @@ export class PumpSdk {
96
116
  }
97
117
 
98
118
  decodeGlobalVolumeAccumulator(
99
- accountInfo: AccountInfo<Buffer>,
119
+ accountInfo: AccountInfo<Buffer>
100
120
  ): GlobalVolumeAccumulator {
101
121
  return this.offlinePumpProgram.coder.accounts.decode<GlobalVolumeAccumulator>(
102
122
  "globalVolumeAccumulator",
103
- accountInfo.data,
123
+ accountInfo.data
104
124
  );
105
125
  }
106
126
 
107
127
  decodeUserVolumeAccumulator(
108
- accountInfo: AccountInfo<Buffer>,
128
+ accountInfo: AccountInfo<Buffer>
109
129
  ): UserVolumeAccumulator {
110
130
  return this.offlinePumpProgram.coder.accounts.decode<UserVolumeAccumulator>(
111
131
  "userVolumeAccumulator",
112
- accountInfo.data,
132
+ accountInfo.data
113
133
  );
114
134
  }
115
135
 
116
136
  decodeUserVolumeAccumulatorNullable(
117
- accountInfo: AccountInfo<Buffer>,
137
+ accountInfo: AccountInfo<Buffer>
118
138
  ): UserVolumeAccumulator | null {
119
139
  try {
120
140
  return this.decodeUserVolumeAccumulator(accountInfo);
@@ -159,7 +179,7 @@ export class PumpSdk {
159
179
  uri,
160
180
  creator,
161
181
  user,
162
- mayhemMode
182
+ mayhemMode,
163
183
  }: {
164
184
  mint: PublicKey;
165
185
  name: string;
@@ -214,11 +234,16 @@ export class PumpSdk {
214
234
  await this.extendAccountInstruction({
215
235
  account: bondingCurvePda(mint),
216
236
  user,
217
- }),
237
+ })
218
238
  );
219
239
  }
220
240
 
221
- const associatedUser = getAssociatedTokenAddressSync(mint, user, true, tokenProgram);
241
+ const associatedUser = getAssociatedTokenAddressSync(
242
+ mint,
243
+ user,
244
+ true,
245
+ tokenProgram
246
+ );
222
247
 
223
248
  if (!associatedUserAccountInfo) {
224
249
  instructions.push(
@@ -228,7 +253,7 @@ export class PumpSdk {
228
253
  user,
229
254
  mint,
230
255
  tokenProgram
231
- ),
256
+ )
232
257
  );
233
258
  }
234
259
 
@@ -244,7 +269,7 @@ export class PumpSdk {
244
269
  slippage,
245
270
  tokenProgram,
246
271
  mayhemMode: bondingCurve.isMayhemMode,
247
- }),
272
+ })
248
273
  );
249
274
 
250
275
  return instructions;
@@ -273,9 +298,22 @@ export class PumpSdk {
273
298
  solAmount: BN;
274
299
  mayhemMode: boolean;
275
300
  }): Promise<TransactionInstruction[]> {
276
- const associatedUser = getAssociatedTokenAddressSync(mint, user, true, TOKEN_2022_PROGRAM_ID);
301
+ const associatedUser = getAssociatedTokenAddressSync(
302
+ mint,
303
+ user,
304
+ true,
305
+ TOKEN_2022_PROGRAM_ID
306
+ );
277
307
  return [
278
- await this.createV2Instruction({ mint, name, symbol, uri, creator, user, mayhemMode }),
308
+ await this.createV2Instruction({
309
+ mint,
310
+ name,
311
+ symbol,
312
+ uri,
313
+ creator,
314
+ user,
315
+ mayhemMode,
316
+ }),
279
317
  await this.extendAccountInstruction({
280
318
  account: bondingCurvePda(mint),
281
319
  user,
@@ -285,7 +323,7 @@ export class PumpSdk {
285
323
  associatedUser,
286
324
  user,
287
325
  mint,
288
- TOKEN_2022_PROGRAM_ID,
326
+ TOKEN_2022_PROGRAM_ID
289
327
  ),
290
328
  await this.buyInstruction({
291
329
  global,
@@ -337,7 +375,7 @@ export class PumpSdk {
337
375
  user,
338
376
  associatedUser,
339
377
  user,
340
- mint,
378
+ mint
341
379
  ),
342
380
  await this.buyInstruction({
343
381
  global,
@@ -385,7 +423,7 @@ export class PumpSdk {
385
423
  feeRecipient: getFeeRecipient(global, mayhemMode),
386
424
  amount,
387
425
  solAmount: solAmount.add(
388
- solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000)),
426
+ solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000))
389
427
  ),
390
428
  tokenProgram,
391
429
  });
@@ -401,7 +439,7 @@ export class PumpSdk {
401
439
  solAmount,
402
440
  slippage,
403
441
  tokenProgram = TOKEN_PROGRAM_ID,
404
- mayhemMode = false
442
+ mayhemMode = false,
405
443
  }: {
406
444
  global: Global;
407
445
  bondingCurveAccountInfo: AccountInfo<Buffer>;
@@ -421,7 +459,7 @@ export class PumpSdk {
421
459
  await this.extendAccountInstruction({
422
460
  account: bondingCurvePda(mint),
423
461
  user,
424
- }),
462
+ })
425
463
  );
426
464
  }
427
465
 
@@ -433,10 +471,10 @@ export class PumpSdk {
433
471
  feeRecipient: getFeeRecipient(global, mayhemMode),
434
472
  amount,
435
473
  solAmount: solAmount.sub(
436
- solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000)),
474
+ solAmount.mul(new BN(Math.floor(slippage * 10))).div(new BN(1000))
437
475
  ),
438
476
  tokenProgram,
439
- }),
477
+ })
440
478
  );
441
479
 
442
480
  return instructions;
@@ -462,21 +500,36 @@ export class PumpSdk {
462
500
  withdrawAuthority,
463
501
  mint,
464
502
  user,
465
- tokenProgram = TOKEN_PROGRAM_ID
503
+ tokenProgram = TOKEN_PROGRAM_ID,
466
504
  }: {
467
505
  withdrawAuthority: PublicKey;
468
506
  mint: PublicKey;
469
507
  user: PublicKey;
470
508
  tokenProgram: PublicKey;
471
509
  }): Promise<TransactionInstruction> {
472
- const bondingCurve = bondingCurvePda(mint)
473
- const associatedBondingCurve = getAssociatedTokenAddressSync(mint, bondingCurve, true, tokenProgram)
510
+ const bondingCurve = bondingCurvePda(mint);
511
+ const associatedBondingCurve = getAssociatedTokenAddressSync(
512
+ mint,
513
+ bondingCurve,
514
+ true,
515
+ tokenProgram
516
+ );
474
517
 
475
518
  const poolAuthority = pumpPoolAuthorityPda(mint);
476
- const poolAuthorityMintAccount = getAssociatedTokenAddressSync(mint, poolAuthority, true, tokenProgram)
519
+ const poolAuthorityMintAccount = getAssociatedTokenAddressSync(
520
+ mint,
521
+ poolAuthority,
522
+ true,
523
+ tokenProgram
524
+ );
477
525
 
478
526
  const pool = canonicalPumpPoolPda(mint);
479
- const poolBaseTokenAccount = getAssociatedTokenAddressSync(mint, pool, true, tokenProgram)
527
+ const poolBaseTokenAccount = getAssociatedTokenAddressSync(
528
+ mint,
529
+ pool,
530
+ true,
531
+ tokenProgram
532
+ );
480
533
  return this.offlinePumpProgram.methods
481
534
  .migrate()
482
535
  .accountsPartial({
@@ -485,13 +538,13 @@ export class PumpSdk {
485
538
  withdrawAuthority,
486
539
  associatedBondingCurve,
487
540
  poolAuthorityMintAccount,
488
- poolBaseTokenAccount
541
+ poolBaseTokenAccount,
489
542
  })
490
543
  .instruction();
491
544
  }
492
545
 
493
546
  async syncUserVolumeAccumulator(
494
- user: PublicKey,
547
+ user: PublicKey
495
548
  ): Promise<TransactionInstruction> {
496
549
  return await this.offlinePumpProgram.methods
497
550
  .syncUserVolumeAccumulator()
@@ -500,7 +553,7 @@ export class PumpSdk {
500
553
  }
501
554
 
502
555
  async syncUserVolumeAccumulatorBothPrograms(
503
- user: PublicKey,
556
+ user: PublicKey
504
557
  ): Promise<TransactionInstruction[]> {
505
558
  return [
506
559
  await this.syncUserVolumeAccumulator(user),
@@ -540,7 +593,7 @@ export class PumpSdk {
540
593
  }
541
594
 
542
595
  async closeUserVolumeAccumulator(
543
- user: PublicKey,
596
+ user: PublicKey
544
597
  ): Promise<TransactionInstruction> {
545
598
  return await this.offlinePumpProgram.methods
546
599
  .closeUserVolumeAccumulator()
@@ -567,7 +620,12 @@ export class PumpSdk {
567
620
  }): Promise<TransactionInstruction> {
568
621
  return await this.getBuyInstructionInternal({
569
622
  user,
570
- associatedUser: getAssociatedTokenAddressSync(mint, user, true, tokenProgram),
623
+ associatedUser: getAssociatedTokenAddressSync(
624
+ mint,
625
+ user,
626
+ true,
627
+ tokenProgram
628
+ ),
571
629
  mint,
572
630
  creator,
573
631
  feeRecipient,
@@ -632,7 +690,7 @@ export class PumpSdk {
632
690
  feeRecipient,
633
691
  amount,
634
692
  solAmount,
635
- tokenProgram
693
+ tokenProgram,
636
694
  });
637
695
  }
638
696
 
@@ -658,10 +716,15 @@ export class PumpSdk {
658
716
  .accountsPartial({
659
717
  feeRecipient,
660
718
  mint,
661
- associatedUser: getAssociatedTokenAddressSync(mint, user, true, tokenProgram),
719
+ associatedUser: getAssociatedTokenAddressSync(
720
+ mint,
721
+ user,
722
+ true,
723
+ tokenProgram
724
+ ),
662
725
  user,
663
726
  creatorVault: creatorVaultPda(creator),
664
- tokenProgram: tokenProgram
727
+ tokenProgram: tokenProgram,
665
728
  })
666
729
  .instruction();
667
730
  }
@@ -669,12 +732,18 @@ export class PumpSdk {
669
732
 
670
733
  export const PUMP_SDK = new PumpSdk();
671
734
 
672
- export function getFeeRecipient(global: Global, mayhemMode: boolean): PublicKey {
735
+ export function getFeeRecipient(
736
+ global: Global,
737
+ mayhemMode: boolean
738
+ ): PublicKey {
673
739
  if (mayhemMode) {
674
- const feeRecipients = [global.reservedFeeRecipient, ...global.reservedFeeRecipients];
740
+ const feeRecipients = [
741
+ global.reservedFeeRecipient,
742
+ ...global.reservedFeeRecipients,
743
+ ];
675
744
  return feeRecipients[Math.floor(Math.random() * feeRecipients.length)];
676
745
  } else {
677
- const feeRecipients = [global.feeRecipient, ...global.feeRecipients,];
746
+ const feeRecipients = [global.feeRecipient, ...global.feeRecipients];
678
747
  return feeRecipients[Math.floor(Math.random() * feeRecipients.length)];
679
748
  }
680
749
  }