pump-trader 1.2.3 → 1.2.5

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.js CHANGED
@@ -1048,8 +1048,8 @@ class PumpTrader {
1048
1048
  const [feeConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fee_config"), SEEDS.AMM_FEE_CONFIG], PROGRAM_IDS.FEE);
1049
1049
  const protocolFeeRecipient = globalConfig.protocolFeeRecipients[0];
1050
1050
  const protocolFeeRecipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(SOL_MINT, protocolFeeRecipient, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
1051
- const newFeeRecipient = this.pickFeeRecipient();
1052
- const newFeeRecipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolKeys.quoteMint, newFeeRecipient, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
1051
+ const buybackFeeRecipient = this.pickBuybackFeeRecipient();
1052
+ const buybackFeeRecipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolKeys.quoteMint, buybackFeeRecipient, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
1053
1053
  const remainingKeys = [];
1054
1054
  if (poolKeys.isCashbackCoin) {
1055
1055
  const userVolumeAccumulatorWsolAta = (0, spl_token_1.getAssociatedTokenAddressSync)(SOL_MINT, userVolumeAccumulator, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
@@ -1070,8 +1070,8 @@ class PumpTrader {
1070
1070
  isWritable: true,
1071
1071
  });
1072
1072
  }
1073
- remainingKeys.push({ pubkey: newFeeRecipient, isSigner: false, isWritable: false }, {
1074
- pubkey: newFeeRecipientTokenAccount,
1073
+ remainingKeys.push({ pubkey: buybackFeeRecipient, isSigner: false, isWritable: false }, {
1074
+ pubkey: buybackFeeRecipientTokenAccount,
1075
1075
  isSigner: false,
1076
1076
  isWritable: true,
1077
1077
  });
@@ -1140,8 +1140,8 @@ class PumpTrader {
1140
1140
  const [feeConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fee_config"), SEEDS.AMM_FEE_CONFIG], PROGRAM_IDS.FEE);
1141
1141
  const protocolFeeRecipient = globalConfig.protocolFeeRecipients[0];
1142
1142
  const protocolFeeRecipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(SOL_MINT, protocolFeeRecipient, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
1143
- const newFeeRecipient = this.pickFeeRecipient();
1144
- const newFeeRecipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolKeys.quoteMint, newFeeRecipient, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
1143
+ const buybackFeeRecipient = this.pickBuybackFeeRecipient();
1144
+ const buybackFeeRecipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolKeys.quoteMint, buybackFeeRecipient, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
1145
1145
  const [userVolumeAccumulator] = web3_js_1.PublicKey.findProgramAddressSync([
1146
1146
  Buffer.from("user_volume_accumulator"),
1147
1147
  this.publicKey.toBuffer(),
@@ -1166,8 +1166,8 @@ class PumpTrader {
1166
1166
  isWritable: true,
1167
1167
  });
1168
1168
  }
1169
- remainingKeys.push({ pubkey: newFeeRecipient, isSigner: false, isWritable: false }, {
1170
- pubkey: newFeeRecipientTokenAccount,
1169
+ remainingKeys.push({ pubkey: buybackFeeRecipient, isSigner: false, isWritable: false }, {
1170
+ pubkey: buybackFeeRecipientTokenAccount,
1171
1171
  isSigner: false,
1172
1172
  isWritable: true,
1173
1173
  });
package/index.js CHANGED
@@ -58,6 +58,17 @@ const DISCRIMINATORS = {
58
58
  const AMM_FEE_BPS = 100n; // 1%
59
59
  const BPS_DENOMINATOR = 10000n;
60
60
  const PUMP_NEW_FEE_RECIPIENTS = [
61
+ "62qc2CNXwrYqQScmEdiZFFAnJR262PxWEuNQtxfafNgV",
62
+ "7VtfL8fvgNfhz17qKRMjzQEXgbdpnHHHQRh54R9jP2RJ",
63
+ "7hTckgnGnLQR6sdH7YkqFTAA7VwTfYFaZ6EhEsU3saCX",
64
+ "9rPYyANsfQZw3DnDmKE3YCQF5E8oD89UXoHn9JFEhJUz",
65
+ "AVmoTthdrX6tKt4nDjco2D775W2YK3sDhxPcMmzUAmTY",
66
+ "CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM",
67
+ "FWsW1xNtWscwNmKv6wVsU1iTzRN6wmmk3MjxRP5tT7hz",
68
+ "G5UZAVbAf46s7cKWoyKu8kYTip9DGTpbLZ2qa9Aq69dP",
69
+ ].map((value) => new PublicKey(value));
70
+
71
+ const PUMP_BUYBACK_FEE_RECIPIENTS = [
61
72
  "5YxQFdt3Tr9zJLvkFccqXVUwhdTWJQc1fFg2YPbxvxeD",
62
73
  "9M4giFFMxmFGXtc3feFzRai56WbBqehoSeRE5GK7gf7",
63
74
  "GXPFM2caqTtQYC2cJ5yJRi9VDkpsYZXzYdwYpGnLmtDL",
@@ -360,6 +371,12 @@ export class PumpTrader {
360
371
  return PUMP_NEW_FEE_RECIPIENTS[index % PUMP_NEW_FEE_RECIPIENTS.length];
361
372
  }
362
373
 
374
+ pickBuybackFeeRecipient(index = 0) {
375
+ return PUMP_BUYBACK_FEE_RECIPIENTS[
376
+ index % PUMP_BUYBACK_FEE_RECIPIENTS.length
377
+ ];
378
+ }
379
+
363
380
  buildBondingBuyKeys(args) {
364
381
  const tokenProgramId = args.tokenProgramId ?? TOKEN_PROGRAM_ID;
365
382
 
@@ -1452,10 +1469,10 @@ export class PumpTrader {
1452
1469
  TOKEN_PROGRAM_ID,
1453
1470
  ASSOCIATED_TOKEN_PROGRAM_ID,
1454
1471
  );
1455
- const newFeeRecipient = this.pickFeeRecipient();
1456
- const newFeeRecipientTokenAccount = getAssociatedTokenAddressSync(
1472
+ const buybackFeeRecipient = this.pickBuybackFeeRecipient();
1473
+ const buybackFeeRecipientTokenAccount = getAssociatedTokenAddressSync(
1457
1474
  poolKeys.quoteMint,
1458
- newFeeRecipient,
1475
+ buybackFeeRecipient,
1459
1476
  true,
1460
1477
  TOKEN_PROGRAM_ID,
1461
1478
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -1487,9 +1504,9 @@ export class PumpTrader {
1487
1504
  });
1488
1505
  }
1489
1506
  remainingKeys.push(
1490
- { pubkey: newFeeRecipient, isSigner: false, isWritable: false },
1507
+ { pubkey: buybackFeeRecipient, isSigner: false, isWritable: false },
1491
1508
  {
1492
- pubkey: newFeeRecipientTokenAccount,
1509
+ pubkey: buybackFeeRecipientTokenAccount,
1493
1510
  isSigner: false,
1494
1511
  isWritable: true,
1495
1512
  },
@@ -1594,10 +1611,10 @@ export class PumpTrader {
1594
1611
  TOKEN_PROGRAM_ID,
1595
1612
  ASSOCIATED_TOKEN_PROGRAM_ID,
1596
1613
  );
1597
- const newFeeRecipient = this.pickFeeRecipient();
1598
- const newFeeRecipientTokenAccount = getAssociatedTokenAddressSync(
1614
+ const buybackFeeRecipient = this.pickBuybackFeeRecipient();
1615
+ const buybackFeeRecipientTokenAccount = getAssociatedTokenAddressSync(
1599
1616
  poolKeys.quoteMint,
1600
- newFeeRecipient,
1617
+ buybackFeeRecipient,
1601
1618
  true,
1602
1619
  TOKEN_PROGRAM_ID,
1603
1620
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -1632,9 +1649,9 @@ export class PumpTrader {
1632
1649
  }
1633
1650
  remainingKeys.push({ pubkey: poolV2, isSigner: false, isWritable: false });
1634
1651
  remainingKeys.push(
1635
- { pubkey: newFeeRecipient, isSigner: false, isWritable: false },
1652
+ { pubkey: buybackFeeRecipient, isSigner: false, isWritable: false },
1636
1653
  {
1637
- pubkey: newFeeRecipientTokenAccount,
1654
+ pubkey: buybackFeeRecipientTokenAccount,
1638
1655
  isSigner: false,
1639
1656
  isWritable: true,
1640
1657
  },
package/index.ts CHANGED
@@ -1731,10 +1731,10 @@ export class PumpTrader {
1731
1731
  TOKEN_PROGRAM_ID,
1732
1732
  ASSOCIATED_TOKEN_PROGRAM_ID,
1733
1733
  );
1734
- const newFeeRecipient = this.pickFeeRecipient();
1735
- const newFeeRecipientTokenAccount = getAssociatedTokenAddressSync(
1734
+ const buybackFeeRecipient = this.pickBuybackFeeRecipient();
1735
+ const buybackFeeRecipientTokenAccount = getAssociatedTokenAddressSync(
1736
1736
  poolKeys.quoteMint,
1737
- newFeeRecipient,
1737
+ buybackFeeRecipient,
1738
1738
  true,
1739
1739
  TOKEN_PROGRAM_ID,
1740
1740
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -1766,9 +1766,9 @@ export class PumpTrader {
1766
1766
  });
1767
1767
  }
1768
1768
  remainingKeys.push(
1769
- { pubkey: newFeeRecipient, isSigner: false, isWritable: false },
1769
+ { pubkey: buybackFeeRecipient, isSigner: false, isWritable: false },
1770
1770
  {
1771
- pubkey: newFeeRecipientTokenAccount,
1771
+ pubkey: buybackFeeRecipientTokenAccount,
1772
1772
  isSigner: false,
1773
1773
  isWritable: true,
1774
1774
  },
@@ -1873,10 +1873,10 @@ export class PumpTrader {
1873
1873
  TOKEN_PROGRAM_ID,
1874
1874
  ASSOCIATED_TOKEN_PROGRAM_ID,
1875
1875
  );
1876
- const newFeeRecipient = this.pickFeeRecipient();
1877
- const newFeeRecipientTokenAccount = getAssociatedTokenAddressSync(
1876
+ const buybackFeeRecipient = this.pickBuybackFeeRecipient();
1877
+ const buybackFeeRecipientTokenAccount = getAssociatedTokenAddressSync(
1878
1878
  poolKeys.quoteMint,
1879
- newFeeRecipient,
1879
+ buybackFeeRecipient,
1880
1880
  true,
1881
1881
  TOKEN_PROGRAM_ID,
1882
1882
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -1920,9 +1920,9 @@ export class PumpTrader {
1920
1920
  });
1921
1921
  }
1922
1922
  remainingKeys.push(
1923
- { pubkey: newFeeRecipient, isSigner: false, isWritable: false },
1923
+ { pubkey: buybackFeeRecipient, isSigner: false, isWritable: false },
1924
1924
  {
1925
- pubkey: newFeeRecipientTokenAccount,
1925
+ pubkey: buybackFeeRecipientTokenAccount,
1926
1926
  isSigner: false,
1927
1927
  isWritable: true,
1928
1928
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pump-trader",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "PumpFun 交易库 - 自动判断 Token Program 和内盘/外盘",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,209 +0,0 @@
1
- import test from "node:test";
2
- import assert from "node:assert/strict";
3
-
4
- import bs58 from "bs58";
5
- import { Keypair, PublicKey } from "@solana/web3.js";
6
- import { ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from "@solana/spl-token";
7
-
8
- import { PumpTrader } from "../index";
9
-
10
- const SOL_MINT = new PublicKey("So11111111111111111111111111111111111111112");
11
- const FEE_RECIPIENTS = [
12
- "5YxQFdt3Tr9zJLvkFccqXVUwhdTWJQc1fFg2YPbxvxeD",
13
- "9M4giFFMxmFGXtc3feFzRai56WbBqehoSeRE5GK7gf7",
14
- "GXPFM2caqTtQYC2cJ5yJRi9VDkpsYZXzYdwYpGnLmtDL",
15
- "3BpXnfJaUTiwXnJNe7Ej1rcbzqTTQUvLShZaWazebsVR",
16
- "5cjcW9wExnJJiqgLjq7DEG75Pm6JBgE1hNv4B2vHXUW6",
17
- "EHAAiTxcdDwQ3U4bU6YcMsQGaekdzLS3B5SmYo46kJtL",
18
- "5eHhjP8JaYkz83CWwvGU2uMUXefd3AazWGx4gpcuEEYD",
19
- "A7hAgCzFw14fejgCp387JUJRMNyz4j89JKnhtKU8piqW"
20
- ].map((value) => new PublicKey(value));
21
-
22
- function createTrader() {
23
- return new PumpTrader("http://127.0.0.1:8899", bs58.encode(Keypair.generate().secretKey));
24
- }
25
-
26
- function createPoolInfo(isCashbackCoin: boolean) {
27
- return {
28
- pool: Keypair.generate().publicKey,
29
- poolAuthority: Keypair.generate().publicKey,
30
- poolKeys: {
31
- baseMint: Keypair.generate().publicKey,
32
- quoteMint: SOL_MINT,
33
- poolBaseTokenAccount: Keypair.generate().publicKey,
34
- poolQuoteTokenAccount: Keypair.generate().publicKey,
35
- coinCreator: Keypair.generate().publicKey,
36
- isCashbackCoin
37
- },
38
- globalConfig: {
39
- address: Keypair.generate().publicKey,
40
- protocolFeeRecipients: FEE_RECIPIENTS
41
- }
42
- };
43
- }
44
-
45
- test("bonding buy appends mutable fee recipient after bondingCurveV2", () => {
46
- const trader = createTrader() as any;
47
- const bondingCurveV2 = Keypair.generate().publicKey;
48
- const feeRecipient = FEE_RECIPIENTS[0];
49
-
50
- const keys = trader.buildBondingBuyKeys({
51
- global: Keypair.generate().publicKey,
52
- globalFeeRecipient: Keypair.generate().publicKey,
53
- mint: Keypair.generate().publicKey,
54
- bonding: Keypair.generate().publicKey,
55
- associatedBondingCurve: Keypair.generate().publicKey,
56
- userAta: Keypair.generate().publicKey,
57
- wallet: Keypair.generate().publicKey,
58
- creatorVault: Keypair.generate().publicKey,
59
- eventAuthority: Keypair.generate().publicKey,
60
- pumpProgram: Keypair.generate().publicKey,
61
- globalVolumeAccumulator: Keypair.generate().publicKey,
62
- userVolumeAccumulator: Keypair.generate().publicKey,
63
- feeConfig: Keypair.generate().publicKey,
64
- feeProgram: Keypair.generate().publicKey,
65
- bondingCurveV2,
66
- feeRecipient
67
- });
68
-
69
- assert.equal(keys.length, 18);
70
- assert.equal(keys.at(-2).pubkey.toBase58(), bondingCurveV2.toBase58());
71
- assert.equal(keys.at(-2).isWritable, false);
72
- assert.equal(keys.at(-1).pubkey.toBase58(), feeRecipient.toBase58());
73
- assert.equal(keys.at(-1).isWritable, true);
74
- });
75
-
76
- test("bonding sell appends mutable fee recipient after optional cashback and bondingCurveV2", () => {
77
- const trader = createTrader() as any;
78
- const baseArgs = {
79
- global: Keypair.generate().publicKey,
80
- globalFeeRecipient: Keypair.generate().publicKey,
81
- mint: Keypair.generate().publicKey,
82
- bonding: Keypair.generate().publicKey,
83
- associatedBondingCurve: Keypair.generate().publicKey,
84
- userAta: Keypair.generate().publicKey,
85
- wallet: Keypair.generate().publicKey,
86
- creatorVault: Keypair.generate().publicKey,
87
- eventAuthority: Keypair.generate().publicKey,
88
- pumpProgram: Keypair.generate().publicKey,
89
- feeConfig: Keypair.generate().publicKey,
90
- feeProgram: Keypair.generate().publicKey,
91
- bondingCurveV2: Keypair.generate().publicKey,
92
- feeRecipient: FEE_RECIPIENTS[0],
93
- userVolumeAccumulator: Keypair.generate().publicKey
94
- };
95
-
96
- const nonCashback = trader.buildBondingSellKeys({
97
- ...baseArgs,
98
- isCashbackCoin: false
99
- });
100
- assert.equal(nonCashback.length, 16);
101
- assert.equal(nonCashback.at(-2).pubkey.toBase58(), baseArgs.bondingCurveV2.toBase58());
102
- assert.equal(nonCashback.at(-1).pubkey.toBase58(), baseArgs.feeRecipient.toBase58());
103
- assert.equal(nonCashback.at(-1).isWritable, true);
104
-
105
- const cashback = trader.buildBondingSellKeys({
106
- ...baseArgs,
107
- isCashbackCoin: true
108
- });
109
- assert.equal(cashback.length, 17);
110
- assert.equal(cashback.at(-3).pubkey.toBase58(), baseArgs.userVolumeAccumulator.toBase58());
111
- assert.equal(cashback.at(-2).pubkey.toBase58(), baseArgs.bondingCurveV2.toBase58());
112
- assert.equal(cashback.at(-1).pubkey.toBase58(), baseArgs.feeRecipient.toBase58());
113
- });
114
-
115
- test("amm buy places poolV2 before fee recipient pair for non-cashback coins", () => {
116
- const trader = createTrader();
117
- const poolInfo = createPoolInfo(false);
118
- const userBaseAta = Keypair.generate().publicKey;
119
- const userQuoteAta = Keypair.generate().publicKey;
120
-
121
- const instruction = trader.createAmmBuyInstruction(
122
- poolInfo as any,
123
- userBaseAta,
124
- userQuoteAta,
125
- 1n,
126
- 2n,
127
- TOKEN_PROGRAM_ID
128
- );
129
-
130
- const feeRecipient = poolInfo.globalConfig.protocolFeeRecipients[0];
131
- const feeRecipientAta = getAssociatedTokenAddressSync(
132
- SOL_MINT,
133
- feeRecipient,
134
- true,
135
- TOKEN_PROGRAM_ID,
136
- ASSOCIATED_TOKEN_PROGRAM_ID
137
- );
138
-
139
- assert.equal(instruction.keys.length, 26);
140
- assert.equal(instruction.keys.at(-3)?.pubkey.toBase58(), trader.deriveAmmPoolV2(poolInfo.poolKeys.baseMint).toBase58());
141
- assert.equal(instruction.keys.at(-2)?.pubkey.toBase58(), feeRecipient.toBase58());
142
- assert.equal(instruction.keys.at(-2)?.isWritable, false);
143
- assert.equal(instruction.keys.at(-1)?.pubkey.toBase58(), feeRecipientAta.toBase58());
144
- assert.equal(instruction.keys.at(-1)?.isWritable, true);
145
- });
146
-
147
- test("amm buy places cashback account before poolV2 and fee recipient tail", () => {
148
- const trader = createTrader();
149
- const poolInfo = createPoolInfo(true);
150
-
151
- const instruction = trader.createAmmBuyInstruction(
152
- poolInfo as any,
153
- Keypair.generate().publicKey,
154
- Keypair.generate().publicKey,
155
- 1n,
156
- 2n,
157
- TOKEN_PROGRAM_ID
158
- );
159
-
160
- assert.equal(instruction.keys.length, 27);
161
- assert.equal(instruction.keys.at(-3)?.isWritable, false);
162
- assert.equal(instruction.keys.at(-2)?.pubkey.toBase58(), poolInfo.globalConfig.protocolFeeRecipients[0].toBase58());
163
- assert.equal(instruction.keys.at(-1)?.isWritable, true);
164
- });
165
-
166
- test("amm sell places poolV2 before fee recipient pair for non-cashback coins", () => {
167
- const trader = createTrader();
168
- const poolInfo = createPoolInfo(false);
169
-
170
- const instruction = trader.createAmmSellInstruction(
171
- poolInfo as any,
172
- Keypair.generate().publicKey,
173
- Keypair.generate().publicKey,
174
- 1n,
175
- 2n,
176
- TOKEN_PROGRAM_ID
177
- );
178
-
179
- assert.equal(instruction.keys.length, 24);
180
- assert.equal(instruction.keys.at(-3)?.pubkey.toBase58(), trader.deriveAmmPoolV2(poolInfo.poolKeys.baseMint).toBase58());
181
- assert.equal(instruction.keys.at(-2)?.pubkey.toBase58(), poolInfo.globalConfig.protocolFeeRecipients[0].toBase58());
182
- assert.equal(instruction.keys.at(-1)?.isWritable, true);
183
- });
184
-
185
- test("amm sell places cashback accounts before poolV2 and fee recipient tail", () => {
186
- const trader = createTrader();
187
- const poolInfo = createPoolInfo(true);
188
-
189
- const instruction = trader.createAmmSellInstruction(
190
- poolInfo as any,
191
- Keypair.generate().publicKey,
192
- Keypair.generate().publicKey,
193
- 1n,
194
- 2n,
195
- TOKEN_PROGRAM_ID
196
- );
197
-
198
- assert.equal(instruction.keys.length, 26);
199
- assert.equal(instruction.keys.at(-3)?.pubkey.toBase58(), trader.deriveAmmPoolV2(poolInfo.poolKeys.baseMint).toBase58());
200
- assert.equal(instruction.keys.at(-2)?.pubkey.toBase58(), poolInfo.globalConfig.protocolFeeRecipients[0].toBase58());
201
- assert.equal(instruction.keys.at(-1)?.pubkey.toBase58(), getAssociatedTokenAddressSync(
202
- SOL_MINT,
203
- poolInfo.globalConfig.protocolFeeRecipients[0],
204
- true,
205
- TOKEN_PROGRAM_ID,
206
- ASSOCIATED_TOKEN_PROGRAM_ID
207
- ).toBase58());
208
- assert.equal(instruction.keys.at(-1)?.isWritable, true);
209
- });