@drift-labs/sdk 2.63.0-beta.0 → 2.63.0-beta.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/VERSION +1 -1
- package/lib/math/amm.js +5 -1
- package/package.json +1 -1
- package/src/math/amm.ts +13 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.63.0-beta.
|
|
1
|
+
2.63.0-beta.1
|
package/lib/math/amm.js
CHANGED
|
@@ -339,7 +339,11 @@ function calculateSpreadBN(baseSpread, lastOracleReservePriceSpreadPct, lastOrac
|
|
|
339
339
|
}
|
|
340
340
|
spreadTerms.longSpreadwPS = longSpread;
|
|
341
341
|
spreadTerms.shortSpreadwPS = shortSpread;
|
|
342
|
-
const
|
|
342
|
+
const maxSpreadBaseline = Math.min(Math.max(lastOracleReservePriceSpreadPct.abs().toNumber(), lastOracleConfPct.muln(2).toNumber(), anchor_1.BN.max(markStd, oracleStd)
|
|
343
|
+
.mul(numericConstants_1.PERCENTAGE_PRECISION)
|
|
344
|
+
.div(reservePrice)
|
|
345
|
+
.toNumber()), numericConstants_1.BID_ASK_SPREAD_PRECISION.toNumber());
|
|
346
|
+
const maxTargetSpread = Math.floor(Math.max(maxSpread, maxSpreadBaseline));
|
|
343
347
|
const inventorySpreadScale = calculateInventoryScale(baseAssetAmountWithAmm, baseAssetReserve, minBaseAssetReserve, maxBaseAssetReserve, baseAssetAmountWithAmm.gt(numericConstants_1.ZERO) ? longSpread : shortSpread, maxTargetSpread);
|
|
344
348
|
if (baseAssetAmountWithAmm.gt(numericConstants_1.ZERO)) {
|
|
345
349
|
longSpread *= inventorySpreadScale;
|
package/package.json
CHANGED
package/src/math/amm.ts
CHANGED
|
@@ -658,8 +658,20 @@ export function calculateSpreadBN(
|
|
|
658
658
|
spreadTerms.longSpreadwPS = longSpread;
|
|
659
659
|
spreadTerms.shortSpreadwPS = shortSpread;
|
|
660
660
|
|
|
661
|
+
const maxSpreadBaseline = Math.min(
|
|
662
|
+
Math.max(
|
|
663
|
+
lastOracleReservePriceSpreadPct.abs().toNumber(),
|
|
664
|
+
lastOracleConfPct.muln(2).toNumber(),
|
|
665
|
+
BN.max(markStd, oracleStd)
|
|
666
|
+
.mul(PERCENTAGE_PRECISION)
|
|
667
|
+
.div(reservePrice)
|
|
668
|
+
.toNumber()
|
|
669
|
+
),
|
|
670
|
+
BID_ASK_SPREAD_PRECISION.toNumber()
|
|
671
|
+
);
|
|
672
|
+
|
|
661
673
|
const maxTargetSpread: number = Math.floor(
|
|
662
|
-
Math.max(maxSpread,
|
|
674
|
+
Math.max(maxSpread, maxSpreadBaseline)
|
|
663
675
|
);
|
|
664
676
|
|
|
665
677
|
const inventorySpreadScale = calculateInventoryScale(
|