pump-trader 1.0.9 → 1.1.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/index.js CHANGED
@@ -605,6 +605,7 @@ class PumpTrader {
605
605
  async ammBuy(tokenAddr, totalSolIn, tradeOpt) {
606
606
  const mint = new web3_js_1.PublicKey(tokenAddr);
607
607
  const poolInfo = await this.getAmmPoolInfo(mint);
608
+ const reserves = await this.getAmmPoolReserves(poolInfo.poolKeys);
608
609
  const solChunks = this.splitByMax(totalSolIn, tradeOpt.maxSolPerTx);
609
610
  const tokenProgram = await this.detectTokenProgram(tokenAddr);
610
611
  const pendingTransactions = [];
@@ -612,16 +613,13 @@ class PumpTrader {
612
613
  for (let i = 0; i < solChunks.length; i++) {
613
614
  try {
614
615
  const solIn = solChunks[i];
615
- const reserves = await this.getAmmPoolReserves(poolInfo.poolKeys);
616
- const rawSlippageBps = this.calcSlippage({
616
+ const baseAmountOut = this.calculateAmmBuyOutput(solIn, reserves);
617
+ const slippageBps = this.calcSlippage({
617
618
  tradeSize: solIn,
618
619
  reserve: reserves.quoteAmount,
619
620
  slippageOpt: tradeOpt.slippage
620
621
  });
621
- const slippageBps = Math.max(0, Math.min(rawSlippageBps, 9000));
622
622
  const maxQuoteIn = (solIn * BigInt(10_000 + slippageBps)) / 10000n;
623
- const estimatedBaseOut = this.calculateAmmBuyOutput(solIn, reserves);
624
- const baseAmountOut = ((estimatedBaseOut * BigInt(10_000 - slippageBps)) / 10000n) || 1n;
625
623
  const priority = this.genPriority(tradeOpt.priority);
626
624
  const tx = new web3_js_1.Transaction().add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priority }));
627
625
  const userBaseAta = await this.ensureAta(tx, poolInfo.poolKeys.baseMint, tokenProgram.programId);
@@ -797,8 +795,7 @@ class PumpTrader {
797
795
  DISCRIMINATORS.BUY,
798
796
  u64(baseAmountOut),
799
797
  u64(maxQuoteAmountIn),
800
- // Match Pump UI buy payload tail (1 byte)
801
- Buffer.from([1])
798
+ Buffer.from([1, 1])
802
799
  ])
803
800
  });
804
801
  }
package/index.js CHANGED
@@ -836,6 +836,7 @@ export class PumpTrader {
836
836
  async ammBuy(tokenAddr, totalSolIn, tradeOpt) {
837
837
  const mint = new PublicKey(tokenAddr);
838
838
  const poolInfo = await this.getAmmPoolInfo(mint);
839
+ const reserves = await this.getAmmPoolReserves(poolInfo.poolKeys);
839
840
  const solChunks = this.splitByMax(totalSolIn, tradeOpt.maxSolPerTx);
840
841
  const tokenProgram = await this.detectTokenProgram(tokenAddr);
841
842
  const pendingTransactions = [];
@@ -844,16 +845,13 @@ export class PumpTrader {
844
845
  for (let i = 0; i < solChunks.length; i++) {
845
846
  try {
846
847
  const solIn = solChunks[i];
847
- const reserves = await this.getAmmPoolReserves(poolInfo.poolKeys);
848
- const rawSlippageBps = this.calcSlippage({
848
+ const baseAmountOut = this.calculateAmmBuyOutput(solIn, reserves);
849
+ const slippageBps = this.calcSlippage({
849
850
  tradeSize: solIn,
850
851
  reserve: reserves.quoteAmount,
851
852
  slippageOpt: tradeOpt.slippage
852
853
  });
853
- const slippageBps = Math.max(0, Math.min(rawSlippageBps, 9000));
854
854
  const maxQuoteIn = (solIn * BigInt(10_000 + slippageBps)) / 10_000n;
855
- const estimatedBaseOut = this.calculateAmmBuyOutput(solIn, reserves);
856
- const baseAmountOut = ((estimatedBaseOut * BigInt(10_000 - slippageBps)) / 10_000n) || 1n;
857
855
  const priority = this.genPriority(tradeOpt.priority);
858
856
 
859
857
  const tx = new Transaction().add(
@@ -1153,7 +1151,7 @@ export class PumpTrader {
1153
1151
  DISCRIMINATORS.BUY,
1154
1152
  u64(baseAmountOut),
1155
1153
  u64(maxQuoteAmountIn),
1156
- Buffer.from([1])
1154
+ Buffer.from([1, 1])
1157
1155
  ])
1158
1156
  });
1159
1157
  }
package/index.ts CHANGED
@@ -943,6 +943,7 @@ export class PumpTrader {
943
943
  async ammBuy(tokenAddr: string, totalSolIn: bigint, tradeOpt: TradeOptions): Promise<TradeResult> {
944
944
  const mint = new PublicKey(tokenAddr);
945
945
  const poolInfo = await this.getAmmPoolInfo(mint);
946
+ const reserves = await this.getAmmPoolReserves(poolInfo.poolKeys);
946
947
  const solChunks = this.splitByMax(totalSolIn, tradeOpt.maxSolPerTx);
947
948
  const tokenProgram = await this.detectTokenProgram(tokenAddr);
948
949
  const pendingTransactions: PendingTransaction[] = [];
@@ -951,16 +952,13 @@ export class PumpTrader {
951
952
  for (let i = 0; i < solChunks.length; i++) {
952
953
  try {
953
954
  const solIn = solChunks[i];
954
- const reserves = await this.getAmmPoolReserves(poolInfo.poolKeys);
955
- const rawSlippageBps = this.calcSlippage({
955
+ const baseAmountOut = this.calculateAmmBuyOutput(solIn, reserves);
956
+ const slippageBps = this.calcSlippage({
956
957
  tradeSize: solIn,
957
958
  reserve: reserves.quoteAmount,
958
959
  slippageOpt: tradeOpt.slippage
959
960
  });
960
- const slippageBps = Math.max(0, Math.min(rawSlippageBps, 9000));
961
961
  const maxQuoteIn = (solIn * BigInt(10_000 + slippageBps)) / 10_000n;
962
- const estimatedBaseOut = this.calculateAmmBuyOutput(solIn, reserves);
963
- const baseAmountOut = ((estimatedBaseOut * BigInt(10_000 - slippageBps)) / 10_000n) || 1n;
964
962
  const priority = this.genPriority(tradeOpt.priority);
965
963
 
966
964
  const tx = new Transaction().add(
@@ -1266,8 +1264,7 @@ export class PumpTrader {
1266
1264
  DISCRIMINATORS.BUY,
1267
1265
  u64(baseAmountOut),
1268
1266
  u64(maxQuoteAmountIn),
1269
- // Match Pump UI buy payload tail (1 byte)
1270
- Buffer.from([1])
1267
+ Buffer.from([1, 1])
1271
1268
  ])
1272
1269
  });
1273
1270
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pump-trader",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "PumpFun 交易库 - 自动判断 Token Program 和内盘/外盘",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",