@typus/typus-sdk 0.4.2 → 0.4.3

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.
@@ -53,27 +53,71 @@ var apiToken = "5864284783:AAHwXWgt2YgLENdJ9mVBUDBVLHXrMLNgkic";
53
53
  */
54
54
  var chatId = "-1001784476809";
55
55
  (function () { return __awaiter(void 0, void 0, void 0, function () {
56
- var bidType, newAuctionType, endAuctionType, renewSec, vault;
56
+ var bidTypes, newAuctionType, endAuctionTypes, renewSec, vault;
57
57
  return __generator(this, function (_a) {
58
58
  switch (_a.label) {
59
59
  case 0:
60
- bidType = constants_1.DOV_PACKAGE + "::dutch::NewBid<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>";
60
+ bidTypes = [
61
+ constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>",
62
+ constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::btc::BTC>",
63
+ constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::sui::SUI>",
64
+ ];
61
65
  newAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewAuction";
62
- endAuctionType = "";
66
+ endAuctionTypes = [
67
+ constants_1.DOV_PACKAGE + "::dutch::Delivery<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>",
68
+ constants_1.DOV_PACKAGE + "::dutch::Delivery<" + constants_1.TOKEN_PACKAGE + "::btc::BTC>",
69
+ constants_1.DOV_PACKAGE + "::dutch::Delivery<" + constants_1.TOKEN_PACKAGE + "::sui::SUI>",
70
+ ];
63
71
  renewSec = 10;
64
72
  return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY)];
65
73
  case 1:
66
74
  vault = _a.sent();
67
- return [4 /*yield*/, getBidEventsCranker(bidType, renewSec, vault)
68
- // await getNewAuctionEventsCranker(newAuctionType, renewSec, vault)//evolution
69
- // await getEndAuctionEventsCranker(endAuctionType, renewSec, vault)
70
- ]; //new_bid
75
+ bidTypes.map(function (bidType) { return __awaiter(void 0, void 0, void 0, function () {
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0: return [4 /*yield*/, getBidEventsCranker(bidType, renewSec, vault)]; //new_bid
79
+ case 1:
80
+ _a.sent(); //new_bid
81
+ return [2 /*return*/];
82
+ }
83
+ });
84
+ }); });
85
+ return [4 /*yield*/, getNewAuctionEventsCranker(newAuctionType, renewSec, vault)]; //evolution
71
86
  case 2:
72
- _a.sent(); //new_bid
87
+ _a.sent(); //evolution
88
+ endAuctionTypes.map(function (endAuctionType) { return __awaiter(void 0, void 0, void 0, function () {
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0: return [4 /*yield*/, getEndAuctionEventsCranker(endAuctionType, renewSec, vault)];
92
+ case 1:
93
+ _a.sent();
94
+ return [2 /*return*/];
95
+ }
96
+ });
97
+ }); });
73
98
  return [2 /*return*/];
74
99
  }
75
100
  });
76
101
  }); })();
102
+ function generateBidId(vault) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ var liveVault, res;
105
+ return __generator(this, function (_a) {
106
+ liveVault = vault === null || vault === void 0 ? void 0 : vault.filter(function (v) {
107
+ var start = moment_1.default.unix(Number(v.config.activationTsMs) / 1000);
108
+ return start.isBefore((0, moment_1.default)());
109
+ });
110
+ res = liveVault.map(function (v) {
111
+ var expiration = moment_1.default
112
+ .unix(Number(v.config.expirationTsMs) / 1000)
113
+ .format("DDMMMYY");
114
+ var bidId = "".concat(v.asset, "-").concat(expiration, "-").concat(v.config.payoffConfig.strike, "-C");
115
+ return bidId;
116
+ });
117
+ return [2 /*return*/, res];
118
+ });
119
+ });
120
+ }
77
121
  function getBidEventsCranker(type, renewSec, vault) {
78
122
  return __awaiter(this, void 0, void 0, function () {
79
123
  var res;
@@ -81,52 +125,55 @@ function getBidEventsCranker(type, renewSec, vault) {
81
125
  return __generator(this, function (_a) {
82
126
  res = [];
83
127
  node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
84
- var events, newRes, newBid, newBidFormat_1, telegramText;
128
+ var events, newRes, newBid, format_1, bidIds_1, telegramText;
85
129
  var _this = this;
86
130
  return __generator(this, function (_a) {
87
131
  switch (_a.label) {
88
- case 0:
89
- console.log("listening for every " + renewSec.toString() + " s...");
90
- return [4 /*yield*/, provider.getEvents(
91
- /// from object id , can only get one event
92
- // { Object: "0x89bc7299c684413ab81f7536603451277b8ed754" },
93
- // { Transaction: "4aTaXLyCwT9geQg5PC3UAGGBMbuySFCzeJ6Cf62RrUEg"},
94
- { MoveEvent: type }, null, null)];
132
+ case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
95
133
  case 1:
96
134
  events = _a.sent();
97
135
  newRes = events.data;
98
- if (newRes.length != res.length) {
99
- console.log("the total bid event number now:" + events.data.length);
100
- console.log("there are " + (newRes.length - res.length).toString() + " new bids");
101
- newBid = newRes.filter(function (_a) {
102
- var id1 = _a.timestamp;
103
- return !res.some(function (_a) {
104
- var id2 = _a.timestamp;
105
- return id2 === id1;
106
- });
136
+ if (!(newRes.length != res.length)) return [3 /*break*/, 3];
137
+ console.log("the total bid event number now: " + events.data.length);
138
+ console.log("there are " + (newRes.length - res.length).toString() + " new bids");
139
+ newBid = newRes.filter(function (_a) {
140
+ var id1 = _a.timestamp;
141
+ return !res.some(function (_a) {
142
+ var id2 = _a.timestamp;
143
+ return id2 === id1;
107
144
  });
108
- console.log("new bid amount: " + newBid.length);
109
- newBidFormat_1 = "";
110
- newBid.map(function (e) { return __awaiter(_this, void 0, void 0, function () {
111
- var tmp, asset, time, price, size;
112
- return __generator(this, function (_a) {
113
- tmp = vault.find(function (vault) {
114
- return (vault.vaultIdx == (e.event.moveEvent.fields.index).toString());
115
- });
116
- asset = tmp === null || tmp === void 0 ? void 0 : tmp.asset;
117
- time = moment_1.default.unix(e.timestamp / 1000).format("DDMMMYY");
118
- price = e.event.moveEvent.fields.price;
145
+ });
146
+ console.log("new bid amount: " + newBid.length);
147
+ format_1 = "";
148
+ return [4 /*yield*/, generateBidId(vault)];
149
+ case 2:
150
+ bidIds_1 = _a.sent();
151
+ // [
152
+ // 'ETH-18Jan23-1750-C',
153
+ // 'BTC-18Jan23-21800-C',
154
+ // 'ETH-17Jan23-1750-C',
155
+ // 'SUI-18Jan23-9-C'
156
+ // ]
157
+ newBid.map(function (e) { return __awaiter(_this, void 0, void 0, function () {
158
+ var bidId, size;
159
+ return __generator(this, function (_a) {
160
+ bidId = bidIds_1.find(function (bidId) { return e.event.moveEvent.type.includes(bidId.split("-")[0]); });
161
+ if (bidId) {
119
162
  size = (Number(e.event.moveEvent.fields.size) / (Math.pow(10, constants_1.TOKEN_DECIMAL))).toString();
120
- newBidFormat_1 += asset + "-" + time + "-" + price + "-C" + " is bid with " + size + " " + asset + "!";
121
- return [2 /*return*/];
122
- });
123
- }); });
124
- telegramText = newBidFormat_1;
125
- console.log(telegramText);
126
- // sendEventToTelegramChannel(telegramText)
127
- res = newRes;
128
- }
129
- return [2 /*return*/];
163
+ format_1 += bidId + " is bid with " + size + " " + bidId.split("-")[0] + "! \n";
164
+ }
165
+ else {
166
+ console.log("can't get bidId in getBidEventsCranker");
167
+ }
168
+ return [2 /*return*/];
169
+ });
170
+ }); });
171
+ telegramText = format_1;
172
+ console.log(telegramText);
173
+ sendEventToTelegramChannel(telegramText);
174
+ res = newRes;
175
+ _a.label = 3;
176
+ case 3: return [2 /*return*/];
130
177
  }
131
178
  });
132
179
  }); });
@@ -142,40 +189,31 @@ function getNewAuctionEventsCranker(type, renewSec, vault) {
142
189
  return __generator(this, function (_a) {
143
190
  res = [];
144
191
  node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
145
- var events, newRes, newAuction, msg_1, telegramText;
192
+ var events, newRes, format_2, bidIds, telegramText;
146
193
  var _this = this;
147
194
  return __generator(this, function (_a) {
148
195
  switch (_a.label) {
149
- case 0:
150
- console.log("listening for every " + renewSec.toString() + " s...");
151
- return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
196
+ case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
152
197
  case 1:
153
198
  events = _a.sent();
154
199
  newRes = events.data;
155
- if (newRes.length != res.length) {
156
- newAuction = newRes.filter(function (e) {
157
- return res.indexOf(e) === -1;
200
+ if (!(newRes.length != res.length)) return [3 /*break*/, 3];
201
+ format_2 = "";
202
+ return [4 /*yield*/, generateBidId(vault)];
203
+ case 2:
204
+ bidIds = _a.sent();
205
+ bidIds.map(function (bidId) { return __awaiter(_this, void 0, void 0, function () {
206
+ return __generator(this, function (_a) {
207
+ format_2 += bidId + " auction is live now! \n";
208
+ return [2 /*return*/];
158
209
  });
159
- msg_1 = "";
160
- newAuction.map(function (e) { return __awaiter(_this, void 0, void 0, function () {
161
- var tmp, asset, time, price;
162
- return __generator(this, function (_a) {
163
- tmp = vault.find(function (vault) {
164
- return (vault.vaultIdx == (e.event.moveEvent.fields.index).toString());
165
- });
166
- asset = tmp === null || tmp === void 0 ? void 0 : tmp.asset;
167
- time = moment_1.default.unix(e.timestamp / 1000).format("DDMMMYY");
168
- price = Number(e.event.moveEvent.fields.strike) / (Math.pow(10, constants_1.PRICE_DECIMAL));
169
- msg_1 += asset + "-" + time + "-" + price + "-C" + " auction is live now!\n";
170
- return [2 /*return*/];
171
- });
172
- }); });
173
- telegramText = msg_1;
174
- console.log(telegramText);
175
- // sendEventToTelegramChannel(telegramText)
176
- res = newRes;
177
- }
178
- return [2 /*return*/];
210
+ }); });
211
+ telegramText = format_2;
212
+ console.log(telegramText);
213
+ sendEventToTelegramChannel(telegramText);
214
+ res = newRes;
215
+ _a.label = 3;
216
+ case 3: return [2 /*return*/];
179
217
  }
180
218
  });
181
219
  }); });
@@ -191,33 +229,31 @@ function getEndAuctionEventsCranker(type, renewSec, vault) {
191
229
  return __generator(this, function (_a) {
192
230
  res = [];
193
231
  node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
194
- var events, newRes, newAuction, msg, telegramText;
232
+ var events, newRes, format_3, bidIds, telegramText;
195
233
  var _this = this;
196
234
  return __generator(this, function (_a) {
197
235
  switch (_a.label) {
198
- case 0:
199
- console.log("listening for every " + renewSec.toString() + " s...");
200
- return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
236
+ case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
201
237
  case 1:
202
238
  events = _a.sent();
203
239
  newRes = events.data;
204
- if (newRes.length != res.length) {
205
- newAuction = newRes.filter(function (e) {
206
- return res.indexOf(e) === -1;
240
+ if (!(newRes.length != res.length)) return [3 /*break*/, 3];
241
+ format_3 = "";
242
+ return [4 /*yield*/, generateBidId(vault)];
243
+ case 2:
244
+ bidIds = _a.sent();
245
+ bidIds.map(function (bidId) { return __awaiter(_this, void 0, void 0, function () {
246
+ return __generator(this, function (_a) {
247
+ format_3 += bidId + " auction is closed! \n";
248
+ return [2 /*return*/];
207
249
  });
208
- msg = "";
209
- newAuction.map(function (e) { return __awaiter(_this, void 0, void 0, function () {
210
- return __generator(this, function (_a) {
211
- console.log(e);
212
- return [2 /*return*/];
213
- });
214
- }); });
215
- telegramText = msg;
216
- console.log(telegramText);
217
- // sendEventToTelegramChannel(telegramText)
218
- res = newRes;
219
- }
220
- return [2 /*return*/];
250
+ }); });
251
+ telegramText = format_3;
252
+ console.log(telegramText);
253
+ sendEventToTelegramChannel(telegramText);
254
+ res = newRes;
255
+ _a.label = 3;
256
+ case 3: return [2 /*return*/];
221
257
  }
222
258
  });
223
259
  }); });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var constants_1 = require("../constants");
40
+ var getMakersShares_1 = require("../utils/getMakersShares");
41
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
42
+ var makersShares;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0: return [4 /*yield*/, (0, getMakersShares_1.getMakersShares)(constants_1.MAKER_SHARE_TABLE, constants_1.COVERED_CALL_REGISTRY)];
46
+ case 1:
47
+ makersShares = _a.sent();
48
+ console.log(makersShares);
49
+ return [2 /*return*/];
50
+ }
51
+ });
52
+ }); })();
@@ -0,0 +1,7 @@
1
+ export interface MakerShare {
2
+ coveredCallVaultIndex: string;
3
+ share: string;
4
+ maker: string;
5
+ depositAmount: string;
6
+ }
7
+ export declare function getMakersShares(makerShareTable: string, registry: string): Promise<MakerShare[]>;
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __values = (this && this.__values) || function(o) {
39
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
+ if (m) return m.call(o);
41
+ if (o && typeof o.length === "number") return {
42
+ next: function () {
43
+ if (o && i >= o.length) o = void 0;
44
+ return { value: o && o[i++], done: !o };
45
+ }
46
+ };
47
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.getMakersShares = void 0;
51
+ var sui_js_1 = require("@mysten/sui.js");
52
+ var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
53
+ function getSubVaultsData(registry) {
54
+ return __awaiter(this, void 0, void 0, function () {
55
+ var subVaultsData, coveredCallVaults, coveredCallVaultsId, objsInfo, objsInfo_1, objsInfo_1_1, objInfo, vaultId, vault, subVaultData;
56
+ var e_1, _a;
57
+ return __generator(this, function (_b) {
58
+ switch (_b.label) {
59
+ case 0:
60
+ subVaultsData = new Map();
61
+ return [4 /*yield*/, provider.getObjectsOwnedByObject(registry)];
62
+ case 1:
63
+ coveredCallVaults = _b.sent();
64
+ coveredCallVaultsId = coveredCallVaults.map(function (e) { return e.objectId; });
65
+ return [4 /*yield*/, provider.getObjectBatch(coveredCallVaultsId)];
66
+ case 2:
67
+ objsInfo = _b.sent();
68
+ try {
69
+ for (objsInfo_1 = __values(objsInfo), objsInfo_1_1 = objsInfo_1.next(); !objsInfo_1_1.done; objsInfo_1_1 = objsInfo_1.next()) {
70
+ objInfo = objsInfo_1_1.value;
71
+ if (objInfo.status != "Exists") {
72
+ console.log("obj not exist");
73
+ continue;
74
+ }
75
+ vaultId = Number(objInfo.details.data.fields.name);
76
+ vault = objInfo.details.data.fields.value.fields.vault.fields;
77
+ subVaultData = {
78
+ makerTotalSupply: Number(vault.maker_sub_vault.fields.balance),
79
+ makerTotalBalance: Number(vault.maker_sub_vault.fields.share_supply),
80
+ };
81
+ subVaultsData.set(vaultId, subVaultData);
82
+ }
83
+ }
84
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
85
+ finally {
86
+ try {
87
+ if (objsInfo_1_1 && !objsInfo_1_1.done && (_a = objsInfo_1.return)) _a.call(objsInfo_1);
88
+ }
89
+ finally { if (e_1) throw e_1.error; }
90
+ }
91
+ return [2 /*return*/, subVaultsData];
92
+ }
93
+ });
94
+ });
95
+ }
96
+ function getMakersShares(makerShareTable, registry) {
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ var subVaultsData, makerShareIds, makerShares;
99
+ return __generator(this, function (_a) {
100
+ switch (_a.label) {
101
+ case 0: return [4 /*yield*/, getSubVaultsData(registry)]; //vault idx to subvault info
102
+ case 1:
103
+ subVaultsData = _a.sent() //vault idx to subvault info
104
+ ;
105
+ return [4 /*yield*/, provider.getObjectsOwnedByObject(makerShareTable)];
106
+ case 2:
107
+ makerShareIds = (_a.sent()).map(function (x) { return x.objectId; });
108
+ return [4 /*yield*/, provider.getObjectBatch(makerShareIds)];
109
+ case 3:
110
+ makerShares = (_a.sent()).map(function (x) {
111
+ var _a, _b;
112
+ if (x.status != "Exists") {
113
+ console.log("obj not exist");
114
+ return {};
115
+ }
116
+ //@ts-ignore
117
+ var obj = (x.details.data.fields);
118
+ /*
119
+ {
120
+ id: { id: '0xae32e84281a8e08fade4f72d0c5f861061deb608' },
121
+ name: {
122
+ type: '0xb92f3c4c26151b86977b8811765fe74cb133a35f::covered_call::MakerShareKey',
123
+ fields: { index: '0', maker: '0x4a3b00eac21bfbe062932a5c2b9710245edb2cc2' }
124
+ },
125
+ value: '23000000000'
126
+ }
127
+ */
128
+ var index = obj.name.fields.index;
129
+ var share = obj.value;
130
+ var maker = obj.name.fields.maker;
131
+ var depositAmount = (Number(share) / ((_a = subVaultsData.get(Number(index))) === null || _a === void 0 ? void 0 : _a.makerTotalSupply) * ((_b = subVaultsData.get(Number(index))) === null || _b === void 0 ? void 0 : _b.makerTotalBalance));
132
+ var res = {
133
+ coveredCallVaultIndex: index,
134
+ //@ts-ignore
135
+ share: share,
136
+ //@ts-ignore
137
+ maker: maker,
138
+ depositAmount: depositAmount.toFixed(0),
139
+ };
140
+ return res;
141
+ });
142
+ return [2 /*return*/, makerShares];
143
+ }
144
+ });
145
+ });
146
+ }
147
+ exports.getMakersShares = getMakersShares;
@@ -88,7 +88,7 @@ function getVaultDataFromRegistry(registry) {
88
88
  config = objInfo.details.data.fields.value.fields.config.fields;
89
89
  vault = objInfo.details.data.fields.value.fields.vault.fields;
90
90
  prev = objInfo.details.data.fields.value.fields.prev;
91
- prev = (prev != null) ? prev : 0;
91
+ prev = (prev != null) ? prev : null;
92
92
  vaultConfig = config.vault_config.fields;
93
93
  vaultConfigRes = {
94
94
  strikeOtmPct: vaultConfig.strike_otm_pct,
@@ -172,7 +172,7 @@ function getVaultDataFromRegistry(registry) {
172
172
  case 3:
173
173
  next = objInfo.details.data.fields.value.fields.next;
174
174
  totalBidSize = objInfo.details.data.fields.value.fields.total_bid_size;
175
- deliveryInfo = objInfo.details.data.fields.value.fields.delivery_info;
175
+ deliveryInfo = objInfo.details.data.fields.value.fields.delivery_info ? objInfo.details.data.fields.value.fields.delivery_info.fields : null;
176
176
  owner = objInfo.details.data.fields.value.fields.owner;
177
177
  tvl = Number(vault.regular_sub_vault.fields.balance) + Number(vault.rolling_sub_vault.fields.balance);
178
178
  res = {
@@ -182,7 +182,7 @@ function getVaultDataFromRegistry(registry) {
182
182
  config: configRes,
183
183
  vault: vaultRes,
184
184
  auction: auctionRes,
185
- prev: prev.toString(),
185
+ prev: (prev) ? prev.toString() : null,
186
186
  next: next,
187
187
  totalBidSize: totalBidSize,
188
188
  deliveryInfo: deliveryInfo,
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": "0.4.2",
5
+ "version": "0.4.3",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.5.0",
8
8
  "@mysten/sui.js": "^0.20.0",