@typus/typus-perp-sdk 1.1.44 → 1.1.46
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 +11 -1
- package/dist/src/api/sentio.js +27 -33
- package/package.json +1 -1
package/dist/src/api/sentio.d.ts
CHANGED
|
@@ -41,5 +41,15 @@ interface tlpComparison {
|
|
|
41
41
|
tlp_price: number;
|
|
42
42
|
}
|
|
43
43
|
export declare function getUserPnlFromSentio(startTimestamp: number, endTimestamp: number, userAddress?: string): Promise<any[]>;
|
|
44
|
-
export declare
|
|
44
|
+
export declare enum LeaderboardType {
|
|
45
|
+
RWA = "rwa",
|
|
46
|
+
CRYPTO = "crypto"
|
|
47
|
+
}
|
|
48
|
+
export type LeaderboardData = {
|
|
49
|
+
Address: string;
|
|
50
|
+
Trading_Vol: number;
|
|
51
|
+
Volume_Share_Top10: number;
|
|
52
|
+
PrizePool_Share: number;
|
|
53
|
+
};
|
|
54
|
+
export declare function getLeaderboardFromSentio(startTs: number, endTs: number, type?: LeaderboardType): Promise<LeaderboardData[]>;
|
|
45
55
|
export {};
|
package/dist/src/api/sentio.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LeaderboardType = void 0;
|
|
3
4
|
exports.getFromSentio = getFromSentio;
|
|
4
5
|
exports.getRecentTradesFromSentio = getRecentTradesFromSentio;
|
|
5
6
|
exports.getTradingVolumeFromSentio = getTradingVolumeFromSentio;
|
|
@@ -674,34 +675,41 @@ async function getUserPnlFromSentio(startTimestamp, endTimestamp, userAddress) {
|
|
|
674
675
|
return [];
|
|
675
676
|
}
|
|
676
677
|
}
|
|
677
|
-
|
|
678
|
+
var LeaderboardType;
|
|
679
|
+
(function (LeaderboardType) {
|
|
680
|
+
LeaderboardType["RWA"] = "rwa";
|
|
681
|
+
LeaderboardType["CRYPTO"] = "crypto";
|
|
682
|
+
})(LeaderboardType || (exports.LeaderboardType = LeaderboardType = {}));
|
|
683
|
+
async function getLeaderboardFromSentio(startTs, endTs, type = LeaderboardType.CRYPTO) {
|
|
678
684
|
let apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
|
|
679
|
-
let size =
|
|
685
|
+
let size = 10;
|
|
680
686
|
let requestData = {
|
|
681
687
|
sqlQuery: {
|
|
682
688
|
sql: `
|
|
683
689
|
WITH
|
|
684
690
|
event AS (
|
|
685
691
|
SELECT
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
+
s.score / power(10, 9) AS volume,
|
|
693
|
+
s.distinct_id
|
|
694
|
+
FROM Score s
|
|
695
|
+
LEFT JOIN OrderFilled o ON s.transaction_hash = o.transaction_hash
|
|
696
|
+
WHERE o.base_token NOT IN (
|
|
697
|
+
'XAU', 'XAG', 'USOIL', 'JPY', 'SPYX', 'QQQX',
|
|
698
|
+
'TSLAX', 'NVDAX', 'AAPLX', 'GOOGLX', 'METAX'
|
|
699
|
+
)
|
|
700
|
+
AND s.timestamp >= ${startTs} AND s.timestamp < ${endTs}
|
|
692
701
|
),
|
|
693
702
|
sum_vol AS (
|
|
694
703
|
SELECT
|
|
695
|
-
logical_date,
|
|
696
704
|
distinct_id,
|
|
697
705
|
sum(volume) AS total_volume
|
|
698
706
|
FROM event
|
|
699
|
-
GROUP BY
|
|
707
|
+
GROUP BY distinct_id
|
|
700
708
|
),
|
|
701
709
|
ranked AS (
|
|
702
710
|
SELECT
|
|
703
711
|
*,
|
|
704
|
-
row_number() OVER (
|
|
712
|
+
row_number() OVER (ORDER BY total_volume DESC) AS rk
|
|
705
713
|
FROM sum_vol
|
|
706
714
|
),
|
|
707
715
|
top10 AS (
|
|
@@ -711,59 +719,50 @@ async function getLeaderboardFromSentio(startTs, endTs, checkRwaOnly = false) {
|
|
|
711
719
|
),
|
|
712
720
|
top10_sum AS (
|
|
713
721
|
SELECT
|
|
714
|
-
logical_date,
|
|
715
722
|
sum(total_volume) AS top10_total_volume
|
|
716
723
|
FROM top10
|
|
717
|
-
GROUP BY logical_date
|
|
718
724
|
)
|
|
719
725
|
SELECT
|
|
720
|
-
toDateTime(logical_date + INTERVAL 3 HOUR) AS Date,
|
|
721
726
|
t.distinct_id as Address,
|
|
722
727
|
t.total_volume as Trading_Vol,
|
|
723
728
|
cast(t.total_volume AS Decimal256(18)) / cast(s.top10_total_volume AS Decimal256(18)) AS Volume_Share_Top10,
|
|
724
729
|
Volume_Share_Top10 * 350 as PrizePool_Share
|
|
725
730
|
FROM top10 t
|
|
726
|
-
JOIN top10_sum s
|
|
727
|
-
WHERE Date >= ${startTs} AND Date < ${endTs}
|
|
731
|
+
CROSS JOIN top10_sum s
|
|
728
732
|
ORDER BY
|
|
729
|
-
|
|
730
|
-
t.rk ASC,
|
|
731
|
-
Volume_Share_Top10
|
|
732
|
-
|
|
733
|
+
t.rk ASC
|
|
733
734
|
`,
|
|
734
735
|
size,
|
|
735
736
|
},
|
|
736
737
|
};
|
|
737
|
-
if (
|
|
738
|
+
if (type === LeaderboardType.RWA) {
|
|
738
739
|
requestData = {
|
|
739
740
|
sqlQuery: {
|
|
740
741
|
sql: `
|
|
741
742
|
WITH
|
|
742
743
|
event AS (
|
|
743
744
|
SELECT
|
|
744
|
-
s.timestamp,
|
|
745
|
-
toDate(s.timestamp - INTERVAL 3 HOUR) AS logical_date,
|
|
746
745
|
s.score / power(10, 9) AS volume,
|
|
747
746
|
s.distinct_id
|
|
748
747
|
FROM Score s
|
|
749
748
|
LEFT JOIN OrderFilled o ON s.transaction_hash = o.transaction_hash
|
|
750
749
|
WHERE o.base_token IN (
|
|
751
750
|
'XAU', 'XAG', 'USOIL', 'JPY', 'SPYX', 'QQQX',
|
|
752
|
-
'TSLAX', 'NVDAX', 'AAPLX', 'GOOGLX', '
|
|
751
|
+
'TSLAX', 'NVDAX', 'AAPLX', 'GOOGLX', 'METAX'
|
|
753
752
|
)
|
|
753
|
+
AND s.timestamp >= ${startTs} AND s.timestamp < ${endTs}
|
|
754
754
|
),
|
|
755
755
|
sum_vol AS (
|
|
756
756
|
SELECT
|
|
757
|
-
logical_date,
|
|
758
757
|
distinct_id,
|
|
759
758
|
sum(volume) AS total_volume
|
|
760
759
|
FROM event
|
|
761
|
-
GROUP BY
|
|
760
|
+
GROUP BY distinct_id
|
|
762
761
|
),
|
|
763
762
|
ranked AS (
|
|
764
763
|
SELECT
|
|
765
764
|
*,
|
|
766
|
-
row_number() OVER (
|
|
765
|
+
row_number() OVER (ORDER BY total_volume DESC) AS rk
|
|
767
766
|
FROM sum_vol
|
|
768
767
|
),
|
|
769
768
|
top10 AS (
|
|
@@ -773,22 +772,17 @@ async function getLeaderboardFromSentio(startTs, endTs, checkRwaOnly = false) {
|
|
|
773
772
|
),
|
|
774
773
|
top10_sum AS (
|
|
775
774
|
SELECT
|
|
776
|
-
logical_date,
|
|
777
775
|
sum(total_volume) AS top10_total_volume
|
|
778
776
|
FROM top10
|
|
779
|
-
GROUP BY logical_date
|
|
780
777
|
)
|
|
781
778
|
SELECT
|
|
782
|
-
toDateTime(logical_date + INTERVAL 3 HOUR) AS Date,
|
|
783
779
|
t.distinct_id AS Address,
|
|
784
780
|
t.total_volume AS Trading_Vol,
|
|
785
781
|
CAST(t.total_volume AS Decimal256(18)) / CAST(s.top10_total_volume AS Decimal256(18)) AS Volume_Share_Top10,
|
|
786
782
|
Volume_Share_Top10 * 350 AS PrizePool_Share
|
|
787
783
|
FROM top10 t
|
|
788
|
-
JOIN top10_sum s
|
|
789
|
-
WHERE Date >= ${startTs} AND Date < ${endTs}
|
|
784
|
+
CROSS JOIN top10_sum s
|
|
790
785
|
ORDER BY
|
|
791
|
-
Date DESC,
|
|
792
786
|
t.rk ASC
|
|
793
787
|
`,
|
|
794
788
|
size,
|