@typus/typus-perp-sdk 1.0.69 → 1.0.71
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/src/api/sentio.js +12 -9
- package/dist/src/fetch.d.ts +6 -2
- package/dist/src/fetch.js +37 -10
- package/package.json +1 -1
package/dist/src/api/sentio.js
CHANGED
|
@@ -104,7 +104,7 @@ function getTradingVolumeFromSentio(fromTimestamp, interval, toTimestamp) {
|
|
|
104
104
|
requestData = {
|
|
105
105
|
timeRange: {
|
|
106
106
|
start: "".concat(fromTimestamp),
|
|
107
|
-
end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp :
|
|
107
|
+
end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp : now()),
|
|
108
108
|
step: 3600 * interval,
|
|
109
109
|
},
|
|
110
110
|
limit: 30 * 24,
|
|
@@ -170,6 +170,9 @@ function getTradingVolumeFromSentio(fromTimestamp, interval, toTimestamp) {
|
|
|
170
170
|
});
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
+
function now() {
|
|
174
|
+
return Math.round(Date.now() / 1000);
|
|
175
|
+
}
|
|
173
176
|
function getTlpFeeFromSentio(fromTimestamp, toTimestamp) {
|
|
174
177
|
return __awaiter(this, void 0, void 0, function () {
|
|
175
178
|
var apiUrl, requestData, jsonData, response, data, first, last, fee;
|
|
@@ -180,7 +183,7 @@ function getTlpFeeFromSentio(fromTimestamp, toTimestamp) {
|
|
|
180
183
|
requestData = {
|
|
181
184
|
timeRange: {
|
|
182
185
|
start: "".concat(fromTimestamp),
|
|
183
|
-
end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp :
|
|
186
|
+
end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp : now()),
|
|
184
187
|
step: 3600,
|
|
185
188
|
},
|
|
186
189
|
limit: 20,
|
|
@@ -234,7 +237,7 @@ function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
|
|
|
234
237
|
requestData = {
|
|
235
238
|
timeRange: {
|
|
236
239
|
start: "".concat(fromTimestamp),
|
|
237
|
-
end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp :
|
|
240
|
+
end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp : now()),
|
|
238
241
|
step: 3600,
|
|
239
242
|
},
|
|
240
243
|
limit: 1,
|
|
@@ -288,7 +291,7 @@ function getAccumulatedUser() {
|
|
|
288
291
|
requestData = {
|
|
289
292
|
timeRange: {
|
|
290
293
|
start: "now-1h",
|
|
291
|
-
end:
|
|
294
|
+
end: now(),
|
|
292
295
|
step: 3600,
|
|
293
296
|
timezone: "Asia/Taipei",
|
|
294
297
|
},
|
|
@@ -356,7 +359,7 @@ function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
|
|
|
356
359
|
requestData = {
|
|
357
360
|
timeRange: {
|
|
358
361
|
start: "".concat(fromTimestamp),
|
|
359
|
-
end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp :
|
|
362
|
+
end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp : now()),
|
|
360
363
|
step: 3600,
|
|
361
364
|
},
|
|
362
365
|
limit: 30 * 24,
|
|
@@ -391,7 +394,7 @@ function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
|
|
|
391
394
|
data = _a.sent();
|
|
392
395
|
samples = data.results[0].matrix.samples;
|
|
393
396
|
// console.log(samples[0].values);
|
|
394
|
-
return [2 /*return*/, samples];
|
|
397
|
+
return [2 /*return*/, samples[0].values];
|
|
395
398
|
}
|
|
396
399
|
});
|
|
397
400
|
});
|
|
@@ -399,6 +402,6 @@ function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
|
|
|
399
402
|
// getVolumeFromSentio();
|
|
400
403
|
// getAccumulatedUser();
|
|
401
404
|
// getTradingVolumeFromSentio(1747008000, 1, 1747011600);
|
|
402
|
-
// getTlpPriceFromSentio(
|
|
403
|
-
// getTotalVolumeFromSentio(
|
|
404
|
-
// getTlpFeeFromSentio(
|
|
405
|
+
// getTlpPriceFromSentio(now() - 3600 * 24 * 30).then((x) => console.dir(x, { depth: null }));
|
|
406
|
+
// getTotalVolumeFromSentio(now() - 3600 * 24 * 30).then((x) => console.log(x));
|
|
407
|
+
// getTlpFeeFromSentio(now() - 3600 * 24 * 30).then((x) => console.log(x));
|
package/dist/src/fetch.d.ts
CHANGED
|
@@ -21,9 +21,13 @@ export declare function getUserOrders(config: TypusConfig, user: string): Promis
|
|
|
21
21
|
export declare function getUserPositions(config: TypusConfig, user: string): Promise<Position[]>;
|
|
22
22
|
export declare function parseOptionBidReceipts(positions: Position[]): (TypusBidReceipt | null)[];
|
|
23
23
|
/**
|
|
24
|
-
* @returns [
|
|
24
|
+
* @returns [lpShare, incentives][]
|
|
25
25
|
*/
|
|
26
|
-
export declare function getUserStake(config: TypusConfig, user: string): Promise<[
|
|
26
|
+
export declare function getUserStake(config: TypusConfig, user: string): Promise<[LpUserShare, string[]][]>;
|
|
27
|
+
/**
|
|
28
|
+
* @returns deactivatingShares[]
|
|
29
|
+
*/
|
|
30
|
+
export declare function getDeactivatingShares(config: TypusConfig, user: string): Promise<DeactivatingShares<typeof TLP_TOKEN>[]>;
|
|
27
31
|
/**
|
|
28
32
|
* @returns [liquidationPrice, pnl(in USD)]
|
|
29
33
|
*/
|
package/dist/src/fetch.js
CHANGED
|
@@ -56,6 +56,7 @@ exports.getUserOrders = getUserOrders;
|
|
|
56
56
|
exports.getUserPositions = getUserPositions;
|
|
57
57
|
exports.parseOptionBidReceipts = parseOptionBidReceipts;
|
|
58
58
|
exports.getUserStake = getUserStake;
|
|
59
|
+
exports.getDeactivatingShares = getDeactivatingShares;
|
|
59
60
|
exports.getLiquidationPriceAndPnl = getLiquidationPriceAndPnl;
|
|
60
61
|
exports.getPositionCount = getPositionCount;
|
|
61
62
|
exports.getAllPositions = getAllPositions;
|
|
@@ -350,11 +351,11 @@ function parseOptionBidReceipts(positions) {
|
|
|
350
351
|
});
|
|
351
352
|
}
|
|
352
353
|
/**
|
|
353
|
-
* @returns [
|
|
354
|
+
* @returns [lpShare, incentives][]
|
|
354
355
|
*/
|
|
355
356
|
function getUserStake(config, user) {
|
|
356
357
|
return __awaiter(this, void 0, void 0, function () {
|
|
357
|
-
var provider, tx, res, returnValues, reader, lpShares_1
|
|
358
|
+
var provider, tx, res, returnValues, reader, lpShares_1;
|
|
358
359
|
return __generator(this, function (_a) {
|
|
359
360
|
switch (_a.label) {
|
|
360
361
|
case 0:
|
|
@@ -371,11 +372,6 @@ function getUserStake(config, user) {
|
|
|
371
372
|
index: BigInt(0),
|
|
372
373
|
user: user,
|
|
373
374
|
});
|
|
374
|
-
(0, functions_3.getUserDeactivatingShares)(tx, _1.TLP_TOKEN, {
|
|
375
|
-
registry: _1.LP_POOL,
|
|
376
|
-
index: BigInt(0),
|
|
377
|
-
user: user,
|
|
378
|
-
});
|
|
379
375
|
return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: user, transactionBlock: tx })];
|
|
380
376
|
case 1:
|
|
381
377
|
res = _a.sent();
|
|
@@ -394,7 +390,38 @@ function getUserStake(config, user) {
|
|
|
394
390
|
});
|
|
395
391
|
lpShares_1.push([lpShare, incentives]);
|
|
396
392
|
});
|
|
397
|
-
|
|
393
|
+
return [2 /*return*/, lpShares_1];
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
return [2 /*return*/, []];
|
|
397
|
+
}
|
|
398
|
+
return [2 /*return*/];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* @returns deactivatingShares[]
|
|
405
|
+
*/
|
|
406
|
+
function getDeactivatingShares(config, user) {
|
|
407
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
408
|
+
var provider, tx, res, returnValues, reader, deactivatingShares_1;
|
|
409
|
+
return __generator(this, function (_a) {
|
|
410
|
+
switch (_a.label) {
|
|
411
|
+
case 0:
|
|
412
|
+
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
413
|
+
tx = new transactions_1.Transaction();
|
|
414
|
+
(0, functions_3.getUserDeactivatingShares)(tx, _1.TLP_TOKEN, {
|
|
415
|
+
registry: _1.LP_POOL,
|
|
416
|
+
index: BigInt(0),
|
|
417
|
+
user: user,
|
|
418
|
+
});
|
|
419
|
+
return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: user, transactionBlock: tx })];
|
|
420
|
+
case 1:
|
|
421
|
+
res = _a.sent();
|
|
422
|
+
// console.log(res);
|
|
423
|
+
if (res.results) {
|
|
424
|
+
returnValues = res.results[0].returnValues[0][0];
|
|
398
425
|
reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
|
|
399
426
|
deactivatingShares_1 = [];
|
|
400
427
|
reader.readVec(function (reader) {
|
|
@@ -404,10 +431,10 @@ function getUserStake(config, user) {
|
|
|
404
431
|
deactivatingShares_1.push(lpShare);
|
|
405
432
|
});
|
|
406
433
|
// console.log(deactivatingShares);
|
|
407
|
-
return [2 /*return*/,
|
|
434
|
+
return [2 /*return*/, deactivatingShares_1];
|
|
408
435
|
}
|
|
409
436
|
else {
|
|
410
|
-
return [2 /*return*/, [
|
|
437
|
+
return [2 /*return*/, []];
|
|
411
438
|
}
|
|
412
439
|
return [2 /*return*/];
|
|
413
440
|
}
|