@pear-protocol/hyperliquid-sdk 0.0.2 → 0.0.4
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/dist/index.d.ts +16 -2
- package/dist/index.esm.js +32 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +32 -12
- package/dist/index.js.map +1 -1
- package/dist/migration-sdk.d.ts +16 -2
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -98,7 +98,9 @@ class PearHyperliquidClient {
|
|
|
98
98
|
*/
|
|
99
99
|
class PearMigrationSDK {
|
|
100
100
|
constructor(client) {
|
|
101
|
-
this.
|
|
101
|
+
this.isTradeHistorySyncRunning = false;
|
|
102
|
+
this.isOpenPositionsSyncRunning = false;
|
|
103
|
+
this.isOpenOrdersSyncRunning = false;
|
|
102
104
|
this.client = client;
|
|
103
105
|
}
|
|
104
106
|
/**
|
|
@@ -107,16 +109,16 @@ class PearMigrationSDK {
|
|
|
107
109
|
*/
|
|
108
110
|
async syncTradeHistory(payload) {
|
|
109
111
|
// If sync is already running, return immediately
|
|
110
|
-
if (this.
|
|
112
|
+
if (this.isTradeHistorySyncRunning) {
|
|
111
113
|
return null;
|
|
112
114
|
}
|
|
113
115
|
try {
|
|
114
|
-
this.
|
|
116
|
+
this.isTradeHistorySyncRunning = true;
|
|
115
117
|
const response = await this.client.syncTradeHistory(payload);
|
|
116
118
|
return response;
|
|
117
119
|
}
|
|
118
120
|
finally {
|
|
119
|
-
this.
|
|
121
|
+
this.isTradeHistorySyncRunning = false;
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
/**
|
|
@@ -125,16 +127,16 @@ class PearMigrationSDK {
|
|
|
125
127
|
*/
|
|
126
128
|
async syncOpenPositions(payload) {
|
|
127
129
|
// If sync is already running, return immediately
|
|
128
|
-
if (this.
|
|
130
|
+
if (this.isOpenPositionsSyncRunning) {
|
|
129
131
|
return null;
|
|
130
132
|
}
|
|
131
133
|
try {
|
|
132
|
-
this.
|
|
134
|
+
this.isOpenPositionsSyncRunning = true;
|
|
133
135
|
const response = await this.client.syncOpenPositions(payload);
|
|
134
136
|
return response;
|
|
135
137
|
}
|
|
136
138
|
finally {
|
|
137
|
-
this.
|
|
139
|
+
this.isOpenPositionsSyncRunning = false;
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
/**
|
|
@@ -143,23 +145,41 @@ class PearMigrationSDK {
|
|
|
143
145
|
*/
|
|
144
146
|
async syncOpenOrders(payload) {
|
|
145
147
|
// If sync is already running, return immediately
|
|
146
|
-
if (this.
|
|
148
|
+
if (this.isOpenOrdersSyncRunning) {
|
|
147
149
|
return null;
|
|
148
150
|
}
|
|
149
151
|
try {
|
|
150
|
-
this.
|
|
152
|
+
this.isOpenOrdersSyncRunning = true;
|
|
151
153
|
const response = await this.client.syncOpenOrders(payload);
|
|
152
154
|
return response;
|
|
153
155
|
}
|
|
154
156
|
finally {
|
|
155
|
-
this.
|
|
157
|
+
this.isOpenOrdersSyncRunning = false;
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
/**
|
|
159
|
-
* Check if sync is currently running
|
|
161
|
+
* Check if any sync is currently running
|
|
160
162
|
*/
|
|
161
163
|
isSyncInProgress() {
|
|
162
|
-
return this.
|
|
164
|
+
return this.isTradeHistorySyncRunning || this.isOpenPositionsSyncRunning || this.isOpenOrdersSyncRunning;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Check if trade history sync is currently running
|
|
168
|
+
*/
|
|
169
|
+
isTradeHistorySyncInProgress() {
|
|
170
|
+
return this.isTradeHistorySyncRunning;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Check if open positions sync is currently running
|
|
174
|
+
*/
|
|
175
|
+
isOpenPositionsSyncInProgress() {
|
|
176
|
+
return this.isOpenPositionsSyncRunning;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Check if open orders sync is currently running
|
|
180
|
+
*/
|
|
181
|
+
isOpenOrdersSyncInProgress() {
|
|
182
|
+
return this.isOpenOrdersSyncRunning;
|
|
163
183
|
}
|
|
164
184
|
/**
|
|
165
185
|
* Get the underlying client instance
|