@drift-labs/sdk 2.43.0-beta.17 → 2.43.0-beta.19
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/dlob/DLOB.d.ts +9 -3
- package/lib/dlob/DLOB.js +77 -14
- package/lib/driftClient.js +10 -10
- package/package.json +1 -1
- package/src/dlob/DLOB.ts +114 -20
- package/src/driftClient.ts +10 -10
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.43.0-beta.
|
|
1
|
+
2.43.0-beta.19
|
package/lib/dlob/DLOB.d.ts
CHANGED
|
@@ -87,10 +87,16 @@ export declare class DLOB {
|
|
|
87
87
|
takerNode: DLOBNode;
|
|
88
88
|
makerNode: DLOBNode;
|
|
89
89
|
} | undefined;
|
|
90
|
-
getBestAsk(marketIndex: number,
|
|
91
|
-
getBestBid(marketIndex: number,
|
|
90
|
+
getBestAsk(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): BN;
|
|
91
|
+
getBestBid(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): BN;
|
|
92
|
+
getStopLosses(marketIndex: number, marketType: MarketType, direction: PositionDirection): Generator<DLOBNode>;
|
|
93
|
+
getStopLossMarkets(marketIndex: number, marketType: MarketType, direction: PositionDirection): Generator<DLOBNode>;
|
|
94
|
+
getStopLossLimits(marketIndex: number, marketType: MarketType, direction: PositionDirection): Generator<DLOBNode>;
|
|
95
|
+
getTakeProfits(marketIndex: number, marketType: MarketType, direction: PositionDirection): Generator<DLOBNode>;
|
|
96
|
+
getTakeProfitMarkets(marketIndex: number, marketType: MarketType, direction: PositionDirection): Generator<DLOBNode>;
|
|
97
|
+
getTakeProfitLimits(marketIndex: number, marketType: MarketType, direction: PositionDirection): Generator<DLOBNode>;
|
|
92
98
|
findNodesToTrigger(marketIndex: number, slot: number, oraclePrice: BN, marketType: MarketType, stateAccount: StateAccount): NodeToTrigger[];
|
|
93
|
-
|
|
99
|
+
printTop(driftClient: DriftClient, slotSubscriber: SlotSubscriber, marketIndex: number, marketType: MarketType): void;
|
|
94
100
|
getDLOBOrders(): DLOBOrders;
|
|
95
101
|
getNodeLists(): Generator<NodeList<DLOBNodeType>>;
|
|
96
102
|
/**
|
package/lib/dlob/DLOB.js
CHANGED
|
@@ -796,16 +796,80 @@ class DLOB {
|
|
|
796
796
|
};
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
|
-
getBestAsk(marketIndex,
|
|
800
|
-
return this.
|
|
799
|
+
getBestAsk(marketIndex, slot, marketType, oraclePriceData) {
|
|
800
|
+
return this.getRestingLimitAsks(marketIndex, slot, marketType, oraclePriceData)
|
|
801
801
|
.next()
|
|
802
802
|
.value.getPrice(oraclePriceData, slot);
|
|
803
803
|
}
|
|
804
|
-
getBestBid(marketIndex,
|
|
805
|
-
return this.
|
|
804
|
+
getBestBid(marketIndex, slot, marketType, oraclePriceData) {
|
|
805
|
+
return this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData)
|
|
806
806
|
.next()
|
|
807
807
|
.value.getPrice(oraclePriceData, slot);
|
|
808
808
|
}
|
|
809
|
+
*getStopLosses(marketIndex, marketType, direction) {
|
|
810
|
+
const marketTypeStr = (0, __1.getVariant)(marketType);
|
|
811
|
+
const marketNodeLists = this.orderLists.get(marketTypeStr).get(marketIndex);
|
|
812
|
+
if ((0, __1.isVariant)(direction, 'long') && marketNodeLists.trigger.below) {
|
|
813
|
+
for (const node of marketNodeLists.trigger.below.getGenerator()) {
|
|
814
|
+
if ((0, __1.isVariant)(node.order.direction, 'short')) {
|
|
815
|
+
yield node;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
else if ((0, __1.isVariant)(direction, 'short') && marketNodeLists.trigger.above) {
|
|
820
|
+
for (const node of marketNodeLists.trigger.above.getGenerator()) {
|
|
821
|
+
if ((0, __1.isVariant)(node.order.direction, 'long')) {
|
|
822
|
+
yield node;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
*getStopLossMarkets(marketIndex, marketType, direction) {
|
|
828
|
+
for (const node of this.getStopLosses(marketIndex, marketType, direction)) {
|
|
829
|
+
if ((0, __1.isVariant)(node.order.orderType, 'triggerMarket')) {
|
|
830
|
+
yield node;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
*getStopLossLimits(marketIndex, marketType, direction) {
|
|
835
|
+
for (const node of this.getStopLosses(marketIndex, marketType, direction)) {
|
|
836
|
+
if ((0, __1.isVariant)(node.order.orderType, 'triggerLimit')) {
|
|
837
|
+
yield node;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
*getTakeProfits(marketIndex, marketType, direction) {
|
|
842
|
+
const marketTypeStr = (0, __1.getVariant)(marketType);
|
|
843
|
+
const marketNodeLists = this.orderLists.get(marketTypeStr).get(marketIndex);
|
|
844
|
+
if ((0, __1.isVariant)(direction, 'long') && marketNodeLists.trigger.above) {
|
|
845
|
+
for (const node of marketNodeLists.trigger.above.getGenerator()) {
|
|
846
|
+
if ((0, __1.isVariant)(node.order.direction, 'short')) {
|
|
847
|
+
yield node;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
else if ((0, __1.isVariant)(direction, 'short') && marketNodeLists.trigger.below) {
|
|
852
|
+
for (const node of marketNodeLists.trigger.below.getGenerator()) {
|
|
853
|
+
if ((0, __1.isVariant)(node.order.direction, 'long')) {
|
|
854
|
+
yield node;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
*getTakeProfitMarkets(marketIndex, marketType, direction) {
|
|
860
|
+
for (const node of this.getTakeProfits(marketIndex, marketType, direction)) {
|
|
861
|
+
if ((0, __1.isVariant)(node.order.orderType, 'triggerMarket')) {
|
|
862
|
+
yield node;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
*getTakeProfitLimits(marketIndex, marketType, direction) {
|
|
867
|
+
for (const node of this.getTakeProfits(marketIndex, marketType, direction)) {
|
|
868
|
+
if ((0, __1.isVariant)(node.order.orderType, 'triggerLimit')) {
|
|
869
|
+
yield node;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
}
|
|
809
873
|
findNodesToTrigger(marketIndex, slot, oraclePrice, marketType, stateAccount) {
|
|
810
874
|
if ((0, exchangeStatus_1.exchangePaused)(stateAccount)) {
|
|
811
875
|
return [];
|
|
@@ -845,15 +909,12 @@ class DLOB {
|
|
|
845
909
|
}
|
|
846
910
|
return nodesToTrigger;
|
|
847
911
|
}
|
|
848
|
-
|
|
912
|
+
printTop(driftClient, slotSubscriber, marketIndex, marketType) {
|
|
849
913
|
if ((0, __1.isVariant)(marketType, 'perp')) {
|
|
850
|
-
const market = driftClient.getPerpMarketAccount(marketIndex);
|
|
851
914
|
const slot = slotSubscriber.getSlot();
|
|
852
915
|
const oraclePriceData = driftClient.getOracleDataForPerpMarket(marketIndex);
|
|
853
|
-
const
|
|
854
|
-
const
|
|
855
|
-
const bestAsk = this.getBestAsk(marketIndex, fallbackAsk, slot, marketType, oraclePriceData);
|
|
856
|
-
const bestBid = this.getBestBid(marketIndex, fallbackBid, slot, marketType, oraclePriceData);
|
|
916
|
+
const bestAsk = this.getBestAsk(marketIndex, slot, marketType, oraclePriceData);
|
|
917
|
+
const bestBid = this.getBestBid(marketIndex, slot, marketType, oraclePriceData);
|
|
857
918
|
const mid = bestAsk.add(bestBid).div(new __1.BN(2));
|
|
858
919
|
const bidSpread = ((0, __1.convertToNumber)(bestBid, __1.PRICE_PRECISION) /
|
|
859
920
|
(0, __1.convertToNumber)(oraclePriceData.price, __1.PRICE_PRECISION) -
|
|
@@ -863,7 +924,8 @@ class DLOB {
|
|
|
863
924
|
(0, __1.convertToNumber)(oraclePriceData.price, __1.PRICE_PRECISION) -
|
|
864
925
|
1) *
|
|
865
926
|
100.0;
|
|
866
|
-
|
|
927
|
+
const name = (0, __1.decodeName)(driftClient.getPerpMarketAccount(marketIndex).name);
|
|
928
|
+
console.log(`Market ${name} Orders`);
|
|
867
929
|
console.log(` Ask`, (0, __1.convertToNumber)(bestAsk, __1.PRICE_PRECISION).toFixed(3), `(${askSpread.toFixed(4)}%)`);
|
|
868
930
|
console.log(` Mid`, (0, __1.convertToNumber)(mid, __1.PRICE_PRECISION).toFixed(3));
|
|
869
931
|
console.log(` Bid`, (0, __1.convertToNumber)(bestBid, __1.PRICE_PRECISION).toFixed(3), `(${bidSpread.toFixed(4)}%)`);
|
|
@@ -871,8 +933,8 @@ class DLOB {
|
|
|
871
933
|
else if ((0, __1.isVariant)(marketType, 'spot')) {
|
|
872
934
|
const slot = slotSubscriber.getSlot();
|
|
873
935
|
const oraclePriceData = driftClient.getOracleDataForPerpMarket(marketIndex);
|
|
874
|
-
const bestAsk = this.getBestAsk(marketIndex,
|
|
875
|
-
const bestBid = this.getBestBid(marketIndex,
|
|
936
|
+
const bestAsk = this.getBestAsk(marketIndex, slot, marketType, oraclePriceData);
|
|
937
|
+
const bestBid = this.getBestBid(marketIndex, slot, marketType, oraclePriceData);
|
|
876
938
|
const mid = bestAsk.add(bestBid).div(new __1.BN(2));
|
|
877
939
|
const bidSpread = ((0, __1.convertToNumber)(bestBid, __1.PRICE_PRECISION) /
|
|
878
940
|
(0, __1.convertToNumber)(oraclePriceData.price, __1.PRICE_PRECISION) -
|
|
@@ -882,7 +944,8 @@ class DLOB {
|
|
|
882
944
|
(0, __1.convertToNumber)(oraclePriceData.price, __1.PRICE_PRECISION) -
|
|
883
945
|
1) *
|
|
884
946
|
100.0;
|
|
885
|
-
|
|
947
|
+
const name = (0, __1.decodeName)(driftClient.getSpotMarketAccount(marketIndex).name);
|
|
948
|
+
console.log(`Market ${name} Orders`);
|
|
886
949
|
console.log(` Ask`, (0, __1.convertToNumber)(bestAsk, __1.PRICE_PRECISION).toFixed(3), `(${askSpread.toFixed(4)}%)`);
|
|
887
950
|
console.log(` Mid`, (0, __1.convertToNumber)(mid, __1.PRICE_PRECISION).toFixed(3));
|
|
888
951
|
console.log(` Bid`, (0, __1.convertToNumber)(bestBid, __1.PRICE_PRECISION).toFixed(3), `(${bidSpread.toFixed(4)}%)`);
|
package/lib/driftClient.js
CHANGED
|
@@ -2639,12 +2639,12 @@ class DriftClient {
|
|
|
2639
2639
|
oraclePriceOffset: newOraclePriceOffset || null,
|
|
2640
2640
|
triggerPrice: newTriggerPrice || null,
|
|
2641
2641
|
triggerCondition: newTriggerCondition || null,
|
|
2642
|
-
auctionDuration: auctionDuration ||
|
|
2643
|
-
auctionStartPrice: auctionStartPrice ||
|
|
2644
|
-
auctionEndPrice: auctionEndPrice ||
|
|
2645
|
-
reduceOnly: reduceOnly ||
|
|
2642
|
+
auctionDuration: auctionDuration || 0,
|
|
2643
|
+
auctionStartPrice: auctionStartPrice || numericConstants_1.ZERO,
|
|
2644
|
+
auctionEndPrice: auctionEndPrice || numericConstants_1.ZERO,
|
|
2645
|
+
reduceOnly: reduceOnly || false,
|
|
2646
2646
|
postOnly: postOnly || null,
|
|
2647
|
-
immediateOrCancel: immediateOrCancel ||
|
|
2647
|
+
immediateOrCancel: immediateOrCancel || false,
|
|
2648
2648
|
policy: policy || null,
|
|
2649
2649
|
maxTs: maxTs || null,
|
|
2650
2650
|
};
|
|
@@ -2693,12 +2693,12 @@ class DriftClient {
|
|
|
2693
2693
|
oraclePriceOffset: newOraclePriceOffset || null,
|
|
2694
2694
|
triggerPrice: newTriggerPrice || null,
|
|
2695
2695
|
triggerCondition: newTriggerCondition || null,
|
|
2696
|
-
auctionDuration: auctionDuration ||
|
|
2697
|
-
auctionStartPrice: auctionStartPrice ||
|
|
2698
|
-
auctionEndPrice: auctionEndPrice ||
|
|
2699
|
-
reduceOnly: reduceOnly ||
|
|
2696
|
+
auctionDuration: auctionDuration || 0,
|
|
2697
|
+
auctionStartPrice: auctionStartPrice || numericConstants_1.ZERO,
|
|
2698
|
+
auctionEndPrice: auctionEndPrice || numericConstants_1.ZERO,
|
|
2699
|
+
reduceOnly: reduceOnly || false,
|
|
2700
2700
|
postOnly: postOnly || null,
|
|
2701
|
-
immediateOrCancel: immediateOrCancel ||
|
|
2701
|
+
immediateOrCancel: immediateOrCancel || false,
|
|
2702
2702
|
policy: policy || null,
|
|
2703
2703
|
maxTs: maxTs || null,
|
|
2704
2704
|
};
|
package/package.json
CHANGED
package/src/dlob/DLOB.ts
CHANGED
|
@@ -2,9 +2,8 @@ import { getOrderSignature, getVammNodeGenerator, NodeList } from './NodeList';
|
|
|
2
2
|
import {
|
|
3
3
|
BASE_PRECISION,
|
|
4
4
|
BN,
|
|
5
|
-
calculateAskPrice,
|
|
6
|
-
calculateBidPrice,
|
|
7
5
|
convertToNumber,
|
|
6
|
+
decodeName,
|
|
8
7
|
DLOBNode,
|
|
9
8
|
DLOBNodeType,
|
|
10
9
|
DriftClient,
|
|
@@ -1430,14 +1429,12 @@ export class DLOB {
|
|
|
1430
1429
|
|
|
1431
1430
|
public getBestAsk(
|
|
1432
1431
|
marketIndex: number,
|
|
1433
|
-
fallbackAsk: BN | undefined,
|
|
1434
1432
|
slot: number,
|
|
1435
1433
|
marketType: MarketType,
|
|
1436
1434
|
oraclePriceData: OraclePriceData
|
|
1437
1435
|
): BN {
|
|
1438
|
-
return this.
|
|
1436
|
+
return this.getRestingLimitAsks(
|
|
1439
1437
|
marketIndex,
|
|
1440
|
-
fallbackAsk,
|
|
1441
1438
|
slot,
|
|
1442
1439
|
marketType,
|
|
1443
1440
|
oraclePriceData
|
|
@@ -1448,14 +1445,12 @@ export class DLOB {
|
|
|
1448
1445
|
|
|
1449
1446
|
public getBestBid(
|
|
1450
1447
|
marketIndex: number,
|
|
1451
|
-
fallbackBid: BN | undefined,
|
|
1452
1448
|
slot: number,
|
|
1453
1449
|
marketType: MarketType,
|
|
1454
1450
|
oraclePriceData: OraclePriceData
|
|
1455
1451
|
): BN {
|
|
1456
|
-
return this.
|
|
1452
|
+
return this.getRestingLimitBids(
|
|
1457
1453
|
marketIndex,
|
|
1458
|
-
fallbackBid,
|
|
1459
1454
|
slot,
|
|
1460
1455
|
marketType,
|
|
1461
1456
|
oraclePriceData
|
|
@@ -1464,6 +1459,108 @@ export class DLOB {
|
|
|
1464
1459
|
.value.getPrice(oraclePriceData, slot);
|
|
1465
1460
|
}
|
|
1466
1461
|
|
|
1462
|
+
public *getStopLosses(
|
|
1463
|
+
marketIndex: number,
|
|
1464
|
+
marketType: MarketType,
|
|
1465
|
+
direction: PositionDirection
|
|
1466
|
+
): Generator<DLOBNode> {
|
|
1467
|
+
const marketTypeStr = getVariant(marketType) as MarketTypeStr;
|
|
1468
|
+
const marketNodeLists = this.orderLists.get(marketTypeStr).get(marketIndex);
|
|
1469
|
+
|
|
1470
|
+
if (isVariant(direction, 'long') && marketNodeLists.trigger.below) {
|
|
1471
|
+
for (const node of marketNodeLists.trigger.below.getGenerator()) {
|
|
1472
|
+
if (isVariant(node.order.direction, 'short')) {
|
|
1473
|
+
yield node;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
} else if (isVariant(direction, 'short') && marketNodeLists.trigger.above) {
|
|
1477
|
+
for (const node of marketNodeLists.trigger.above.getGenerator()) {
|
|
1478
|
+
if (isVariant(node.order.direction, 'long')) {
|
|
1479
|
+
yield node;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
public *getStopLossMarkets(
|
|
1486
|
+
marketIndex: number,
|
|
1487
|
+
marketType: MarketType,
|
|
1488
|
+
direction: PositionDirection
|
|
1489
|
+
): Generator<DLOBNode> {
|
|
1490
|
+
for (const node of this.getStopLosses(marketIndex, marketType, direction)) {
|
|
1491
|
+
if (isVariant(node.order.orderType, 'triggerMarket')) {
|
|
1492
|
+
yield node;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
public *getStopLossLimits(
|
|
1498
|
+
marketIndex: number,
|
|
1499
|
+
marketType: MarketType,
|
|
1500
|
+
direction: PositionDirection
|
|
1501
|
+
): Generator<DLOBNode> {
|
|
1502
|
+
for (const node of this.getStopLosses(marketIndex, marketType, direction)) {
|
|
1503
|
+
if (isVariant(node.order.orderType, 'triggerLimit')) {
|
|
1504
|
+
yield node;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
public *getTakeProfits(
|
|
1510
|
+
marketIndex: number,
|
|
1511
|
+
marketType: MarketType,
|
|
1512
|
+
direction: PositionDirection
|
|
1513
|
+
): Generator<DLOBNode> {
|
|
1514
|
+
const marketTypeStr = getVariant(marketType) as MarketTypeStr;
|
|
1515
|
+
const marketNodeLists = this.orderLists.get(marketTypeStr).get(marketIndex);
|
|
1516
|
+
|
|
1517
|
+
if (isVariant(direction, 'long') && marketNodeLists.trigger.above) {
|
|
1518
|
+
for (const node of marketNodeLists.trigger.above.getGenerator()) {
|
|
1519
|
+
if (isVariant(node.order.direction, 'short')) {
|
|
1520
|
+
yield node;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
} else if (isVariant(direction, 'short') && marketNodeLists.trigger.below) {
|
|
1524
|
+
for (const node of marketNodeLists.trigger.below.getGenerator()) {
|
|
1525
|
+
if (isVariant(node.order.direction, 'long')) {
|
|
1526
|
+
yield node;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
public *getTakeProfitMarkets(
|
|
1533
|
+
marketIndex: number,
|
|
1534
|
+
marketType: MarketType,
|
|
1535
|
+
direction: PositionDirection
|
|
1536
|
+
): Generator<DLOBNode> {
|
|
1537
|
+
for (const node of this.getTakeProfits(
|
|
1538
|
+
marketIndex,
|
|
1539
|
+
marketType,
|
|
1540
|
+
direction
|
|
1541
|
+
)) {
|
|
1542
|
+
if (isVariant(node.order.orderType, 'triggerMarket')) {
|
|
1543
|
+
yield node;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
public *getTakeProfitLimits(
|
|
1549
|
+
marketIndex: number,
|
|
1550
|
+
marketType: MarketType,
|
|
1551
|
+
direction: PositionDirection
|
|
1552
|
+
): Generator<DLOBNode> {
|
|
1553
|
+
for (const node of this.getTakeProfits(
|
|
1554
|
+
marketIndex,
|
|
1555
|
+
marketType,
|
|
1556
|
+
direction
|
|
1557
|
+
)) {
|
|
1558
|
+
if (isVariant(node.order.orderType, 'triggerLimit')) {
|
|
1559
|
+
yield node;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1467
1564
|
public findNodesToTrigger(
|
|
1468
1565
|
marketIndex: number,
|
|
1469
1566
|
slot: number,
|
|
@@ -1512,32 +1609,25 @@ export class DLOB {
|
|
|
1512
1609
|
return nodesToTrigger;
|
|
1513
1610
|
}
|
|
1514
1611
|
|
|
1515
|
-
public
|
|
1516
|
-
sdkConfig: any,
|
|
1612
|
+
public printTop(
|
|
1517
1613
|
driftClient: DriftClient,
|
|
1518
1614
|
slotSubscriber: SlotSubscriber,
|
|
1519
1615
|
marketIndex: number,
|
|
1520
1616
|
marketType: MarketType
|
|
1521
1617
|
) {
|
|
1522
1618
|
if (isVariant(marketType, 'perp')) {
|
|
1523
|
-
const market = driftClient.getPerpMarketAccount(marketIndex);
|
|
1524
|
-
|
|
1525
1619
|
const slot = slotSubscriber.getSlot();
|
|
1526
1620
|
const oraclePriceData =
|
|
1527
1621
|
driftClient.getOracleDataForPerpMarket(marketIndex);
|
|
1528
|
-
const fallbackAsk = calculateAskPrice(market, oraclePriceData);
|
|
1529
|
-
const fallbackBid = calculateBidPrice(market, oraclePriceData);
|
|
1530
1622
|
|
|
1531
1623
|
const bestAsk = this.getBestAsk(
|
|
1532
1624
|
marketIndex,
|
|
1533
|
-
fallbackAsk,
|
|
1534
1625
|
slot,
|
|
1535
1626
|
marketType,
|
|
1536
1627
|
oraclePriceData
|
|
1537
1628
|
);
|
|
1538
1629
|
const bestBid = this.getBestBid(
|
|
1539
1630
|
marketIndex,
|
|
1540
|
-
fallbackBid,
|
|
1541
1631
|
slot,
|
|
1542
1632
|
marketType,
|
|
1543
1633
|
oraclePriceData
|
|
@@ -1555,7 +1645,10 @@ export class DLOB {
|
|
|
1555
1645
|
1) *
|
|
1556
1646
|
100.0;
|
|
1557
1647
|
|
|
1558
|
-
|
|
1648
|
+
const name = decodeName(
|
|
1649
|
+
driftClient.getPerpMarketAccount(marketIndex).name
|
|
1650
|
+
);
|
|
1651
|
+
console.log(`Market ${name} Orders`);
|
|
1559
1652
|
console.log(
|
|
1560
1653
|
` Ask`,
|
|
1561
1654
|
convertToNumber(bestAsk, PRICE_PRECISION).toFixed(3),
|
|
@@ -1574,14 +1667,12 @@ export class DLOB {
|
|
|
1574
1667
|
|
|
1575
1668
|
const bestAsk = this.getBestAsk(
|
|
1576
1669
|
marketIndex,
|
|
1577
|
-
undefined,
|
|
1578
1670
|
slot,
|
|
1579
1671
|
marketType,
|
|
1580
1672
|
oraclePriceData
|
|
1581
1673
|
);
|
|
1582
1674
|
const bestBid = this.getBestBid(
|
|
1583
1675
|
marketIndex,
|
|
1584
|
-
undefined,
|
|
1585
1676
|
slot,
|
|
1586
1677
|
marketType,
|
|
1587
1678
|
oraclePriceData
|
|
@@ -1599,7 +1690,10 @@ export class DLOB {
|
|
|
1599
1690
|
1) *
|
|
1600
1691
|
100.0;
|
|
1601
1692
|
|
|
1602
|
-
|
|
1693
|
+
const name = decodeName(
|
|
1694
|
+
driftClient.getSpotMarketAccount(marketIndex).name
|
|
1695
|
+
);
|
|
1696
|
+
console.log(`Market ${name} Orders`);
|
|
1603
1697
|
console.log(
|
|
1604
1698
|
` Ask`,
|
|
1605
1699
|
convertToNumber(bestAsk, PRICE_PRECISION).toFixed(3),
|
package/src/driftClient.ts
CHANGED
|
@@ -4649,12 +4649,12 @@ export class DriftClient {
|
|
|
4649
4649
|
oraclePriceOffset: newOraclePriceOffset || null,
|
|
4650
4650
|
triggerPrice: newTriggerPrice || null,
|
|
4651
4651
|
triggerCondition: newTriggerCondition || null,
|
|
4652
|
-
auctionDuration: auctionDuration ||
|
|
4653
|
-
auctionStartPrice: auctionStartPrice ||
|
|
4654
|
-
auctionEndPrice: auctionEndPrice ||
|
|
4655
|
-
reduceOnly: reduceOnly ||
|
|
4652
|
+
auctionDuration: auctionDuration || 0,
|
|
4653
|
+
auctionStartPrice: auctionStartPrice || ZERO,
|
|
4654
|
+
auctionEndPrice: auctionEndPrice || ZERO,
|
|
4655
|
+
reduceOnly: reduceOnly || false,
|
|
4656
4656
|
postOnly: postOnly || null,
|
|
4657
|
-
immediateOrCancel: immediateOrCancel ||
|
|
4657
|
+
immediateOrCancel: immediateOrCancel || false,
|
|
4658
4658
|
policy: policy || null,
|
|
4659
4659
|
maxTs: maxTs || null,
|
|
4660
4660
|
};
|
|
@@ -4767,12 +4767,12 @@ export class DriftClient {
|
|
|
4767
4767
|
oraclePriceOffset: newOraclePriceOffset || null,
|
|
4768
4768
|
triggerPrice: newTriggerPrice || null,
|
|
4769
4769
|
triggerCondition: newTriggerCondition || null,
|
|
4770
|
-
auctionDuration: auctionDuration ||
|
|
4771
|
-
auctionStartPrice: auctionStartPrice ||
|
|
4772
|
-
auctionEndPrice: auctionEndPrice ||
|
|
4773
|
-
reduceOnly: reduceOnly ||
|
|
4770
|
+
auctionDuration: auctionDuration || 0,
|
|
4771
|
+
auctionStartPrice: auctionStartPrice || ZERO,
|
|
4772
|
+
auctionEndPrice: auctionEndPrice || ZERO,
|
|
4773
|
+
reduceOnly: reduceOnly || false,
|
|
4774
4774
|
postOnly: postOnly || null,
|
|
4775
|
-
immediateOrCancel: immediateOrCancel ||
|
|
4775
|
+
immediateOrCancel: immediateOrCancel || false,
|
|
4776
4776
|
policy: policy || null,
|
|
4777
4777
|
maxTs: maxTs || null,
|
|
4778
4778
|
};
|