pinpet-sdk 2.1.17 → 2.1.19
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/pinpet-sdk.cjs.js +87 -47
- package/dist/pinpet-sdk.esm.js +87 -47
- package/dist/pinpet-sdk.js +87 -47
- package/dist/pinpet-sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/modules/simulator/buy_sell_token.js +3 -6
- package/src/modules/simulator/calcLiq.js +60 -17
- package/src/modules/simulator/calc_sol_liq.js +1 -1
- package/src/utils/curve_amm.js +1 -1
package/dist/pinpet-sdk.cjs.js
CHANGED
|
@@ -41917,12 +41917,12 @@ decimal.exports;
|
|
|
41917
41917
|
|
|
41918
41918
|
var decimalExports = decimal.exports;
|
|
41919
41919
|
|
|
41920
|
-
const Decimal = decimalExports;
|
|
41920
|
+
const Decimal$1 = decimalExports;
|
|
41921
41921
|
|
|
41922
41922
|
// Configure Decimal.js to use 50-bit precision for better accuracy with tiny prices
|
|
41923
41923
|
// Increased from 28 to 50 to handle extremely small prices (e.g., 0.000000041571)
|
|
41924
41924
|
// ROUND_HALF_UP ensures consistent rounding behavior
|
|
41925
|
-
Decimal.set({ precision: 50, rounding: Decimal.ROUND_HALF_UP });
|
|
41925
|
+
Decimal$1.set({ precision: 50, rounding: Decimal$1.ROUND_HALF_UP });
|
|
41926
41926
|
|
|
41927
41927
|
|
|
41928
41928
|
/**
|
|
@@ -41950,19 +41950,19 @@ class CurveAMM$8 {
|
|
|
41950
41950
|
* Initial SOL reserve amount, represented as Decimal
|
|
41951
41951
|
* @type {Decimal}
|
|
41952
41952
|
*/
|
|
41953
|
-
static INITIAL_SOL_RESERVE_DECIMAL = new Decimal('30');
|
|
41953
|
+
static INITIAL_SOL_RESERVE_DECIMAL = new Decimal$1('30');
|
|
41954
41954
|
|
|
41955
41955
|
/**
|
|
41956
41956
|
* Initial Token reserve amount, represented as Decimal
|
|
41957
41957
|
* @type {Decimal}
|
|
41958
41958
|
*/
|
|
41959
|
-
static INITIAL_TOKEN_RESERVE_DECIMAL = new Decimal('1073000000');
|
|
41959
|
+
static INITIAL_TOKEN_RESERVE_DECIMAL = new Decimal$1('1073000000');
|
|
41960
41960
|
|
|
41961
41961
|
/**
|
|
41962
41962
|
* Initial constant K value, represented as Decimal
|
|
41963
41963
|
* @type {Decimal}
|
|
41964
41964
|
*/
|
|
41965
|
-
static INITIAL_K_DECIMAL = new Decimal('32190000000');
|
|
41965
|
+
static INITIAL_K_DECIMAL = new Decimal$1('32190000000');
|
|
41966
41966
|
|
|
41967
41967
|
/**
|
|
41968
41968
|
* Minimum price that can appear, below this price may cause overflow
|
|
@@ -41970,33 +41970,33 @@ class CurveAMM$8 {
|
|
|
41970
41970
|
* Reduced from 1e-9 to 1e-12 to support wider range of pool configurations
|
|
41971
41971
|
* @type {Decimal}
|
|
41972
41972
|
*/
|
|
41973
|
-
static INITIAL_MIN_PRICE_DECIMAL = new Decimal('0.000000000001'); // 1e-12
|
|
41973
|
+
static INITIAL_MIN_PRICE_DECIMAL = new Decimal$1('0.000000000001'); // 1e-12
|
|
41974
41974
|
|
|
41975
41975
|
/**
|
|
41976
41976
|
* Decimal representation of precision factor = 10^23
|
|
41977
41977
|
* @type {Decimal}
|
|
41978
41978
|
*/
|
|
41979
41979
|
//static PRICE_PRECISION_FACTOR_DECIMAL = new Decimal('10000000000000000000000000000');
|
|
41980
|
-
static PRICE_PRECISION_FACTOR_DECIMAL = new Decimal('100000000000000000000000');
|
|
41980
|
+
static PRICE_PRECISION_FACTOR_DECIMAL = new Decimal$1('100000000000000000000000');
|
|
41981
41981
|
|
|
41982
41982
|
/**
|
|
41983
41983
|
* Decimal representation of Token precision factor = 1000000000 (10^9)
|
|
41984
41984
|
* @type {Decimal}
|
|
41985
41985
|
*/
|
|
41986
|
-
static TOKEN_PRECISION_FACTOR_DECIMAL = new Decimal('1000000000');
|
|
41986
|
+
static TOKEN_PRECISION_FACTOR_DECIMAL = new Decimal$1('1000000000');
|
|
41987
41987
|
|
|
41988
41988
|
/**
|
|
41989
41989
|
* Decimal representation of SOL precision factor = 1000000000
|
|
41990
41990
|
* @type {Decimal}
|
|
41991
41991
|
*/
|
|
41992
|
-
static SOL_PRECISION_FACTOR_DECIMAL = new Decimal('1000000000');
|
|
41992
|
+
static SOL_PRECISION_FACTOR_DECIMAL = new Decimal$1('1000000000');
|
|
41993
41993
|
|
|
41994
41994
|
|
|
41995
41995
|
/**
|
|
41996
41996
|
* Maximum price for u128 (matches PRICE_CALCULATION_LIMIT in Rust)
|
|
41997
41997
|
* @type {bigint}
|
|
41998
41998
|
*/
|
|
41999
|
-
static MAX_U128_PRICE =
|
|
41999
|
+
static MAX_U128_PRICE = 70000000000000000000000000000n;
|
|
42000
42000
|
|
|
42001
42001
|
|
|
42002
42002
|
/**
|
|
@@ -42018,7 +42018,7 @@ class CurveAMM$8 {
|
|
|
42018
42018
|
if (typeof price === 'bigint') {
|
|
42019
42019
|
price = price.toString();
|
|
42020
42020
|
}
|
|
42021
|
-
const priceDecimal = new Decimal(price);
|
|
42021
|
+
const priceDecimal = new Decimal$1(price);
|
|
42022
42022
|
return priceDecimal.div(this.PRICE_PRECISION_FACTOR_DECIMAL);
|
|
42023
42023
|
}
|
|
42024
42024
|
|
|
@@ -42068,9 +42068,9 @@ class CurveAMM$8 {
|
|
|
42068
42068
|
if (typeof price === 'bigint') {
|
|
42069
42069
|
price = price.toString();
|
|
42070
42070
|
}
|
|
42071
|
-
const priceDecimal = new Decimal(price);
|
|
42071
|
+
const priceDecimal = new Decimal$1(price);
|
|
42072
42072
|
// Use old precision factor 10^15
|
|
42073
|
-
const oldPrecisionFactor = new Decimal('1000000000000000');
|
|
42073
|
+
const oldPrecisionFactor = new Decimal$1('1000000000000000');
|
|
42074
42074
|
return priceDecimal.div(oldPrecisionFactor);
|
|
42075
42075
|
}
|
|
42076
42076
|
|
|
@@ -42083,7 +42083,7 @@ class CurveAMM$8 {
|
|
|
42083
42083
|
*/
|
|
42084
42084
|
static decimalToU64(price) {
|
|
42085
42085
|
// Directly use old precision factor for conversion
|
|
42086
|
-
const oldPrecisionFactor = new Decimal('1000000000000000');
|
|
42086
|
+
const oldPrecisionFactor = new Decimal$1('1000000000000000');
|
|
42087
42087
|
const scaled = price.mul(oldPrecisionFactor);
|
|
42088
42088
|
const floored = scaled.floor();
|
|
42089
42089
|
if (floored.isNaN() || floored.isNegative() || floored.gt('18446744073709551615')) {
|
|
@@ -42102,7 +42102,7 @@ class CurveAMM$8 {
|
|
|
42102
42102
|
*/
|
|
42103
42103
|
static decimalToU64Ceil(price) {
|
|
42104
42104
|
// Directly use old precision factor for conversion
|
|
42105
|
-
const oldPrecisionFactor = new Decimal('1000000000000000');
|
|
42105
|
+
const oldPrecisionFactor = new Decimal$1('1000000000000000');
|
|
42106
42106
|
const scaled = price.mul(oldPrecisionFactor);
|
|
42107
42107
|
const ceiled = scaled.ceil();
|
|
42108
42108
|
if (ceiled.isNaN() || ceiled.isNegative() || ceiled.gt('18446744073709551615')) {
|
|
@@ -42186,7 +42186,7 @@ class CurveAMM$8 {
|
|
|
42186
42186
|
if (typeof amount === 'bigint') {
|
|
42187
42187
|
amount = amount.toString();
|
|
42188
42188
|
}
|
|
42189
|
-
const amountDecimal = new Decimal(amount);
|
|
42189
|
+
const amountDecimal = new Decimal$1(amount);
|
|
42190
42190
|
return amountDecimal.div(this.TOKEN_PRECISION_FACTOR_DECIMAL);
|
|
42191
42191
|
}
|
|
42192
42192
|
|
|
@@ -42200,7 +42200,7 @@ class CurveAMM$8 {
|
|
|
42200
42200
|
if (typeof amount === 'bigint') {
|
|
42201
42201
|
amount = amount.toString();
|
|
42202
42202
|
}
|
|
42203
|
-
const amountDecimal = new Decimal(amount);
|
|
42203
|
+
const amountDecimal = new Decimal$1(amount);
|
|
42204
42204
|
return amountDecimal.div(this.SOL_PRECISION_FACTOR_DECIMAL);
|
|
42205
42205
|
}
|
|
42206
42206
|
|
|
@@ -42218,8 +42218,8 @@ class CurveAMM$8 {
|
|
|
42218
42218
|
* const k2 = CurveAMM.calculateK(60, 1073000000);
|
|
42219
42219
|
*/
|
|
42220
42220
|
static calculateK(initialVirtualSol, initialVirtualToken) {
|
|
42221
|
-
const sol = new Decimal(initialVirtualSol);
|
|
42222
|
-
const token = new Decimal(initialVirtualToken);
|
|
42221
|
+
const sol = new Decimal$1(initialVirtualSol);
|
|
42222
|
+
const token = new Decimal$1(initialVirtualToken);
|
|
42223
42223
|
return sol.mul(token);
|
|
42224
42224
|
}
|
|
42225
42225
|
|
|
@@ -42241,8 +42241,8 @@ class CurveAMM$8 {
|
|
|
42241
42241
|
* @returns {bigint|null} u128格式的初始价格
|
|
42242
42242
|
*/
|
|
42243
42243
|
static getInitialPriceWithParams(initialVirtualSol, initialVirtualToken) {
|
|
42244
|
-
const sol = new Decimal(initialVirtualSol);
|
|
42245
|
-
const token = new Decimal(initialVirtualToken);
|
|
42244
|
+
const sol = new Decimal$1(initialVirtualSol);
|
|
42245
|
+
const token = new Decimal$1(initialVirtualToken);
|
|
42246
42246
|
const initialPrice = sol.div(token);
|
|
42247
42247
|
return this.decimalToU128(initialPrice);
|
|
42248
42248
|
}
|
|
@@ -42485,7 +42485,7 @@ class CurveAMM$8 {
|
|
|
42485
42485
|
}
|
|
42486
42486
|
|
|
42487
42487
|
// Warning for extremely small prices that may have precision issues
|
|
42488
|
-
const warningPrice = new Decimal('0.0000001'); // 10^-7
|
|
42488
|
+
const warningPrice = new Decimal$1('0.0000001'); // 10^-7
|
|
42489
42489
|
if (price.lt(warningPrice)) {
|
|
42490
42490
|
// Only log once per execution to avoid spam (use a static flag)
|
|
42491
42491
|
if (!this._tinyPriceWarningShown) {
|
|
@@ -43039,7 +43039,7 @@ class CurveAMM$8 {
|
|
|
43039
43039
|
if (typeof price === 'bigint') {
|
|
43040
43040
|
price = price.toString();
|
|
43041
43041
|
}
|
|
43042
|
-
const priceDecimal = new Decimal(price);
|
|
43042
|
+
const priceDecimal = new Decimal$1(price);
|
|
43043
43043
|
const convertedPrice = priceDecimal.div(this.PRICE_PRECISION_FACTOR_DECIMAL);
|
|
43044
43044
|
return convertedPrice.toFixed(decimalPlaces);
|
|
43045
43045
|
}
|
|
@@ -46030,6 +46030,7 @@ var long_shrot_stop = {
|
|
|
46030
46030
|
};
|
|
46031
46031
|
|
|
46032
46032
|
const CurveAMM$5 = curve_amm;
|
|
46033
|
+
const Decimal = decimalExports;
|
|
46033
46034
|
|
|
46034
46035
|
|
|
46035
46036
|
/**
|
|
@@ -46146,13 +46147,14 @@ function calcLiqTokenBuy$1(price, buyTokenAmount, orders, onceMaxOrder, passOrde
|
|
|
46146
46147
|
|
|
46147
46148
|
try {
|
|
46148
46149
|
const priceBigInt = BigInt(price);
|
|
46149
|
-
const
|
|
46150
|
-
const
|
|
46150
|
+
const initialVirtualSolDecimal = new Decimal(initialVirtualSol).div(CurveAMM$5.SOL_PRECISION_FACTOR_DECIMAL);
|
|
46151
|
+
const initialVirtualTokenDecimal = new Decimal(initialVirtualToken).div(CurveAMM$5.TOKEN_PRECISION_FACTOR_DECIMAL);
|
|
46152
|
+
|
|
46151
46153
|
[, result.ideal_lp_sol_amount] = CurveAMM$5.buyFromPriceWithTokenOutputWithParams(
|
|
46152
46154
|
priceBigInt,
|
|
46153
46155
|
buyTokenAmountBigInt,
|
|
46154
|
-
|
|
46155
|
-
|
|
46156
|
+
initialVirtualSolDecimal,
|
|
46157
|
+
initialVirtualTokenDecimal
|
|
46156
46158
|
);
|
|
46157
46159
|
// console.log(`理想计算: 当前价格=${priceBigInt}, 目标代币=${buyTokenAmountBigInt}, 理想SOL=${result.ideal_lp_sol_amount}`);
|
|
46158
46160
|
} catch (error) {
|
|
@@ -46162,7 +46164,18 @@ function calcLiqTokenBuy$1(price, buyTokenAmount, orders, onceMaxOrder, passOrde
|
|
|
46162
46164
|
|
|
46163
46165
|
// orders 长度为0 时要单独计算
|
|
46164
46166
|
if (orders.length === 0) {
|
|
46165
|
-
|
|
46167
|
+
|
|
46168
|
+
|
|
46169
|
+
const initialVirtualSolDecimal = new Decimal(initialVirtualSol).div(CurveAMM$5.SOL_PRECISION_FACTOR_DECIMAL);
|
|
46170
|
+
const initialVirtualTokenDecimal = new Decimal(initialVirtualToken).div(CurveAMM$5.TOKEN_PRECISION_FACTOR_DECIMAL);
|
|
46171
|
+
|
|
46172
|
+
|
|
46173
|
+
[result.free_lp_sol_amount_sum, result.free_lp_token_amount_sum] = CurveAMM$5.buyFromPriceToPriceWithParams(
|
|
46174
|
+
BigInt(price),
|
|
46175
|
+
CurveAMM$5.MAX_U128_PRICE,
|
|
46176
|
+
initialVirtualSolDecimal,
|
|
46177
|
+
initialVirtualTokenDecimal
|
|
46178
|
+
);
|
|
46166
46179
|
result.has_infinite_lp = true;
|
|
46167
46180
|
result.real_lp_sol_amount = result.ideal_lp_sol_amount;
|
|
46168
46181
|
return result
|
|
@@ -46210,7 +46223,14 @@ function calcLiqTokenBuy$1(price, buyTokenAmount, orders, onceMaxOrder, passOrde
|
|
|
46210
46223
|
// 如果存在价格间隙,计算自由流动性
|
|
46211
46224
|
if (endPrice > startPrice) {
|
|
46212
46225
|
try {
|
|
46213
|
-
const
|
|
46226
|
+
const initialVirtualSolDecimal = new Decimal(initialVirtualSol).div(CurveAMM$5.SOL_PRECISION_FACTOR_DECIMAL);
|
|
46227
|
+
const initialVirtualTokenDecimal = new Decimal(initialVirtualToken).div(CurveAMM$5.TOKEN_PRECISION_FACTOR_DECIMAL);
|
|
46228
|
+
const gapLiquidity = CurveAMM$5.buyFromPriceToPriceWithParams(
|
|
46229
|
+
startPrice,
|
|
46230
|
+
endPrice,
|
|
46231
|
+
initialVirtualSolDecimal,
|
|
46232
|
+
initialVirtualTokenDecimal
|
|
46233
|
+
);
|
|
46214
46234
|
if (gapLiquidity && Array.isArray(gapLiquidity) && gapLiquidity.length === 2) {
|
|
46215
46235
|
const [solAmount, tokenAmount] = gapLiquidity;
|
|
46216
46236
|
|
|
@@ -46348,7 +46368,14 @@ function calcLiqTokenBuy$1(price, buyTokenAmount, orders, onceMaxOrder, passOrde
|
|
|
46348
46368
|
|
|
46349
46369
|
if (maxPrice > lastEndPrice) {
|
|
46350
46370
|
try {
|
|
46351
|
-
const
|
|
46371
|
+
const initialVirtualSolDecimal = new Decimal(initialVirtualSol).div(CurveAMM$5.SOL_PRECISION_FACTOR_DECIMAL);
|
|
46372
|
+
const initialVirtualTokenDecimal = new Decimal(initialVirtualToken).div(CurveAMM$5.TOKEN_PRECISION_FACTOR_DECIMAL);
|
|
46373
|
+
const infiniteLiquidity = CurveAMM$5.buyFromPriceToPriceWithParams(
|
|
46374
|
+
lastEndPrice,
|
|
46375
|
+
maxPrice,
|
|
46376
|
+
initialVirtualSolDecimal,
|
|
46377
|
+
initialVirtualTokenDecimal
|
|
46378
|
+
);
|
|
46352
46379
|
if (infiniteLiquidity && Array.isArray(infiniteLiquidity) && infiniteLiquidity.length === 2) {
|
|
46353
46380
|
const [solAmount, tokenAmount] = infiniteLiquidity;
|
|
46354
46381
|
|
|
@@ -46505,13 +46532,15 @@ function calcLiqTokenSell$1(price, sellTokenAmount, orders, onceMaxOrder, passOr
|
|
|
46505
46532
|
// 计算理想情况下卖出能获得的SOL数量
|
|
46506
46533
|
try {
|
|
46507
46534
|
const priceBigInt = BigInt(price);
|
|
46508
|
-
const
|
|
46509
|
-
const
|
|
46535
|
+
const initialVirtualSolDecimal = new Decimal(initialVirtualSol).div(CurveAMM$5.SOL_PRECISION_FACTOR_DECIMAL);
|
|
46536
|
+
const initialVirtualTokenDecimal = new Decimal(initialVirtualToken).div(CurveAMM$5.TOKEN_PRECISION_FACTOR_DECIMAL);
|
|
46537
|
+
|
|
46538
|
+
//console.log("initialVirtualSolDecimal,initialVirtualTokenDecimal = ",initialVirtualSolDecimal.toString(),initialVirtualTokenDecimal.toString());
|
|
46510
46539
|
[, result.ideal_lp_sol_amount] = CurveAMM$5.sellFromPriceWithTokenInputWithParams(
|
|
46511
46540
|
priceBigInt,
|
|
46512
46541
|
sellTokenAmountBigInt,
|
|
46513
|
-
|
|
46514
|
-
|
|
46542
|
+
initialVirtualSolDecimal,
|
|
46543
|
+
initialVirtualTokenDecimal
|
|
46515
46544
|
);
|
|
46516
46545
|
// console.log(`理想计算: 当前价格=${priceBigInt}, 卖出代币=${sellTokenAmountBigInt}, 理想SOL=${result.ideal_lp_sol_amount}`);
|
|
46517
46546
|
} catch (error) {
|
|
@@ -46520,13 +46549,13 @@ function calcLiqTokenSell$1(price, sellTokenAmount, orders, onceMaxOrder, passOr
|
|
|
46520
46549
|
|
|
46521
46550
|
// orders 长度为0 时要单独计算
|
|
46522
46551
|
if (orders.length === 0) {
|
|
46523
|
-
const
|
|
46524
|
-
const
|
|
46552
|
+
const initialVirtualSolDecimal = new Decimal(initialVirtualSol).div(CurveAMM$5.SOL_PRECISION_FACTOR_DECIMAL);
|
|
46553
|
+
const initialVirtualTokenDecimal = new Decimal(initialVirtualToken).div(CurveAMM$5.TOKEN_PRECISION_FACTOR_DECIMAL);
|
|
46525
46554
|
const sellResult = CurveAMM$5.sellFromPriceToPriceWithParams(
|
|
46526
46555
|
BigInt(price),
|
|
46527
46556
|
CurveAMM$5.MIN_U128_PRICE,
|
|
46528
|
-
|
|
46529
|
-
|
|
46557
|
+
initialVirtualSolDecimal,
|
|
46558
|
+
initialVirtualTokenDecimal
|
|
46530
46559
|
);
|
|
46531
46560
|
if (sellResult) {
|
|
46532
46561
|
[result.free_lp_token_amount_sum, result.free_lp_sol_amount_sum] = sellResult;
|
|
@@ -46583,7 +46612,14 @@ function calcLiqTokenSell$1(price, sellTokenAmount, orders, onceMaxOrder, passOr
|
|
|
46583
46612
|
// 如果存在价格间隙(卖出时startPrice应该大于endPrice)
|
|
46584
46613
|
if (startPrice > endPrice) {
|
|
46585
46614
|
try {
|
|
46586
|
-
const
|
|
46615
|
+
const initialVirtualSolDecimal = new Decimal(initialVirtualSol).div(CurveAMM$5.SOL_PRECISION_FACTOR_DECIMAL);
|
|
46616
|
+
const initialVirtualTokenDecimal = new Decimal(initialVirtualToken).div(CurveAMM$5.TOKEN_PRECISION_FACTOR_DECIMAL);
|
|
46617
|
+
const gapLiquidity = CurveAMM$5.sellFromPriceToPriceWithParams(
|
|
46618
|
+
startPrice,
|
|
46619
|
+
endPrice,
|
|
46620
|
+
initialVirtualSolDecimal,
|
|
46621
|
+
initialVirtualTokenDecimal
|
|
46622
|
+
);
|
|
46587
46623
|
if (gapLiquidity && Array.isArray(gapLiquidity) && gapLiquidity.length === 2) {
|
|
46588
46624
|
const [tokenAmount, solAmount] = gapLiquidity;
|
|
46589
46625
|
|
|
@@ -46711,7 +46747,14 @@ function calcLiqTokenSell$1(price, sellTokenAmount, orders, onceMaxOrder, passOr
|
|
|
46711
46747
|
if (lastEndPrice > minPrice) {
|
|
46712
46748
|
|
|
46713
46749
|
try {
|
|
46714
|
-
const
|
|
46750
|
+
const initialVirtualSolDecimal = new Decimal(initialVirtualSol).div(CurveAMM$5.SOL_PRECISION_FACTOR_DECIMAL);
|
|
46751
|
+
const initialVirtualTokenDecimal = new Decimal(initialVirtualToken).div(CurveAMM$5.TOKEN_PRECISION_FACTOR_DECIMAL);
|
|
46752
|
+
const infiniteLiquidity = CurveAMM$5.sellFromPriceToPriceWithParams(
|
|
46753
|
+
lastEndPrice,
|
|
46754
|
+
minPrice,
|
|
46755
|
+
initialVirtualSolDecimal,
|
|
46756
|
+
initialVirtualTokenDecimal
|
|
46757
|
+
);
|
|
46715
46758
|
if (infiniteLiquidity && Array.isArray(infiniteLiquidity) && infiniteLiquidity.length === 2) {
|
|
46716
46759
|
const [tokenAmount, solAmount] = infiniteLiquidity;
|
|
46717
46760
|
|
|
@@ -46789,7 +46832,7 @@ const { calcLiqTokenBuy, calcLiqTokenSell } = calcLiq;
|
|
|
46789
46832
|
async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPrice = null, ordersData = null) {
|
|
46790
46833
|
// 获取价格和订单数据
|
|
46791
46834
|
|
|
46792
|
-
console.log('simulateTokenBuy', mint, buyTokenAmount, passOrder, lastPrice, ordersData);
|
|
46835
|
+
//console.log('simulateTokenBuy', mint, buyTokenAmount, passOrder, lastPrice, ordersData);
|
|
46793
46836
|
|
|
46794
46837
|
let price = lastPrice;
|
|
46795
46838
|
if (!price) {
|
|
@@ -46817,11 +46860,6 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
|
|
|
46817
46860
|
throw new Error(`Failed to get curve account data: ${error.message}`);
|
|
46818
46861
|
}
|
|
46819
46862
|
|
|
46820
|
-
// console.log('simulateTokenBuy 获取的数据:');
|
|
46821
|
-
// console.log('价格:', price);
|
|
46822
|
-
// console.log('订单数量:', orders.length);
|
|
46823
|
-
// 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}`));
|
|
46824
|
-
|
|
46825
46863
|
// 调用 calcLiqTokenBuy 进行流动性计算(传入动态流动池参数)
|
|
46826
46864
|
try {
|
|
46827
46865
|
const liqResult = calcLiqTokenBuy(
|
|
@@ -46954,6 +46992,8 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
|
|
|
46954
46992
|
price = await this.sdk.data.price(mint);
|
|
46955
46993
|
}
|
|
46956
46994
|
|
|
46995
|
+
//console.log("price=",price);
|
|
46996
|
+
|
|
46957
46997
|
let orders;
|
|
46958
46998
|
if (!ordersData) {
|
|
46959
46999
|
const ordersResponse = await this.sdk.data.orders(mint, {
|
|
@@ -47363,7 +47403,7 @@ function calcLiqSolBuy$1(price, buySolAmount, orders, onceMaxOrder, passOrderID
|
|
|
47363
47403
|
? new Decimal(initialVirtualToken.toString()).div(CurveAMM$4.TOKEN_PRECISION_FACTOR_DECIMAL)
|
|
47364
47404
|
: CurveAMM$4.INITIAL_TOKEN_RESERVE_DECIMAL;
|
|
47365
47405
|
|
|
47366
|
-
console.log("calcLiqSolBuy: virtualSol,virtualToken=",virtualSol,virtualToken)
|
|
47406
|
+
//console.log("calcLiqSolBuy: virtualSol,virtualToken=",virtualSol,virtualToken)
|
|
47367
47407
|
|
|
47368
47408
|
|
|
47369
47409
|
// 3. 处理空订单情况(第一阶段)
|