@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/dist/index.d.cts
CHANGED
|
@@ -15257,6 +15257,7 @@ declare function calculateBaseToQuoteFromAmountIn(configState: {
|
|
|
15257
15257
|
sqrtPrice: BN$1;
|
|
15258
15258
|
liquidity: BN$1;
|
|
15259
15259
|
}>;
|
|
15260
|
+
sqrtStartPrice: BN$1;
|
|
15260
15261
|
}, currentSqrtPrice: BN$1, amountIn: BN$1): SwapAmount;
|
|
15261
15262
|
/**
|
|
15262
15263
|
* Calculate output amount from quote to base from amount in
|
package/dist/index.d.ts
CHANGED
|
@@ -15257,6 +15257,7 @@ declare function calculateBaseToQuoteFromAmountIn(configState: {
|
|
|
15257
15257
|
sqrtPrice: BN$1;
|
|
15258
15258
|
liquidity: BN$1;
|
|
15259
15259
|
}>;
|
|
15260
|
+
sqrtStartPrice: BN$1;
|
|
15260
15261
|
}, currentSqrtPrice: BN$1, amountIn: BN$1): SwapAmount;
|
|
15261
15262
|
/**
|
|
15262
15263
|
* Calculate output amount from quote to base from amount in
|
package/dist/index.js
CHANGED
|
@@ -2626,6 +2626,13 @@ function calculateBaseToQuoteFromAmountIn(configState, currentSqrtPrice, amountI
|
|
|
2626
2626
|
amountLeft: new BN12(0)
|
|
2627
2627
|
};
|
|
2628
2628
|
}
|
|
2629
|
+
if (currentSqrtPrice.eq(configState.sqrtStartPrice)) {
|
|
2630
|
+
return {
|
|
2631
|
+
outputAmount: new BN12(0),
|
|
2632
|
+
nextSqrtPrice: currentSqrtPrice,
|
|
2633
|
+
amountLeft: amountIn
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2629
2636
|
let totalOutputAmount = new BN12(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 BN12(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 BN12(0)
|
|
2718
|
+
nextSqrtPrice: currentSqrtPriceLocal
|
|
2700
2719
|
};
|
|
2701
2720
|
}
|
|
2702
2721
|
function calculateQuoteToBaseFromAmountIn(configState, currentSqrtPrice, amountIn, stopSqrtPrice) {
|