@typus/typus-perp-sdk 1.1.0 → 1.1.2

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.
@@ -100,7 +100,7 @@ function getRecentTradesFromSentio(base_token) {
100
100
  }
101
101
  requestData = {
102
102
  sqlQuery: {
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 "),
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 GREATEST(PlaceOrder.collateral, RemovePosition.remaining_collateral_amount) 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 AND RealizeFunding.transaction_hash == OrderFilled.transaction_hash\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 AND RealizeFunding.transaction_hash == OrderFilled.transaction_hash\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 "),
104
104
  size: 100,
105
105
  },
106
106
  };
@@ -534,7 +534,7 @@ function getLeaderboardFromSentio(startTs, endTs) {
534
534
  requestData = {
535
535
  version: 25,
536
536
  sqlQuery: {
537
- 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 WHERE Date >= ".concat(startTs, " AND Date < ").concat(endTs, "\n ORDER BY\n Date DESC,\n t.rk ASC,\n Volume_Share_Top10\n\n "),
537
+ 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 score/power(10, 9) AS volume,\n distinct_id\n FROM Score\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 WHERE Date >= ".concat(startTs, " AND Date < ").concat(endTs, "\n ORDER BY\n Date DESC,\n t.rk ASC,\n Volume_Share_Top10\n\n "),
538
538
  size: size,
539
539
  },
540
540
  };
@@ -569,4 +569,4 @@ function getLeaderboardFromSentio(startTs, endTs) {
569
569
  // getTlpFeeFromSentio(0).then((x) => console.log(x));
570
570
  // getUserPnlFromSentio(parseTimestamp("2025-06-24 11:00:00"), parseTimestamp("2025-07-08 11:00:00")).then((x) => console.log(x));
571
571
  // getMinuteTradingVolumeFromSentio("SUI", 30, 10).then((x) => console.log(x));
572
- // getLeaderboardFromSentio(1753142400, 1753401600).then((x) => console.log(x, x.length));
572
+ // getLeaderboardFromSentio(1754362800, 1754362800 + 60 * 60 * 24 * 14).then((x) => console.log(x, x.length));
@@ -84,7 +84,7 @@ function createTradingOrder(config, tx, pythClient, input) {
84
84
  tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
85
85
  cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
86
86
  baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
87
- if (TOKEN == constants_1.tokenType.MAINNET.SUI && config.sponsored) {
87
+ if (TOKEN == "SUI" && config.sponsored) {
88
88
  // split together
89
89
  _a = __read((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], config.sponsored), 2), coin = _a[0], suiCoin = _a[1];
90
90
  }
@@ -177,7 +177,7 @@ function increaseCollateral(config, tx, pythClient, input) {
177
177
  tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
178
178
  cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
179
179
  baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
180
- if (TOKEN == constants_1.tokenType.MAINNET.SUI && config.sponsored) {
180
+ if (TOKEN == "SUI" && config.sponsored) {
181
181
  // split together
182
182
  _a = __read((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], config.sponsored), 2), coin = _a[0], suiCoin = _a[1];
183
183
  }
@@ -102,7 +102,7 @@ function mintStakeLp(config, tx, pythClient, input) {
102
102
  case 0:
103
103
  tokens = input.lpPool.tokenPools.map(function (p) { return (0, constants_1.typeArgToAsset)("0x" + p.tokenType.name); });
104
104
  cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
105
- if (input.cTOKEN == constants_1.tokenType.MAINNET.SUI && config.sponsored) {
105
+ if (input.cTOKEN == "SUI" && config.sponsored) {
106
106
  // split together
107
107
  _a = __read((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], config.sponsored), 2), coin = _a[0], suiCoin = _a[1];
108
108
  }
@@ -406,7 +406,7 @@ function swap(config, tx, pythClient, input) {
406
406
  case 0:
407
407
  fromToken = constants_1.tokenType[__1.NETWORK][input.FROM_TOKEN];
408
408
  toToken = constants_1.tokenType[__1.NETWORK][input.TO_TOKEN];
409
- if (input.FROM_TOKEN == constants_1.tokenType.MAINNET.SUI && config.sponsored) {
409
+ if (input.FROM_TOKEN == "SUI" && config.sponsored) {
410
410
  // split together
411
411
  _a = __read((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, "2"], config.sponsored), 2), coin = _a[0], suiCoin = _a[1];
412
412
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",