@drift-labs/sdk 2.113.0-beta.0 → 2.113.0-beta.1
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/browser/decode/user.js +1 -1
- package/lib/browser/dlob/DLOB.js +2 -2
- package/lib/browser/dlob/NodeList.js +1 -1
- package/lib/browser/math/orders.js +3 -3
- package/lib/browser/types.d.ts +6 -0
- package/lib/browser/types.js +2 -0
- package/lib/browser/user.js +1 -1
- package/lib/node/decode/user.js +1 -1
- package/lib/node/dlob/DLOB.js +2 -2
- package/lib/node/dlob/NodeList.js +1 -1
- package/lib/node/math/orders.js +3 -3
- package/lib/node/types.d.ts +6 -0
- package/lib/node/types.js +2 -0
- package/lib/node/user.js +1 -1
- package/package.json +1 -1
- package/src/decode/user.ts +1 -1
- package/src/dlob/DLOB.ts +2 -2
- package/src/dlob/NodeList.ts +1 -1
- package/src/math/orders.ts +3 -3
- package/src/types.ts +2 -0
- package/src/user.ts +1 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.113.0-beta.
|
|
1
|
+
2.113.0-beta.1
|
|
@@ -121,7 +121,7 @@ function decodeUser(buffer) {
|
|
|
121
121
|
const orders = [];
|
|
122
122
|
for (let i = 0; i < 32; i++) {
|
|
123
123
|
// skip order if it's not open
|
|
124
|
-
if (buffer.readUint8(offset + 82)
|
|
124
|
+
if (buffer.readUint8(offset + 82) !== 1) {
|
|
125
125
|
offset += 96;
|
|
126
126
|
continue;
|
|
127
127
|
}
|
package/lib/browser/dlob/DLOB.js
CHANGED
|
@@ -73,7 +73,7 @@ class DLOB {
|
|
|
73
73
|
}
|
|
74
74
|
insertOrder(order, userAccount, slot, isUserProtectedMaker, onInsert) {
|
|
75
75
|
var _a;
|
|
76
|
-
if ((0, __1.isVariant)(order.status, '
|
|
76
|
+
if (!(0, __1.isVariant)(order.status, 'open')) {
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
if (!(0, __1.isOneOfVariant)(order.orderType, SUPPORTED_ORDER_TYPES)) {
|
|
@@ -145,7 +145,7 @@ class DLOB {
|
|
|
145
145
|
}
|
|
146
146
|
delete(order, userAccount, slot, isUserProtectedMaker, onDelete) {
|
|
147
147
|
var _a;
|
|
148
|
-
if ((0, __1.isVariant)(order.status, '
|
|
148
|
+
if (!(0, __1.isVariant)(order.status, 'open')) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
this.updateRestingLimitOrders(slot);
|
|
@@ -20,7 +20,7 @@ class NodeList {
|
|
|
20
20
|
this.nodeMap.clear();
|
|
21
21
|
}
|
|
22
22
|
insert(order, marketType, userAccount, isProtectedMaker, applyProtectedMakerOffset) {
|
|
23
|
-
if ((0, __1.isVariant)(order.status, '
|
|
23
|
+
if (!(0, __1.isVariant)(order.status, 'open')) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
const newNode = (0, DLOBNode_1.createNode)(this.nodeType, order, userAccount, isProtectedMaker, applyProtectedMakerOffset);
|
|
@@ -7,7 +7,7 @@ const anchor_1 = require("@coral-xyz/anchor");
|
|
|
7
7
|
const auction_1 = require("./auction");
|
|
8
8
|
const amm_1 = require("./amm");
|
|
9
9
|
function isOrderRiskIncreasing(user, order) {
|
|
10
|
-
if ((0, types_1.isVariant)(order.status, '
|
|
10
|
+
if (!(0, types_1.isVariant)(order.status, 'open')) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
13
|
const position = user.getPerpPosition(order.marketIndex) ||
|
|
@@ -34,7 +34,7 @@ function isOrderRiskIncreasing(user, order) {
|
|
|
34
34
|
}
|
|
35
35
|
exports.isOrderRiskIncreasing = isOrderRiskIncreasing;
|
|
36
36
|
function isOrderRiskIncreasingInSameDirection(user, order) {
|
|
37
|
-
if ((0, types_1.isVariant)(order.status, '
|
|
37
|
+
if (!(0, types_1.isVariant)(order.status, 'open')) {
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
40
|
const position = user.getPerpPosition(order.marketIndex) ||
|
|
@@ -56,7 +56,7 @@ function isOrderRiskIncreasingInSameDirection(user, order) {
|
|
|
56
56
|
}
|
|
57
57
|
exports.isOrderRiskIncreasingInSameDirection = isOrderRiskIncreasingInSameDirection;
|
|
58
58
|
function isOrderReduceOnly(user, order) {
|
|
59
|
-
if ((0, types_1.isVariant)(order.status, '
|
|
59
|
+
if (!(0, types_1.isVariant)(order.status, 'open')) {
|
|
60
60
|
return false;
|
|
61
61
|
}
|
|
62
62
|
const position = user.getPerpPosition(order.marketIndex) ||
|
package/lib/browser/types.d.ts
CHANGED
|
@@ -264,6 +264,12 @@ export declare class OrderStatus {
|
|
|
264
264
|
static readonly OPEN: {
|
|
265
265
|
open: {};
|
|
266
266
|
};
|
|
267
|
+
static readonly FILLED: {
|
|
268
|
+
filled: {};
|
|
269
|
+
};
|
|
270
|
+
static readonly CANCELED: {
|
|
271
|
+
canceled: {};
|
|
272
|
+
};
|
|
267
273
|
}
|
|
268
274
|
export declare class OrderAction {
|
|
269
275
|
static readonly PLACE: {
|
package/lib/browser/types.js
CHANGED
|
@@ -164,6 +164,8 @@ class OrderStatus {
|
|
|
164
164
|
exports.OrderStatus = OrderStatus;
|
|
165
165
|
OrderStatus.INIT = { init: {} };
|
|
166
166
|
OrderStatus.OPEN = { open: {} };
|
|
167
|
+
OrderStatus.FILLED = { filled: {} };
|
|
168
|
+
OrderStatus.CANCELED = { canceled: {} };
|
|
167
169
|
class OrderAction {
|
|
168
170
|
}
|
|
169
171
|
exports.OrderAction = OrderAction;
|
package/lib/browser/user.js
CHANGED
package/lib/node/decode/user.js
CHANGED
|
@@ -121,7 +121,7 @@ function decodeUser(buffer) {
|
|
|
121
121
|
const orders = [];
|
|
122
122
|
for (let i = 0; i < 32; i++) {
|
|
123
123
|
// skip order if it's not open
|
|
124
|
-
if (buffer.readUint8(offset + 82)
|
|
124
|
+
if (buffer.readUint8(offset + 82) !== 1) {
|
|
125
125
|
offset += 96;
|
|
126
126
|
continue;
|
|
127
127
|
}
|
package/lib/node/dlob/DLOB.js
CHANGED
|
@@ -73,7 +73,7 @@ class DLOB {
|
|
|
73
73
|
}
|
|
74
74
|
insertOrder(order, userAccount, slot, isUserProtectedMaker, onInsert) {
|
|
75
75
|
var _a;
|
|
76
|
-
if ((0, __1.isVariant)(order.status, '
|
|
76
|
+
if (!(0, __1.isVariant)(order.status, 'open')) {
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
if (!(0, __1.isOneOfVariant)(order.orderType, SUPPORTED_ORDER_TYPES)) {
|
|
@@ -145,7 +145,7 @@ class DLOB {
|
|
|
145
145
|
}
|
|
146
146
|
delete(order, userAccount, slot, isUserProtectedMaker, onDelete) {
|
|
147
147
|
var _a;
|
|
148
|
-
if ((0, __1.isVariant)(order.status, '
|
|
148
|
+
if (!(0, __1.isVariant)(order.status, 'open')) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
this.updateRestingLimitOrders(slot);
|
|
@@ -20,7 +20,7 @@ class NodeList {
|
|
|
20
20
|
this.nodeMap.clear();
|
|
21
21
|
}
|
|
22
22
|
insert(order, marketType, userAccount, isProtectedMaker, applyProtectedMakerOffset) {
|
|
23
|
-
if ((0, __1.isVariant)(order.status, '
|
|
23
|
+
if (!(0, __1.isVariant)(order.status, 'open')) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
const newNode = (0, DLOBNode_1.createNode)(this.nodeType, order, userAccount, isProtectedMaker, applyProtectedMakerOffset);
|
package/lib/node/math/orders.js
CHANGED
|
@@ -7,7 +7,7 @@ const anchor_1 = require("@coral-xyz/anchor");
|
|
|
7
7
|
const auction_1 = require("./auction");
|
|
8
8
|
const amm_1 = require("./amm");
|
|
9
9
|
function isOrderRiskIncreasing(user, order) {
|
|
10
|
-
if ((0, types_1.isVariant)(order.status, '
|
|
10
|
+
if (!(0, types_1.isVariant)(order.status, 'open')) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
13
|
const position = user.getPerpPosition(order.marketIndex) ||
|
|
@@ -34,7 +34,7 @@ function isOrderRiskIncreasing(user, order) {
|
|
|
34
34
|
}
|
|
35
35
|
exports.isOrderRiskIncreasing = isOrderRiskIncreasing;
|
|
36
36
|
function isOrderRiskIncreasingInSameDirection(user, order) {
|
|
37
|
-
if ((0, types_1.isVariant)(order.status, '
|
|
37
|
+
if (!(0, types_1.isVariant)(order.status, 'open')) {
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
40
|
const position = user.getPerpPosition(order.marketIndex) ||
|
|
@@ -56,7 +56,7 @@ function isOrderRiskIncreasingInSameDirection(user, order) {
|
|
|
56
56
|
}
|
|
57
57
|
exports.isOrderRiskIncreasingInSameDirection = isOrderRiskIncreasingInSameDirection;
|
|
58
58
|
function isOrderReduceOnly(user, order) {
|
|
59
|
-
if ((0, types_1.isVariant)(order.status, '
|
|
59
|
+
if (!(0, types_1.isVariant)(order.status, 'open')) {
|
|
60
60
|
return false;
|
|
61
61
|
}
|
|
62
62
|
const position = user.getPerpPosition(order.marketIndex) ||
|
package/lib/node/types.d.ts
CHANGED
|
@@ -264,6 +264,12 @@ export declare class OrderStatus {
|
|
|
264
264
|
static readonly OPEN: {
|
|
265
265
|
open: {};
|
|
266
266
|
};
|
|
267
|
+
static readonly FILLED: {
|
|
268
|
+
filled: {};
|
|
269
|
+
};
|
|
270
|
+
static readonly CANCELED: {
|
|
271
|
+
canceled: {};
|
|
272
|
+
};
|
|
267
273
|
}
|
|
268
274
|
export declare class OrderAction {
|
|
269
275
|
static readonly PLACE: {
|
package/lib/node/types.js
CHANGED
|
@@ -164,6 +164,8 @@ class OrderStatus {
|
|
|
164
164
|
exports.OrderStatus = OrderStatus;
|
|
165
165
|
OrderStatus.INIT = { init: {} };
|
|
166
166
|
OrderStatus.OPEN = { open: {} };
|
|
167
|
+
OrderStatus.FILLED = { filled: {} };
|
|
168
|
+
OrderStatus.CANCELED = { canceled: {} };
|
|
167
169
|
class OrderAction {
|
|
168
170
|
}
|
|
169
171
|
exports.OrderAction = OrderAction;
|
package/lib/node/user.js
CHANGED
package/package.json
CHANGED
package/src/decode/user.ts
CHANGED
|
@@ -139,7 +139,7 @@ export function decodeUser(buffer: Buffer): UserAccount {
|
|
|
139
139
|
const orders: Order[] = [];
|
|
140
140
|
for (let i = 0; i < 32; i++) {
|
|
141
141
|
// skip order if it's not open
|
|
142
|
-
if (buffer.readUint8(offset + 82)
|
|
142
|
+
if (buffer.readUint8(offset + 82) !== 1) {
|
|
143
143
|
offset += 96;
|
|
144
144
|
continue;
|
|
145
145
|
}
|
package/src/dlob/DLOB.ts
CHANGED
|
@@ -188,7 +188,7 @@ export class DLOB {
|
|
|
188
188
|
isUserProtectedMaker: boolean,
|
|
189
189
|
onInsert?: OrderBookCallback
|
|
190
190
|
): void {
|
|
191
|
-
if (isVariant(order.status, '
|
|
191
|
+
if (!isVariant(order.status, 'open')) {
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -290,7 +290,7 @@ export class DLOB {
|
|
|
290
290
|
isUserProtectedMaker: boolean,
|
|
291
291
|
onDelete?: OrderBookCallback
|
|
292
292
|
): void {
|
|
293
|
-
if (isVariant(order.status, '
|
|
293
|
+
if (!isVariant(order.status, 'open')) {
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
296
|
|
package/src/dlob/NodeList.ts
CHANGED
package/src/math/orders.ts
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from './amm';
|
|
23
23
|
|
|
24
24
|
export function isOrderRiskIncreasing(user: User, order: Order): boolean {
|
|
25
|
-
if (isVariant(order.status, '
|
|
25
|
+
if (!isVariant(order.status, 'open')) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -63,7 +63,7 @@ export function isOrderRiskIncreasingInSameDirection(
|
|
|
63
63
|
user: User,
|
|
64
64
|
order: Order
|
|
65
65
|
): boolean {
|
|
66
|
-
if (isVariant(order.status, '
|
|
66
|
+
if (!isVariant(order.status, 'open')) {
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -93,7 +93,7 @@ export function isOrderRiskIncreasingInSameDirection(
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export function isOrderReduceOnly(user: User, order: Order): boolean {
|
|
96
|
-
if (isVariant(order.status, '
|
|
96
|
+
if (!isVariant(order.status, 'open')) {
|
|
97
97
|
return false;
|
|
98
98
|
}
|
|
99
99
|
|
package/src/types.ts
CHANGED
|
@@ -174,6 +174,8 @@ export class MarketType {
|
|
|
174
174
|
export class OrderStatus {
|
|
175
175
|
static readonly INIT = { init: {} };
|
|
176
176
|
static readonly OPEN = { open: {} };
|
|
177
|
+
static readonly FILLED = { filled: {} };
|
|
178
|
+
static readonly CANCELED = { canceled: {} };
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
export class OrderAction {
|