pinpet-sdk 2.1.8 → 2.1.10

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
@@ -331,7 +331,11 @@ export declare class CurveAMM {
331
331
  static calculateInitialK(): any;
332
332
  static getInitialPrice(): bigint | null;
333
333
 
334
- // AMM calculation methods
334
+ // Custom pool parameters calculation (动态流动池)
335
+ static calculateK(initialVirtualSol: any, initialVirtualToken: any): any;
336
+ static getInitialPriceWithParams(initialVirtualSol: any, initialVirtualToken: any): bigint | null;
337
+
338
+ // AMM calculation methods (default pool parameters)
335
339
  static calculateReservesByPrice(price: any, k: any): [any, any] | null;
336
340
  static buyFromPriceToPrice(startLowPrice: bigint | string | number, endHighPrice: bigint | string | number): [bigint, bigint] | null;
337
341
  static sellFromPriceToPrice(startHighPrice: bigint | string | number, endLowPrice: bigint | string | number): [bigint, bigint] | null;
@@ -340,6 +344,15 @@ export declare class CurveAMM {
340
344
  static buyFromPriceWithTokenOutput(startLowPrice: bigint | string | number, tokenOutputAmount: bigint | string | number): [bigint, bigint] | null;
341
345
  static sellFromPriceWithSolOutput(startHighPrice: bigint | string | number, solOutputAmount: bigint | string | number): [bigint, bigint] | null;
342
346
 
347
+ // AMM calculation methods with custom pool parameters (动态流动池)
348
+ static priceToReservesWithParams(price: any, initialVirtualSol: any, initialVirtualToken: any): [any, any] | null;
349
+ static buyFromPriceToPriceWithParams(startLowPrice: bigint | string | number, endHighPrice: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
350
+ static sellFromPriceToPriceWithParams(startHighPrice: bigint | string | number, endLowPrice: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
351
+ static buyFromPriceWithSolInputWithParams(startLowPrice: bigint | string | number, solInputAmount: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
352
+ static sellFromPriceWithTokenInputWithParams(startHighPrice: bigint | string | number, tokenInputAmount: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
353
+ static buyFromPriceWithTokenOutputWithParams(startLowPrice: bigint | string | number, tokenOutputAmount: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
354
+ static sellFromPriceWithSolOutputWithParams(startHighPrice: bigint | string | number, solOutputAmount: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
355
+
343
356
  // Fee and price display methods
344
357
  static calculateAmountAfterFee(amount: bigint | string | number, fee: number): bigint | null;
345
358
  static formatPriceForDisplay(price: bigint | string | number, decimalPlaces?: number): string;
@@ -16708,6 +16708,13 @@ class TokenModule$1 {
16708
16708
  * @param {PublicKey} params.payer - Creator public key (payer)
16709
16709
  * @param {anchor.BN} params.buyTokenAmount - Amount of tokens to buy
16710
16710
  * @param {anchor.BN} params.maxSolAmount - Maximum SOL to spend
16711
+ *
16712
+ * === 第二阶段新增:高级版池子可选参数 ===
16713
+ * @param {anchor.BN} [params.customLpSol] - 自定义流动池SOL数量(lamports,9位精度)
16714
+ * @param {anchor.BN} [params.customLpToken] - 自定义流动池Token数量(最小单位,9位精度)
16715
+ * @param {number} [params.customBorrowRatio] - 自定义借贷池代币占比(5-30表示5%-30%)
16716
+ * @param {number} [params.customBorrowDuration] - 自定义借贷时长(秒)
16717
+ *
16711
16718
  * @param {Object} options - Optional parameters
16712
16719
  * @param {number} options.computeUnits - Compute units limit, default 1800000
16713
16720
  * @returns {Promise<Object>} Object containing transaction, signers and account info
@@ -16719,7 +16726,12 @@ class TokenModule$1 {
16719
16726
  uri,
16720
16727
  payer,
16721
16728
  buyTokenAmount,
16722
- maxSolAmount
16729
+ maxSolAmount,
16730
+ // 新增参数
16731
+ customLpSol = null,
16732
+ customLpToken = null,
16733
+ customBorrowRatio = null,
16734
+ customBorrowDuration = null
16723
16735
  }, options = {}) {
16724
16736
  const { computeUnits = 1800000 } = options;
16725
16737
 
@@ -16738,14 +16750,19 @@ class TokenModule$1 {
16738
16750
  throw new Error('buyTokenAmount and maxSolAmount must be anchor.BN type');
16739
16751
  }
16740
16752
 
16741
- // 2. 调用 create 方法获取 create 交易
16753
+ // 2. 调用 create 方法获取 create 交易(传递自定义参数)
16742
16754
  console.log('Step 1: Building create transaction...');
16743
16755
  const createResult = await this.create({
16744
16756
  mint,
16745
16757
  name,
16746
16758
  symbol,
16747
16759
  uri,
16748
- payer
16760
+ payer,
16761
+ // 传递自定义流动池参数
16762
+ customLpSol,
16763
+ customLpToken,
16764
+ customBorrowRatio,
16765
+ customBorrowDuration
16749
16766
  });
16750
16767
 
16751
16768
  // 3. 从 params 账户读取手续费接收地址
@@ -41935,9 +41952,11 @@ class CurveAMM$7 {
41935
41952
 
41936
41953
  /**
41937
41954
  * Minimum price that can appear, below this price may cause overflow
41955
+ * Note: With dynamic liquidity pools, prices can be much smaller (e.g., 3e-10)
41956
+ * Reduced from 1e-9 to 1e-12 to support wider range of pool configurations
41938
41957
  * @type {Decimal}
41939
41958
  */
41940
- static INITIAL_MIN_PRICE_DECIMAL = new Decimal('0.000000001');
41959
+ static INITIAL_MIN_PRICE_DECIMAL = new Decimal('0.000000000001'); // 1e-12
41941
41960
 
41942
41961
  /**
41943
41962
  * Decimal representation of precision factor = 10^23
@@ -42743,9 +42762,83 @@ class CurveAMM$7 {
42743
42762
  return [endPriceU128, solAmountU64];
42744
42763
  }
42745
42764
 
42765
+ /**
42766
+ * 基于起始价格和期望token输出量计算需要的SOL输入量和结束价格(带自定义流动池参数)
42767
+ * Based on starting price and desired token output, calculate required SOL input and ending price (with custom pool params)
42768
+ *
42769
+ * @param {bigint|string|number} startLowPrice - Starting price (lower)
42770
+ * @param {bigint|string|number} tokenOutputAmount - Desired token amount to obtain
42771
+ * @param {string|number|Decimal} initialVirtualSol - Initial virtual SOL reserve
42772
+ * @param {string|number|Decimal} initialVirtualToken - Initial virtual token reserve
42773
+ * @returns {[bigint, bigint]|null} Returns [price after transaction, SOL amount to pay] on success, null on failure
42774
+ * Price rounded down, SOL amount rounded up
42775
+ */
42776
+ static buyFromPriceWithTokenOutputWithParams(startLowPrice, tokenOutputAmount, initialVirtualSol, initialVirtualToken) {
42777
+ // Convert to Decimal for calculation
42778
+ const startPriceDec = this.u128ToDecimal(startLowPrice);
42779
+ const tokenOutputDec = this.u64ToTokenDecimal(tokenOutputAmount);
42780
+
42781
+ // Check if input parameters are valid
42782
+ if (startPriceDec.lte(0)) {
42783
+ return null;
42784
+ }
42785
+
42786
+ // If token output amount is 0, return unchanged price and SOL input of 0
42787
+ if (tokenOutputDec.eq(0)) {
42788
+ const endPriceU128 = this.decimalToU128(startPriceDec);
42789
+ if (endPriceU128 === null) return null;
42790
+ return [endPriceU128, 0n];
42791
+ }
42792
+
42793
+ if (tokenOutputDec.lt(0)) {
42794
+ return null;
42795
+ }
42796
+
42797
+ // Use custom pool parameters to calculate k value
42798
+ const k = this.calculateK(initialVirtualSol, initialVirtualToken);
42799
+
42800
+ // Calculate reserves for starting state
42801
+ const startReserves = this.calculateReservesByPrice(startPriceDec, k);
42802
+ if (!startReserves) return null;
42803
+
42804
+ const [startSolReserve, startTokenReserve] = startReserves;
42805
+
42806
+ // Calculate token reserves for ending state
42807
+ const endTokenReserve = startTokenReserve.sub(tokenOutputDec);
42808
+
42809
+ // Check if token reserves are sufficient
42810
+ if (endTokenReserve.lte(0)) {
42811
+ return null;
42812
+ }
42813
+
42814
+ // Calculate SOL reserve for ending state using AMM formula
42815
+ const endSolReserve = k.div(endTokenReserve);
42816
+
42817
+ // Calculate required SOL input amount
42818
+ const solInputAmount = endSolReserve.sub(startSolReserve);
42819
+
42820
+ // Calculate ending price
42821
+ const endPrice = endSolReserve.div(endTokenReserve);
42822
+
42823
+ // Check if calculation results are valid
42824
+ if (solInputAmount.lte(0) || endPrice.lte(0)) {
42825
+ return null;
42826
+ }
42827
+
42828
+ // Convert back to appropriate types with required rounding
42829
+ const endPriceU128 = this.decimalToU128(endPrice); // Price rounded down
42830
+ const solAmountU64 = this.solDecimalToU64Ceil(solInputAmount); // SOL rounded up
42831
+
42832
+ if (endPriceU128 === null || solAmountU64 === null) {
42833
+ return null;
42834
+ }
42835
+
42836
+ return [endPriceU128, solAmountU64];
42837
+ }
42838
+
42746
42839
  /**
42747
42840
  * Calculate required token input amount and ending price based on starting price and expected SOL output amount
42748
- *
42841
+ *
42749
42842
  * @param {bigint|string|number} startHighPrice - Starting price
42750
42843
  * @param {bigint|string|number} solOutputAmount - Desired SOL amount to obtain
42751
42844
  * @returns {[bigint, bigint]|null} Returns [price after transaction, token amount to pay] on success, null on failure
@@ -42814,9 +42907,83 @@ class CurveAMM$7 {
42814
42907
  return [endPriceU128, tokenAmountU64];
42815
42908
  }
42816
42909
 
42910
+ /**
42911
+ * 基于起始价格和期望SOL输出量计算需要的token输入量和结束价格(带自定义流动池参数)
42912
+ * Based on starting price and desired SOL output, calculate required token input and ending price (with custom pool params)
42913
+ *
42914
+ * @param {bigint|string|number} startHighPrice - Starting price (higher)
42915
+ * @param {bigint|string|number} solOutputAmount - Desired SOL amount to obtain
42916
+ * @param {string|number|Decimal} initialVirtualSol - Initial virtual SOL reserve
42917
+ * @param {string|number|Decimal} initialVirtualToken - Initial virtual token reserve
42918
+ * @returns {[bigint, bigint]|null} Returns [price after transaction, token amount to pay] on success, null on failure
42919
+ * Price rounded down, token amount rounded up
42920
+ */
42921
+ static sellFromPriceWithSolOutputWithParams(startHighPrice, solOutputAmount, initialVirtualSol, initialVirtualToken) {
42922
+ // Convert to Decimal for calculation
42923
+ const startPriceDec = this.u128ToDecimal(startHighPrice);
42924
+ const solOutputDec = this.u64ToSolDecimal(solOutputAmount);
42925
+
42926
+ // Check if input parameters are valid
42927
+ if (startPriceDec.lte(0)) {
42928
+ return null;
42929
+ }
42930
+
42931
+ // If SOL output amount is 0, return unchanged price and token input of 0
42932
+ if (solOutputDec.eq(0)) {
42933
+ const endPriceU128 = this.decimalToU128(startPriceDec);
42934
+ if (endPriceU128 === null) return null;
42935
+ return [endPriceU128, 0n];
42936
+ }
42937
+
42938
+ if (solOutputDec.lt(0)) {
42939
+ return null;
42940
+ }
42941
+
42942
+ // Use custom pool parameters to calculate k value
42943
+ const k = this.calculateK(initialVirtualSol, initialVirtualToken);
42944
+
42945
+ // Calculate reserves for starting state
42946
+ const startReserves = this.calculateReservesByPrice(startPriceDec, k);
42947
+ if (!startReserves) return null;
42948
+
42949
+ const [startSolReserve, startTokenReserve] = startReserves;
42950
+
42951
+ // Calculate SOL reserves for ending state
42952
+ const endSolReserve = startSolReserve.sub(solOutputDec);
42953
+
42954
+ // Check if SOL reserves are sufficient
42955
+ if (endSolReserve.lte(0)) {
42956
+ return null;
42957
+ }
42958
+
42959
+ // Calculate token reserves for ending state according to AMM formula
42960
+ const endTokenReserve = k.div(endSolReserve);
42961
+
42962
+ // Calculate required token input amount
42963
+ const tokenInputAmount = endTokenReserve.sub(startTokenReserve);
42964
+
42965
+ // Calculate ending price
42966
+ const endPrice = endSolReserve.div(endTokenReserve);
42967
+
42968
+ // Check if calculation results are valid
42969
+ if (tokenInputAmount.lte(0) || endPrice.lte(0)) {
42970
+ return null;
42971
+ }
42972
+
42973
+ // Convert back to appropriate types with required rounding
42974
+ const endPriceU128 = this.decimalToU128(endPrice); // Price rounded down
42975
+ const tokenAmountU64 = this.tokenDecimalToU64Ceil(tokenInputAmount); // Token rounded up
42976
+
42977
+ if (endPriceU128 === null || tokenAmountU64 === null) {
42978
+ return null;
42979
+ }
42980
+
42981
+ return [endPriceU128, tokenAmountU64];
42982
+ }
42983
+
42817
42984
  /**
42818
42985
  * Calculate remaining amount after deducting fees
42819
- *
42986
+ *
42820
42987
  * @param {bigint|string|number} amount - Original amount
42821
42988
  * @param {number} fee - Fee rate, expressed with FEE_DENOMINATOR as denominator
42822
42989
  * Example: 1000 represents 1% fee (1000/100000)
@@ -45915,7 +46082,7 @@ const CurveAMM$4 = curve_amm;
45915
46082
  * @throws {Error} 无限流动性计算失败:最大价格流动性计算异常 Infinite liquidity calculation failure: max price liquidity calculation exception
45916
46083
  * @throws {Error} 订单数据格式错误:订单对象缺少必需字段 Order data format error: order object missing required fields
45917
46084
  */
45918
- function calcLiqTokenBuy$1(price, buyTokenAmount, orders, onceMaxOrder, passOrder = null) {
46085
+ function calcLiqTokenBuy$1(price, buyTokenAmount, orders, onceMaxOrder, passOrder = null, initialVirtualSol = null, initialVirtualToken = null) {
45919
46086
  // 由于是买入操作 肯定拿的是 up_orders 方向的 订单 lock_lp_start_price < lock_lp_end_price
45920
46087
  // 并且 lock_lp_start_price 在 orders 中是从小到大排序的
45921
46088
 
@@ -45932,6 +46099,9 @@ function calcLiqTokenBuy$1(price, buyTokenAmount, orders, onceMaxOrder, passOrde
45932
46099
  if (!onceMaxOrder || onceMaxOrder <= 0) {
45933
46100
  throw new Error('参数验证错误:onceMaxOrder 必须是正数 Parameter validation error: onceMaxOrder must be a positive number');
45934
46101
  }
46102
+ if (initialVirtualSol === null || initialVirtualToken === null) {
46103
+ throw new Error('参数验证错误:initialVirtualSol 和 initialVirtualToken 不能为空 Parameter validation error: initialVirtualSol and initialVirtualToken cannot be null');
46104
+ }
45935
46105
 
45936
46106
  const result = {
45937
46107
  free_lp_sol_amount_sum: 0n, // 间隙中可使用的sol流动性数量
@@ -45962,7 +46132,14 @@ function calcLiqTokenBuy$1(price, buyTokenAmount, orders, onceMaxOrder, passOrde
45962
46132
 
45963
46133
  try {
45964
46134
  const priceBigInt = BigInt(price);
45965
- [, result.ideal_lp_sol_amount] = CurveAMM$4.buyFromPriceWithTokenOutput(priceBigInt, buyTokenAmountBigInt);
46135
+ const initialVirtualSolBigInt = BigInt(initialVirtualSol.toString());
46136
+ const initialVirtualTokenBigInt = BigInt(initialVirtualToken.toString());
46137
+ [, result.ideal_lp_sol_amount] = CurveAMM$4.buyFromPriceWithTokenOutputWithParams(
46138
+ priceBigInt,
46139
+ buyTokenAmountBigInt,
46140
+ initialVirtualSolBigInt,
46141
+ initialVirtualTokenBigInt
46142
+ );
45966
46143
  // console.log(`理想计算: 当前价格=${priceBigInt}, 目标代币=${buyTokenAmountBigInt}, 理想SOL=${result.ideal_lp_sol_amount}`);
45967
46144
  } catch (error) {
45968
46145
  throw new Error(`buy流动性计算错误:理想流动性计算失败 Liquidity calculation error: Ideal liquidity calculation failed - ${error.message}`);
@@ -46268,7 +46445,7 @@ function calcLiqTokenBuy$1(price, buyTokenAmount, orders, onceMaxOrder, passOrde
46268
46445
  * @throws {Error} 无限流动性计算失败:最小价格流动性计算异常 Infinite liquidity calculation failure: min price liquidity calculation exception
46269
46446
  * @throws {Error} 订单数据格式错误:订单对象缺少必需字段 Order data format error: order object missing required fields
46270
46447
  */
46271
- function calcLiqTokenSell$1(price, sellTokenAmount, orders, onceMaxOrder, passOrder = null) {
46448
+ function calcLiqTokenSell$1(price, sellTokenAmount, orders, onceMaxOrder, passOrder = null, initialVirtualSol = null, initialVirtualToken = null) {
46272
46449
  // 由于是卖出操作 肯定拿的是 down_orders 方向的 订单 lock_lp_start_price > lock_lp_end_price
46273
46450
  // 并且 lock_lp_start_price 在 orders 中是从大到小排序的
46274
46451
 
@@ -46285,6 +46462,9 @@ function calcLiqTokenSell$1(price, sellTokenAmount, orders, onceMaxOrder, passOr
46285
46462
  if (!onceMaxOrder || onceMaxOrder <= 0) {
46286
46463
  throw new Error('参数验证错误:onceMaxOrder 必须是正数 Parameter validation error: onceMaxOrder must be a positive number');
46287
46464
  }
46465
+ if (initialVirtualSol === null || initialVirtualToken === null) {
46466
+ throw new Error('参数验证错误:initialVirtualSol 和 initialVirtualToken 不能为空 Parameter validation error: initialVirtualSol and initialVirtualToken cannot be null');
46467
+ }
46288
46468
 
46289
46469
  const result = {
46290
46470
  free_lp_sol_amount_sum: 0n, // 间隙中可使用的sol流动性数量
@@ -46311,7 +46491,14 @@ function calcLiqTokenSell$1(price, sellTokenAmount, orders, onceMaxOrder, passOr
46311
46491
  // 计算理想情况下卖出能获得的SOL数量
46312
46492
  try {
46313
46493
  const priceBigInt = BigInt(price);
46314
- [, result.ideal_lp_sol_amount] = CurveAMM$4.sellFromPriceWithTokenInput(priceBigInt, sellTokenAmountBigInt);
46494
+ const initialVirtualSolBigInt = BigInt(initialVirtualSol.toString());
46495
+ const initialVirtualTokenBigInt = BigInt(initialVirtualToken.toString());
46496
+ [, result.ideal_lp_sol_amount] = CurveAMM$4.sellFromPriceWithTokenInputWithParams(
46497
+ priceBigInt,
46498
+ sellTokenAmountBigInt,
46499
+ initialVirtualSolBigInt,
46500
+ initialVirtualTokenBigInt
46501
+ );
46315
46502
  // console.log(`理想计算: 当前价格=${priceBigInt}, 卖出代币=${sellTokenAmountBigInt}, 理想SOL=${result.ideal_lp_sol_amount}`);
46316
46503
  } catch (error) {
46317
46504
  throw new Error(`sell流动性计算错误:理想流动性计算失败 Liquidity calculation error: Ideal liquidity calculation failed - ${error.message}`);
@@ -46319,7 +46506,14 @@ function calcLiqTokenSell$1(price, sellTokenAmount, orders, onceMaxOrder, passOr
46319
46506
 
46320
46507
  // orders 长度为0 时要单独计算
46321
46508
  if (orders.length === 0) {
46322
- const sellResult = CurveAMM$4.sellFromPriceToPrice(BigInt(price), CurveAMM$4.MIN_U128_PRICE);
46509
+ const initialVirtualSolBigInt = BigInt(initialVirtualSol.toString());
46510
+ const initialVirtualTokenBigInt = BigInt(initialVirtualToken.toString());
46511
+ const sellResult = CurveAMM$4.sellFromPriceToPriceWithParams(
46512
+ BigInt(price),
46513
+ CurveAMM$4.MIN_U128_PRICE,
46514
+ initialVirtualSolBigInt,
46515
+ initialVirtualTokenBigInt
46516
+ );
46323
46517
  if (sellResult) {
46324
46518
  [result.free_lp_token_amount_sum, result.free_lp_sol_amount_sum] = sellResult;
46325
46519
  } else {
@@ -46601,19 +46795,29 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
46601
46795
  orders = ordersData.data.orders.slice(0, this.sdk.MAX_ORDERS_COUNT + 1);
46602
46796
  }
46603
46797
 
46798
+ // 获取动态流动池参数
46799
+ let curveData;
46800
+ try {
46801
+ curveData = await this.sdk.chain.getCurveAccount(mint);
46802
+ } catch (error) {
46803
+ throw new Error(`Failed to get curve account data: ${error.message}`);
46804
+ }
46805
+
46604
46806
  // console.log('simulateTokenBuy 获取的数据:');
46605
46807
  // console.log('价格:', price);
46606
46808
  // console.log('订单数量:', orders.length);
46607
46809
  // orders.forEach((order, i) => console.log(`订单${i}: start=${order.lock_lp_start_price}, end=${order.lock_lp_end_price}, sol=${order.lock_lp_sol_amount}, token=${order.lock_lp_token_amount}`));
46608
46810
 
46609
- // 调用 calcLiqTokenBuy 进行流动性计算
46811
+ // 调用 calcLiqTokenBuy 进行流动性计算(传入动态流动池参数)
46610
46812
  try {
46611
46813
  const liqResult = calcLiqTokenBuy(
46612
46814
  price,
46613
- buyTokenAmount,
46815
+ buyTokenAmount,
46614
46816
  orders,
46615
46817
  this.sdk.MAX_ORDERS_COUNT,
46616
- passOrder
46818
+ passOrder,
46819
+ curveData.initialVirtualSol,
46820
+ curveData.initialVirtualToken
46617
46821
  );
46618
46822
 
46619
46823
  // console.log('\n=== calcLiqTokenBuy 返回结果 ===');
@@ -46662,7 +46866,9 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
46662
46866
  suggestedAmount,
46663
46867
  orders,
46664
46868
  this.sdk.MAX_ORDERS_COUNT,
46665
- passOrder
46869
+ passOrder,
46870
+ curveData.initialVirtualSol,
46871
+ curveData.initialVirtualToken
46666
46872
  );
46667
46873
 
46668
46874
  const recalcRealSol = BigInt(recalcResult.real_lp_sol_amount);
@@ -46744,19 +46950,29 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
46744
46950
  orders = ordersData.data.orders.slice(0, this.sdk.MAX_ORDERS_COUNT + 1);
46745
46951
  }
46746
46952
 
46953
+ // 获取动态流动池参数
46954
+ let curveData;
46955
+ try {
46956
+ curveData = await this.sdk.chain.getCurveAccount(mint);
46957
+ } catch (error) {
46958
+ throw new Error(`Failed to get curve account data: ${error.message}`);
46959
+ }
46960
+
46747
46961
  // console.log('simulateTokenSell 获取的数据:');
46748
46962
  // console.log('价格:', price);
46749
46963
  // console.log('订单数量:', orders.length);
46750
46964
  // orders.forEach((order, i) => console.log(`订单${i}: start=${order.lock_lp_start_price}, end=${order.lock_lp_end_price}, sol=${order.lock_lp_sol_amount}, token=${order.lock_lp_token_amount}`));
46751
46965
 
46752
- // 调用 calcLiqTokenSell 进行流动性计算
46966
+ // 调用 calcLiqTokenSell 进行流动性计算(传入动态流动池参数)
46753
46967
  try {
46754
46968
  const liqResult = calcLiqTokenSell(
46755
46969
  price,
46756
46970
  sellTokenAmount,
46757
46971
  orders,
46758
46972
  this.sdk.MAX_ORDERS_COUNT,
46759
- passOrder
46973
+ passOrder,
46974
+ curveData.initialVirtualSol,
46975
+ curveData.initialVirtualToken
46760
46976
  );
46761
46977
 
46762
46978
  // console.log('\n=== calcLiqTokenSell 返回结果 ===');
@@ -46805,7 +47021,9 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
46805
47021
  suggestedAmount,
46806
47022
  orders,
46807
47023
  this.sdk.MAX_ORDERS_COUNT,
46808
- passOrder
47024
+ passOrder,
47025
+ curveData.initialVirtualSol,
47026
+ curveData.initialVirtualToken
46809
47027
  );
46810
47028
 
46811
47029
  const recalcRealSol = BigInt(recalcResult.real_lp_sol_amount);