@raydium-io/raydium-sdk-v2 0.1.56-alpha → 0.1.57-alpha

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raydium-io/raydium-sdk-v2",
3
- "version": "0.1.56-alpha",
3
+ "version": "0.1.57-alpha",
4
4
  "description": "An SDK for building applications on top of Raydium.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./lib/index.js",
@@ -742,20 +742,23 @@ export default class LiquidityModule extends ModuleBase {
742
742
  const { baseReserve, quoteReserve } = poolInfo;
743
743
 
744
744
  const reserves = [baseReserve, quoteReserve];
745
+ const mintDecimals = [poolInfo.mintA.decimals, poolInfo.mintB.decimals];
745
746
 
746
747
  // input is fixed
747
748
  const input = mintIn == poolInfo.mintA.address ? "base" : "quote";
748
749
  if (input === "quote") {
749
750
  reserves.reverse();
751
+ mintDecimals.reverse();
750
752
  }
751
753
 
752
754
  const [reserveIn, reserveOut] = reserves;
755
+ const [mintInDecimals, mintOutDecimals] = mintDecimals;
753
756
  const isVersion4 = poolInfo.version === 4;
754
757
  let currentPrice: Decimal;
755
758
  if (isVersion4) {
756
759
  currentPrice = new Decimal(reserveOut.toString())
757
- .div(10 ** poolInfo.mintB.decimals)
758
- .div(new Decimal(reserveIn.toString()).div(10 ** poolInfo.mintA.decimals));
760
+ .div(10 ** mintOutDecimals)
761
+ .div(new Decimal(reserveIn.toString()).div(10 ** mintInDecimals));
759
762
  } else {
760
763
  const p = getStablePrice(
761
764
  this.stableLayout.stableModelData,
@@ -813,8 +816,8 @@ export default class LiquidityModule extends ModuleBase {
813
816
  );
814
817
  if (!amountInRaw.isZero() && !amountOutRaw.isZero()) {
815
818
  executionPrice = new Decimal(amountOutRaw.toString())
816
- .div(10 ** poolInfo.mintB.decimals)
817
- .div(new Decimal(amountInRaw.sub(feeRaw).toString()).div(10 ** poolInfo.mintA.decimals));
819
+ .div(10 ** mintOutDecimals)
820
+ .div(new Decimal(amountInRaw.sub(feeRaw).toString()).div(10 ** mintInDecimals));
818
821
  }
819
822
 
820
823
  const priceImpact = currentPrice.sub(executionPrice).div(currentPrice).mul(100);