@drift-labs/sdk 2.40.0-beta.3 → 2.40.0-beta.4
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 +7 -2
- package/package.json +1 -1
- package/src/math/amm.ts +9 -2
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.40.0-beta.
|
|
1
|
+
2.40.0-beta.4
|
package/lib/math/amm.js
CHANGED
|
@@ -253,8 +253,13 @@ function calculateVolSpreadBN(lastOracleConfPct, reservePrice, markStd, oracleSt
|
|
|
253
253
|
const clampMax = numericConstants_1.PERCENTAGE_PRECISION.mul(new anchor_1.BN(16)).div(new anchor_1.BN(10));
|
|
254
254
|
const longVolSpreadFactor = (0, __1.clampBN)(longIntensity.mul(numericConstants_1.PERCENTAGE_PRECISION).div(anchor_1.BN.max(numericConstants_1.ONE, volume24H)), clampMin, clampMax);
|
|
255
255
|
const shortVolSpreadFactor = (0, __1.clampBN)(shortIntensity.mul(numericConstants_1.PERCENTAGE_PRECISION).div(anchor_1.BN.max(numericConstants_1.ONE, volume24H)), clampMin, clampMax);
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
// only consider confidence interval at full value when above 25 bps
|
|
257
|
+
let confComponent = lastOracleConfPct;
|
|
258
|
+
if (lastOracleConfPct.lte(numericConstants_1.PRICE_PRECISION.div(new anchor_1.BN(400)))) {
|
|
259
|
+
confComponent = lastOracleConfPct.div(new anchor_1.BN(10));
|
|
260
|
+
}
|
|
261
|
+
const longVolSpread = anchor_1.BN.max(confComponent, volSpread.mul(longVolSpreadFactor).div(numericConstants_1.PERCENTAGE_PRECISION));
|
|
262
|
+
const shortVolSpread = anchor_1.BN.max(confComponent, volSpread.mul(shortVolSpreadFactor).div(numericConstants_1.PERCENTAGE_PRECISION));
|
|
258
263
|
return [longVolSpread, shortVolSpread];
|
|
259
264
|
}
|
|
260
265
|
exports.calculateVolSpreadBN = calculateVolSpreadBN;
|
package/package.json
CHANGED
package/src/math/amm.ts
CHANGED
|
@@ -471,12 +471,19 @@ export function calculateVolSpreadBN(
|
|
|
471
471
|
clampMax
|
|
472
472
|
);
|
|
473
473
|
|
|
474
|
+
// only consider confidence interval at full value when above 25 bps
|
|
475
|
+
let confComponent = lastOracleConfPct;
|
|
476
|
+
|
|
477
|
+
if (lastOracleConfPct.lte(PRICE_PRECISION.div(new BN(400)))) {
|
|
478
|
+
confComponent = lastOracleConfPct.div(new BN(10));
|
|
479
|
+
}
|
|
480
|
+
|
|
474
481
|
const longVolSpread = BN.max(
|
|
475
|
-
|
|
482
|
+
confComponent,
|
|
476
483
|
volSpread.mul(longVolSpreadFactor).div(PERCENTAGE_PRECISION)
|
|
477
484
|
);
|
|
478
485
|
const shortVolSpread = BN.max(
|
|
479
|
-
|
|
486
|
+
confComponent,
|
|
480
487
|
volSpread.mul(shortVolSpreadFactor).div(PERCENTAGE_PRECISION)
|
|
481
488
|
);
|
|
482
489
|
|