@drift-labs/sdk 2.18.0-beta.1 → 2.18.0-beta.2
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/lib/dlob/DLOB.d.ts +1 -1
- package/lib/dlob/DLOB.js +2 -18
- package/lib/driftClient.js +1 -1
- package/lib/idl/drift.json +1 -1
- package/package.json +1 -1
- package/src/dlob/DLOB.ts +2 -39
- package/src/driftClient.ts +1 -1
- package/src/idl/drift.json +1 -1
package/lib/dlob/DLOB.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export declare class DLOB {
|
|
|
88
88
|
getMakerLimitBids(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, fallbackAsk?: BN): Generator<DLOBNode>;
|
|
89
89
|
getAsks(marketIndex: number, fallbackAsk: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): Generator<DLOBNode>;
|
|
90
90
|
getBids(marketIndex: number, fallbackBid: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): Generator<DLOBNode>;
|
|
91
|
-
findCrossingRestingLimitOrders(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData
|
|
91
|
+
findCrossingRestingLimitOrders(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): NodeToFill[];
|
|
92
92
|
determineMakerAndTaker(askNode: DLOBNode, bidNode: DLOBNode): {
|
|
93
93
|
takerNode: DLOBNode;
|
|
94
94
|
makerNode: DLOBNode;
|
package/lib/dlob/DLOB.js
CHANGED
|
@@ -310,7 +310,7 @@ class DLOB {
|
|
|
310
310
|
}
|
|
311
311
|
findRestingLimitOrderNodesToFill(marketIndex, slot, marketType, oraclePriceData, isAmmPaused, minAuctionDuration, fallbackAsk, fallbackBid) {
|
|
312
312
|
const nodesToFill = new Array();
|
|
313
|
-
const crossingNodes = this.findCrossingRestingLimitOrders(marketIndex, slot, marketType, oraclePriceData
|
|
313
|
+
const crossingNodes = this.findCrossingRestingLimitOrders(marketIndex, slot, marketType, oraclePriceData);
|
|
314
314
|
for (const crossingNode of crossingNodes) {
|
|
315
315
|
nodesToFill.push(crossingNode);
|
|
316
316
|
}
|
|
@@ -711,7 +711,7 @@ class DLOB {
|
|
|
711
711
|
.gt(currentNode.getPrice(oraclePriceData, slot));
|
|
712
712
|
});
|
|
713
713
|
}
|
|
714
|
-
findCrossingRestingLimitOrders(marketIndex, slot, marketType, oraclePriceData
|
|
714
|
+
findCrossingRestingLimitOrders(marketIndex, slot, marketType, oraclePriceData) {
|
|
715
715
|
const nodesToFill = new Array();
|
|
716
716
|
for (const askNode of this.getRestingLimitAsks(marketIndex, slot, marketType, oraclePriceData)) {
|
|
717
717
|
const bidGenerator = this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData);
|
|
@@ -735,22 +735,6 @@ class DLOB {
|
|
|
735
735
|
continue;
|
|
736
736
|
}
|
|
737
737
|
const { takerNode, makerNode } = makerAndTaker;
|
|
738
|
-
// extra guard against bad fills for limit orders where auction is incomplete
|
|
739
|
-
if (!__1.isFallbackAvailableLiquiditySource(takerNode.order, minAuctionDuration, slot)) {
|
|
740
|
-
let bidPrice;
|
|
741
|
-
let askPrice;
|
|
742
|
-
if (__1.isVariant(takerNode.order.direction, 'long')) {
|
|
743
|
-
bidPrice = __1.BN.min(takerNode.getPrice(oraclePriceData, slot), fallbackAsk || __1.BN_MAX);
|
|
744
|
-
askPrice = makerNode.getPrice(oraclePriceData, slot);
|
|
745
|
-
}
|
|
746
|
-
else {
|
|
747
|
-
bidPrice = makerNode.getPrice(oraclePriceData, slot);
|
|
748
|
-
askPrice = __1.BN.max(takerNode.getPrice(oraclePriceData, slot), fallbackBid || __1.ZERO);
|
|
749
|
-
}
|
|
750
|
-
if (bidPrice.lt(askPrice)) {
|
|
751
|
-
continue;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
738
|
const bidBaseRemaining = bidOrder.baseAssetAmount.sub(bidOrder.baseAssetAmountFilled);
|
|
755
739
|
const askBaseRemaining = askOrder.baseAssetAmount.sub(askOrder.baseAssetAmountFilled);
|
|
756
740
|
const baseFilled = __1.BN.min(bidBaseRemaining, askBaseRemaining);
|
package/lib/driftClient.js
CHANGED
|
@@ -2094,7 +2094,7 @@ class DriftClient {
|
|
|
2094
2094
|
writablePerpMarketIndexes: [marketIndex],
|
|
2095
2095
|
writableSpotMarketIndexes: [numericConstants_1.QUOTE_SPOT_MARKET_INDEX],
|
|
2096
2096
|
});
|
|
2097
|
-
const spotMarket = this.
|
|
2097
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
2098
2098
|
return await this.program.instruction.resolvePerpBankruptcy(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, marketIndex, {
|
|
2099
2099
|
accounts: {
|
|
2100
2100
|
state: await this.getStatePublicKey(),
|
package/lib/idl/drift.json
CHANGED
package/package.json
CHANGED
package/src/dlob/DLOB.ts
CHANGED
|
@@ -24,8 +24,6 @@ import {
|
|
|
24
24
|
UserMap,
|
|
25
25
|
OrderRecord,
|
|
26
26
|
OrderActionRecord,
|
|
27
|
-
ZERO,
|
|
28
|
-
BN_MAX,
|
|
29
27
|
isRestingLimitOrder,
|
|
30
28
|
isTakingOrder,
|
|
31
29
|
isFallbackAvailableLiquiditySource,
|
|
@@ -535,10 +533,7 @@ export class DLOB {
|
|
|
535
533
|
marketIndex,
|
|
536
534
|
slot,
|
|
537
535
|
marketType,
|
|
538
|
-
oraclePriceData
|
|
539
|
-
minAuctionDuration,
|
|
540
|
-
fallbackAsk,
|
|
541
|
-
fallbackBid
|
|
536
|
+
oraclePriceData
|
|
542
537
|
);
|
|
543
538
|
|
|
544
539
|
for (const crossingNode of crossingNodes) {
|
|
@@ -1294,10 +1289,7 @@ export class DLOB {
|
|
|
1294
1289
|
marketIndex: number,
|
|
1295
1290
|
slot: number,
|
|
1296
1291
|
marketType: MarketType,
|
|
1297
|
-
oraclePriceData: OraclePriceData
|
|
1298
|
-
minAuctionDuration: number,
|
|
1299
|
-
fallbackAsk: BN | undefined,
|
|
1300
|
-
fallbackBid: BN | undefined
|
|
1292
|
+
oraclePriceData: OraclePriceData
|
|
1301
1293
|
): NodeToFill[] {
|
|
1302
1294
|
const nodesToFill = new Array<NodeToFill>();
|
|
1303
1295
|
|
|
@@ -1341,35 +1333,6 @@ export class DLOB {
|
|
|
1341
1333
|
|
|
1342
1334
|
const { takerNode, makerNode } = makerAndTaker;
|
|
1343
1335
|
|
|
1344
|
-
// extra guard against bad fills for limit orders where auction is incomplete
|
|
1345
|
-
if (
|
|
1346
|
-
!isFallbackAvailableLiquiditySource(
|
|
1347
|
-
takerNode.order,
|
|
1348
|
-
minAuctionDuration,
|
|
1349
|
-
slot
|
|
1350
|
-
)
|
|
1351
|
-
) {
|
|
1352
|
-
let bidPrice: BN;
|
|
1353
|
-
let askPrice: BN;
|
|
1354
|
-
if (isVariant(takerNode.order.direction, 'long')) {
|
|
1355
|
-
bidPrice = BN.min(
|
|
1356
|
-
takerNode.getPrice(oraclePriceData, slot),
|
|
1357
|
-
fallbackAsk || BN_MAX
|
|
1358
|
-
);
|
|
1359
|
-
askPrice = makerNode.getPrice(oraclePriceData, slot);
|
|
1360
|
-
} else {
|
|
1361
|
-
bidPrice = makerNode.getPrice(oraclePriceData, slot);
|
|
1362
|
-
askPrice = BN.max(
|
|
1363
|
-
takerNode.getPrice(oraclePriceData, slot),
|
|
1364
|
-
fallbackBid || ZERO
|
|
1365
|
-
);
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
if (bidPrice.lt(askPrice)) {
|
|
1369
|
-
continue;
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
1336
|
const bidBaseRemaining = bidOrder.baseAssetAmount.sub(
|
|
1374
1337
|
bidOrder.baseAssetAmountFilled
|
|
1375
1338
|
);
|
package/src/driftClient.ts
CHANGED
|
@@ -3695,7 +3695,7 @@ export class DriftClient {
|
|
|
3695
3695
|
writableSpotMarketIndexes: [QUOTE_SPOT_MARKET_INDEX],
|
|
3696
3696
|
});
|
|
3697
3697
|
|
|
3698
|
-
const spotMarket = this.
|
|
3698
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
3699
3699
|
|
|
3700
3700
|
return await this.program.instruction.resolvePerpBankruptcy(
|
|
3701
3701
|
QUOTE_SPOT_MARKET_INDEX,
|
package/src/idl/drift.json
CHANGED