@typus/typus-sdk 1.6.3 → 1.6.4

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.
@@ -10,7 +10,7 @@ interface VaultHistorySummary {
10
10
  TotalOptionProfit: number;
11
11
  TotalSell: string;
12
12
  }
13
- export declare function getVaultHistory(index: string, limit?: number): Promise<VaultHistory[]>;
13
+ export declare function getVaultHistory(indices: string[], limit?: number): Promise<VaultHistory[]>;
14
14
  interface VaultHistory {
15
15
  ActivationDate: string;
16
16
  BidderPNL: string;
@@ -117,8 +117,8 @@ function getFilledSummary(startTimestamp) {
117
117
  });
118
118
  });
119
119
  }
120
- function getVaultHistory(index_1) {
121
- return __awaiter(this, arguments, void 0, function (index, limit) {
120
+ function getVaultHistory(indices_1) {
121
+ return __awaiter(this, arguments, void 0, function (indices, limit) {
122
122
  var apiUrl, requestData, jsonData, response, data, result;
123
123
  if (limit === void 0) { limit = 100; }
124
124
  return __generator(this, function (_a) {
@@ -127,7 +127,7 @@ function getVaultHistory(index_1) {
127
127
  apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
128
128
  requestData = {
129
129
  sqlQuery: {
130
- sql: "\n WITH hourly_price_table AS (\n SELECT\n symbol,\n toStartOfHour(time) AS hour,\n argMax(price, time) AS hourly_price -- Get the most recent price before or at the hour\n FROM\n token.prices\n GROUP BY\n symbol, hour\n ),\n safu_otc_aggregated AS (\n SELECT\n index,\n round,\n AVG(delivery_price) AS delivery_price,\n SUM(delivery_size) AS delivery_size,\n SUM(bidder_bid_value) AS bidder_bid_value\n FROM SafuOtc\n GROUP BY index, round\n )\n SELECT\n Settle.timestamp as timestamp,\n Settle.index as Index,\n Settle.round as Round,\n NewAuction.start_ts_ms as ActivationDate,\n COALESCE(NULLIF(UpdateStrike.strikes, ''), NewAuction.strikes) AS Strikes, -- \u5982\u679C UpdateStrike.strikes \u662F\u7A7A\u5B57\u7B26\u4E32\uFF0C\u5C31\u4F7F\u7528 NewAuction.strikes\n Settle.oracle_price as SettlePrice,\n -- Settle.share_price as share_price,\n -- Settle.settle_balance as SettleBalance,\n Activate.deposit_balance as DepositAmount,\n DepositAmount * Settle.price_d_token as DepositAmountUSD,\n Delivery.max_size as MaxSize,\n (safu_otc_aggregated.delivery_size + Delivery.delivery_size) as TotalSell,\n CASE WHEN MaxSize != 0 THEN TotalSell / MaxSize ELSE 0 END AS Filled,\n Delivery.delivery_size as DeliverySize,\n Delivery.delivery_price as DeliveryPrice,\n safu_otc_aggregated.delivery_size as OtcSize,\n safu_otc_aggregated.delivery_price as OtcPrice,\n Delivery.bidder_bid_value as BidderPremium,\n BidderPremium * Delivery.price_b_token as BidderPremiumUSD,\n Delivery.incentive_bid_value as IncentivePremium,\n safu_otc_aggregated.bidder_bid_value as OtcPremium,\n (Delivery.bidder_bid_value + Delivery.incentive_bid_value + safu_otc_aggregated.bidder_bid_value) AS Premium, -- Total Premium b_token\n Premium * Delivery.price_b_token AS PremiumUSD,\n Delivery.depositor_incentive_value as BpIncentive, -- SUI or SCA based on o_token\n BpIncentive * Delivery.price_o_token as BpIncentiveUSD,\n Delivery.fixed_incentive_amount as FixedIncentive, -- SUI\n FixedIncentive * hourly_price_table.hourly_price as FixedIncentiveUSD,\n (1 - Settle.share_price) as LossPecentage,\n (Settle.settle_balance - Settle.settled_balance) as OptionProfit, -- d_token\n OptionProfit * Settle.price_d_token as OptionProfitUSD,\n PremiumUSD + BpIncentiveUSD + FixedIncentiveUSD - OptionProfitUSD as DepositorPNL,\n -- CASE WHEN DepositAmountUSD != 0 THEN DepositorPNL / DepositAmountUSD ELSE 0 END AS DepositorROI,\n OptionProfitUSD - BidderPremiumUSD as BidderPNL,\n CASE WHEN BidderPremiumUSD != 0 THEN BidderPNL / BidderPremiumUSD ELSE 0 END AS BidderROI,\n Settle.d_token as d_token,\n Delivery.b_token as b_token,\n Delivery.o_token as o_token\n FROM Settle\n JOIN Activate ON Settle.index = Activate.index AND Settle.round = Activate.round\n JOIN NewAuction ON Settle.index = NewAuction.index AND Settle.round = NewAuction.round\n LEFT JOIN UpdateStrike ON Settle.index = UpdateStrike.index AND Settle.round = UpdateStrike.round\n JOIN Delivery ON Settle.index = Delivery.index AND Settle.round = Delivery.round\n LEFT JOIN safu_otc_aggregated ON Settle.index = safu_otc_aggregated.index AND Settle.round = safu_otc_aggregated.round\n -- LEFT JOIN hourly_price_table ON LOWER(Settle.d_token) = hourly_price_table.symbol AND toStartOfHour(Settle.timestamp) = hourly_price_table.hour\n LEFT JOIN hourly_price_table ON 'sui' = hourly_price_table.symbol AND toStartOfHour(Settle.timestamp) = hourly_price_table.hour\n WHERE Settle.index = ".concat(index, "\n ORDER BY ActivationDate DESC;\n "),
130
+ sql: "\n WITH hourly_price_table AS (\n SELECT\n symbol,\n toStartOfHour(time) AS hour,\n argMax(price, time) AS hourly_price -- Get the most recent price before or at the hour\n FROM\n token.prices\n GROUP BY\n symbol, hour\n ),\n safu_otc_aggregated AS (\n SELECT\n index,\n round,\n AVG(delivery_price) AS delivery_price,\n SUM(delivery_size) AS delivery_size,\n SUM(bidder_bid_value) AS bidder_bid_value\n FROM SafuOtc\n GROUP BY index, round\n )\n SELECT\n Settle.timestamp as timestamp,\n Settle.index as Index,\n Settle.round as Round,\n NewAuction.start_ts_ms as ActivationDate,\n COALESCE(NULLIF(UpdateStrike.strikes, ''), NewAuction.strikes) AS Strikes, -- \u5982\u679C UpdateStrike.strikes \u662F\u7A7A\u5B57\u7B26\u4E32\uFF0C\u5C31\u4F7F\u7528 NewAuction.strikes\n Settle.oracle_price as SettlePrice,\n -- Settle.share_price as share_price,\n -- Settle.settle_balance as SettleBalance,\n Activate.deposit_balance as DepositAmount,\n DepositAmount * Settle.price_d_token as DepositAmountUSD,\n Delivery.max_size as MaxSize,\n (safu_otc_aggregated.delivery_size + Delivery.delivery_size) as TotalSell,\n CASE WHEN MaxSize != 0 THEN TotalSell / MaxSize ELSE 0 END AS Filled,\n Delivery.delivery_size as DeliverySize,\n Delivery.delivery_price as DeliveryPrice,\n safu_otc_aggregated.delivery_size as OtcSize,\n safu_otc_aggregated.delivery_price as OtcPrice,\n Delivery.bidder_bid_value as BidderPremium,\n BidderPremium * Delivery.price_b_token as BidderPremiumUSD,\n Delivery.incentive_bid_value as IncentivePremium,\n safu_otc_aggregated.bidder_bid_value as OtcPremium,\n (Delivery.bidder_bid_value + Delivery.incentive_bid_value + safu_otc_aggregated.bidder_bid_value) AS Premium, -- Total Premium b_token\n Premium * Delivery.price_b_token AS PremiumUSD,\n Delivery.depositor_incentive_value as BpIncentive, -- SUI or SCA based on o_token\n BpIncentive * Delivery.price_o_token as BpIncentiveUSD,\n Delivery.fixed_incentive_amount as FixedIncentive, -- SUI\n FixedIncentive * hourly_price_table.hourly_price as FixedIncentiveUSD,\n (1 - Settle.share_price) as LossPecentage,\n (Settle.settle_balance - Settle.settled_balance) as OptionProfit, -- d_token\n OptionProfit * Settle.price_d_token as OptionProfitUSD,\n PremiumUSD + BpIncentiveUSD + FixedIncentiveUSD - OptionProfitUSD as DepositorPNL,\n -- CASE WHEN DepositAmountUSD != 0 THEN DepositorPNL / DepositAmountUSD ELSE 0 END AS DepositorROI,\n OptionProfitUSD - BidderPremiumUSD as BidderPNL,\n CASE WHEN BidderPremiumUSD != 0 THEN BidderPNL / BidderPremiumUSD ELSE 0 END AS BidderROI,\n Settle.d_token as d_token,\n Delivery.b_token as b_token,\n Delivery.o_token as o_token\n FROM Settle\n JOIN Activate ON Settle.index = Activate.index AND Settle.round = Activate.round\n JOIN NewAuction ON Settle.index = NewAuction.index AND Settle.round = NewAuction.round\n LEFT JOIN UpdateStrike ON Settle.index = UpdateStrike.index AND Settle.round = UpdateStrike.round\n JOIN Delivery ON Settle.index = Delivery.index AND Settle.round = Delivery.round\n LEFT JOIN safu_otc_aggregated ON Settle.index = safu_otc_aggregated.index AND Settle.round = safu_otc_aggregated.round\n -- LEFT JOIN hourly_price_table ON LOWER(Settle.d_token) = hourly_price_table.symbol AND toStartOfHour(Settle.timestamp) = hourly_price_table.hour\n LEFT JOIN hourly_price_table ON 'sui' = hourly_price_table.symbol AND toStartOfHour(Settle.timestamp) = hourly_price_table.hour\n WHERE Settle.index IN (".concat(indices.join(","), ")\n ORDER BY ActivationDate DESC;\n "),
131
131
  size: limit,
132
132
  },
133
133
  };
@@ -153,4 +153,4 @@ function getVaultHistory(index_1) {
153
153
  // console.log(quarterly_timestamp);
154
154
  // getVaultHistorySummary();
155
155
  // getFilledSummary(quarterly_timestamp);
156
- // getVaultHistory("78", 3);
156
+ // getVaultHistory(["78", "79"], 2);
@@ -69,14 +69,26 @@ var countFloating = function (value) {
69
69
  };
70
70
  exports.countFloating = countFloating;
71
71
  function splitCoins(tx, token, coins, amount) {
72
- var _a = __read((0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.SUI
73
- ? tx.splitCoins(tx.gas, [tx.pure.u64(amount)])
74
- : (function () {
75
- var coin = coins.pop();
76
- if (coins.length > 0) {
77
- tx.mergeCoins(tx.object(coin), coins.map(function (id) { return tx.object(id); }));
78
- }
79
- return tx.splitCoins(tx.object(coin), [tx.pure.u64(amount)]);
80
- })(), 1), coin = _a[0];
72
+ var _a, _b;
73
+ var coin;
74
+ if (coins.length == 0) {
75
+ // support zero coin input for closing position
76
+ _a = __read(tx.moveCall({
77
+ target: "0x2::coin::zero",
78
+ typeArguments: [token],
79
+ arguments: [],
80
+ }), 1), coin = _a[0];
81
+ }
82
+ else {
83
+ _b = __read((0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.SUI
84
+ ? tx.splitCoins(tx.gas, [tx.pure.u64(amount)])
85
+ : (function () {
86
+ var coin = coins.pop();
87
+ if (coins.length > 0) {
88
+ tx.mergeCoins(tx.object(coin), coins.map(function (id) { return tx.object(id); }));
89
+ }
90
+ return tx.splitCoins(tx.object(coin), [tx.pure.u64(amount)]);
91
+ })(), 1), coin = _b[0];
92
+ }
81
93
  return coin;
82
94
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.6.3",
5
+ "version": "1.6.4",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.11.1",
8
8
  "@mysten/kiosk": "0.9.34",