@typus/typus-sdk 1.0.65 → 1.0.66

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.
@@ -1,6 +1,6 @@
1
1
  import { PortfolioVault } from "./portfolio-vault";
2
- export declare function getDb(apiUrl: string, functionNames: string[], vaultIndex?: string | undefined): Promise<any>;
3
- export declare function getShowMap(apiUrl: string, portfolioVaults: Map<string, PortfolioVault>, vaultIndex?: string | undefined): Promise<Map<string, Map<string, Show>>>;
2
+ export declare function getDb(database: string, functionNames: string[], vaultIndex: string | undefined, startTsMs: string, limit: number): Promise<any>;
3
+ export declare function getShowMap(database: string, portfolioVaults: Map<string, PortfolioVault>, vaultIndex?: string | undefined, startTsMs?: string, limit?: number): Promise<Map<string, Map<string, Show>>>;
4
4
  interface Show {
5
5
  ProjectedAPY: number;
6
6
  ActivationDate: Date;
@@ -12,5 +12,8 @@ interface Show {
12
12
  PaidToDepositors: number;
13
13
  PaidToBidders: number;
14
14
  EarnedByDepositors: number;
15
+ NewAuctionTx: string | undefined;
16
+ DeliveryTx: string | undefined;
17
+ SettleTx: string | undefined;
15
18
  }
16
19
  export {};
@@ -37,14 +37,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getShowMap = exports.getDb = void 0;
40
- function getDb(apiUrl, functionNames, vaultIndex) {
41
- if (vaultIndex === void 0) { vaultIndex = undefined; }
40
+ var apiUrl = "https://us-central1-aqueous-freedom-378103.cloudfunctions.net/mongodb";
41
+ function getDb(database, functionNames, vaultIndex, startTsMs, limit) {
42
42
  return __awaiter(this, void 0, void 0, function () {
43
43
  var jsonData, response, data;
44
44
  return __generator(this, function (_a) {
45
45
  switch (_a.label) {
46
46
  case 0:
47
- jsonData = JSON.stringify({ functionNames: functionNames, vaultIndex: vaultIndex });
47
+ jsonData = JSON.stringify({
48
+ database: database,
49
+ functionNames: functionNames,
50
+ vaultIndex: vaultIndex,
51
+ startTsMs: startTsMs,
52
+ limit: limit,
53
+ });
48
54
  return [4 /*yield*/, fetch(apiUrl, {
49
55
  method: "POST",
50
56
  headers: { "Content-Type": "application/json" },
@@ -63,14 +69,16 @@ function getDb(apiUrl, functionNames, vaultIndex) {
63
69
  });
64
70
  }
65
71
  exports.getDb = getDb;
66
- function getShowMap(apiUrl, portfolioVaults, vaultIndex) {
72
+ function getShowMap(database, portfolioVaults, vaultIndex, startTsMs, limit) {
67
73
  if (vaultIndex === void 0) { vaultIndex = undefined; }
74
+ if (startTsMs === void 0) { startTsMs = "0"; }
75
+ if (limit === void 0) { limit = 1000; }
68
76
  return __awaiter(this, void 0, void 0, function () {
69
77
  var events, groupEventMap, showMap;
70
78
  var _this = this;
71
79
  return __generator(this, function (_a) {
72
80
  switch (_a.label) {
73
- case 0: return [4 /*yield*/, getDb(apiUrl, ["NewAuction", "Delivery", "Settle"], vaultIndex)];
81
+ case 0: return [4 /*yield*/, getDb(database, ["NewAuction", "Delivery", "Settle"], vaultIndex, startTsMs, limit)];
74
82
  case 1:
75
83
  events = _a.sent();
76
84
  return [4 /*yield*/, events.reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
@@ -170,10 +178,10 @@ function getShowMap(apiUrl, portfolioVaults, vaultIndex) {
170
178
  }
171
179
  exports.getShowMap = getShowMap;
172
180
  function groupEventToShow(groupEvent, portfolioVault) {
173
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
181
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
174
182
  return __awaiter(this, void 0, void 0, function () {
175
183
  var PaidToDepositors, portfolio_payoff, PaidToBidders, exp, result;
176
- return __generator(this, function (_o) {
184
+ return __generator(this, function (_r) {
177
185
  PaidToDepositors = Number((_a = groupEvent.deliveryEvent) === null || _a === void 0 ? void 0 : _a.premium_value) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal));
178
186
  portfolio_payoff = ((_b = groupEvent.settleEvent) === null || _b === void 0 ? void 0 : _b.portfolio_payoff_is_neg)
179
187
  ? Number(-((_c = groupEvent.settleEvent) === null || _c === void 0 ? void 0 : _c.portfolio_payoff))
@@ -192,16 +200,19 @@ function groupEventToShow(groupEvent, portfolioVault) {
192
200
  }
193
201
  result = {
194
202
  // newAuctionEvent
195
- ActivationDate: new Date(Number((_e = groupEvent.newAuctionEvent) === null || _e === void 0 ? void 0 : _e.timestamp_ms)),
196
- StrikePrice: (_f = groupEvent.newAuctionEvent) === null || _f === void 0 ? void 0 : _f.vault_config.payoffConfigs.map(function (payoffConfig) { return Number(payoffConfig.strike) / Math.pow(10, 8); }),
203
+ NewAuctionTx: (_e = groupEvent.newAuctionEvent) === null || _e === void 0 ? void 0 : _e.tx_digest,
204
+ ActivationDate: new Date(Number((_f = groupEvent.newAuctionEvent) === null || _f === void 0 ? void 0 : _f.timestamp_ms)),
205
+ StrikePrice: (_g = groupEvent.newAuctionEvent) === null || _g === void 0 ? void 0 : _g.vault_config.payoffConfigs.map(function (payoffConfig) { return Number(payoffConfig.strike) / Math.pow(10, 8); }),
197
206
  // deliveryEvent
198
- ProjectedAPY: Math.pow((1 + (1.01 * Number((_g = groupEvent.deliveryEvent) === null || _g === void 0 ? void 0 : _g.delivery_price)) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal))), exp) - 1,
199
- Filled: Number((_h = groupEvent.deliveryEvent) === null || _h === void 0 ? void 0 : _h.delivery_size) / Number((_j = groupEvent.deliveryEvent) === null || _j === void 0 ? void 0 : _j.max_size),
207
+ DeliveryTx: (_h = groupEvent.deliveryEvent) === null || _h === void 0 ? void 0 : _h.tx_digest,
208
+ ProjectedAPY: Math.pow((1 + (1.01 * Number((_j = groupEvent.deliveryEvent) === null || _j === void 0 ? void 0 : _j.delivery_price)) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal))), exp) - 1,
209
+ Filled: Number((_k = groupEvent.deliveryEvent) === null || _k === void 0 ? void 0 : _k.delivery_size) / Number((_l = groupEvent.deliveryEvent) === null || _l === void 0 ? void 0 : _l.max_size),
200
210
  PaidToDepositors: PaidToDepositors,
201
211
  // settleEvent
202
- SettlementTime: new Date(Number((_k = groupEvent.settleEvent) === null || _k === void 0 ? void 0 : _k.timestamp_ms)),
203
- SettlePrice: Number((_l = groupEvent.settleEvent) === null || _l === void 0 ? void 0 : _l.oracle_price) / Math.pow(10, 8),
204
- Return: Number((_m = groupEvent.settleEvent) === null || _m === void 0 ? void 0 : _m.share_price) / Math.pow(10, 8) - 1,
212
+ SettleTx: (_m = groupEvent.settleEvent) === null || _m === void 0 ? void 0 : _m.tx_digest,
213
+ SettlementTime: new Date(Number((_o = groupEvent.settleEvent) === null || _o === void 0 ? void 0 : _o.timestamp_ms)),
214
+ SettlePrice: Number((_p = groupEvent.settleEvent) === null || _p === void 0 ? void 0 : _p.oracle_price) / Math.pow(10, 8),
215
+ Return: Number((_q = groupEvent.settleEvent) === null || _q === void 0 ? void 0 : _q.share_price) / Math.pow(10, 8) - 1,
205
216
  PaidToBidders: PaidToBidders,
206
217
  EarnedByDepositors: PaidToDepositors - PaidToBidders,
207
218
  };
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.0.65",
5
+ "version": "1.0.66",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.1",
8
8
  "@mysten/sui.js": "^0.34.1",