@typus/typus-perp-sdk 1.1.45 → 1.1.47

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,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 function getLeaderboardFromSentio(startTs: number, endTs: number, checkRwaOnly?: boolean): Promise<any[]>;
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 {};
@@ -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,7 +675,12 @@ async function getUserPnlFromSentio(startTimestamp, endTimestamp, userAddress) {
674
675
  return [];
675
676
  }
676
677
  }
677
- async function getLeaderboardFromSentio(startTs, endTs, checkRwaOnly = false) {
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
685
  let size = 10;
680
686
  let requestData = {
@@ -683,10 +689,15 @@ async function getLeaderboardFromSentio(startTs, endTs, checkRwaOnly = false) {
683
689
  WITH
684
690
  event AS (
685
691
  SELECT
686
- score/power(10, 9) AS volume,
687
- distinct_id
688
- FROM Score
689
- WHERE timestamp >= ${startTs} AND timestamp < ${endTs}
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}
690
701
  ),
691
702
  sum_vol AS (
692
703
  SELECT
@@ -724,7 +735,7 @@ async function getLeaderboardFromSentio(startTs, endTs, checkRwaOnly = false) {
724
735
  size,
725
736
  },
726
737
  };
727
- if (checkRwaOnly) {
738
+ if (type === LeaderboardType.RWA) {
728
739
  requestData = {
729
740
  sqlQuery: {
730
741
  sql: `
@@ -629,7 +629,13 @@ async function getOrderMatchFromSentio(userAddress, startTimestamp, events, data
629
629
  // console.log(x, related);
630
630
  if (related) {
631
631
  x.order_type = related.order_type;
632
- x.collateral = related.collateral;
632
+ if (related?.position_id !== null) {
633
+ const origin_order_filled_event = order_match.findLast(e => e.market == x.market && e.position_id == related?.position_id);
634
+ if (origin_order_filled_event) {
635
+ const origin_order_place_event = events.findLast((e) => e.order_id == origin_order_filled_event?.order_id && e.market == origin_order_filled_event?.market);
636
+ x.collateral = origin_order_place_event?.collateral ?? related.collateral;
637
+ }
638
+ }
633
639
  x.dov_index = related.dov_index;
634
640
  // it mean filled by matching cranker
635
641
  if (x.action === "Order Filled (Close Position)") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",