@typus/typus-perp-sdk 1.0.80 → 1.0.82
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.d.ts +2 -0
- package/dist/src/api/sentio.js +78 -1
- package/dist/src/index.js +1 -1
- package/package.json +2 -2
package/dist/src/api/sentio.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function getRecentTradesFromSentio(base_token?: TOKEN): Promise<a
|
|
|
11
11
|
* value: Volume[]
|
|
12
12
|
*/
|
|
13
13
|
export declare function getTradingVolumeFromSentio(fromTimestamp: number, interval: number, toTimestamp?: number): Promise<Map<string, Volume[]>>;
|
|
14
|
+
export declare function getMinuteTradingVolumeFromSentio(base_token: TOKEN, minute: number, size: number): Promise<any[]>;
|
|
14
15
|
export interface Volume {
|
|
15
16
|
timestamp: string;
|
|
16
17
|
value: number;
|
|
@@ -31,3 +32,4 @@ export declare function getTlpPriceFromSentio(fromTimestamp?: number, toTimestam
|
|
|
31
32
|
value: number;
|
|
32
33
|
}[]>;
|
|
33
34
|
export declare function getUserPnlFromSentio(startTimestamp: number, endTimestamp: number, userAddress?: string): Promise<any[]>;
|
|
35
|
+
export declare function getLeaderboardFromSentio(size: number): Promise<any[]>;
|
package/dist/src/api/sentio.js
CHANGED
|
@@ -39,11 +39,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.getFromSentio = getFromSentio;
|
|
40
40
|
exports.getRecentTradesFromSentio = getRecentTradesFromSentio;
|
|
41
41
|
exports.getTradingVolumeFromSentio = getTradingVolumeFromSentio;
|
|
42
|
+
exports.getMinuteTradingVolumeFromSentio = getMinuteTradingVolumeFromSentio;
|
|
42
43
|
exports.getTlpFeeFromSentio = getTlpFeeFromSentio;
|
|
43
44
|
exports.getTotalVolumeFromSentio = getTotalVolumeFromSentio;
|
|
44
45
|
exports.getAccumulatedUser = getAccumulatedUser;
|
|
45
46
|
exports.getTlpPriceFromSentio = getTlpPriceFromSentio;
|
|
46
47
|
exports.getUserPnlFromSentio = getUserPnlFromSentio;
|
|
48
|
+
exports.getLeaderboardFromSentio = getLeaderboardFromSentio;
|
|
47
49
|
var src_1 = require("../../src");
|
|
48
50
|
var headers = {
|
|
49
51
|
"api-key": "ffJa6FwxeJNrQP8NZ5doEMXqdSA7XM6mT",
|
|
@@ -98,7 +100,7 @@ function getRecentTradesFromSentio(base_token) {
|
|
|
98
100
|
}
|
|
99
101
|
requestData = {
|
|
100
102
|
sqlQuery: {
|
|
101
|
-
sql: "\n SELECT\n
|
|
103
|
+
sql: "\n SELECT * FROM (\n SELECT\n PlaceOrder.timestamp as timestamp,\n PlaceOrder.base_token as base_token,\n PlaceOrder.collateral_token as collateral_token,\n PlaceOrder.order_type as order_type,\n OrderFilled.order_type as status,\n PlaceOrder.side as side,\n PlaceOrder.distinct_id as distinct_id,\n price,\n size,\n realized_amount-realized_fee-RealizeFunding.realized_funding_fee as realized_pnl,\n OrderFilled.realized_pnl-RealizeFunding.realized_funding_fee_usd as realized_pnl_usd,\n RemovePosition.remaining_collateral_amount - realized_pnl as collateral_amount,\n PlaceOrder.transaction_hash as transaction_hash\n FROM PlaceOrder\n LEFT JOIN OrderFilled ON OrderFilled.order_id == PlaceOrder.order_id AND OrderFilled.base_token == PlaceOrder.base_token\n LEFT JOIN RealizeFunding ON RealizeFunding.position_id == OrderFilled.position_id AND RealizeFunding.base_token == OrderFilled.base_token\n LEFT JOIN RealizeOption ON RealizeOption.position_id == OrderFilled.position_id AND RealizeOption.base_token == OrderFilled.base_token AND RealizeOption.transaction_hash == OrderFilled.transaction_hash\n LEFT JOIN RemovePosition ON RemovePosition.transaction_hash == OrderFilled.transaction_hash\n ".concat(tokenFilter, "\n UNION ALL\n SELECT\n PlaceOrderWithBidReceipt.timestamp as timestamp,\n PlaceOrderWithBidReceipt.base_token as base_token,\n PlaceOrderWithBidReceipt.collateral_token as collateral_token,\n PlaceOrderWithBidReceipt.order_type as order_type,\n OrderFilled.order_type as status,\n PlaceOrderWithBidReceipt.side as side,\n PlaceOrderWithBidReceipt.distinct_id as distinct_id,\n price,\n size,\n realized_amount-realized_fee-RealizeFunding.realized_funding_fee as realized_pnl,\n OrderFilled.realized_pnl-RealizeFunding.realized_funding_fee_usd as realized_pnl_usd,\n RealizeOption.exercise_balance_value as collateral_amount,\n PlaceOrderWithBidReceipt.transaction_hash as transaction_hash\n FROM PlaceOrderWithBidReceipt\n JOIN OrderFilled ON OrderFilled.order_id == PlaceOrderWithBidReceipt.order_id AND OrderFilled.base_token == PlaceOrderWithBidReceipt.base_token\n LEFT JOIN RealizeFunding ON RealizeFunding.position_id == OrderFilled.position_id AND RealizeFunding.base_token == OrderFilled.base_token\n LEFT JOIN RealizeOption ON RealizeOption.position_id == OrderFilled.position_id AND RealizeOption.base_token == OrderFilled.base_token AND RealizeOption.transaction_hash == OrderFilled.transaction_hash\n ").concat(tokenFilter, "\n ) AS combined\n ORDER BY timestamp DESC\n "),
|
|
102
104
|
size: 100,
|
|
103
105
|
},
|
|
104
106
|
};
|
|
@@ -210,6 +212,42 @@ function getTradingVolumeFromSentio(fromTimestamp, interval, toTimestamp) {
|
|
|
210
212
|
});
|
|
211
213
|
});
|
|
212
214
|
}
|
|
215
|
+
function getMinuteTradingVolumeFromSentio(base_token, minute, size) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
217
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
218
|
+
return __generator(this, function (_a) {
|
|
219
|
+
switch (_a.label) {
|
|
220
|
+
case 0:
|
|
221
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp_mainnet/sql/execute";
|
|
222
|
+
requestData = {
|
|
223
|
+
sqlQuery: {
|
|
224
|
+
sql: "\n SELECT\n toDateTime(intDiv(toUnixTimestamp(timestamp), 60 * ".concat(minute, ") * 60 * ").concat(minute, ") as ts_start,\n sum(filled_size) AS total_filled_size\n FROM OrderFilled\n WHERE base_token = '").concat((0, src_1.toSentioToken)(base_token), "'\n GROUP BY ts_start\n ORDER BY ts_start DESC;\n "),
|
|
225
|
+
size: size,
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
jsonData = JSON.stringify(requestData);
|
|
229
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
230
|
+
method: "POST",
|
|
231
|
+
headers: headers,
|
|
232
|
+
body: jsonData,
|
|
233
|
+
})];
|
|
234
|
+
case 1:
|
|
235
|
+
response = _a.sent();
|
|
236
|
+
return [4 /*yield*/, response.json()];
|
|
237
|
+
case 2:
|
|
238
|
+
data = _a.sent();
|
|
239
|
+
// console.log(data);
|
|
240
|
+
if (data.result) {
|
|
241
|
+
return [2 /*return*/, data.result.rows];
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
return [2 /*return*/, []];
|
|
245
|
+
}
|
|
246
|
+
return [2 /*return*/];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
}
|
|
213
251
|
function now() {
|
|
214
252
|
return Math.round(Date.now() / 1000);
|
|
215
253
|
}
|
|
@@ -485,6 +523,43 @@ function getUserPnlFromSentio(startTimestamp, endTimestamp, userAddress) {
|
|
|
485
523
|
});
|
|
486
524
|
});
|
|
487
525
|
}
|
|
526
|
+
function getLeaderboardFromSentio(size) {
|
|
527
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
528
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
529
|
+
return __generator(this, function (_a) {
|
|
530
|
+
switch (_a.label) {
|
|
531
|
+
case 0:
|
|
532
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp_mainnet/sql/execute";
|
|
533
|
+
requestData = {
|
|
534
|
+
version: 25,
|
|
535
|
+
sqlQuery: {
|
|
536
|
+
sql: "\n WITH\n event AS (\n SELECT\n timestamp,\n toDate(timestamp - INTERVAL 3 HOUR) AS logical_date,\n toDate(timestamp - INTERVAL 3 HOUR) AS date,\n filled_price * filled_size AS volume,\n distinct_id\n FROM OrderFilled\n ),\n sum_vol AS (\n SELECT\n logical_date,\n distinct_id,\n sum(volume) AS total_volume\n FROM event\n GROUP BY logical_date, distinct_id\n ),\n ranked AS (\n SELECT\n *,\n row_number() OVER (PARTITION BY logical_date ORDER BY total_volume DESC) AS rk\n FROM sum_vol\n ),\n top10 AS (\n SELECT *\n FROM ranked\n WHERE rk <= 10\n ),\n top10_sum AS (\n SELECT\n logical_date,\n sum(total_volume) AS top10_total_volume\n FROM top10\n GROUP BY logical_date\n )\n SELECT\n toDateTime(logical_date + INTERVAL 3 HOUR) AS Date,\n t.distinct_id as Address,\n t.total_volume as Trading_Vol,\n cast(t.total_volume AS Decimal256(18)) / cast(s.top10_total_volume AS Decimal256(18)) AS Volume_Share_Top10,\n Volume_Share_Top10 * 150 as PrizePool_Share\n FROM top10 t\n JOIN top10_sum s ON t.logical_date = s.logical_date\n ORDER BY\n Date DESC,\n t.rk ASC,\n Volume_Share_Top10\n\n ",
|
|
537
|
+
size: size,
|
|
538
|
+
},
|
|
539
|
+
};
|
|
540
|
+
jsonData = JSON.stringify(requestData);
|
|
541
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
542
|
+
method: "POST",
|
|
543
|
+
headers: headers,
|
|
544
|
+
body: jsonData,
|
|
545
|
+
})];
|
|
546
|
+
case 1:
|
|
547
|
+
response = _a.sent();
|
|
548
|
+
return [4 /*yield*/, response.json()];
|
|
549
|
+
case 2:
|
|
550
|
+
data = _a.sent();
|
|
551
|
+
// console.log(data);
|
|
552
|
+
if (data.result) {
|
|
553
|
+
return [2 /*return*/, data.result.rows];
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
return [2 /*return*/, []];
|
|
557
|
+
}
|
|
558
|
+
return [2 /*return*/];
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
}
|
|
488
563
|
// getRecentTradesFromSentio().then((x) => console.log(x));
|
|
489
564
|
// getAccumulatedUser().then((x) => console.log(x));
|
|
490
565
|
// getTradingVolumeFromSentio(1747008000, 1, 1747011600);
|
|
@@ -492,3 +567,5 @@ function getUserPnlFromSentio(startTimestamp, endTimestamp, userAddress) {
|
|
|
492
567
|
// getTotalVolumeFromSentio(0).then((x) => console.log(x));
|
|
493
568
|
// getTlpFeeFromSentio(0).then((x) => console.log(x));
|
|
494
569
|
// getUserPnlFromSentio(parseTimestamp("2025-06-24 11:00:00"), parseTimestamp("2025-07-08 11:00:00")).then((x) => console.log(x));
|
|
570
|
+
// getMinuteTradingVolumeFromSentio("SUI", 30, 10).then((x) => console.log(x));
|
|
571
|
+
// getLeaderboardFromSentio(10).then((x) => console.log(x));
|
package/dist/src/index.js
CHANGED
|
@@ -26,7 +26,7 @@ dotenv_1.default.config();
|
|
|
26
26
|
// default MAINNET
|
|
27
27
|
exports.NETWORK = process.env.NEXT_PUBLIC_CLUSTER == "testnet" ? "TESTNET" : "MAINNET";
|
|
28
28
|
// console.log(`Load .env NEXT_PUBLIC_CLUSTER: ${process.env.NEXT_PUBLIC_CLUSTER}`);
|
|
29
|
-
console.log(
|
|
29
|
+
// console.log(`Initializing Typus Perp SDK for ${NETWORK}`);
|
|
30
30
|
/** Register the MVR plugin globally */
|
|
31
31
|
var transactions_1 = require("@mysten/sui/transactions");
|
|
32
32
|
var mvrPlugin = exports.NETWORK == "MAINNET" ? "https://mainnet.mvr.mystenlabs.com" : "https://testnet.mvr.mystenlabs.com";
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typus/typus-perp-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.82",
|
|
4
4
|
"repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
|
|
5
5
|
"author": "Typus",
|
|
6
6
|
"description": "typus perp sdk",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@typus/typus-sdk": "1.7.
|
|
9
|
+
"@typus/typus-sdk": "1.7.11"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/bs58": "^4.0.1",
|