@drift-labs/sdk 2.49.0-beta.15 → 2.49.0-beta.16
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.49.0-beta.
|
|
1
|
+
2.49.0-beta.16
|
|
@@ -83,6 +83,7 @@ class OrderSubscriber {
|
|
|
83
83
|
if (!this.mostRecentSlot || slot > this.mostRecentSlot) {
|
|
84
84
|
this.mostRecentSlot = slot;
|
|
85
85
|
}
|
|
86
|
+
this.eventEmitter.emit('updateReceived', new web3_js_1.PublicKey(key), slot, dataType);
|
|
86
87
|
const slotAndUserAccount = this.usersAccounts.get(key);
|
|
87
88
|
if (!slotAndUserAccount || slotAndUserAccount.slot <= slot) {
|
|
88
89
|
let userAccount;
|
|
@@ -101,13 +102,14 @@ class OrderSubscriber {
|
|
|
101
102
|
else {
|
|
102
103
|
userAccount = data;
|
|
103
104
|
}
|
|
105
|
+
this.eventEmitter.emit('userUpdated', userAccount, new web3_js_1.PublicKey(key), slot, dataType);
|
|
104
106
|
const newOrders = userAccount.orders.filter((order) => {
|
|
105
107
|
var _a;
|
|
106
108
|
return order.slot.toNumber() > ((_a = slotAndUserAccount === null || slotAndUserAccount === void 0 ? void 0 : slotAndUserAccount.slot) !== null && _a !== void 0 ? _a : 0) &&
|
|
107
109
|
order.slot.toNumber() <= slot;
|
|
108
110
|
});
|
|
109
111
|
if (newOrders.length > 0) {
|
|
110
|
-
this.eventEmitter.emit('
|
|
112
|
+
this.eventEmitter.emit('orderCreated', userAccount, newOrders, new web3_js_1.PublicKey(key), slot, dataType);
|
|
111
113
|
}
|
|
112
114
|
if (userAccount.hasOpenOrder) {
|
|
113
115
|
this.usersAccounts.set(key, { slot, userAccount });
|
|
@@ -15,5 +15,7 @@ export type OrderSubscriberConfig = {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
export interface OrderSubscriberEvents {
|
|
18
|
-
|
|
18
|
+
orderCreated: (account: UserAccount, updatedOrders: Order[], pubkey: PublicKey, slot: number, dataType: 'raw' | 'decoded') => void;
|
|
19
|
+
userUpdated: (account: UserAccount, pubkey: PublicKey, slot: number, dataType: 'raw' | 'decoded') => void;
|
|
20
|
+
updateReceived: (pubkey: PublicKey, slot: number, dataType: 'raw' | 'decoded') => void;
|
|
19
21
|
}
|
package/package.json
CHANGED
|
@@ -123,6 +123,13 @@ export class OrderSubscriber {
|
|
|
123
123
|
this.mostRecentSlot = slot;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
this.eventEmitter.emit(
|
|
127
|
+
'updateReceived',
|
|
128
|
+
new PublicKey(key),
|
|
129
|
+
slot,
|
|
130
|
+
dataType
|
|
131
|
+
);
|
|
132
|
+
|
|
126
133
|
const slotAndUserAccount = this.usersAccounts.get(key);
|
|
127
134
|
if (!slotAndUserAccount || slotAndUserAccount.slot <= slot) {
|
|
128
135
|
let userAccount: UserAccount;
|
|
@@ -152,6 +159,14 @@ export class OrderSubscriber {
|
|
|
152
159
|
userAccount = data as UserAccount;
|
|
153
160
|
}
|
|
154
161
|
|
|
162
|
+
this.eventEmitter.emit(
|
|
163
|
+
'userUpdated',
|
|
164
|
+
userAccount,
|
|
165
|
+
new PublicKey(key),
|
|
166
|
+
slot,
|
|
167
|
+
dataType
|
|
168
|
+
);
|
|
169
|
+
|
|
155
170
|
const newOrders = userAccount.orders.filter(
|
|
156
171
|
(order) =>
|
|
157
172
|
order.slot.toNumber() > (slotAndUserAccount?.slot ?? 0) &&
|
|
@@ -159,7 +174,7 @@ export class OrderSubscriber {
|
|
|
159
174
|
);
|
|
160
175
|
if (newOrders.length > 0) {
|
|
161
176
|
this.eventEmitter.emit(
|
|
162
|
-
'
|
|
177
|
+
'orderCreated',
|
|
163
178
|
userAccount,
|
|
164
179
|
newOrders,
|
|
165
180
|
new PublicKey(key),
|
|
@@ -19,11 +19,22 @@ export type OrderSubscriberConfig = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export interface OrderSubscriberEvents {
|
|
22
|
-
|
|
22
|
+
orderCreated: (
|
|
23
23
|
account: UserAccount,
|
|
24
24
|
updatedOrders: Order[],
|
|
25
25
|
pubkey: PublicKey,
|
|
26
26
|
slot: number,
|
|
27
27
|
dataType: 'raw' | 'decoded'
|
|
28
28
|
) => void;
|
|
29
|
+
userUpdated: (
|
|
30
|
+
account: UserAccount,
|
|
31
|
+
pubkey: PublicKey,
|
|
32
|
+
slot: number,
|
|
33
|
+
dataType: 'raw' | 'decoded'
|
|
34
|
+
) => void;
|
|
35
|
+
updateReceived: (
|
|
36
|
+
pubkey: PublicKey,
|
|
37
|
+
slot: number,
|
|
38
|
+
dataType: 'raw' | 'decoded'
|
|
39
|
+
) => void;
|
|
29
40
|
}
|