@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/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/raydium/index.js +1 -1
- package/lib/raydium/index.js.map +1 -1
- package/lib/raydium/index.mjs +1 -1
- package/lib/raydium/index.mjs.map +1 -1
- package/lib/raydium/liquidity/liquidity.js +1 -1
- package/lib/raydium/liquidity/liquidity.js.map +1 -1
- package/lib/raydium/liquidity/liquidity.mjs +1 -1
- package/lib/raydium/liquidity/liquidity.mjs.map +1 -1
- package/lib/raydium/raydium.js +1 -1
- package/lib/raydium/raydium.js.map +1 -1
- package/lib/raydium/raydium.mjs +1 -1
- package/lib/raydium/raydium.mjs.map +1 -1
- package/package.json +1 -1
- package/src/raydium/liquidity/liquidity.ts +7 -4
package/package.json
CHANGED
|
@@ -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 **
|
|
758
|
-
.div(new Decimal(reserveIn.toString()).div(10 **
|
|
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 **
|
|
817
|
-
.div(new Decimal(amountInRaw.sub(feeRaw).toString()).div(10 **
|
|
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);
|