@drift-labs/sdk 2.33.1-beta.2 → 2.33.1-beta.3
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/idl/drift.json +5 -2
- package/lib/math/oracles.js +2 -3
- package/lib/types.d.ts +2 -2
- package/package.json +1 -1
- package/src/idl/drift.json +5 -2
- package/src/math/oracles.ts +7 -7
- package/src/types.ts +2 -2
- package/tests/dlob/helpers.ts +2 -2
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.33.1-beta.
|
|
1
|
+
2.33.1-beta.3
|
package/lib/idl/drift.json
CHANGED
|
@@ -6900,11 +6900,11 @@
|
|
|
6900
6900
|
"kind": "struct",
|
|
6901
6901
|
"fields": [
|
|
6902
6902
|
{
|
|
6903
|
-
"name": "
|
|
6903
|
+
"name": "markOraclePercentDivergence",
|
|
6904
6904
|
"type": "u64"
|
|
6905
6905
|
},
|
|
6906
6906
|
{
|
|
6907
|
-
"name": "
|
|
6907
|
+
"name": "oracleTwap5minPercentDivergence",
|
|
6908
6908
|
"type": "u64"
|
|
6909
6909
|
}
|
|
6910
6910
|
]
|
|
@@ -7637,6 +7637,9 @@
|
|
|
7637
7637
|
{
|
|
7638
7638
|
"name": "Initial"
|
|
7639
7639
|
},
|
|
7640
|
+
{
|
|
7641
|
+
"name": "Fill"
|
|
7642
|
+
},
|
|
7640
7643
|
{
|
|
7641
7644
|
"name": "Maintenance"
|
|
7642
7645
|
}
|
package/lib/math/oracles.js
CHANGED
|
@@ -45,9 +45,8 @@ function isOracleTooDivergent(amm, oraclePriceData, oracleGuardRails, now) {
|
|
|
45
45
|
.div(sinceStart.add(sinceLastUpdate));
|
|
46
46
|
const oracleSpread = oracleTwap5min.sub(oraclePriceData.price);
|
|
47
47
|
const oracleSpreadPct = oracleSpread.mul(numericConstants_1.PRICE_PRECISION).div(oracleTwap5min);
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
.gte(numericConstants_1.BID_ASK_SPREAD_PRECISION.mul(oracleGuardRails.priceDivergence.markOracleDivergenceNumerator).div(oracleGuardRails.priceDivergence.markOracleDivergenceDenominator));
|
|
48
|
+
const maxDivergence = index_1.BN.max(oracleGuardRails.priceDivergence.markOraclePercentDivergence, numericConstants_1.PERCENTAGE_PRECISION.div(new index_1.BN(10)));
|
|
49
|
+
const tooDivergent = oracleSpreadPct.abs().gte(maxDivergence);
|
|
51
50
|
return tooDivergent;
|
|
52
51
|
}
|
|
53
52
|
exports.isOracleTooDivergent = isOracleTooDivergent;
|
package/lib/types.d.ts
CHANGED
|
@@ -1035,8 +1035,8 @@ export type OrderFillerRewardStructure = {
|
|
|
1035
1035
|
};
|
|
1036
1036
|
export type OracleGuardRails = {
|
|
1037
1037
|
priceDivergence: {
|
|
1038
|
-
|
|
1039
|
-
|
|
1038
|
+
markOraclePercentDivergence: BN;
|
|
1039
|
+
oracleTwap5MinPercentDivergence: BN;
|
|
1040
1040
|
};
|
|
1041
1041
|
validity: {
|
|
1042
1042
|
slotsBeforeStaleForAmm: BN;
|
package/package.json
CHANGED
package/src/idl/drift.json
CHANGED
|
@@ -6900,11 +6900,11 @@
|
|
|
6900
6900
|
"kind": "struct",
|
|
6901
6901
|
"fields": [
|
|
6902
6902
|
{
|
|
6903
|
-
"name": "
|
|
6903
|
+
"name": "markOraclePercentDivergence",
|
|
6904
6904
|
"type": "u64"
|
|
6905
6905
|
},
|
|
6906
6906
|
{
|
|
6907
|
-
"name": "
|
|
6907
|
+
"name": "oracleTwap5minPercentDivergence",
|
|
6908
6908
|
"type": "u64"
|
|
6909
6909
|
}
|
|
6910
6910
|
]
|
|
@@ -7637,6 +7637,9 @@
|
|
|
7637
7637
|
{
|
|
7638
7638
|
"name": "Initial"
|
|
7639
7639
|
},
|
|
7640
|
+
{
|
|
7641
|
+
"name": "Fill"
|
|
7642
|
+
},
|
|
7640
7643
|
{
|
|
7641
7644
|
"name": "Maintenance"
|
|
7642
7645
|
}
|
package/src/math/oracles.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ONE,
|
|
8
8
|
ZERO,
|
|
9
9
|
FIVE_MINUTE,
|
|
10
|
+
PERCENTAGE_PRECISION,
|
|
10
11
|
} from '../constants/numericConstants';
|
|
11
12
|
import { BN, HistoricalOracleData, PerpMarketAccount } from '../index';
|
|
12
13
|
import { assert } from '../assert/assert';
|
|
@@ -78,13 +79,12 @@ export function isOracleTooDivergent(
|
|
|
78
79
|
const oracleSpread = oracleTwap5min.sub(oraclePriceData.price);
|
|
79
80
|
const oracleSpreadPct = oracleSpread.mul(PRICE_PRECISION).div(oracleTwap5min);
|
|
80
81
|
|
|
81
|
-
const
|
|
82
|
-
.
|
|
83
|
-
.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
82
|
+
const maxDivergence = BN.max(
|
|
83
|
+
oracleGuardRails.priceDivergence.markOraclePercentDivergence,
|
|
84
|
+
PERCENTAGE_PRECISION.div(new BN(10))
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const tooDivergent = oracleSpreadPct.abs().gte(maxDivergence);
|
|
88
88
|
|
|
89
89
|
return tooDivergent;
|
|
90
90
|
}
|
package/src/types.ts
CHANGED
|
@@ -1013,8 +1013,8 @@ export type OrderFillerRewardStructure = {
|
|
|
1013
1013
|
|
|
1014
1014
|
export type OracleGuardRails = {
|
|
1015
1015
|
priceDivergence: {
|
|
1016
|
-
|
|
1017
|
-
|
|
1016
|
+
markOraclePercentDivergence: BN;
|
|
1017
|
+
oracleTwap5MinPercentDivergence: BN;
|
|
1018
1018
|
};
|
|
1019
1019
|
validity: {
|
|
1020
1020
|
slotsBeforeStaleForAmm: BN;
|
package/tests/dlob/helpers.ts
CHANGED
|
@@ -511,8 +511,8 @@ export const mockStateAccount: StateAccount = {
|
|
|
511
511
|
liquidationDuration: 0,
|
|
512
512
|
oracleGuardRails: {
|
|
513
513
|
priceDivergence: {
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
markOraclePercentDivergence: new BN(0),
|
|
515
|
+
oracleTwap5MinPercentDivergence: new BN(0),
|
|
516
516
|
},
|
|
517
517
|
validity: {
|
|
518
518
|
slotsBeforeStaleForAmm: new BN(0),
|