@typus/typus-perp-sdk 1.1.44 → 1.1.45

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.
@@ -676,32 +676,29 @@ async function getUserPnlFromSentio(startTimestamp, endTimestamp, userAddress) {
676
676
  }
677
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
- let size = (10 * (endTs - startTs)) / 60 / 60 / 24; // day * 10
679
+ let size = 10;
680
680
  let requestData = {
681
681
  sqlQuery: {
682
682
  sql: `
683
683
  WITH
684
684
  event AS (
685
685
  SELECT
686
- timestamp,
687
- toDate(timestamp - INTERVAL 3 HOUR) AS logical_date,
688
- toDate(timestamp - INTERVAL 3 HOUR) AS date,
689
686
  score/power(10, 9) AS volume,
690
687
  distinct_id
691
688
  FROM Score
689
+ WHERE timestamp >= ${startTs} AND timestamp < ${endTs}
692
690
  ),
693
691
  sum_vol AS (
694
692
  SELECT
695
- logical_date,
696
693
  distinct_id,
697
694
  sum(volume) AS total_volume
698
695
  FROM event
699
- GROUP BY logical_date, distinct_id
696
+ GROUP BY distinct_id
700
697
  ),
701
698
  ranked AS (
702
699
  SELECT
703
700
  *,
704
- row_number() OVER (PARTITION BY logical_date ORDER BY total_volume DESC) AS rk
701
+ row_number() OVER (ORDER BY total_volume DESC) AS rk
705
702
  FROM sum_vol
706
703
  ),
707
704
  top10 AS (
@@ -711,25 +708,18 @@ async function getLeaderboardFromSentio(startTs, endTs, checkRwaOnly = false) {
711
708
  ),
712
709
  top10_sum AS (
713
710
  SELECT
714
- logical_date,
715
711
  sum(total_volume) AS top10_total_volume
716
712
  FROM top10
717
- GROUP BY logical_date
718
713
  )
719
714
  SELECT
720
- toDateTime(logical_date + INTERVAL 3 HOUR) AS Date,
721
715
  t.distinct_id as Address,
722
716
  t.total_volume as Trading_Vol,
723
717
  cast(t.total_volume AS Decimal256(18)) / cast(s.top10_total_volume AS Decimal256(18)) AS Volume_Share_Top10,
724
718
  Volume_Share_Top10 * 350 as PrizePool_Share
725
719
  FROM top10 t
726
- JOIN top10_sum s ON t.logical_date = s.logical_date
727
- WHERE Date >= ${startTs} AND Date < ${endTs}
720
+ CROSS JOIN top10_sum s
728
721
  ORDER BY
729
- Date DESC,
730
- t.rk ASC,
731
- Volume_Share_Top10
732
-
722
+ t.rk ASC
733
723
  `,
734
724
  size,
735
725
  },
@@ -741,29 +731,27 @@ async function getLeaderboardFromSentio(startTs, endTs, checkRwaOnly = false) {
741
731
  WITH
742
732
  event AS (
743
733
  SELECT
744
- s.timestamp,
745
- toDate(s.timestamp - INTERVAL 3 HOUR) AS logical_date,
746
734
  s.score / power(10, 9) AS volume,
747
735
  s.distinct_id
748
736
  FROM Score s
749
737
  LEFT JOIN OrderFilled o ON s.transaction_hash = o.transaction_hash
750
738
  WHERE o.base_token IN (
751
739
  'XAU', 'XAG', 'USOIL', 'JPY', 'SPYX', 'QQQX',
752
- 'TSLAX', 'NVDAX', 'AAPLX', 'GOOGLX', 'MEATAX'
740
+ 'TSLAX', 'NVDAX', 'AAPLX', 'GOOGLX', 'METAX'
753
741
  )
742
+ AND s.timestamp >= ${startTs} AND s.timestamp < ${endTs}
754
743
  ),
755
744
  sum_vol AS (
756
745
  SELECT
757
- logical_date,
758
746
  distinct_id,
759
747
  sum(volume) AS total_volume
760
748
  FROM event
761
- GROUP BY logical_date, distinct_id
749
+ GROUP BY distinct_id
762
750
  ),
763
751
  ranked AS (
764
752
  SELECT
765
753
  *,
766
- row_number() OVER (PARTITION BY logical_date ORDER BY total_volume DESC) AS rk
754
+ row_number() OVER (ORDER BY total_volume DESC) AS rk
767
755
  FROM sum_vol
768
756
  ),
769
757
  top10 AS (
@@ -773,22 +761,17 @@ async function getLeaderboardFromSentio(startTs, endTs, checkRwaOnly = false) {
773
761
  ),
774
762
  top10_sum AS (
775
763
  SELECT
776
- logical_date,
777
764
  sum(total_volume) AS top10_total_volume
778
765
  FROM top10
779
- GROUP BY logical_date
780
766
  )
781
767
  SELECT
782
- toDateTime(logical_date + INTERVAL 3 HOUR) AS Date,
783
768
  t.distinct_id AS Address,
784
769
  t.total_volume AS Trading_Vol,
785
770
  CAST(t.total_volume AS Decimal256(18)) / CAST(s.top10_total_volume AS Decimal256(18)) AS Volume_Share_Top10,
786
771
  Volume_Share_Top10 * 350 AS PrizePool_Share
787
772
  FROM top10 t
788
- JOIN top10_sum s ON t.logical_date = s.logical_date
789
- WHERE Date >= ${startTs} AND Date < ${endTs}
773
+ CROSS JOIN top10_sum s
790
774
  ORDER BY
791
- Date DESC,
792
775
  t.rk ASC
793
776
  `,
794
777
  size,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.1.44",
3
+ "version": "1.1.45",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",