@drift-labs/sdk 2.95.0-beta.7 → 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 CHANGED
@@ -1 +1 @@
1
- 2.95.0-beta.7
1
+ 2.95.0-beta.8
@@ -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;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.95.0-beta.7",
3
+ "version": "2.95.0-beta.8",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -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),