pump-trader 1.1.2 → 1.1.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/dist/index.d.ts CHANGED
@@ -33,6 +33,8 @@ interface BondingCurveState {
33
33
  realSolReserves: bigint;
34
34
  tokenTotalSupply: bigint;
35
35
  complete: boolean;
36
+ isMayhemMode?: boolean;
37
+ isCashbackCoin?: boolean;
36
38
  }
37
39
  interface BondingInfo {
38
40
  bonding: PublicKey;
package/dist/index.js CHANGED
@@ -100,6 +100,8 @@ function parsePoolKeys(data) {
100
100
  const coinCreator = new web3_js_1.PublicKey(data.slice(offset, offset + 32));
101
101
  offset += 32;
102
102
  const isMayhemMode = data.readUInt8(offset) === 1;
103
+ offset += 1;
104
+ const isCashbackCoin = offset < data.length ? data.readUInt8(offset) === 1 : false;
103
105
  return {
104
106
  creator,
105
107
  baseMint,
@@ -108,7 +110,8 @@ function parsePoolKeys(data) {
108
110
  poolBaseTokenAccount,
109
111
  poolQuoteTokenAccount,
110
112
  coinCreator,
111
- isMayhemMode
113
+ isMayhemMode,
114
+ isCashbackCoin
112
115
  };
113
116
  }
114
117
  /* ================= PumpTrader 类 ================= */
@@ -240,6 +243,10 @@ class PumpTrader {
240
243
  state.complete = data[offset] === 1;
241
244
  offset += 1;
242
245
  const creator = new web3_js_1.PublicKey(data.slice(offset, offset + 32));
246
+ offset += 32;
247
+ state.isMayhemMode = offset < data.length ? data[offset] === 1 : false;
248
+ offset += 1;
249
+ state.isCashbackCoin = offset < data.length ? data[offset] === 1 : false;
243
250
  return { bonding, state, creator };
244
251
  }
245
252
  /* ---------- 价格计算 ---------- */
@@ -559,6 +566,12 @@ class PumpTrader {
559
566
  const userAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, this.wallet.publicKey, false, tokenProgram.programId, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
560
567
  const [creatorVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("creator-vault"), creator.toBuffer()], PROGRAM_IDS.PUMP);
561
568
  const [feeConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fee_config"), SEEDS.FEE_CONFIG], PROGRAM_IDS.FEE);
569
+ const [userVolumeAccumulator] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("user_volume_accumulator"), this.wallet.publicKey.toBuffer()], PROGRAM_IDS.PUMP);
570
+ const sellRemainingKeys = [];
571
+ if (state.isCashbackCoin) {
572
+ sellRemainingKeys.push({ pubkey: userVolumeAccumulator, isSigner: false, isWritable: true });
573
+ }
574
+ sellRemainingKeys.push({ pubkey: bondingCurveV2, isSigner: false, isWritable: false });
562
575
  for (let i = 0; i < tokenChunks.length; i++) {
563
576
  try {
564
577
  const tokenIn = tokenChunks[i];
@@ -588,7 +601,7 @@ class PumpTrader {
588
601
  { pubkey: PROGRAM_IDS.PUMP, isSigner: false, isWritable: false },
589
602
  { pubkey: feeConfig, isSigner: false, isWritable: false },
590
603
  { pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
591
- { pubkey: bondingCurveV2, isSigner: false, isWritable: false }
604
+ ...sellRemainingKeys
592
605
  ],
593
606
  data: Buffer.concat([
594
607
  DISCRIMINATORS.SELL,
@@ -778,6 +791,12 @@ class PumpTrader {
778
791
  const [feeConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fee_config"), SEEDS.AMM_FEE_CONFIG], PROGRAM_IDS.FEE);
779
792
  const protocolFeeRecipient = globalConfig.protocolFeeRecipients[0];
780
793
  const protocolFeeRecipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(SOL_MINT, protocolFeeRecipient, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
794
+ const remainingKeys = [];
795
+ if (poolKeys.isCashbackCoin) {
796
+ const userVolumeAccumulatorWsolAta = (0, spl_token_1.getAssociatedTokenAddressSync)(SOL_MINT, userVolumeAccumulator, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
797
+ remainingKeys.push({ pubkey: userVolumeAccumulatorWsolAta, isSigner: false, isWritable: true });
798
+ }
799
+ remainingKeys.push({ pubkey: poolV2, isSigner: false, isWritable: false });
781
800
  return new web3_js_1.TransactionInstruction({
782
801
  programId: PROGRAM_IDS.PUMP_AMM,
783
802
  keys: [
@@ -804,7 +823,7 @@ class PumpTrader {
804
823
  { pubkey: userVolumeAccumulator, isSigner: false, isWritable: true },
805
824
  { pubkey: feeConfig, isSigner: false, isWritable: false },
806
825
  { pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
807
- { pubkey: poolV2, isSigner: false, isWritable: false }
826
+ ...remainingKeys
808
827
  ],
809
828
  data: Buffer.concat([
810
829
  DISCRIMINATORS.BUY,
@@ -823,6 +842,13 @@ class PumpTrader {
823
842
  const [feeConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fee_config"), SEEDS.AMM_FEE_CONFIG], PROGRAM_IDS.FEE);
824
843
  const protocolFeeRecipient = globalConfig.protocolFeeRecipients[0];
825
844
  const protocolFeeRecipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(SOL_MINT, protocolFeeRecipient, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
845
+ const [userVolumeAccumulator] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("user_volume_accumulator"), this.wallet.publicKey.toBuffer()], PROGRAM_IDS.PUMP_AMM);
846
+ const userVolumeAccumulatorWsolAta = (0, spl_token_1.getAssociatedTokenAddressSync)(SOL_MINT, userVolumeAccumulator, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
847
+ const remainingKeys = [];
848
+ if (poolKeys.isCashbackCoin) {
849
+ remainingKeys.push({ pubkey: userVolumeAccumulatorWsolAta, isSigner: false, isWritable: true }, { pubkey: userVolumeAccumulator, isSigner: false, isWritable: true });
850
+ }
851
+ remainingKeys.push({ pubkey: poolV2, isSigner: false, isWritable: false });
826
852
  return new web3_js_1.TransactionInstruction({
827
853
  programId: PROGRAM_IDS.PUMP_AMM,
828
854
  keys: [
@@ -847,7 +873,7 @@ class PumpTrader {
847
873
  { pubkey: coinCreatorVaultAuthority, isSigner: false, isWritable: false },
848
874
  { pubkey: feeConfig, isSigner: false, isWritable: false },
849
875
  { pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
850
- { pubkey: poolV2, isSigner: false, isWritable: false }
876
+ ...remainingKeys
851
877
  ],
852
878
  data: Buffer.concat([
853
879
  DISCRIMINATORS.SELL,
package/index.js CHANGED
@@ -141,6 +141,8 @@ function parsePoolKeys(data) {
141
141
  offset += 32;
142
142
 
143
143
  const isMayhemMode = data.readUInt8(offset) === 1;
144
+ offset += 1;
145
+ const isCashbackCoin = offset < data.length ? data.readUInt8(offset) === 1 : false;
144
146
 
145
147
  return {
146
148
  creator,
@@ -150,7 +152,8 @@ function parsePoolKeys(data) {
150
152
  poolBaseTokenAccount,
151
153
  poolQuoteTokenAccount,
152
154
  coinCreator,
153
- isMayhemMode
155
+ isMayhemMode,
156
+ isCashbackCoin
154
157
  };
155
158
  }
156
159
 
@@ -309,6 +312,10 @@ export class PumpTrader {
309
312
  offset += 1;
310
313
 
311
314
  const creator = new PublicKey(data.slice(offset, offset + 32));
315
+ offset += 32;
316
+ state.isMayhemMode = offset < data.length ? data[offset] === 1 : false;
317
+ offset += 1;
318
+ state.isCashbackCoin = offset < data.length ? data[offset] === 1 : false;
312
319
 
313
320
  return { bonding, state, creator };
314
321
  }
@@ -661,6 +668,17 @@ export class PumpTrader {
661
668
  PROGRAM_IDS.FEE
662
669
  );
663
670
 
671
+ const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
672
+ [Buffer.from("user_volume_accumulator"), this.wallet.publicKey.toBuffer()],
673
+ PROGRAM_IDS.PUMP
674
+ );
675
+
676
+ const sellRemainingKeys = [];
677
+ if (state.isCashbackCoin) {
678
+ sellRemainingKeys.push({ pubkey: userVolumeAccumulator, isSigner: false, isWritable: true });
679
+ }
680
+ sellRemainingKeys.push({ pubkey: bondingCurveV2, isSigner: false, isWritable: false });
681
+
664
682
  for (let i = 0; i < solChunks.length; i++) {
665
683
  try {
666
684
  const solIn = solChunks[i];
@@ -815,7 +833,7 @@ export class PumpTrader {
815
833
  { pubkey: PROGRAM_IDS.PUMP, isSigner: false, isWritable: false },
816
834
  { pubkey: feeConfig, isSigner: false, isWritable: false },
817
835
  { pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
818
- { pubkey: bondingCurveV2, isSigner: false, isWritable: false }
836
+ ...sellRemainingKeys
819
837
  ],
820
838
  data: Buffer.concat([
821
839
  DISCRIMINATORS.SELL,
@@ -1136,6 +1154,19 @@ export class PumpTrader {
1136
1154
  ASSOCIATED_TOKEN_PROGRAM_ID
1137
1155
  );
1138
1156
 
1157
+ const remainingKeys = [];
1158
+ if (poolKeys.isCashbackCoin) {
1159
+ const userVolumeAccumulatorWsolAta = getAssociatedTokenAddressSync(
1160
+ SOL_MINT,
1161
+ userVolumeAccumulator,
1162
+ true,
1163
+ TOKEN_PROGRAM_ID,
1164
+ ASSOCIATED_TOKEN_PROGRAM_ID
1165
+ );
1166
+ remainingKeys.push({ pubkey: userVolumeAccumulatorWsolAta, isSigner: false, isWritable: true });
1167
+ }
1168
+ remainingKeys.push({ pubkey: poolV2, isSigner: false, isWritable: false });
1169
+
1139
1170
  return new TransactionInstruction({
1140
1171
  programId: PROGRAM_IDS.PUMP_AMM,
1141
1172
  keys: [
@@ -1162,7 +1193,7 @@ export class PumpTrader {
1162
1193
  { pubkey: userVolumeAccumulator, isSigner: false, isWritable: true },
1163
1194
  { pubkey: feeConfig, isSigner: false, isWritable: false },
1164
1195
  { pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
1165
- { pubkey: poolV2, isSigner: false, isWritable: false }
1196
+ ...remainingKeys
1166
1197
  ],
1167
1198
  data: Buffer.concat([
1168
1199
  DISCRIMINATORS.BUY,
@@ -1209,6 +1240,28 @@ export class PumpTrader {
1209
1240
  ASSOCIATED_TOKEN_PROGRAM_ID
1210
1241
  );
1211
1242
 
1243
+ const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
1244
+ [Buffer.from("user_volume_accumulator"), this.wallet.publicKey.toBuffer()],
1245
+ PROGRAM_IDS.PUMP_AMM
1246
+ );
1247
+
1248
+ const userVolumeAccumulatorWsolAta = getAssociatedTokenAddressSync(
1249
+ SOL_MINT,
1250
+ userVolumeAccumulator,
1251
+ true,
1252
+ TOKEN_PROGRAM_ID,
1253
+ ASSOCIATED_TOKEN_PROGRAM_ID
1254
+ );
1255
+
1256
+ const remainingKeys = [];
1257
+ if (poolKeys.isCashbackCoin) {
1258
+ remainingKeys.push(
1259
+ { pubkey: userVolumeAccumulatorWsolAta, isSigner: false, isWritable: true },
1260
+ { pubkey: userVolumeAccumulator, isSigner: false, isWritable: true }
1261
+ );
1262
+ }
1263
+ remainingKeys.push({ pubkey: poolV2, isSigner: false, isWritable: false });
1264
+
1212
1265
  return new TransactionInstruction({
1213
1266
  programId: PROGRAM_IDS.PUMP_AMM,
1214
1267
  keys: [
@@ -1233,7 +1286,7 @@ export class PumpTrader {
1233
1286
  { pubkey: coinCreatorVaultAuthority, isSigner: false, isWritable: false },
1234
1287
  { pubkey: feeConfig, isSigner: false, isWritable: false },
1235
1288
  { pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
1236
- { pubkey: poolV2, isSigner: false, isWritable: false }
1289
+ ...remainingKeys
1237
1290
  ],
1238
1291
  data: Buffer.concat([
1239
1292
  DISCRIMINATORS.SELL,
package/index.ts CHANGED
@@ -63,6 +63,8 @@ interface BondingCurveState {
63
63
  realSolReserves: bigint;
64
64
  tokenTotalSupply: bigint;
65
65
  complete: boolean;
66
+ isMayhemMode?: boolean;
67
+ isCashbackCoin?: boolean;
66
68
  }
67
69
 
68
70
  interface BondingInfo {
@@ -239,6 +241,8 @@ function parsePoolKeys(data: Buffer) {
239
241
  offset += 32;
240
242
 
241
243
  const isMayhemMode = data.readUInt8(offset) === 1;
244
+ offset += 1;
245
+ const isCashbackCoin = offset < data.length ? data.readUInt8(offset) === 1 : false;
242
246
 
243
247
  return {
244
248
  creator,
@@ -248,7 +252,8 @@ function parsePoolKeys(data: Buffer) {
248
252
  poolBaseTokenAccount,
249
253
  poolQuoteTokenAccount,
250
254
  coinCreator,
251
- isMayhemMode
255
+ isMayhemMode,
256
+ isCashbackCoin
252
257
  };
253
258
  }
254
259
 
@@ -407,6 +412,11 @@ export class PumpTrader {
407
412
  offset += 1;
408
413
 
409
414
  const creator = new PublicKey(data.slice(offset, offset + 32));
415
+ offset += 32;
416
+
417
+ state.isMayhemMode = offset < data.length ? data[offset] === 1 : false;
418
+ offset += 1;
419
+ state.isCashbackCoin = offset < data.length ? data[offset] === 1 : false;
410
420
 
411
421
  return { bonding, state, creator };
412
422
  }
@@ -887,6 +897,17 @@ export class PumpTrader {
887
897
  PROGRAM_IDS.FEE
888
898
  );
889
899
 
900
+ const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
901
+ [Buffer.from("user_volume_accumulator"), this.wallet.publicKey.toBuffer()],
902
+ PROGRAM_IDS.PUMP
903
+ );
904
+
905
+ const sellRemainingKeys = [];
906
+ if (state.isCashbackCoin) {
907
+ sellRemainingKeys.push({ pubkey: userVolumeAccumulator, isSigner: false, isWritable: true });
908
+ }
909
+ sellRemainingKeys.push({ pubkey: bondingCurveV2, isSigner: false, isWritable: false });
910
+
890
911
  for (let i = 0; i < tokenChunks.length; i++) {
891
912
  try {
892
913
  const tokenIn = tokenChunks[i];
@@ -922,7 +943,7 @@ export class PumpTrader {
922
943
  { pubkey: PROGRAM_IDS.PUMP, isSigner: false, isWritable: false },
923
944
  { pubkey: feeConfig, isSigner: false, isWritable: false },
924
945
  { pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
925
- { pubkey: bondingCurveV2, isSigner: false, isWritable: false }
946
+ ...sellRemainingKeys
926
947
  ],
927
948
  data: Buffer.concat([
928
949
  DISCRIMINATORS.SELL,
@@ -1249,6 +1270,19 @@ export class PumpTrader {
1249
1270
  ASSOCIATED_TOKEN_PROGRAM_ID
1250
1271
  );
1251
1272
 
1273
+ const remainingKeys = [];
1274
+ if (poolKeys.isCashbackCoin) {
1275
+ const userVolumeAccumulatorWsolAta = getAssociatedTokenAddressSync(
1276
+ SOL_MINT,
1277
+ userVolumeAccumulator,
1278
+ true,
1279
+ TOKEN_PROGRAM_ID,
1280
+ ASSOCIATED_TOKEN_PROGRAM_ID
1281
+ );
1282
+ remainingKeys.push({ pubkey: userVolumeAccumulatorWsolAta, isSigner: false, isWritable: true });
1283
+ }
1284
+ remainingKeys.push({ pubkey: poolV2, isSigner: false, isWritable: false });
1285
+
1252
1286
  return new TransactionInstruction({
1253
1287
  programId: PROGRAM_IDS.PUMP_AMM,
1254
1288
  keys: [
@@ -1275,7 +1309,7 @@ export class PumpTrader {
1275
1309
  { pubkey: userVolumeAccumulator, isSigner: false, isWritable: true },
1276
1310
  { pubkey: feeConfig, isSigner: false, isWritable: false },
1277
1311
  { pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
1278
- { pubkey: poolV2, isSigner: false, isWritable: false }
1312
+ ...remainingKeys
1279
1313
  ],
1280
1314
  data: Buffer.concat([
1281
1315
  DISCRIMINATORS.BUY,
@@ -1329,6 +1363,28 @@ export class PumpTrader {
1329
1363
  ASSOCIATED_TOKEN_PROGRAM_ID
1330
1364
  );
1331
1365
 
1366
+ const [userVolumeAccumulator] = PublicKey.findProgramAddressSync(
1367
+ [Buffer.from("user_volume_accumulator"), this.wallet.publicKey.toBuffer()],
1368
+ PROGRAM_IDS.PUMP_AMM
1369
+ );
1370
+
1371
+ const userVolumeAccumulatorWsolAta = getAssociatedTokenAddressSync(
1372
+ SOL_MINT,
1373
+ userVolumeAccumulator,
1374
+ true,
1375
+ TOKEN_PROGRAM_ID,
1376
+ ASSOCIATED_TOKEN_PROGRAM_ID
1377
+ );
1378
+
1379
+ const remainingKeys = [];
1380
+ if (poolKeys.isCashbackCoin) {
1381
+ remainingKeys.push(
1382
+ { pubkey: userVolumeAccumulatorWsolAta, isSigner: false, isWritable: true },
1383
+ { pubkey: userVolumeAccumulator, isSigner: false, isWritable: true }
1384
+ );
1385
+ }
1386
+ remainingKeys.push({ pubkey: poolV2, isSigner: false, isWritable: false });
1387
+
1332
1388
  return new TransactionInstruction({
1333
1389
  programId: PROGRAM_IDS.PUMP_AMM,
1334
1390
  keys: [
@@ -1353,7 +1409,7 @@ export class PumpTrader {
1353
1409
  { pubkey: coinCreatorVaultAuthority, isSigner: false, isWritable: false },
1354
1410
  { pubkey: feeConfig, isSigner: false, isWritable: false },
1355
1411
  { pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
1356
- { pubkey: poolV2, isSigner: false, isWritable: false }
1412
+ ...remainingKeys
1357
1413
  ],
1358
1414
  data: Buffer.concat([
1359
1415
  DISCRIMINATORS.SELL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pump-trader",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "PumpFun 交易库 - 自动判断 Token Program 和内盘/外盘",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",