@drift-labs/sdk 2.83.0-beta.10 → 2.83.0-beta.11
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/auction.js +2 -2
- package/lib/math/orders.js +1 -1
- package/package.json +1 -1
- package/src/math/auction.ts +2 -2
- package/src/math/orders.ts +5 -2
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.83.0-beta.
|
|
1
|
+
2.83.0-beta.11
|
package/lib/math/auction.js
CHANGED
|
@@ -69,7 +69,7 @@ function getAuctionPriceForOracleOffsetAuction(order, slot, oraclePrice) {
|
|
|
69
69
|
const deltaDenominator = new _1.BN(order.auctionDuration);
|
|
70
70
|
const deltaNumerator = _1.BN.min(slotsElapsed, deltaDenominator);
|
|
71
71
|
if (deltaDenominator.eq(_1.ZERO)) {
|
|
72
|
-
return oraclePrice.add(order.auctionEndPrice);
|
|
72
|
+
return _1.BN.max(oraclePrice.add(order.auctionEndPrice), _1.ONE);
|
|
73
73
|
}
|
|
74
74
|
let priceOffsetDelta;
|
|
75
75
|
if ((0, types_1.isVariant)(order.direction, 'long')) {
|
|
@@ -91,7 +91,7 @@ function getAuctionPriceForOracleOffsetAuction(order, slot, oraclePrice) {
|
|
|
91
91
|
else {
|
|
92
92
|
priceOffset = order.auctionStartPrice.sub(priceOffsetDelta);
|
|
93
93
|
}
|
|
94
|
-
return oraclePrice.add(priceOffset);
|
|
94
|
+
return _1.BN.max(oraclePrice.add(priceOffset), _1.ONE);
|
|
95
95
|
}
|
|
96
96
|
exports.getAuctionPriceForOracleOffsetAuction = getAuctionPriceForOracleOffsetAuction;
|
|
97
97
|
function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice, auctionEndPrice, limitPrice, }) {
|
package/lib/math/orders.js
CHANGED
|
@@ -102,7 +102,7 @@ function getLimitPrice(order, oraclePriceData, slot, fallbackPrice) {
|
|
|
102
102
|
limitPrice = (0, auction_1.getAuctionPrice)(order, slot, oraclePriceData.price);
|
|
103
103
|
}
|
|
104
104
|
else if (order.oraclePriceOffset !== 0) {
|
|
105
|
-
limitPrice = oraclePriceData.price.add(new anchor_1.BN(order.oraclePriceOffset));
|
|
105
|
+
limitPrice = anchor_1.BN.max(oraclePriceData.price.add(new anchor_1.BN(order.oraclePriceOffset)), numericConstants_1.ONE);
|
|
106
106
|
}
|
|
107
107
|
else if (order.price.eq(numericConstants_1.ZERO)) {
|
|
108
108
|
limitPrice = fallbackPrice;
|
package/package.json
CHANGED
package/src/math/auction.ts
CHANGED
|
@@ -88,7 +88,7 @@ export function getAuctionPriceForOracleOffsetAuction(
|
|
|
88
88
|
const deltaNumerator = BN.min(slotsElapsed, deltaDenominator);
|
|
89
89
|
|
|
90
90
|
if (deltaDenominator.eq(ZERO)) {
|
|
91
|
-
return oraclePrice.add(order.auctionEndPrice);
|
|
91
|
+
return BN.max(oraclePrice.add(order.auctionEndPrice), ONE);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
let priceOffsetDelta;
|
|
@@ -111,7 +111,7 @@ export function getAuctionPriceForOracleOffsetAuction(
|
|
|
111
111
|
priceOffset = order.auctionStartPrice.sub(priceOffsetDelta);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
return oraclePrice.add(priceOffset);
|
|
114
|
+
return BN.max(oraclePrice.add(priceOffset), ONE);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
export function deriveOracleAuctionParams({
|
package/src/math/orders.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Order,
|
|
8
8
|
PositionDirection,
|
|
9
9
|
} from '../types';
|
|
10
|
-
import { ZERO, TWO } from '../constants/numericConstants';
|
|
10
|
+
import { ZERO, TWO, ONE } from '../constants/numericConstants';
|
|
11
11
|
import { BN } from '@coral-xyz/anchor';
|
|
12
12
|
import { OraclePriceData } from '../oracles/types';
|
|
13
13
|
import {
|
|
@@ -160,7 +160,10 @@ export function getLimitPrice(
|
|
|
160
160
|
if (hasAuctionPrice(order, slot)) {
|
|
161
161
|
limitPrice = getAuctionPrice(order, slot, oraclePriceData.price);
|
|
162
162
|
} else if (order.oraclePriceOffset !== 0) {
|
|
163
|
-
limitPrice =
|
|
163
|
+
limitPrice = BN.max(
|
|
164
|
+
oraclePriceData.price.add(new BN(order.oraclePriceOffset)),
|
|
165
|
+
ONE
|
|
166
|
+
);
|
|
164
167
|
} else if (order.price.eq(ZERO)) {
|
|
165
168
|
limitPrice = fallbackPrice;
|
|
166
169
|
} else {
|