@drift-labs/sdk 0.1.36-master.0 → 0.1.36-master.3
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/accounts/pollingClearingHouseAccountSubscriber.js +10 -2
- package/lib/accounts/pollingOracleSubscriber.d.ts +1 -0
- package/lib/accounts/pollingOracleSubscriber.js +15 -4
- package/lib/accounts/pollingTokenAccountSubscriber.d.ts +1 -0
- package/lib/accounts/pollingTokenAccountSubscriber.js +15 -4
- package/lib/accounts/pollingUserAccountSubscriber.js +7 -2
- package/lib/idl/clearing_house.json +286 -286
- package/lib/math/amm.d.ts +1 -0
- package/lib/math/amm.js +16 -3
- package/lib/math/state.d.ts +8 -0
- package/lib/math/state.js +15 -0
- package/package.json +1 -1
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +12 -2
- package/src/accounts/pollingOracleSubscriber.ts +18 -4
- package/src/accounts/pollingTokenAccountSubscriber.ts +17 -4
- package/src/accounts/pollingUserAccountSubscriber.ts +7 -2
- package/src/idl/clearing_house.json +286 -286
- package/src/math/amm.ts +20 -2
- package/src/math/state.ts +14 -0
|
@@ -41,8 +41,13 @@ class PollingClearingHouseAccountSubscriber {
|
|
|
41
41
|
});
|
|
42
42
|
yield this.updateAccountsToPoll();
|
|
43
43
|
yield this.addToAccountLoader();
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
let subscriptionSucceeded = false;
|
|
45
|
+
let retries = 0;
|
|
46
|
+
while (!subscriptionSucceeded && retries < 5) {
|
|
47
|
+
yield this.fetch();
|
|
48
|
+
subscriptionSucceeded = this.didSubscriptionSucceed();
|
|
49
|
+
retries++;
|
|
50
|
+
}
|
|
46
51
|
if (subscriptionSucceeded) {
|
|
47
52
|
this.eventEmitter.emit('update');
|
|
48
53
|
}
|
|
@@ -162,6 +167,9 @@ class PollingClearingHouseAccountSubscriber {
|
|
|
162
167
|
// @ts-ignore
|
|
163
168
|
this.eventEmitter.emit(accountToPoll.eventType, account);
|
|
164
169
|
this.eventEmitter.emit('update');
|
|
170
|
+
if (!this.isSubscribed) {
|
|
171
|
+
this.isSubscribed = this.didSubscriptionSucceed();
|
|
172
|
+
}
|
|
165
173
|
});
|
|
166
174
|
}
|
|
167
175
|
this.errorCallbackId = this.accountLoader.addErrorCallbacks((error) => {
|
|
@@ -26,10 +26,18 @@ class PollingOracleSubscriber {
|
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
this.addToAccountLoader();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
let subscriptionSucceeded = false;
|
|
30
|
+
let retries = 0;
|
|
31
|
+
while (!subscriptionSucceeded && retries < 5) {
|
|
32
|
+
yield this.fetch();
|
|
33
|
+
subscriptionSucceeded = this.didSubscriptionSucceed();
|
|
34
|
+
retries++;
|
|
35
|
+
}
|
|
36
|
+
if (subscriptionSucceeded) {
|
|
37
|
+
this.eventEmitter.emit('update');
|
|
38
|
+
}
|
|
39
|
+
this.isSubscribed = subscriptionSucceeded;
|
|
40
|
+
return subscriptionSucceeded;
|
|
33
41
|
});
|
|
34
42
|
}
|
|
35
43
|
addToAccountLoader() {
|
|
@@ -75,5 +83,8 @@ class PollingOracleSubscriber {
|
|
|
75
83
|
this.assertIsSubscribed();
|
|
76
84
|
return this.oraclePriceData;
|
|
77
85
|
}
|
|
86
|
+
didSubscriptionSucceed() {
|
|
87
|
+
return !!this.oraclePriceData;
|
|
88
|
+
}
|
|
78
89
|
}
|
|
79
90
|
exports.PollingOracleSubscriber = PollingOracleSubscriber;
|
|
@@ -26,10 +26,18 @@ class PollingTokenAccountSubscriber {
|
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
this.addToAccountLoader();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
let subscriptionSucceeded = false;
|
|
30
|
+
let retries = 0;
|
|
31
|
+
while (!subscriptionSucceeded && retries < 5) {
|
|
32
|
+
yield this.fetch();
|
|
33
|
+
subscriptionSucceeded = this.didSubscriptionSucceed();
|
|
34
|
+
retries++;
|
|
35
|
+
}
|
|
36
|
+
if (subscriptionSucceeded) {
|
|
37
|
+
this.eventEmitter.emit('update');
|
|
38
|
+
}
|
|
39
|
+
this.isSubscribed = subscriptionSucceeded;
|
|
40
|
+
return subscriptionSucceeded;
|
|
33
41
|
});
|
|
34
42
|
}
|
|
35
43
|
addToAccountLoader() {
|
|
@@ -75,5 +83,8 @@ class PollingTokenAccountSubscriber {
|
|
|
75
83
|
this.assertIsSubscribed();
|
|
76
84
|
return this.tokenAccount;
|
|
77
85
|
}
|
|
86
|
+
didSubscriptionSucceed() {
|
|
87
|
+
return !!this.tokenAccount;
|
|
88
|
+
}
|
|
78
89
|
}
|
|
79
90
|
exports.PollingTokenAccountSubscriber = PollingTokenAccountSubscriber;
|
|
@@ -30,8 +30,13 @@ class PollingUserAccountSubscriber {
|
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
32
|
yield this.addToAccountLoader();
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
let subscriptionSucceeded = false;
|
|
34
|
+
let retries = 0;
|
|
35
|
+
while (!subscriptionSucceeded && retries < 5) {
|
|
36
|
+
yield this.fetchIfUnloaded();
|
|
37
|
+
subscriptionSucceeded = this.didSubscriptionSucceed();
|
|
38
|
+
retries++;
|
|
39
|
+
}
|
|
35
40
|
if (subscriptionSucceeded) {
|
|
36
41
|
this.eventEmitter.emit('update');
|
|
37
42
|
}
|