@meteora-ag/dlmm 1.0.21 → 1.0.22

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.mjs CHANGED
@@ -4941,8 +4941,8 @@ function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBi
4941
4941
  totalWeightX = totalWeightX.add(weighPerPrice);
4942
4942
  }
4943
4943
  });
4944
- const kx = new Decimal(amountX.toNumber()).div(totalWeightX);
4945
- const ky = new Decimal(amountY.toNumber()).div(totalWeightY);
4944
+ const kx = new Decimal(amountX.toString()).div(totalWeightX);
4945
+ const ky = new Decimal(amountY.toString()).div(totalWeightY);
4946
4946
  let k = kx.lessThan(ky) ? kx : ky;
4947
4947
  return distributions.map((bin) => {
4948
4948
  if (bin.binId < activeId) {
@@ -4950,7 +4950,7 @@ function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBi
4950
4950
  return {
4951
4951
  binId: bin.binId,
4952
4952
  amountX: new BN4(0),
4953
- amountY: new BN4(Math.floor(amount.toNumber()))
4953
+ amountY: new BN4(amount.floor().toString())
4954
4954
  };
4955
4955
  }
4956
4956
  if (bin.binId > activeId) {
@@ -4959,7 +4959,7 @@ function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBi
4959
4959
  const amount = k.mul(weighPerPrice);
4960
4960
  return {
4961
4961
  binId: bin.binId,
4962
- amountX: new BN4(Math.floor(amount.toNumber())),
4962
+ amountX: new BN4(amount.floor().toString()),
4963
4963
  amountY: new BN4(0)
4964
4964
  };
4965
4965
  }
@@ -4967,8 +4967,8 @@ function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBi
4967
4967
  const amountYActiveBin = k.mul(wy0);
4968
4968
  return {
4969
4969
  binId: bin.binId,
4970
- amountX: new BN4(Math.floor(amountXActiveBin.toNumber())),
4971
- amountY: new BN4(Math.floor(amountYActiveBin.toNumber()))
4970
+ amountX: new BN4(amountXActiveBin.floor().toString()),
4971
+ amountY: new BN4(amountYActiveBin.floor().toString())
4972
4972
  };
4973
4973
  });
4974
4974
  } else {
@@ -4983,8 +4983,8 @@ function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBi
4983
4983
  totalWeightX = totalWeightX.add(weighPerPrice);
4984
4984
  }
4985
4985
  });
4986
- let kx = new Decimal(amountX.toNumber()).div(totalWeightX);
4987
- let ky = new Decimal(amountY.toNumber()).div(totalWeightY);
4986
+ let kx = new Decimal(amountX.toString()).div(totalWeightX);
4987
+ let ky = new Decimal(amountY.toString()).div(totalWeightY);
4988
4988
  let k = kx.lessThan(ky) ? kx : ky;
4989
4989
  return distributions.map((bin) => {
4990
4990
  if (bin.binId < activeId) {
@@ -4992,7 +4992,7 @@ function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBi
4992
4992
  return {
4993
4993
  binId: bin.binId,
4994
4994
  amountX: new BN4(0),
4995
- amountY: new BN4(Math.floor(amount.toNumber()))
4995
+ amountY: new BN4(amount.floor().toString())
4996
4996
  };
4997
4997
  } else {
4998
4998
  let price = getPriceOfBinByBinId(bin.binId, binStep);
@@ -5000,7 +5000,7 @@ function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBi
5000
5000
  const amount = k.mul(weighPerPrice);
5001
5001
  return {
5002
5002
  binId: bin.binId,
5003
- amountX: new BN4(Math.floor(amount.toNumber())),
5003
+ amountX: new BN4(amount.floor().toString()),
5004
5004
  amountY: new BN4(0)
5005
5005
  };
5006
5006
  }
@@ -5122,7 +5122,7 @@ function autoFillXByWeight(activeId, binStep, amountY, amountXInActiveBin, amoun
5122
5122
  totalWeightX = totalWeightX.add(weighPerPrice);
5123
5123
  }
5124
5124
  });
5125
- const ky = totalWeightY.isZero() ? new Decimal(1) : new Decimal(amountY.toNumber()).div(totalWeightY);
5125
+ const ky = totalWeightY.isZero() ? new Decimal(1) : new Decimal(amountY.toString()).div(totalWeightY);
5126
5126
  const amountX = ky.mul(totalWeightX);
5127
5127
  return new BN4(amountX.floor().toString());
5128
5128
  }