@typus/typus-perp-sdk 1.1.42 → 1.1.44

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.
@@ -41,5 +41,5 @@ 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 function getLeaderboardFromSentio(startTs: number, endTs: number): Promise<any[]>;
44
+ export declare function getLeaderboardFromSentio(startTs: number, endTs: number, checkRwaOnly?: boolean): Promise<any[]>;
45
45
  export {};
@@ -674,7 +674,7 @@ async function getUserPnlFromSentio(startTimestamp, endTimestamp, userAddress) {
674
674
  return [];
675
675
  }
676
676
  }
677
- async function getLeaderboardFromSentio(startTs, endTs) {
677
+ async function getLeaderboardFromSentio(startTs, endTs, checkRwaOnly = false) {
678
678
  let apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
679
679
  let size = (10 * (endTs - startTs)) / 60 / 60 / 24; // day * 10
680
680
  let requestData = {
@@ -721,7 +721,7 @@ async function getLeaderboardFromSentio(startTs, endTs) {
721
721
  t.distinct_id as Address,
722
722
  t.total_volume as Trading_Vol,
723
723
  cast(t.total_volume AS Decimal256(18)) / cast(s.top10_total_volume AS Decimal256(18)) AS Volume_Share_Top10,
724
- Volume_Share_Top10 * 150 as PrizePool_Share
724
+ Volume_Share_Top10 * 350 as PrizePool_Share
725
725
  FROM top10 t
726
726
  JOIN top10_sum s ON t.logical_date = s.logical_date
727
727
  WHERE Date >= ${startTs} AND Date < ${endTs}
@@ -734,6 +734,67 @@ async function getLeaderboardFromSentio(startTs, endTs) {
734
734
  size,
735
735
  },
736
736
  };
737
+ if (checkRwaOnly) {
738
+ requestData = {
739
+ sqlQuery: {
740
+ sql: `
741
+ WITH
742
+ event AS (
743
+ SELECT
744
+ s.timestamp,
745
+ toDate(s.timestamp - INTERVAL 3 HOUR) AS logical_date,
746
+ s.score / power(10, 9) AS volume,
747
+ s.distinct_id
748
+ FROM Score s
749
+ LEFT JOIN OrderFilled o ON s.transaction_hash = o.transaction_hash
750
+ WHERE o.base_token IN (
751
+ 'XAU', 'XAG', 'USOIL', 'JPY', 'SPYX', 'QQQX',
752
+ 'TSLAX', 'NVDAX', 'AAPLX', 'GOOGLX', 'MEATAX'
753
+ )
754
+ ),
755
+ sum_vol AS (
756
+ SELECT
757
+ logical_date,
758
+ distinct_id,
759
+ sum(volume) AS total_volume
760
+ FROM event
761
+ GROUP BY logical_date, distinct_id
762
+ ),
763
+ ranked AS (
764
+ SELECT
765
+ *,
766
+ row_number() OVER (PARTITION BY logical_date ORDER BY total_volume DESC) AS rk
767
+ FROM sum_vol
768
+ ),
769
+ top10 AS (
770
+ SELECT *
771
+ FROM ranked
772
+ WHERE rk <= 10
773
+ ),
774
+ top10_sum AS (
775
+ SELECT
776
+ logical_date,
777
+ sum(total_volume) AS top10_total_volume
778
+ FROM top10
779
+ GROUP BY logical_date
780
+ )
781
+ SELECT
782
+ toDateTime(logical_date + INTERVAL 3 HOUR) AS Date,
783
+ t.distinct_id AS Address,
784
+ t.total_volume AS Trading_Vol,
785
+ CAST(t.total_volume AS Decimal256(18)) / CAST(s.top10_total_volume AS Decimal256(18)) AS Volume_Share_Top10,
786
+ Volume_Share_Top10 * 350 AS PrizePool_Share
787
+ FROM top10 t
788
+ JOIN top10_sum s ON t.logical_date = s.logical_date
789
+ WHERE Date >= ${startTs} AND Date < ${endTs}
790
+ ORDER BY
791
+ Date DESC,
792
+ t.rk ASC
793
+ `,
794
+ size,
795
+ }
796
+ };
797
+ }
737
798
  let jsonData = JSON.stringify(requestData);
738
799
  let response = await fetch(apiUrl, {
739
800
  method: "POST",
@@ -741,7 +802,7 @@ async function getLeaderboardFromSentio(startTs, endTs) {
741
802
  body: jsonData,
742
803
  });
743
804
  let data = await response.json();
744
- // console.log(data);
805
+ // console.log(data.result.rows);
745
806
  if (data.result) {
746
807
  return data.result.rows;
747
808
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.1.42",
3
+ "version": "1.1.44",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",
@@ -45,4 +45,4 @@
45
45
  },
46
46
  "homepage": "https://github.com/Typus-Lab/typus-perp-sdk#readme",
47
47
  "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
48
- }
48
+ }