@magmaprotocol/magma-clmm-sdk 0.5.83 → 0.5.84

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
@@ -257,7 +257,7 @@ var CachedContent = class {
257
257
  };
258
258
 
259
259
  // src/utils/common.ts
260
- var import_bn12 = __toESM(require("bn.js"));
260
+ var import_bn13 = __toESM(require("bn.js"));
261
261
  var import_bcs = require("@mysten/bcs");
262
262
  var import_ed25519 = require("@mysten/sui/keypairs/ed25519");
263
263
  var import_secp256k1 = require("@mysten/sui/keypairs/secp256k1");
@@ -1812,6 +1812,9 @@ function collectFeesQuote(param) {
1812
1812
  return updateFees(param.position, fee_growth_inside_a, fee_growth_inside_b);
1813
1813
  }
1814
1814
 
1815
+ // src/math/dlmmStrategy.ts
1816
+ var import_bn10 = __toESM(require("bn.js"));
1817
+
1815
1818
  // src/math/dlmmWeightToAmounts.ts
1816
1819
  var import_bn9 = __toESM(require("bn.js"));
1817
1820
  var import_decimal6 = __toESM(require("decimal.js"));
@@ -2228,40 +2231,127 @@ function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amo
2228
2231
  throw new Error(`Unsupported strategy type: ${strategyType}`);
2229
2232
  }
2230
2233
  }
2234
+ function assignLeftAmountX(activeId, binStep, maxBinId, amountX, strategyType) {
2235
+ let weights = [];
2236
+ switch (strategyType) {
2237
+ case 1 /* Spot */: {
2238
+ weights = toWeightSpotBalanced(activeId, maxBinId);
2239
+ break;
2240
+ }
2241
+ case 2 /* Curve */: {
2242
+ weights = toWeightDecendingOrder(activeId, maxBinId);
2243
+ break;
2244
+ }
2245
+ case 3 /* BidAsk */: {
2246
+ weights = toWeightAscendingOrder(activeId, maxBinId);
2247
+ break;
2248
+ }
2249
+ }
2250
+ const amounts = toAmountAskSide(activeId, binStep, amountX, weights);
2251
+ return amounts.map((bin) => {
2252
+ return {
2253
+ binId: bin.binId,
2254
+ amountX: bin.amount,
2255
+ amountY: new import_bn10.default(0)
2256
+ };
2257
+ });
2258
+ }
2259
+ function assignLeftAmountY(activeId, minBinId, amountY, strategyType) {
2260
+ let weights = [];
2261
+ switch (strategyType) {
2262
+ case 1 /* Spot */: {
2263
+ weights = toWeightSpotBalanced(minBinId, activeId);
2264
+ break;
2265
+ }
2266
+ case 2 /* Curve */: {
2267
+ weights = toWeightAscendingOrder(minBinId, activeId);
2268
+ break;
2269
+ }
2270
+ case 3 /* BidAsk */: {
2271
+ weights = toWeightDecendingOrder(minBinId, activeId);
2272
+ break;
2273
+ }
2274
+ }
2275
+ const amounts = toAmountBidSide(activeId, amountY, weights);
2276
+ return amounts.map((bin) => {
2277
+ return {
2278
+ binId: bin.binId,
2279
+ amountX: new import_bn10.default(0),
2280
+ amountY: bin.amount
2281
+ };
2282
+ });
2283
+ }
2284
+ function mergeBinDisplay(to, from) {
2285
+ const binMap = /* @__PURE__ */ new Map();
2286
+ for (const bin of to) {
2287
+ binMap.set(bin.binId, bin);
2288
+ }
2289
+ for (const bin of from) {
2290
+ const existingBin = binMap.get(bin.binId);
2291
+ if (existingBin) {
2292
+ existingBin.amountX = existingBin.amountX.add(bin.amountX);
2293
+ existingBin.amountY = existingBin.amountY.add(bin.amountY);
2294
+ } else {
2295
+ binMap.set(bin.binId, bin);
2296
+ }
2297
+ }
2298
+ return Array.from(binMap.values()).sort((a, b) => {
2299
+ return a.binId - b.binId;
2300
+ });
2301
+ }
2231
2302
  function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amountX, amountY, amountXInActiveBin, amountYInActiveBin, strategyType) {
2232
2303
  const isSingleSideX = amountY.isZero();
2304
+ let res = [];
2233
2305
  switch (strategyType) {
2234
2306
  case 1 /* Spot */: {
2235
2307
  const weights = toWeightSpotBalanced(minBinId, maxBinId);
2236
- return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
2308
+ res = toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
2309
+ break;
2237
2310
  }
2238
2311
  case 2 /* Curve */: {
2239
2312
  if (activeId < minBinId) {
2240
2313
  const weights2 = toWeightDecendingOrder(minBinId, maxBinId);
2241
- return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights2);
2314
+ res = toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights2);
2242
2315
  }
2243
2316
  if (activeId > maxBinId) {
2244
2317
  const weights2 = toWeightAscendingOrder(minBinId, maxBinId);
2245
- return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights2);
2318
+ res = toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights2);
2246
2319
  }
2247
2320
  const weights = toWeightCurve(minBinId, maxBinId, activeId);
2248
- return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
2321
+ res = toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
2322
+ break;
2249
2323
  }
2250
2324
  case 3 /* BidAsk */: {
2251
2325
  if (activeId < minBinId) {
2252
2326
  const weights2 = toWeightAscendingOrder(minBinId, maxBinId);
2253
- return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights2);
2327
+ res = toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights2);
2254
2328
  }
2255
2329
  if (activeId > maxBinId) {
2256
2330
  const weights2 = toWeightDecendingOrder(minBinId, maxBinId);
2257
- return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights2);
2331
+ res = toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights2);
2258
2332
  }
2259
2333
  const weights = toWeightBidAsk(minBinId, maxBinId, activeId);
2260
- return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
2334
+ res = toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
2335
+ break;
2261
2336
  }
2262
2337
  default:
2263
2338
  throw new Error(`Unsupported strategy type: ${strategyType}`);
2264
2339
  }
2340
+ let amountXLeft = amountX;
2341
+ let amountYLeft = amountY;
2342
+ res.forEach((bin) => {
2343
+ amountXLeft = amountXLeft.sub(bin.amountX);
2344
+ amountYLeft = amountYLeft.sub(bin.amountY);
2345
+ });
2346
+ if (amountXLeft.gt(new import_bn10.default(0))) {
2347
+ const xAssigned = assignLeftAmountX(activeId, binStep, maxBinId, amountXLeft, strategyType);
2348
+ res = mergeBinDisplay(res, xAssigned);
2349
+ }
2350
+ if (amountYLeft.gt(new import_bn10.default(0))) {
2351
+ const yAssigned = assignLeftAmountY(activeId, minBinId, amountYLeft, strategyType);
2352
+ res = mergeBinDisplay(res, yAssigned);
2353
+ }
2354
+ return res;
2265
2355
  }
2266
2356
 
2267
2357
  // src/math/LiquidityHelper.ts
@@ -2317,7 +2407,7 @@ function getCoinXYForLiquidity(liquidity, reserveInSize, reserveOutSize, lpSuply
2317
2407
  }
2318
2408
 
2319
2409
  // src/math/percentage.ts
2320
- var import_bn10 = __toESM(require("bn.js"));
2410
+ var import_bn11 = __toESM(require("bn.js"));
2321
2411
  var Percentage = class {
2322
2412
  numerator;
2323
2413
  denominator;
@@ -2345,8 +2435,8 @@ var Percentage = class {
2345
2435
  * @returns
2346
2436
  */
2347
2437
  static fromFraction(numerator, denominator) {
2348
- const num = typeof numerator === "number" ? new import_bn10.default(numerator.toString()) : numerator;
2349
- const denom = typeof denominator === "number" ? new import_bn10.default(denominator.toString()) : denominator;
2438
+ const num = typeof numerator === "number" ? new import_bn11.default(numerator.toString()) : numerator;
2439
+ const denom = typeof denominator === "number" ? new import_bn11.default(denominator.toString()) : denominator;
2350
2440
  return new Percentage(num, denom);
2351
2441
  }
2352
2442
  };
@@ -2446,7 +2536,7 @@ function adjustForCoinSlippage(tokenAmount, slippage, adjustUp) {
2446
2536
  }
2447
2537
 
2448
2538
  // src/math/SplitSwap.ts
2449
- var import_bn11 = __toESM(require("bn.js"));
2539
+ var import_bn12 = __toESM(require("bn.js"));
2450
2540
  var SplitUnit = /* @__PURE__ */ ((SplitUnit2) => {
2451
2541
  SplitUnit2[SplitUnit2["FIVE"] = 5] = "FIVE";
2452
2542
  SplitUnit2[SplitUnit2["TEN"] = 10] = "TEN";
@@ -2504,7 +2594,7 @@ function updateSplitSwapResult(maxIndex, currentIndex, splitSwapResult, stepResu
2504
2594
  return splitSwapResult;
2505
2595
  }
2506
2596
  function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
2507
- let currentLiquidity = new import_bn11.default(poolData.liquidity);
2597
+ let currentLiquidity = new import_bn12.default(poolData.liquidity);
2508
2598
  let { currentSqrtPrice } = poolData;
2509
2599
  let splitSwapResult = {
2510
2600
  amountInArray: [],
@@ -2567,7 +2657,7 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
2567
2657
  targetSqrtPrice,
2568
2658
  currentLiquidity,
2569
2659
  remainerAmount,
2570
- new import_bn11.default(poolData.feeRate),
2660
+ new import_bn12.default(poolData.feeRate),
2571
2661
  byAmountIn
2572
2662
  );
2573
2663
  tempStepResult = stepResult;
@@ -2579,7 +2669,7 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
2579
2669
  splitSwapResult.amountOutArray[i] = splitSwapResult.amountOutArray[i].add(stepResult.amountOut);
2580
2670
  splitSwapResult.feeAmountArray[i] = splitSwapResult.feeAmountArray[i].add(stepResult.feeAmount);
2581
2671
  if (stepResult.nextSqrtPrice.eq(tick.sqrtPrice)) {
2582
- signedLiquidityChange = a2b ? tick.liquidityNet.mul(new import_bn11.default(-1)) : tick.liquidityNet;
2672
+ signedLiquidityChange = a2b ? tick.liquidityNet.mul(new import_bn12.default(-1)) : tick.liquidityNet;
2583
2673
  currentLiquidity = signedLiquidityChange.gt(ZERO) ? currentLiquidity.add(signedLiquidityChange) : currentLiquidity.sub(signedLiquidityChange.abs());
2584
2674
  currentSqrtPrice = tick.sqrtPrice;
2585
2675
  } else {
@@ -2604,7 +2694,7 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
2604
2694
  break;
2605
2695
  }
2606
2696
  if (tempStepResult.nextSqrtPrice.eq(tick.sqrtPrice)) {
2607
- signedLiquidityChange = a2b ? tick.liquidityNet.mul(new import_bn11.default(-1)) : tick.liquidityNet;
2697
+ signedLiquidityChange = a2b ? tick.liquidityNet.mul(new import_bn12.default(-1)) : tick.liquidityNet;
2608
2698
  currentLiquidity = signedLiquidityChange.gt(ZERO) ? currentLiquidity.add(signedLiquidityChange) : currentLiquidity.sub(signedLiquidityChange.abs());
2609
2699
  currentSqrtPrice = tick.sqrtPrice;
2610
2700
  } else {
@@ -2829,7 +2919,7 @@ function buildPool(objects) {
2829
2919
  const rewarders = [];
2830
2920
  fields.rewarder_manager.fields.rewarders.forEach((item) => {
2831
2921
  const { emissions_per_second } = item.fields;
2832
- const emissionSeconds = MathUtil.fromX64(new import_bn12.default(emissions_per_second));
2922
+ const emissionSeconds = MathUtil.fromX64(new import_bn13.default(emissions_per_second));
2833
2923
  const emissionsEveryDay = Math.floor(emissionSeconds.toNumber() * 60 * 60 * 24);
2834
2924
  rewarders.push({
2835
2925
  emissions_per_second,
@@ -3021,11 +3111,11 @@ function buildTickData(objects) {
3021
3111
  const possition = {
3022
3112
  objectId: getObjectId(objects),
3023
3113
  index: asIntN(BigInt(valueItem.index.fields.bits)),
3024
- sqrtPrice: new import_bn12.default(valueItem.sqrt_price),
3025
- liquidityNet: new import_bn12.default(valueItem.liquidity_net.fields.bits),
3026
- liquidityGross: new import_bn12.default(valueItem.liquidity_gross),
3027
- feeGrowthOutsideA: new import_bn12.default(valueItem.fee_growth_outside_a),
3028
- feeGrowthOutsideB: new import_bn12.default(valueItem.fee_growth_outside_b),
3114
+ sqrtPrice: new import_bn13.default(valueItem.sqrt_price),
3115
+ liquidityNet: new import_bn13.default(valueItem.liquidity_net.fields.bits),
3116
+ liquidityGross: new import_bn13.default(valueItem.liquidity_gross),
3117
+ feeGrowthOutsideA: new import_bn13.default(valueItem.fee_growth_outside_a),
3118
+ feeGrowthOutsideB: new import_bn13.default(valueItem.fee_growth_outside_b),
3029
3119
  rewardersGrowthOutside: valueItem.rewards_growth_outside
3030
3120
  };
3031
3121
  return possition;
@@ -3035,11 +3125,11 @@ function buildTickDataByEvent(fields) {
3035
3125
  throw new ClmmpoolsError(`Invalid tick fields.`, "InvalidTickFields" /* InvalidTickFields */);
3036
3126
  }
3037
3127
  const index = asIntN(BigInt(fields.index.bits));
3038
- const sqrtPrice = new import_bn12.default(fields.sqrt_price);
3039
- const liquidityNet = new import_bn12.default(fields.liquidity_net.bits);
3040
- const liquidityGross = new import_bn12.default(fields.liquidity_gross);
3041
- const feeGrowthOutsideA = new import_bn12.default(fields.fee_growth_outside_a);
3042
- const feeGrowthOutsideB = new import_bn12.default(fields.fee_growth_outside_b);
3128
+ const sqrtPrice = new import_bn13.default(fields.sqrt_price);
3129
+ const liquidityNet = new import_bn13.default(fields.liquidity_net.bits);
3130
+ const liquidityGross = new import_bn13.default(fields.liquidity_gross);
3131
+ const feeGrowthOutsideA = new import_bn13.default(fields.fee_growth_outside_a);
3132
+ const feeGrowthOutsideB = new import_bn13.default(fields.fee_growth_outside_b);
3043
3133
  const rewardersGrowthOutside = fields.rewards_growth_outside || [];
3044
3134
  const tick = {
3045
3135
  objectId: "",
@@ -3058,7 +3148,7 @@ function buildClmmPositionName(pool_index, position_index) {
3058
3148
  }
3059
3149
 
3060
3150
  // src/utils/tick.ts
3061
- var import_bn13 = __toESM(require("bn.js"));
3151
+ var import_bn14 = __toESM(require("bn.js"));
3062
3152
  var TickUtil = class {
3063
3153
  /**
3064
3154
  * Get min tick index.
@@ -3098,22 +3188,22 @@ function getRewardInTickRange(pool, tickLower, tickUpper, tickLowerIndex, tickUp
3098
3188
  let rewarder_growth_below = growthGlobal[i];
3099
3189
  if (tickLower !== null) {
3100
3190
  if (pool.current_tick_index < tickLowerIndex) {
3101
- rewarder_growth_below = growthGlobal[i].sub(new import_bn13.default(tickLower.rewardersGrowthOutside[i]));
3191
+ rewarder_growth_below = growthGlobal[i].sub(new import_bn14.default(tickLower.rewardersGrowthOutside[i]));
3102
3192
  } else {
3103
3193
  rewarder_growth_below = tickLower.rewardersGrowthOutside[i];
3104
3194
  }
3105
3195
  }
3106
- let rewarder_growth_above = new import_bn13.default(0);
3196
+ let rewarder_growth_above = new import_bn14.default(0);
3107
3197
  if (tickUpper !== null) {
3108
3198
  if (pool.current_tick_index >= tickUpperIndex) {
3109
- rewarder_growth_above = growthGlobal[i].sub(new import_bn13.default(tickUpper.rewardersGrowthOutside[i]));
3199
+ rewarder_growth_above = growthGlobal[i].sub(new import_bn14.default(tickUpper.rewardersGrowthOutside[i]));
3110
3200
  } else {
3111
3201
  rewarder_growth_above = tickUpper.rewardersGrowthOutside[i];
3112
3202
  }
3113
3203
  }
3114
3204
  const rewGrowthInside = MathUtil.subUnderflowU128(
3115
- MathUtil.subUnderflowU128(new import_bn13.default(growthGlobal[i]), new import_bn13.default(rewarder_growth_below)),
3116
- new import_bn13.default(rewarder_growth_above)
3205
+ MathUtil.subUnderflowU128(new import_bn14.default(growthGlobal[i]), new import_bn14.default(rewarder_growth_below)),
3206
+ new import_bn14.default(rewarder_growth_above)
3117
3207
  );
3118
3208
  rewarderGrowthInside.push(rewGrowthInside);
3119
3209
  }
@@ -3121,7 +3211,7 @@ function getRewardInTickRange(pool, tickLower, tickUpper, tickLowerIndex, tickUp
3121
3211
  }
3122
3212
 
3123
3213
  // src/utils/transaction-util.ts
3124
- var import_bn14 = __toESM(require("bn.js"));
3214
+ var import_bn15 = __toESM(require("bn.js"));
3125
3215
  var import_decimal10 = __toESM(require("decimal.js"));
3126
3216
  var import_transactions = require("@mysten/sui/transactions");
3127
3217
  function findAdjustCoin(coinPair) {
@@ -3430,7 +3520,7 @@ var _TransactionUtil = class {
3430
3520
  const liquidityInput = ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts(
3431
3521
  Number(params.tick_lower),
3432
3522
  Number(params.tick_upper),
3433
- new import_bn14.default(coinAmount),
3523
+ new import_bn15.default(coinAmount),
3434
3524
  params.fix_amount_a,
3435
3525
  true,
3436
3526
  slippage,
@@ -4498,7 +4588,7 @@ var _TransactionUtil = class {
4498
4588
  const basePath = splitPath.basePaths[i];
4499
4589
  a2b.push(basePath.direction);
4500
4590
  poolAddress.push(basePath.poolAddress);
4501
- rawAmountLimit.push(new import_bn14.default(basePath.inputAmount.toString()));
4591
+ rawAmountLimit.push(new import_bn15.default(basePath.inputAmount.toString()));
4502
4592
  if (i === 0) {
4503
4593
  coinType.push(basePath.fromCoin, basePath.toCoin);
4504
4594
  } else {
@@ -4506,8 +4596,8 @@ var _TransactionUtil = class {
4506
4596
  }
4507
4597
  }
4508
4598
  const onePath = {
4509
- amountIn: new import_bn14.default(splitPath.inputAmount.toString()),
4510
- amountOut: new import_bn14.default(splitPath.outputAmount.toString()),
4599
+ amountIn: new import_bn15.default(splitPath.inputAmount.toString()),
4600
+ amountOut: new import_bn15.default(splitPath.outputAmount.toString()),
4511
4601
  poolAddress,
4512
4602
  a2b,
4513
4603
  rawAmountLimit,
@@ -4864,9 +4954,9 @@ var TxBlock = class {
4864
4954
  };
4865
4955
 
4866
4956
  // src/utils/deepbook-utils.ts
4867
- var import_bn15 = __toESM(require("bn.js"));
4957
+ var import_bn16 = __toESM(require("bn.js"));
4868
4958
  var import_transactions3 = require("@mysten/sui/transactions");
4869
- var FLOAT_SCALING = new import_bn15.default(1e9);
4959
+ var FLOAT_SCALING = new import_bn16.default(1e9);
4870
4960
  var DeepbookUtils = class {
4871
4961
  static createAccountCap(senderAddress, sdkOptions, tx, isTransfer = false) {
4872
4962
  if (senderAddress.length === 0) {
@@ -5012,9 +5102,9 @@ var DeepbookUtils = class {
5012
5102
  static async preSwap(sdk, pool, a2b, amountIn) {
5013
5103
  let isExceed = false;
5014
5104
  let amountOut = ZERO;
5015
- let remainAmount = new import_bn15.default(amountIn);
5105
+ let remainAmount = new import_bn16.default(amountIn);
5016
5106
  let feeAmount = ZERO;
5017
- const initAmountIn = new import_bn15.default(amountIn);
5107
+ const initAmountIn = new import_bn16.default(amountIn);
5018
5108
  if (a2b) {
5019
5109
  let bids = await this.getPoolBids(sdk, pool.poolID, pool.baseAsset, pool.quoteAsset);
5020
5110
  if (bids === null) {
@@ -5024,16 +5114,16 @@ var DeepbookUtils = class {
5024
5114
  return b.price - a.price;
5025
5115
  });
5026
5116
  for (let i = 0; i < bids.length; i += 1) {
5027
- const curBidAmount = new import_bn15.default(bids[i].quantity);
5028
- const curBidPrice = new import_bn15.default(bids[i].price);
5029
- const fee = curBidAmount.mul(new import_bn15.default(curBidPrice)).mul(new import_bn15.default(pool.takerFeeRate)).div(FLOAT_SCALING).div(FLOAT_SCALING);
5117
+ const curBidAmount = new import_bn16.default(bids[i].quantity);
5118
+ const curBidPrice = new import_bn16.default(bids[i].price);
5119
+ const fee = curBidAmount.mul(new import_bn16.default(curBidPrice)).mul(new import_bn16.default(pool.takerFeeRate)).div(FLOAT_SCALING).div(FLOAT_SCALING);
5030
5120
  if (remainAmount.gt(curBidAmount)) {
5031
5121
  remainAmount = remainAmount.sub(curBidAmount);
5032
5122
  amountOut = amountOut.add(curBidAmount.mul(curBidPrice).div(FLOAT_SCALING).sub(fee));
5033
5123
  feeAmount = feeAmount.add(fee);
5034
5124
  } else {
5035
- const curOut = remainAmount.mul(new import_bn15.default(bids[i].price)).div(FLOAT_SCALING);
5036
- const curFee = curOut.mul(new import_bn15.default(pool.takerFeeRate)).div(FLOAT_SCALING);
5125
+ const curOut = remainAmount.mul(new import_bn16.default(bids[i].price)).div(FLOAT_SCALING);
5126
+ const curFee = curOut.mul(new import_bn16.default(pool.takerFeeRate)).div(FLOAT_SCALING);
5037
5127
  amountOut = amountOut.add(curOut.sub(curFee));
5038
5128
  remainAmount = remainAmount.sub(remainAmount);
5039
5129
  feeAmount = feeAmount.add(curFee);
@@ -5048,15 +5138,15 @@ var DeepbookUtils = class {
5048
5138
  isExceed = true;
5049
5139
  }
5050
5140
  for (let i = 0; i < asks.length; i += 1) {
5051
- const curAskAmount = new import_bn15.default(asks[i].price).mul(new import_bn15.default(asks[i].quantity)).div(new import_bn15.default(1e9));
5052
- const fee = curAskAmount.mul(new import_bn15.default(pool.takerFeeRate)).div(FLOAT_SCALING);
5141
+ const curAskAmount = new import_bn16.default(asks[i].price).mul(new import_bn16.default(asks[i].quantity)).div(new import_bn16.default(1e9));
5142
+ const fee = curAskAmount.mul(new import_bn16.default(pool.takerFeeRate)).div(FLOAT_SCALING);
5053
5143
  const curAskAmountWithFee = curAskAmount.add(fee);
5054
5144
  if (remainAmount.gt(curAskAmount)) {
5055
- amountOut = amountOut.add(new import_bn15.default(asks[i].quantity));
5145
+ amountOut = amountOut.add(new import_bn16.default(asks[i].quantity));
5056
5146
  remainAmount = remainAmount.sub(curAskAmountWithFee);
5057
5147
  feeAmount = feeAmount.add(fee);
5058
5148
  } else {
5059
- const splitNums = new import_bn15.default(asks[i].quantity).div(new import_bn15.default(pool.lotSize));
5149
+ const splitNums = new import_bn16.default(asks[i].quantity).div(new import_bn16.default(pool.lotSize));
5060
5150
  const splitAmount = curAskAmountWithFee.div(splitNums);
5061
5151
  const swapSplitNum = remainAmount.div(splitAmount);
5062
5152
  amountOut = amountOut.add(swapSplitNum.muln(pool.lotSize));
@@ -5376,7 +5466,7 @@ var PoolModule = class {
5376
5466
  } catch (e) {
5377
5467
  throw new ClmmpoolsError(`Failed tp [arse response from ${url}].`, "InvalidSwapCountUrl" /* InvalidSwapCountUrl */);
5378
5468
  }
5379
- const pools = json.data.pools;
5469
+ const { pools } = json.data;
5380
5470
  if (!pools || pools.length === 0) {
5381
5471
  throw new ClmmpoolsError(`Failed tp [arse response from ${url}].`, "PoolsNotFound" /* PoolsNotFound */);
5382
5472
  }
@@ -5917,7 +6007,7 @@ var PoolModule = class {
5917
6007
  };
5918
6008
 
5919
6009
  // src/modules/positionModule.ts
5920
- var import_bn16 = __toESM(require("bn.js"));
6010
+ var import_bn17 = __toESM(require("bn.js"));
5921
6011
  var import_transactions5 = require("@mysten/sui/transactions");
5922
6012
  var import_utils15 = require("@mysten/sui/utils");
5923
6013
  var PositionModule = class {
@@ -6139,8 +6229,8 @@ var PositionModule = class {
6139
6229
  for (let i = 0; i < valueData.length; i += 1) {
6140
6230
  const { parsedJson } = valueData[i];
6141
6231
  const posRrewarderResult = {
6142
- feeOwedA: new import_bn16.default(parsedJson.fee_owned_a),
6143
- feeOwedB: new import_bn16.default(parsedJson.fee_owned_b),
6232
+ feeOwedA: new import_bn17.default(parsedJson.fee_owned_a),
6233
+ feeOwedB: new import_bn17.default(parsedJson.fee_owned_b),
6144
6234
  position_id: parsedJson.position_id
6145
6235
  };
6146
6236
  result.push(posRrewarderResult);
@@ -6516,7 +6606,7 @@ var PositionModule = class {
6516
6606
  };
6517
6607
 
6518
6608
  // src/modules/rewarderModule.ts
6519
- var import_bn17 = __toESM(require("bn.js"));
6609
+ var import_bn18 = __toESM(require("bn.js"));
6520
6610
  var import_transactions6 = require("@mysten/sui/transactions");
6521
6611
  var RewarderModule = class {
6522
6612
  _sdk;
@@ -6542,7 +6632,7 @@ var RewarderModule = class {
6542
6632
  }
6543
6633
  const emissionsEveryDay = [];
6544
6634
  for (const rewarderInfo of rewarderInfos) {
6545
- const emissionSeconds = MathUtil.fromX64(new import_bn17.default(rewarderInfo.emissions_per_second));
6635
+ const emissionSeconds = MathUtil.fromX64(new import_bn18.default(rewarderInfo.emissions_per_second));
6546
6636
  emissionsEveryDay.push({
6547
6637
  emissions: Math.floor(emissionSeconds.toNumber() * 60 * 60 * 24),
6548
6638
  coin_address: rewarderInfo.coinAddress
@@ -6561,20 +6651,20 @@ var RewarderModule = class {
6561
6651
  const currentPool = await this.sdk.Pool.getPool(poolID);
6562
6652
  const lastTime = currentPool.rewarder_last_updated_time;
6563
6653
  currentPool.rewarder_last_updated_time = currentTime.toString();
6564
- if (Number(currentPool.liquidity) === 0 || currentTime.eq(new import_bn17.default(lastTime))) {
6654
+ if (Number(currentPool.liquidity) === 0 || currentTime.eq(new import_bn18.default(lastTime))) {
6565
6655
  return currentPool;
6566
6656
  }
6567
- const timeDelta = currentTime.div(new import_bn17.default(1e3)).sub(new import_bn17.default(lastTime)).add(new import_bn17.default(15));
6657
+ const timeDelta = currentTime.div(new import_bn18.default(1e3)).sub(new import_bn18.default(lastTime)).add(new import_bn18.default(15));
6568
6658
  const rewarderInfos = currentPool.rewarder_infos;
6569
6659
  for (let i = 0; i < rewarderInfos.length; i += 1) {
6570
6660
  const rewarderInfo = rewarderInfos[i];
6571
6661
  const rewarderGrowthDelta = MathUtil.checkMulDivFloor(
6572
6662
  timeDelta,
6573
- new import_bn17.default(rewarderInfo.emissions_per_second),
6574
- new import_bn17.default(currentPool.liquidity),
6663
+ new import_bn18.default(rewarderInfo.emissions_per_second),
6664
+ new import_bn18.default(currentPool.liquidity),
6575
6665
  128
6576
6666
  );
6577
- this.growthGlobal[i] = new import_bn17.default(rewarderInfo.growth_global).add(new import_bn17.default(rewarderGrowthDelta));
6667
+ this.growthGlobal[i] = new import_bn18.default(rewarderInfo.growth_global).add(new import_bn18.default(rewarderGrowthDelta));
6578
6668
  }
6579
6669
  return currentPool;
6580
6670
  }
@@ -6589,7 +6679,7 @@ var RewarderModule = class {
6589
6679
  */
6590
6680
  async posRewardersAmount(poolID, positionHandle, positionID) {
6591
6681
  const currentTime = Date.parse((/* @__PURE__ */ new Date()).toString());
6592
- const pool = await this.updatePoolRewarder(poolID, new import_bn17.default(currentTime));
6682
+ const pool = await this.updatePoolRewarder(poolID, new import_bn18.default(currentTime));
6593
6683
  const position = await this.sdk.Position.getPositionRewarders(positionHandle, positionID);
6594
6684
  if (position === void 0) {
6595
6685
  return [];
@@ -6610,7 +6700,7 @@ var RewarderModule = class {
6610
6700
  */
6611
6701
  async poolRewardersAmount(accountAddress, poolID) {
6612
6702
  const currentTime = Date.parse((/* @__PURE__ */ new Date()).toString());
6613
- const pool = await this.updatePoolRewarder(poolID, new import_bn17.default(currentTime));
6703
+ const pool = await this.updatePoolRewarder(poolID, new import_bn18.default(currentTime));
6614
6704
  const positions = await this.sdk.Position.getPositionList(accountAddress, [poolID]);
6615
6705
  const tickDatas = await this.getPoolLowerAndUpperTicks(pool.ticks_handle, positions);
6616
6706
  const rewarderAmount = [ZERO, ZERO, ZERO];
@@ -6637,38 +6727,38 @@ var RewarderModule = class {
6637
6727
  const growthInside = [];
6638
6728
  const AmountOwed = [];
6639
6729
  if (rewardersInside.length > 0) {
6640
- let growthDelta0 = MathUtil.subUnderflowU128(rewardersInside[0], new import_bn17.default(position.reward_growth_inside_0));
6641
- if (growthDelta0.gt(new import_bn17.default("3402823669209384634633745948738404"))) {
6730
+ let growthDelta0 = MathUtil.subUnderflowU128(rewardersInside[0], new import_bn18.default(position.reward_growth_inside_0));
6731
+ if (growthDelta0.gt(new import_bn18.default("3402823669209384634633745948738404"))) {
6642
6732
  growthDelta0 = ONE;
6643
6733
  }
6644
- const amountOwed_0 = MathUtil.checkMulShiftRight(new import_bn17.default(position.liquidity), growthDelta0, 64, 128);
6734
+ const amountOwed_0 = MathUtil.checkMulShiftRight(new import_bn18.default(position.liquidity), growthDelta0, 64, 128);
6645
6735
  growthInside.push(rewardersInside[0]);
6646
6736
  AmountOwed.push({
6647
- amount_owed: new import_bn17.default(position.reward_amount_owed_0).add(amountOwed_0),
6737
+ amount_owed: new import_bn18.default(position.reward_amount_owed_0).add(amountOwed_0),
6648
6738
  coin_address: pool.rewarder_infos[0].coinAddress
6649
6739
  });
6650
6740
  }
6651
6741
  if (rewardersInside.length > 1) {
6652
- let growthDelta_1 = MathUtil.subUnderflowU128(rewardersInside[1], new import_bn17.default(position.reward_growth_inside_1));
6653
- if (growthDelta_1.gt(new import_bn17.default("3402823669209384634633745948738404"))) {
6742
+ let growthDelta_1 = MathUtil.subUnderflowU128(rewardersInside[1], new import_bn18.default(position.reward_growth_inside_1));
6743
+ if (growthDelta_1.gt(new import_bn18.default("3402823669209384634633745948738404"))) {
6654
6744
  growthDelta_1 = ONE;
6655
6745
  }
6656
- const amountOwed_1 = MathUtil.checkMulShiftRight(new import_bn17.default(position.liquidity), growthDelta_1, 64, 128);
6746
+ const amountOwed_1 = MathUtil.checkMulShiftRight(new import_bn18.default(position.liquidity), growthDelta_1, 64, 128);
6657
6747
  growthInside.push(rewardersInside[1]);
6658
6748
  AmountOwed.push({
6659
- amount_owed: new import_bn17.default(position.reward_amount_owed_1).add(amountOwed_1),
6749
+ amount_owed: new import_bn18.default(position.reward_amount_owed_1).add(amountOwed_1),
6660
6750
  coin_address: pool.rewarder_infos[1].coinAddress
6661
6751
  });
6662
6752
  }
6663
6753
  if (rewardersInside.length > 2) {
6664
- let growthDelta_2 = MathUtil.subUnderflowU128(rewardersInside[2], new import_bn17.default(position.reward_growth_inside_2));
6665
- if (growthDelta_2.gt(new import_bn17.default("3402823669209384634633745948738404"))) {
6754
+ let growthDelta_2 = MathUtil.subUnderflowU128(rewardersInside[2], new import_bn18.default(position.reward_growth_inside_2));
6755
+ if (growthDelta_2.gt(new import_bn18.default("3402823669209384634633745948738404"))) {
6666
6756
  growthDelta_2 = ONE;
6667
6757
  }
6668
- const amountOwed_2 = MathUtil.checkMulShiftRight(new import_bn17.default(position.liquidity), growthDelta_2, 64, 128);
6758
+ const amountOwed_2 = MathUtil.checkMulShiftRight(new import_bn18.default(position.liquidity), growthDelta_2, 64, 128);
6669
6759
  growthInside.push(rewardersInside[2]);
6670
6760
  AmountOwed.push({
6671
- amount_owed: new import_bn17.default(position.reward_amount_owed_2).add(amountOwed_2),
6761
+ amount_owed: new import_bn18.default(position.reward_amount_owed_2).add(amountOwed_2),
6672
6762
  coin_address: pool.rewarder_infos[2].coinAddress
6673
6763
  });
6674
6764
  }
@@ -6782,8 +6872,8 @@ var RewarderModule = class {
6782
6872
  for (let i = 0; i < valueData.length; i += 1) {
6783
6873
  const { parsedJson } = valueData[i];
6784
6874
  const posRrewarderResult = {
6785
- feeOwedA: new import_bn17.default(parsedJson.fee_owned_a),
6786
- feeOwedB: new import_bn17.default(parsedJson.fee_owned_b),
6875
+ feeOwedA: new import_bn18.default(parsedJson.fee_owned_a),
6876
+ feeOwedB: new import_bn18.default(parsedJson.fee_owned_b),
6787
6877
  position_id: parsedJson.position_id
6788
6878
  };
6789
6879
  result.push(posRrewarderResult);
@@ -6846,7 +6936,7 @@ var RewarderModule = class {
6846
6936
  };
6847
6937
  for (let j = 0; j < params[i].rewarderInfo.length; j += 1) {
6848
6938
  posRrewarderResult.rewarderAmountOwed.push({
6849
- amount_owed: new import_bn17.default(valueData[i].parsedJson.data[j]),
6939
+ amount_owed: new import_bn18.default(valueData[i].parsedJson.data[j]),
6850
6940
  coin_address: params[i].rewarderInfo[j].coinAddress
6851
6941
  });
6852
6942
  }
@@ -7005,7 +7095,7 @@ var RewarderModule = class {
7005
7095
  };
7006
7096
 
7007
7097
  // src/modules/routerModule.ts
7008
- var import_bn18 = __toESM(require("bn.js"));
7098
+ var import_bn19 = __toESM(require("bn.js"));
7009
7099
  var import_cc_graph = require("@syntsugar/cc-graph");
7010
7100
  var import_transactions7 = require("@mysten/sui/transactions");
7011
7101
  function _pairSymbol(base, quote) {
@@ -7287,8 +7377,8 @@ var RouterModule = class {
7287
7377
  if (swapWithMultiPoolParams != null) {
7288
7378
  const preSwapResult2 = await this.sdk.Swap.preSwapWithMultiPool(swapWithMultiPoolParams);
7289
7379
  const onePath2 = {
7290
- amountIn: new import_bn18.default(preSwapResult2.estimatedAmountIn),
7291
- amountOut: new import_bn18.default(preSwapResult2.estimatedAmountOut),
7380
+ amountIn: new import_bn19.default(preSwapResult2.estimatedAmountIn),
7381
+ amountOut: new import_bn19.default(preSwapResult2.estimatedAmountOut),
7292
7382
  poolAddress: [preSwapResult2.poolAddress],
7293
7383
  a2b: [preSwapResult2.aToB],
7294
7384
  rawAmountLimit: byAmountIn ? [preSwapResult2.estimatedAmountOut] : [preSwapResult2.estimatedAmountIn],
@@ -7301,8 +7391,8 @@ var RouterModule = class {
7301
7391
  priceSlippagePoint
7302
7392
  };
7303
7393
  const result2 = {
7304
- amountIn: new import_bn18.default(preSwapResult2.estimatedAmountIn),
7305
- amountOut: new import_bn18.default(preSwapResult2.estimatedAmountOut),
7394
+ amountIn: new import_bn19.default(preSwapResult2.estimatedAmountIn),
7395
+ amountOut: new import_bn19.default(preSwapResult2.estimatedAmountOut),
7306
7396
  paths: [onePath2],
7307
7397
  a2b: preSwapResult2.aToB,
7308
7398
  b2c: void 0,
@@ -7324,8 +7414,8 @@ var RouterModule = class {
7324
7414
  if (swapWithMultiPoolParams != null) {
7325
7415
  const preSwapResult2 = await this.sdk.Swap.preSwapWithMultiPool(swapWithMultiPoolParams);
7326
7416
  const onePath2 = {
7327
- amountIn: new import_bn18.default(preSwapResult2.estimatedAmountIn),
7328
- amountOut: new import_bn18.default(preSwapResult2.estimatedAmountOut),
7417
+ amountIn: new import_bn19.default(preSwapResult2.estimatedAmountIn),
7418
+ amountOut: new import_bn19.default(preSwapResult2.estimatedAmountOut),
7329
7419
  poolAddress: [preSwapResult2.poolAddress],
7330
7420
  a2b: [preSwapResult2.aToB],
7331
7421
  rawAmountLimit: byAmountIn ? [preSwapResult2.estimatedAmountOut] : [preSwapResult2.estimatedAmountIn],
@@ -7338,8 +7428,8 @@ var RouterModule = class {
7338
7428
  priceSlippagePoint
7339
7429
  };
7340
7430
  const result3 = {
7341
- amountIn: new import_bn18.default(preSwapResult2.estimatedAmountIn),
7342
- amountOut: new import_bn18.default(preSwapResult2.estimatedAmountOut),
7431
+ amountIn: new import_bn19.default(preSwapResult2.estimatedAmountIn),
7432
+ amountOut: new import_bn19.default(preSwapResult2.estimatedAmountOut),
7343
7433
  paths: [onePath2],
7344
7434
  a2b: preSwapResult2.aToB,
7345
7435
  b2c: void 0,
@@ -7420,8 +7510,8 @@ var RouterModule = class {
7420
7510
  if (swapWithMultiPoolParams != null) {
7421
7511
  const preSwapResult = await this.sdk.Swap.preSwapWithMultiPool(swapWithMultiPoolParams);
7422
7512
  const onePath = {
7423
- amountIn: new import_bn18.default(preSwapResult.estimatedAmountIn),
7424
- amountOut: new import_bn18.default(preSwapResult.estimatedAmountOut),
7513
+ amountIn: new import_bn19.default(preSwapResult.estimatedAmountIn),
7514
+ amountOut: new import_bn19.default(preSwapResult.estimatedAmountOut),
7425
7515
  poolAddress: [preSwapResult.poolAddress],
7426
7516
  a2b: [preSwapResult.aToB],
7427
7517
  rawAmountLimit: byAmountIn ? [preSwapResult.estimatedAmountOut] : [preSwapResult.estimatedAmountIn],
@@ -7434,8 +7524,8 @@ var RouterModule = class {
7434
7524
  priceSlippagePoint
7435
7525
  };
7436
7526
  const result = {
7437
- amountIn: new import_bn18.default(preSwapResult.estimatedAmountIn),
7438
- amountOut: new import_bn18.default(preSwapResult.estimatedAmountOut),
7527
+ amountIn: new import_bn19.default(preSwapResult.estimatedAmountIn),
7528
+ amountOut: new import_bn19.default(preSwapResult.estimatedAmountOut),
7439
7529
  paths: [onePath],
7440
7530
  a2b: preSwapResult.aToB,
7441
7531
  b2c: void 0,
@@ -7519,13 +7609,13 @@ var RouterModule = class {
7519
7609
  continue;
7520
7610
  }
7521
7611
  if (params[0].byAmountIn) {
7522
- const amount = new import_bn18.default(valueData[i].parsedJson.data.amount_out);
7612
+ const amount = new import_bn19.default(valueData[i].parsedJson.data.amount_out);
7523
7613
  if (amount.gt(tempMaxAmount)) {
7524
7614
  tempIndex = i;
7525
7615
  tempMaxAmount = amount;
7526
7616
  }
7527
7617
  } else {
7528
- const amount = params[i].stepNums > 1 ? new import_bn18.default(valueData[i].parsedJson.data.amount_in) : new import_bn18.default(valueData[i].parsedJson.data.amount_in).add(new import_bn18.default(valueData[i].parsedJson.data.fee_amount));
7618
+ const amount = params[i].stepNums > 1 ? new import_bn19.default(valueData[i].parsedJson.data.amount_in) : new import_bn19.default(valueData[i].parsedJson.data.amount_in).add(new import_bn19.default(valueData[i].parsedJson.data.fee_amount));
7529
7619
  if (amount.lt(tempMaxAmount)) {
7530
7620
  tempIndex = i;
7531
7621
  tempMaxAmount = amount;
@@ -7595,7 +7685,7 @@ var RouterModule = class {
7595
7685
  };
7596
7686
 
7597
7687
  // src/modules/swapModule.ts
7598
- var import_bn19 = __toESM(require("bn.js"));
7688
+ var import_bn20 = __toESM(require("bn.js"));
7599
7689
  var import_decimal11 = __toESM(require("decimal.js"));
7600
7690
  var import_transactions8 = require("@mysten/sui/transactions");
7601
7691
  var AMM_SWAP_MODULE = "amm_swap";
@@ -7711,13 +7801,13 @@ var SwapModule = class {
7711
7801
  continue;
7712
7802
  }
7713
7803
  if (params.byAmountIn) {
7714
- const amount = new import_bn19.default(valueData[i].parsedJson.data.amount_out);
7804
+ const amount = new import_bn20.default(valueData[i].parsedJson.data.amount_out);
7715
7805
  if (amount.gt(tempMaxAmount)) {
7716
7806
  tempIndex = i;
7717
7807
  tempMaxAmount = amount;
7718
7808
  }
7719
7809
  } else {
7720
- const amount = new import_bn19.default(valueData[i].parsedJson.data.amount_out);
7810
+ const amount = new import_bn20.default(valueData[i].parsedJson.data.amount_out);
7721
7811
  if (amount.lt(tempMaxAmount)) {
7722
7812
  tempIndex = i;
7723
7813
  tempMaxAmount = amount;
@@ -7781,7 +7871,7 @@ var SwapModule = class {
7781
7871
  return this.transformSwapData(params, valueData[0].parsedJson.data);
7782
7872
  }
7783
7873
  transformSwapData(params, data) {
7784
- const estimatedAmountIn = data.amount_in && data.fee_amount ? new import_bn19.default(data.amount_in).add(new import_bn19.default(data.fee_amount)).toString() : "";
7874
+ const estimatedAmountIn = data.amount_in && data.fee_amount ? new import_bn20.default(data.amount_in).add(new import_bn20.default(data.fee_amount)).toString() : "";
7785
7875
  return {
7786
7876
  poolAddress: params.pool.poolAddress,
7787
7877
  currentSqrtPrice: params.currentSqrtPrice,
@@ -7798,7 +7888,7 @@ var SwapModule = class {
7798
7888
  transformSwapWithMultiPoolData(params, jsonData) {
7799
7889
  const { data } = jsonData;
7800
7890
  console.log("json data. ", data);
7801
- const estimatedAmountIn = data.amount_in && data.fee_amount ? new import_bn19.default(data.amount_in).add(new import_bn19.default(data.fee_amount)).toString() : "";
7891
+ const estimatedAmountIn = data.amount_in && data.fee_amount ? new import_bn20.default(data.amount_in).add(new import_bn20.default(data.fee_amount)).toString() : "";
7802
7892
  return {
7803
7893
  poolAddress: params.poolAddress,
7804
7894
  estimatedAmountIn,
@@ -9311,7 +9401,7 @@ var TokenModule = class {
9311
9401
  };
9312
9402
 
9313
9403
  // src/modules/routerModuleV2.ts
9314
- var import_bn20 = __toESM(require("bn.js"));
9404
+ var import_bn21 = __toESM(require("bn.js"));
9315
9405
  var import_decimal12 = __toESM(require("decimal.js"));
9316
9406
  var import_uuid = require("uuid");
9317
9407
  var import_axios = __toESM(require("axios"));
@@ -9355,12 +9445,12 @@ var RouterModuleV2 = class {
9355
9445
  outputAmount: basePath.output_amount,
9356
9446
  inputAmount: basePath.input_amount,
9357
9447
  feeRate: basePath.fee_rate,
9358
- currentSqrtPrice: new import_bn20.default(basePath.current_sqrt_price.toString()),
9359
- afterSqrtPrice: basePath.label === "Magma" ? new import_bn20.default(basePath.after_sqrt_price.toString()) : ZERO,
9448
+ currentSqrtPrice: new import_bn21.default(basePath.current_sqrt_price.toString()),
9449
+ afterSqrtPrice: basePath.label === "Magma" ? new import_bn21.default(basePath.after_sqrt_price.toString()) : ZERO,
9360
9450
  fromDecimal: basePath.from_decimal,
9361
9451
  toDecimal: basePath.to_decimal,
9362
9452
  currentPrice: this.calculatePrice(
9363
- new import_bn20.default(basePath.current_sqrt_price.toString()),
9453
+ new import_bn21.default(basePath.current_sqrt_price.toString()),
9364
9454
  basePath.from_decimal,
9365
9455
  basePath.to_decimal,
9366
9456
  basePath.direction,
@@ -9443,7 +9533,7 @@ var RouterModuleV2 = class {
9443
9533
  const priceResult = await this.sdk.Router.priceUseV1(
9444
9534
  from,
9445
9535
  to,
9446
- new import_bn20.default(amount),
9536
+ new import_bn21.default(amount),
9447
9537
  byAmountIn,
9448
9538
  priceSplitPoint,
9449
9539
  partner,
@@ -9455,7 +9545,7 @@ var RouterModuleV2 = class {
9455
9545
  if (path.poolAddress.length > 1) {
9456
9546
  const fromDecimal0 = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
9457
9547
  const toDecimal0 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
9458
- const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[0]), fromDecimal0, toDecimal0) : TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[0]), toDecimal0, fromDecimal0);
9548
+ const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[0]), fromDecimal0, toDecimal0) : TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[0]), toDecimal0, fromDecimal0);
9459
9549
  const path0 = {
9460
9550
  direction: path.a2b[0],
9461
9551
  label: "Magma",
@@ -9472,7 +9562,7 @@ var RouterModuleV2 = class {
9472
9562
  };
9473
9563
  const fromDecimal1 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
9474
9564
  const toDecimal1 = this.sdk.Router.tokenInfo(path.coinType[2]).decimals;
9475
- const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[1]), fromDecimal1, toDecimal1) : TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[1]), toDecimal1, fromDecimal1);
9565
+ const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[1]), fromDecimal1, toDecimal1) : TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[1]), toDecimal1, fromDecimal1);
9476
9566
  const path1 = {
9477
9567
  direction: path.a2b[1],
9478
9568
  label: "Magma",
@@ -9491,7 +9581,7 @@ var RouterModuleV2 = class {
9491
9581
  } else {
9492
9582
  const fromDecimal = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
9493
9583
  const toDecimal = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
9494
- const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[0]), fromDecimal, toDecimal) : TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[0]), toDecimal, fromDecimal);
9584
+ const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[0]), fromDecimal, toDecimal) : TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[0]), toDecimal, fromDecimal);
9495
9585
  const path0 = {
9496
9586
  direction: path.a2b[0],
9497
9587
  label: "Magma",
@@ -9576,7 +9666,7 @@ var RouterModuleV2 = class {
9576
9666
  const priceResult = await this.sdk.Router.priceUseV1(
9577
9667
  from,
9578
9668
  to,
9579
- new import_bn20.default(amount),
9669
+ new import_bn21.default(amount),
9580
9670
  byAmountIn,
9581
9671
  priceSplitPoint,
9582
9672
  partner,
@@ -9588,7 +9678,7 @@ var RouterModuleV2 = class {
9588
9678
  if (path.poolAddress.length > 1) {
9589
9679
  const fromDecimal0 = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
9590
9680
  const toDecimal0 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
9591
- const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[0]), fromDecimal0, toDecimal0) : TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[0]), toDecimal0, fromDecimal0);
9681
+ const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[0]), fromDecimal0, toDecimal0) : TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[0]), toDecimal0, fromDecimal0);
9592
9682
  const path0 = {
9593
9683
  direction: path.a2b[0],
9594
9684
  label: "Magma",
@@ -9605,7 +9695,7 @@ var RouterModuleV2 = class {
9605
9695
  };
9606
9696
  const fromDecimal1 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
9607
9697
  const toDecimal1 = this.sdk.Router.tokenInfo(path.coinType[2]).decimals;
9608
- const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[1]), fromDecimal1, toDecimal1) : TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[1]), toDecimal1, fromDecimal1);
9698
+ const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[1]), fromDecimal1, toDecimal1) : TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[1]), toDecimal1, fromDecimal1);
9609
9699
  const path1 = {
9610
9700
  direction: path.a2b[1],
9611
9701
  label: "Magma",
@@ -9624,7 +9714,7 @@ var RouterModuleV2 = class {
9624
9714
  } else {
9625
9715
  const fromDecimal = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
9626
9716
  const toDecimal = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
9627
- const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[0]), fromDecimal, toDecimal) : TickMath.sqrtPriceX64ToPrice(new import_bn20.default(priceResult.currentSqrtPrice[0]), toDecimal, fromDecimal);
9717
+ const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[0]), fromDecimal, toDecimal) : TickMath.sqrtPriceX64ToPrice(new import_bn21.default(priceResult.currentSqrtPrice[0]), toDecimal, fromDecimal);
9628
9718
  const path0 = {
9629
9719
  direction: path.a2b[0],
9630
9720
  label: "Magma",