pump-trader 1.1.5 → 1.1.8

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,7 +33,6 @@ interface BondingCurveState {
33
33
  realSolReserves: bigint;
34
34
  tokenTotalSupply: bigint;
35
35
  complete: boolean;
36
- quoteMint?: PublicKey;
37
36
  isMayhemMode?: boolean;
38
37
  isCashbackCoin?: boolean;
39
38
  }
@@ -117,9 +116,7 @@ export declare class PumpTrader {
117
116
  price: number;
118
117
  completed: boolean;
119
118
  }>;
120
- getAmmPrice(mint: PublicKey, quoteMint?: PublicKey): Promise<number>;
121
- private getEffectiveQuoteMint;
122
- private getMintDecimals;
119
+ getAmmPrice(mint: PublicKey): Promise<number>;
123
120
  /**
124
121
  * 查询代币余额
125
122
  * @param tokenAddr - 代币地址(可选),如果不传则返回所有代币
package/dist/index.js CHANGED
@@ -304,10 +304,6 @@ class PumpTrader {
304
304
  offset += 1;
305
305
  const creator = new web3_js_1.PublicKey(data.slice(offset, offset + 32));
306
306
  offset += 32;
307
- if (offset + 32 <= data.length - 2) {
308
- state.quoteMint = new web3_js_1.PublicKey(data.slice(offset, offset + 32));
309
- offset += 32;
310
- }
311
307
  state.isMayhemMode = offset < data.length ? data[offset] === 1 : false;
312
308
  offset += 1;
313
309
  state.isCashbackCoin = offset < data.length ? data[offset] === 1 : false;
@@ -340,21 +336,19 @@ class PumpTrader {
340
336
  async getPriceAndStatus(tokenAddr) {
341
337
  const mint = new web3_js_1.PublicKey(tokenAddr);
342
338
  const { state } = await this.loadBonding(mint);
343
- const quoteMint = this.getEffectiveQuoteMint(state.quoteMint);
344
339
  if (state.complete) {
345
- const price = await this.getAmmPrice(mint, quoteMint);
340
+ const price = await this.getAmmPrice(mint);
346
341
  return { price, completed: true };
347
342
  }
348
343
  const oneToken = BigInt(1_000_000);
349
- const quoteOut = this.calcSell(oneToken, state);
350
- const quoteDecimals = await this.getMintDecimals(quoteMint);
351
- const price = Number(quoteOut) / 10 ** quoteDecimals;
344
+ const solOut = this.calcSell(oneToken, state);
345
+ const price = Number(solOut) / 1e9;
352
346
  return { price, completed: false };
353
347
  }
354
- async getAmmPrice(mint, quoteMint = SOL_MINT) {
348
+ async getAmmPrice(mint) {
355
349
  const [poolCreator] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("pool-authority"), mint.toBuffer()], PROGRAM_IDS.PUMP);
356
350
  const indexBuffer = new bn_js_1.default(0).toArrayLike(Buffer, "le", 2);
357
- const [pool] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("pool"), indexBuffer, poolCreator.toBuffer(), mint.toBuffer(), quoteMint.toBuffer()], PROGRAM_IDS.PUMP_AMM);
351
+ const [pool] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("pool"), indexBuffer, poolCreator.toBuffer(), mint.toBuffer(), SOL_MINT.toBuffer()], PROGRAM_IDS.PUMP_AMM);
358
352
  const acc = await this.connection.getAccountInfo(pool);
359
353
  if (!acc)
360
354
  throw new Error("Pool not found");
@@ -365,23 +359,6 @@ class PumpTrader {
365
359
  ]);
366
360
  return quoteInfo.value.uiAmount / baseInfo.value.uiAmount;
367
361
  }
368
- getEffectiveQuoteMint(quoteMint) {
369
- if (!quoteMint || quoteMint.equals(web3_js_1.PublicKey.default)) {
370
- return SOL_MINT;
371
- }
372
- return quoteMint;
373
- }
374
- async getMintDecimals(mint) {
375
- if (mint.equals(SOL_MINT)) {
376
- return 9;
377
- }
378
- const mintInfo = await this.connection.getParsedAccountInfo(mint);
379
- const parsedData = mintInfo.value?.data;
380
- if (parsedData && "parsed" in parsedData) {
381
- return parsedData.parsed.info.decimals;
382
- }
383
- throw new Error(`Unable to determine mint decimals for ${mint.toBase58()}`);
384
- }
385
362
  /* ---------- 余额查询 ---------- */
386
363
  /**
387
364
  * 查询代币余额