@drift-labs/sdk 2.95.0-beta.6 → 2.95.0-beta.8
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/constants/perpMarkets.js +2 -2
- package/lib/math/auction.d.ts +5 -1
- package/lib/math/auction.js +5 -1
- package/package.json +1 -1
- package/src/constants/perpMarkets.ts +2 -2
- package/src/math/auction.ts +16 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.95.0-beta.
|
|
1
|
+
2.95.0-beta.8
|
|
@@ -373,10 +373,10 @@ exports.MainnetPerpMarkets = [
|
|
|
373
373
|
symbol: 'MATIC-PERP',
|
|
374
374
|
baseAssetSymbol: 'MATIC',
|
|
375
375
|
marketIndex: 5,
|
|
376
|
-
oracle: new web3_js_1.PublicKey('
|
|
376
|
+
oracle: new web3_js_1.PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
|
|
377
377
|
launchTs: 1677690149000,
|
|
378
378
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
379
|
-
pythFeedId: '
|
|
379
|
+
pythFeedId: '0xffd11c5a1cfd42f80afb2df4d9f264c15f956d68153335374ec10722edd70472',
|
|
380
380
|
},
|
|
381
381
|
{
|
|
382
382
|
fullName: 'Arbitrum',
|
package/lib/math/auction.d.ts
CHANGED
|
@@ -6,12 +6,16 @@ export declare function isFallbackAvailableLiquiditySource(order: Order, minAuct
|
|
|
6
6
|
export declare function getAuctionPrice(order: Order, slot: number, oraclePrice: BN): BN;
|
|
7
7
|
export declare function getAuctionPriceForFixedAuction(order: Order, slot: number): BN;
|
|
8
8
|
export declare function getAuctionPriceForOracleOffsetAuction(order: Order, slot: number, oraclePrice: BN): BN;
|
|
9
|
-
export declare function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice, auctionEndPrice, limitPrice, }: {
|
|
9
|
+
export declare function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice, auctionEndPrice, limitPrice, auctionPriceCaps, }: {
|
|
10
10
|
direction: PositionDirection;
|
|
11
11
|
oraclePrice: BN;
|
|
12
12
|
auctionStartPrice: BN;
|
|
13
13
|
auctionEndPrice: BN;
|
|
14
14
|
limitPrice: BN;
|
|
15
|
+
auctionPriceCaps?: {
|
|
16
|
+
min: BN;
|
|
17
|
+
max: BN;
|
|
18
|
+
};
|
|
15
19
|
}): {
|
|
16
20
|
auctionStartPrice: BN;
|
|
17
21
|
auctionEndPrice: BN;
|
package/lib/math/auction.js
CHANGED
|
@@ -94,7 +94,7 @@ function getAuctionPriceForOracleOffsetAuction(order, slot, oraclePrice) {
|
|
|
94
94
|
return _1.BN.max(oraclePrice.add(priceOffset), _1.ONE);
|
|
95
95
|
}
|
|
96
96
|
exports.getAuctionPriceForOracleOffsetAuction = getAuctionPriceForOracleOffsetAuction;
|
|
97
|
-
function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice, auctionEndPrice, limitPrice, }) {
|
|
97
|
+
function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice, auctionEndPrice, limitPrice, auctionPriceCaps, }) {
|
|
98
98
|
let oraclePriceOffset;
|
|
99
99
|
if (limitPrice.eq(_1.ZERO) || oraclePrice.eq(_1.ZERO)) {
|
|
100
100
|
oraclePriceOffset = _1.ZERO;
|
|
@@ -114,6 +114,10 @@ function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice,
|
|
|
114
114
|
catch (e) {
|
|
115
115
|
oraclePriceOffsetNum = 0;
|
|
116
116
|
}
|
|
117
|
+
if (auctionPriceCaps) {
|
|
118
|
+
auctionStartPrice = _1.BN.min(_1.BN.max(auctionStartPrice, auctionPriceCaps.min), auctionPriceCaps.max);
|
|
119
|
+
auctionEndPrice = _1.BN.min(_1.BN.max(auctionEndPrice, auctionPriceCaps.min), auctionPriceCaps.max);
|
|
120
|
+
}
|
|
117
121
|
return {
|
|
118
122
|
auctionStartPrice: auctionStartPrice.sub(oraclePrice),
|
|
119
123
|
auctionEndPrice: auctionEndPrice.sub(oraclePrice),
|
package/package.json
CHANGED
|
@@ -416,11 +416,11 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
416
416
|
symbol: 'MATIC-PERP',
|
|
417
417
|
baseAssetSymbol: 'MATIC',
|
|
418
418
|
marketIndex: 5,
|
|
419
|
-
oracle: new PublicKey('
|
|
419
|
+
oracle: new PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
|
|
420
420
|
launchTs: 1677690149000, //todo
|
|
421
421
|
oracleSource: OracleSource.PYTH_PULL,
|
|
422
422
|
pythFeedId:
|
|
423
|
-
'
|
|
423
|
+
'0xffd11c5a1cfd42f80afb2df4d9f264c15f956d68153335374ec10722edd70472',
|
|
424
424
|
},
|
|
425
425
|
{
|
|
426
426
|
fullName: 'Arbitrum',
|
package/src/math/auction.ts
CHANGED
|
@@ -120,12 +120,17 @@ export function deriveOracleAuctionParams({
|
|
|
120
120
|
auctionStartPrice,
|
|
121
121
|
auctionEndPrice,
|
|
122
122
|
limitPrice,
|
|
123
|
+
auctionPriceCaps,
|
|
123
124
|
}: {
|
|
124
125
|
direction: PositionDirection;
|
|
125
126
|
oraclePrice: BN;
|
|
126
127
|
auctionStartPrice: BN;
|
|
127
128
|
auctionEndPrice: BN;
|
|
128
129
|
limitPrice: BN;
|
|
130
|
+
auctionPriceCaps?: {
|
|
131
|
+
min: BN;
|
|
132
|
+
max: BN;
|
|
133
|
+
};
|
|
129
134
|
}): { auctionStartPrice: BN; auctionEndPrice: BN; oraclePriceOffset: number } {
|
|
130
135
|
let oraclePriceOffset;
|
|
131
136
|
|
|
@@ -148,6 +153,17 @@ export function deriveOracleAuctionParams({
|
|
|
148
153
|
oraclePriceOffsetNum = 0;
|
|
149
154
|
}
|
|
150
155
|
|
|
156
|
+
if (auctionPriceCaps) {
|
|
157
|
+
auctionStartPrice = BN.min(
|
|
158
|
+
BN.max(auctionStartPrice, auctionPriceCaps.min),
|
|
159
|
+
auctionPriceCaps.max
|
|
160
|
+
);
|
|
161
|
+
auctionEndPrice = BN.min(
|
|
162
|
+
BN.max(auctionEndPrice, auctionPriceCaps.min),
|
|
163
|
+
auctionPriceCaps.max
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
151
167
|
return {
|
|
152
168
|
auctionStartPrice: auctionStartPrice.sub(oraclePrice),
|
|
153
169
|
auctionEndPrice: auctionEndPrice.sub(oraclePrice),
|