@meteora-ag/dynamic-bonding-curve-sdk 1.5.0 → 1.5.1
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/README.md +1 -1
- package/dist/index.cjs +22 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ The generic flow of how Dynamic Bonding Curve works is as follows:
|
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
63
|
cd packages/dynamic-bonding-curve
|
|
64
|
-
|
|
64
|
+
pnpm start-validator
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
2. Run the tests
|
package/dist/index.cjs
CHANGED
|
@@ -2626,6 +2626,13 @@ function calculateBaseToQuoteFromAmountIn(configState, currentSqrtPrice, amountI
|
|
|
2626
2626
|
amountLeft: new (0, _bnjs2.default)(0)
|
|
2627
2627
|
};
|
|
2628
2628
|
}
|
|
2629
|
+
if (currentSqrtPrice.eq(configState.sqrtStartPrice)) {
|
|
2630
|
+
return {
|
|
2631
|
+
outputAmount: new (0, _bnjs2.default)(0),
|
|
2632
|
+
nextSqrtPrice: currentSqrtPrice,
|
|
2633
|
+
amountLeft: amountIn
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2629
2636
|
let totalOutputAmount = new (0, _bnjs2.default)(0);
|
|
2630
2637
|
let currentSqrtPriceLocal = currentSqrtPrice;
|
|
2631
2638
|
let amountLeft = amountIn;
|
|
@@ -2678,12 +2685,24 @@ function calculateBaseToQuoteFromAmountIn(configState, currentSqrtPrice, amountI
|
|
|
2678
2685
|
}
|
|
2679
2686
|
}
|
|
2680
2687
|
if (!amountLeft.isZero()) {
|
|
2681
|
-
|
|
2688
|
+
let nextSqrtPrice = getNextSqrtPriceFromInput(
|
|
2682
2689
|
currentSqrtPriceLocal,
|
|
2683
2690
|
configState.curve[0].liquidity,
|
|
2684
2691
|
amountLeft,
|
|
2685
2692
|
true
|
|
2686
2693
|
);
|
|
2694
|
+
if (nextSqrtPrice.lt(configState.sqrtStartPrice)) {
|
|
2695
|
+
nextSqrtPrice = configState.sqrtStartPrice;
|
|
2696
|
+
const amountIn2 = getDeltaAmountBaseUnsigned(
|
|
2697
|
+
nextSqrtPrice,
|
|
2698
|
+
currentSqrtPriceLocal,
|
|
2699
|
+
configState.curve[0].liquidity,
|
|
2700
|
+
0 /* Up */
|
|
2701
|
+
);
|
|
2702
|
+
amountLeft = SafeMath.sub(amountLeft, amountIn2);
|
|
2703
|
+
} else {
|
|
2704
|
+
amountLeft = new (0, _bnjs2.default)(0);
|
|
2705
|
+
}
|
|
2687
2706
|
const outputAmount = getDeltaAmountQuoteUnsigned(
|
|
2688
2707
|
nextSqrtPrice,
|
|
2689
2708
|
currentSqrtPriceLocal,
|
|
@@ -2694,9 +2713,9 @@ function calculateBaseToQuoteFromAmountIn(configState, currentSqrtPrice, amountI
|
|
|
2694
2713
|
currentSqrtPriceLocal = nextSqrtPrice;
|
|
2695
2714
|
}
|
|
2696
2715
|
return {
|
|
2716
|
+
amountLeft,
|
|
2697
2717
|
outputAmount: totalOutputAmount,
|
|
2698
|
-
nextSqrtPrice: currentSqrtPriceLocal
|
|
2699
|
-
amountLeft: new (0, _bnjs2.default)(0)
|
|
2718
|
+
nextSqrtPrice: currentSqrtPriceLocal
|
|
2700
2719
|
};
|
|
2701
2720
|
}
|
|
2702
2721
|
function calculateQuoteToBaseFromAmountIn(configState, currentSqrtPrice, amountIn, stopSqrtPrice) {
|