@typus/typus-sdk 0.4.0 → 0.4.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.
@@ -1,15 +1,19 @@
1
- export declare const TOKEN_PACKAGE = "0x1ed338b4e737d89729386b8170b0f45910ad30fa";
2
- export declare const TOKEN_REGISTRY_BTC = "0xf5f939a6a79927e55582985a8bf125d37b0ab297";
3
- export declare const TOKEN_REGISTRY_ETH = "0xb79efcacd84dc70dd6969686d7e7fadadc14c2d5";
4
- export declare const TOKEN_REGISTRY_SUI = "0xde095084d4485b0482ab8dc8fe8c8328902fa223";
5
- export declare const ORACLE_PACKAGE = "0x5b1f5680041041624069ef03f23947001b073642";
6
- export declare const COVERED_CALL_PACKAGE = "0x00d18316601f16439dec0a6b3e40ef861fc84ee4";
7
- export declare const COVERED_CALL_REGISTRY = "0xe3960d9dc8e39328e514d42d3318c5878145c27e";
8
- export declare const COVERED_CALL_MANAGER = "0xfe26a77c66f4ae0314e1510921f8dea9be01db9c";
9
- export declare const USER_SHARE_TABLE = "0x4d98c1efa4aef5b02e8fe27bca6ac4d8dde62935";
10
- export declare const USER_REFUND_TABLE = "0x3e80b4c0f7d1b05a73d180487aa2bbf5e3c77792";
11
- export declare const MAKER_SHARE_TABLE = "0xef0dabd3f82d4cc09c440a61f095a977d72ade05";
12
- export declare const DOV_PACKAGE = "0xdbb42109c373ded4b97016230e5d065fb96813b8";
1
+ export declare const TOKEN_PACKAGE = "0x3e416d10557c532838c2d0d6996c8a3bc81371a7";
2
+ export declare const TOKEN_REGISTRY_BTC = "0xee26a4debb44a6c09e0f446c5c98da2217a0ca5d";
3
+ export declare const TOKEN_REGISTRY_ETH = "0x00c7526bc0b4b7be9fb6d23e60e325700194e018";
4
+ export declare const TOKEN_REGISTRY_SUI = "0x342f858a4f813a8f95ddc216ddf7bcb775a92782";
5
+ export declare const TOKEN_REGISTRY_APT = "0x09de00969635499a7f824688bff570efbf886a68";
6
+ export declare const TOKEN_REGISTRY_DOGE = "0xa33ba6e2c736a2548b8c1cef13fed947c6aae163";
7
+ export declare const TOKEN_REGISTRY_USDC = "0xf22cd5b80e1263e436fb4d71879ebb1b2799aa36";
8
+ export declare const ORACLE_PACKAGE = "0xcba43b3a1672f3c782e2167fc64710799009d5bb";
9
+ export declare const TIME_ORACLE = "0x55031e1edc517a4b16543c1c081ba33a59ffd084";
10
+ export declare const COVERED_CALL_PACKAGE = "0xb92f3c4c26151b86977b8811765fe74cb133a35f";
11
+ export declare const COVERED_CALL_REGISTRY = "0x0a4bd1721cb02a957d1602f5b2e53ad421408acb";
12
+ export declare const COVERED_CALL_MANAGER = "0x6fd90bf4bb9490e5fce51b8eb11fbf37c43f4cbc";
13
+ export declare const USER_SHARE_TABLE = "0xc90f9f13f9823719011a9b2de73bb4d6e05eaf28";
14
+ export declare const USER_REFUND_TABLE = "0x2a63900582a5177f7ff440613ba091618f373bfa";
15
+ export declare const MAKER_SHARE_TABLE = "0xfcfd04446aa3dd004150081df8982c1f09b20fb1";
16
+ export declare const DOV_PACKAGE = "0x49e71a735dc6bdf7327e6c663d04a3e7f68bafd0";
13
17
  export declare const TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
14
18
  export declare const PRICE_DECIMAL = 8;
15
19
  export declare const TOKEN_DECIMAL = 9;
package/lib/constants.js CHANGED
@@ -1,22 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TOKEN_NAME_TO_MODULE = exports.TOKEN_NAME = exports.TEST_MNEMONIC = exports.FAKE_TOKEN_TYPE_ARGUMENT = exports.DEFAULT_TYPE_ARGUMENT = exports.TOKEN_DECIMAL = exports.PRICE_DECIMAL = exports.TEST_MINT_TOKEN = exports.DOV_PACKAGE = exports.MAKER_SHARE_TABLE = exports.USER_REFUND_TABLE = exports.USER_SHARE_TABLE = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.ORACLE_PACKAGE = exports.TOKEN_REGISTRY_SUI = exports.TOKEN_REGISTRY_ETH = exports.TOKEN_REGISTRY_BTC = exports.TOKEN_PACKAGE = void 0;
3
+ exports.TOKEN_NAME_TO_MODULE = exports.TOKEN_NAME = exports.TEST_MNEMONIC = exports.FAKE_TOKEN_TYPE_ARGUMENT = exports.DEFAULT_TYPE_ARGUMENT = exports.TOKEN_DECIMAL = exports.PRICE_DECIMAL = exports.TEST_MINT_TOKEN = exports.DOV_PACKAGE = exports.MAKER_SHARE_TABLE = exports.USER_REFUND_TABLE = exports.USER_SHARE_TABLE = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.TIME_ORACLE = exports.ORACLE_PACKAGE = exports.TOKEN_REGISTRY_USDC = exports.TOKEN_REGISTRY_DOGE = exports.TOKEN_REGISTRY_APT = exports.TOKEN_REGISTRY_SUI = exports.TOKEN_REGISTRY_ETH = exports.TOKEN_REGISTRY_BTC = exports.TOKEN_PACKAGE = void 0;
4
4
  //publish from sui-dev-token
5
- exports.TOKEN_PACKAGE = "0x1ed338b4e737d89729386b8170b0f45910ad30fa";
6
- exports.TOKEN_REGISTRY_BTC = "0xf5f939a6a79927e55582985a8bf125d37b0ab297"; //fake btc registry
7
- exports.TOKEN_REGISTRY_ETH = "0xb79efcacd84dc70dd6969686d7e7fadadc14c2d5"; //fake eth registry
8
- exports.TOKEN_REGISTRY_SUI = "0xde095084d4485b0482ab8dc8fe8c8328902fa223"; //fake usdc registry
5
+ exports.TOKEN_PACKAGE = "0x3e416d10557c532838c2d0d6996c8a3bc81371a7";
6
+ exports.TOKEN_REGISTRY_BTC = "0xee26a4debb44a6c09e0f446c5c98da2217a0ca5d";
7
+ exports.TOKEN_REGISTRY_ETH = "0x00c7526bc0b4b7be9fb6d23e60e325700194e018";
8
+ exports.TOKEN_REGISTRY_SUI = "0x342f858a4f813a8f95ddc216ddf7bcb775a92782";
9
+ exports.TOKEN_REGISTRY_APT = "0x09de00969635499a7f824688bff570efbf886a68";
10
+ exports.TOKEN_REGISTRY_DOGE = "0xa33ba6e2c736a2548b8c1cef13fed947c6aae163";
11
+ exports.TOKEN_REGISTRY_USDC = "0xf22cd5b80e1263e436fb4d71879ebb1b2799aa36";
9
12
  //publish from typus-oracle
10
- exports.ORACLE_PACKAGE = "0x5b1f5680041041624069ef03f23947001b073642";
13
+ exports.ORACLE_PACKAGE = "0xcba43b3a1672f3c782e2167fc64710799009d5bb";
14
+ exports.TIME_ORACLE = "0x55031e1edc517a4b16543c1c081ba33a59ffd084";
11
15
  //publish from typus-dov/cover_call
12
- exports.COVERED_CALL_PACKAGE = "0x00d18316601f16439dec0a6b3e40ef861fc84ee4";
13
- exports.COVERED_CALL_REGISTRY = "0xe3960d9dc8e39328e514d42d3318c5878145c27e";
14
- exports.COVERED_CALL_MANAGER = "0xfe26a77c66f4ae0314e1510921f8dea9be01db9c";
15
- exports.USER_SHARE_TABLE = "0x4d98c1efa4aef5b02e8fe27bca6ac4d8dde62935";
16
- exports.USER_REFUND_TABLE = "0x3e80b4c0f7d1b05a73d180487aa2bbf5e3c77792";
17
- exports.MAKER_SHARE_TABLE = "0xef0dabd3f82d4cc09c440a61f095a977d72ade05";
16
+ exports.COVERED_CALL_PACKAGE = "0xb92f3c4c26151b86977b8811765fe74cb133a35f";
17
+ exports.COVERED_CALL_REGISTRY = "0x0a4bd1721cb02a957d1602f5b2e53ad421408acb";
18
+ exports.COVERED_CALL_MANAGER = "0x6fd90bf4bb9490e5fce51b8eb11fbf37c43f4cbc";
19
+ exports.USER_SHARE_TABLE = "0xc90f9f13f9823719011a9b2de73bb4d6e05eaf28";
20
+ exports.USER_REFUND_TABLE = "0x2a63900582a5177f7ff440613ba091618f373bfa";
21
+ exports.MAKER_SHARE_TABLE = "0xfcfd04446aa3dd004150081df8982c1f09b20fb1";
18
22
  //publish from typus-dov/typus-dov
19
- exports.DOV_PACKAGE = "0xdbb42109c373ded4b97016230e5d065fb96813b8";
23
+ exports.DOV_PACKAGE = "0x49e71a735dc6bdf7327e6c663d04a3e7f68bafd0";
20
24
  exports.TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
21
25
  exports.PRICE_DECIMAL = 8;
22
26
  exports.TOKEN_DECIMAL = 9;
@@ -1,4 +1,5 @@
1
- export declare function getBidEventsCranker(type: string, renewSec: number): Promise<void>;
2
- export declare function getNewAuctionEventsCranker(type: string, renewSec: number): Promise<void>;
3
- export declare function getEndAuctionEventsCranker(type: string, renewSec: number): Promise<void>;
1
+ import { CoveredCallVault } from "../utils/fetchData";
2
+ export declare function getBidEventsCranker(type: string, renewSec: number, vault: CoveredCallVault[]): Promise<void>;
3
+ export declare function getNewAuctionEventsCranker(type: string, renewSec: number, vault: CoveredCallVault[]): Promise<void>;
4
+ export declare function getEndAuctionEventsCranker(type: string, renewSec: number, vault: CoveredCallVault[]): Promise<void>;
4
5
  export declare function sendEventToTelegramChannel(text: any): Promise<void>;
@@ -42,6 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.sendEventToTelegramChannel = exports.getEndAuctionEventsCranker = exports.getNewAuctionEventsCranker = exports.getBidEventsCranker = void 0;
43
43
  var constants_1 = require("../constants");
44
44
  var sui_js_1 = require("@mysten/sui.js");
45
+ var getVaultData_1 = require("../utils/getVaultData");
45
46
  var node_cron_1 = __importDefault(require("node-cron"));
46
47
  var XMLHttpRequest_1 = require("XMLHttpRequest");
47
48
  var moment_1 = __importDefault(require("moment"));
@@ -52,23 +53,28 @@ var apiToken = "5864284783:AAHwXWgt2YgLENdJ9mVBUDBVLHXrMLNgkic";
52
53
  */
53
54
  var chatId = "-1001784476809";
54
55
  (function () { return __awaiter(void 0, void 0, void 0, function () {
55
- var bidType, newAuctionType, renewSec;
56
+ var bidType, newAuctionType, endAuctionType, renewSec, vault;
56
57
  return __generator(this, function (_a) {
57
58
  switch (_a.label) {
58
59
  case 0:
59
60
  bidType = constants_1.DOV_PACKAGE + "::dutch::NewBid<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>";
60
61
  newAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewAuction";
62
+ endAuctionType = "";
61
63
  renewSec = 10;
62
- return [4 /*yield*/, getBidEventsCranker(bidType, renewSec)
63
- // await getNewAuctionEventsCranker(newAuctionType, renewSec)
64
- ];
64
+ return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY)];
65
65
  case 1:
66
- _a.sent();
66
+ 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
71
+ case 2:
72
+ _a.sent(); //new_bid
67
73
  return [2 /*return*/];
68
74
  }
69
75
  });
70
76
  }); })();
71
- function getBidEventsCranker(type, renewSec) {
77
+ function getBidEventsCranker(type, renewSec, vault) {
72
78
  return __awaiter(this, void 0, void 0, function () {
73
79
  var res;
74
80
  var _this = this;
@@ -76,6 +82,7 @@ function getBidEventsCranker(type, renewSec) {
76
82
  res = [];
77
83
  node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
78
84
  var events, newRes, newBid, newBidFormat_1, telegramText;
85
+ var _this = this;
79
86
  return __generator(this, function (_a) {
80
87
  switch (_a.label) {
81
88
  case 0:
@@ -91,18 +98,31 @@ function getBidEventsCranker(type, renewSec) {
91
98
  if (newRes.length != res.length) {
92
99
  console.log("the total bid event number now:" + events.data.length);
93
100
  console.log("there are " + (newRes.length - res.length).toString() + " new bids");
94
- newBid = newRes.filter(function (e) {
95
- return res.indexOf(e) === -1;
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
+ });
96
107
  });
97
108
  console.log("new bid amount: " + newBid.length);
98
109
  newBidFormat_1 = "";
99
- newBid.map(function (e) {
100
- var time = moment_1.default.unix(e.timestamp / 1000).format("YYYY MM/DD HH:mm:ss");
101
- var size = Number(e.event.moveEvent.fields.size) / (Math.pow(10, constants_1.TOKEN_DECIMAL));
102
- newBidFormat_1 += "New bid: \n" + "Time: " + time + " \nBider: " + e.event.moveEvent.sender + " \n" + "Size: " + size.toString() + "\n";
103
- });
104
- console.log(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;
119
+ 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
+ }); });
105
124
  telegramText = newBidFormat_1;
125
+ console.log(telegramText);
106
126
  // sendEventToTelegramChannel(telegramText)
107
127
  res = newRes;
108
128
  }
@@ -115,14 +135,15 @@ function getBidEventsCranker(type, renewSec) {
115
135
  });
116
136
  }
117
137
  exports.getBidEventsCranker = getBidEventsCranker;
118
- function getNewAuctionEventsCranker(type, renewSec) {
138
+ function getNewAuctionEventsCranker(type, renewSec, vault) {
119
139
  return __awaiter(this, void 0, void 0, function () {
120
140
  var res;
121
141
  var _this = this;
122
142
  return __generator(this, function (_a) {
123
143
  res = [];
124
144
  node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
125
- var events, newRes, newAuction, timesFormat_1, telegramText;
145
+ var events, newRes, newAuction, msg_1, telegramText;
146
+ var _this = this;
126
147
  return __generator(this, function (_a) {
127
148
  switch (_a.label) {
128
149
  case 0:
@@ -132,18 +153,25 @@ function getNewAuctionEventsCranker(type, renewSec) {
132
153
  events = _a.sent();
133
154
  newRes = events.data;
134
155
  if (newRes.length != res.length) {
135
- console.log("start a new auction!");
136
- console.log(events);
137
156
  newAuction = newRes.filter(function (e) {
138
157
  return res.indexOf(e) === -1;
139
158
  });
140
- timesFormat_1 = "";
141
- newAuction.map(function (e) {
142
- var time = moment_1.default.unix(e.timestamp / 1000).format("YYYY MM/DD HH:mm:ss");
143
- console.log(time);
144
- timesFormat_1 += time + " \n";
145
- });
146
- telegramText = "start a new auction! Time: \n" + timesFormat_1;
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);
147
175
  // sendEventToTelegramChannel(telegramText)
148
176
  res = newRes;
149
177
  }
@@ -156,9 +184,43 @@ function getNewAuctionEventsCranker(type, renewSec) {
156
184
  });
157
185
  }
158
186
  exports.getNewAuctionEventsCranker = getNewAuctionEventsCranker;
159
- function getEndAuctionEventsCranker(type, renewSec) {
187
+ function getEndAuctionEventsCranker(type, renewSec, vault) {
160
188
  return __awaiter(this, void 0, void 0, function () {
189
+ var res;
190
+ var _this = this;
161
191
  return __generator(this, function (_a) {
192
+ res = [];
193
+ node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
194
+ var events, newRes, newAuction, msg, telegramText;
195
+ var _this = this;
196
+ return __generator(this, function (_a) {
197
+ 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)];
201
+ case 1:
202
+ events = _a.sent();
203
+ newRes = events.data;
204
+ if (newRes.length != res.length) {
205
+ newAuction = newRes.filter(function (e) {
206
+ return res.indexOf(e) === -1;
207
+ });
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*/];
221
+ }
222
+ });
223
+ }); });
162
224
  return [2 /*return*/];
163
225
  });
164
226
  });
@@ -0,0 +1 @@
1
+ export declare function getMakerClaimAllTx(packageId: string, registry: string, typeArgument: string, index: string): Promise<any>;
@@ -0,0 +1,59 @@
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
+ exports.getMakerClaimAllTx = void 0;
40
+ function getMakerClaimAllTx(packageId, registry, typeArgument, index) {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var tx;
43
+ return __generator(this, function (_a) {
44
+ tx = {
45
+ packageObjectId: packageId,
46
+ module: 'covered_call',
47
+ function: 'maker_claim_all',
48
+ typeArguments: [typeArgument],
49
+ arguments: [
50
+ registry,
51
+ index,
52
+ ],
53
+ gasBudget: 10000,
54
+ };
55
+ return [2 /*return*/, tx];
56
+ });
57
+ });
58
+ }
59
+ exports.getMakerClaimAllTx = getMakerClaimAllTx;
@@ -0,0 +1 @@
1
+ export declare function getMakerClaimTx(packageId: string, registry: string, typeArgument: string, index: string): Promise<any>;
@@ -0,0 +1,59 @@
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
+ exports.getMakerClaimTx = void 0;
40
+ function getMakerClaimTx(packageId, registry, typeArgument, index) {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var tx;
43
+ return __generator(this, function (_a) {
44
+ tx = {
45
+ packageObjectId: packageId,
46
+ module: 'covered_call',
47
+ function: 'maker_claim',
48
+ typeArguments: [typeArgument],
49
+ arguments: [
50
+ registry,
51
+ index,
52
+ ],
53
+ gasBudget: 10000,
54
+ };
55
+ return [2 /*return*/, tx];
56
+ });
57
+ });
58
+ }
59
+ exports.getMakerClaimTx = getMakerClaimTx;
@@ -0,0 +1 @@
1
+ export declare function getRefundTx(packageId: string, registry: string, typeArgument: string, index: string): Promise<any>;
@@ -0,0 +1,59 @@
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
+ exports.getRefundTx = void 0;
40
+ function getRefundTx(packageId, registry, typeArgument, index) {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var tx;
43
+ return __generator(this, function (_a) {
44
+ tx = {
45
+ packageObjectId: packageId,
46
+ module: 'covered_call',
47
+ function: 'refund',
48
+ typeArguments: [typeArgument],
49
+ arguments: [
50
+ registry,
51
+ index,
52
+ ],
53
+ gasBudget: 10000,
54
+ };
55
+ return [2 /*return*/, tx];
56
+ });
57
+ });
58
+ }
59
+ exports.getRefundTx = getRefundTx;
@@ -123,8 +123,9 @@ function getUsersShares(userShareTable, registry) {
123
123
  var share = Number(x.details.data.fields.value);
124
124
  //user deposit amount = (user share/total share) * total balance
125
125
  var depositAmount = isRolling ?
126
- (share * ((_a = subVaultsData.get(index)) === null || _a === void 0 ? void 0 : _a.isRollingTotalSupply) / ((_b = subVaultsData.get(index)) === null || _b === void 0 ? void 0 : _b.isRollingTotalBalance)) :
127
- (share * ((_c = subVaultsData.get(index)) === null || _c === void 0 ? void 0 : _c.regularTotalSupply) / ((_d = subVaultsData.get(index)) === null || _d === void 0 ? void 0 : _d.regularTotalBalance));
126
+ (share / ((_a = subVaultsData.get(index)) === null || _a === void 0 ? void 0 : _a.isRollingTotalSupply) * ((_b = subVaultsData.get(index)) === null || _b === void 0 ? void 0 : _b.isRollingTotalBalance)) :
127
+ (share / ((_c = subVaultsData.get(index)) === null || _c === void 0 ? void 0 : _c.regularTotalSupply) * ((_d = subVaultsData.get(index)) === null || _d === void 0 ? void 0 : _d.regularTotalBalance));
128
+ depositAmount = Number(depositAmount.toFixed(0));
128
129
  var res = {
129
130
  coveredCallVaultIndex: index,
130
131
  //@ts-ignore
@@ -35,22 +35,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
38
  var __values = (this && this.__values) || function(o) {
55
39
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
56
40
  if (m) return m.call(o);
@@ -66,31 +50,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
66
50
  exports.getVaultBidPrice = exports.getVaultDataFromRegistry = void 0;
67
51
  var sui_js_1 = require("@mysten/sui.js");
68
52
  var constants_1 = require("../constants");
69
- var createTimeOracle_1 = require("../utils/coveredCall/createTimeOracle");
70
53
  var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
71
54
  function getVaultDataFromRegistry(registry) {
72
55
  return __awaiter(this, void 0, void 0, function () {
73
- var coveredCallVaults, coveredCallVaultsId, objsInfo, vaults, _a, timeOracle, _, _loop_1, objsInfo_1, objsInfo_1_1, objInfo, e_1_1;
74
- var e_1, _b;
75
- return __generator(this, function (_c) {
76
- switch (_c.label) {
56
+ var coveredCallVaults, coveredCallVaultsId, objsInfo, vaults, timeOracle, _loop_1, objsInfo_1, objsInfo_1_1, objInfo, e_1_1;
57
+ var e_1, _a;
58
+ return __generator(this, function (_b) {
59
+ switch (_b.label) {
77
60
  case 0:
78
61
  console.log("registry: " + registry);
79
62
  return [4 /*yield*/, provider.getObjectsOwnedByObject(registry)];
80
63
  case 1:
81
- coveredCallVaults = _c.sent();
64
+ coveredCallVaults = _b.sent();
82
65
  coveredCallVaultsId = coveredCallVaults.map(function (e) { return e.objectId; });
83
66
  return [4 /*yield*/, provider.getObjectBatch(coveredCallVaultsId)];
84
67
  case 2:
85
- objsInfo = _c.sent();
68
+ objsInfo = _b.sent();
86
69
  vaults = [];
87
- return [4 /*yield*/, (0, createTimeOracle_1.createTimeOracle)()];
88
- case 3:
89
- _a = __read.apply(void 0, [_c.sent(), 2]), timeOracle = _a[0], _ = _a[1];
70
+ timeOracle = constants_1.TIME_ORACLE;
90
71
  _loop_1 = function (objInfo) {
91
72
  var vaultId, vaultIdx, type, asset, config, vault, prev, vaultConfig, vaultConfigRes, nextVaultConfig, nextVaultConfigRes, payoffConfig, payoffConfigRes, configRes, maker, regular, rolling, vaultRes, auctionRes, vaultBidPrice, auction, priceConfig, priceConfigRes, next, totalBidSize, deliveryInfo, owner, tvl, res;
92
- return __generator(this, function (_d) {
93
- switch (_d.label) {
73
+ return __generator(this, function (_c) {
74
+ switch (_c.label) {
94
75
  case 0:
95
76
  if (objInfo.status != "Exists") {
96
77
  console.log("obj not exist");
@@ -180,14 +161,14 @@ function getVaultDataFromRegistry(registry) {
180
161
  };
181
162
  return [4 /*yield*/, getVaultBidPrice(auctionRes, timeOracle)];
182
163
  case 1:
183
- vaultBidPrice = _d.sent();
164
+ vaultBidPrice = _c.sent();
184
165
  console.log("get auction in " + vaultId);
185
166
  return [3 /*break*/, 3];
186
167
  case 2:
187
168
  console.log("No auction " + vaultId);
188
169
  auctionRes = {};
189
170
  vaultBidPrice = 0;
190
- _d.label = 3;
171
+ _c.label = 3;
191
172
  case 3:
192
173
  next = objInfo.details.data.fields.value.fields.next;
193
174
  totalBidSize = objInfo.details.data.fields.value.fields.total_bid_size;
@@ -214,33 +195,33 @@ function getVaultDataFromRegistry(registry) {
214
195
  }
215
196
  });
216
197
  };
217
- _c.label = 4;
218
- case 4:
219
- _c.trys.push([4, 9, 10, 11]);
198
+ _b.label = 3;
199
+ case 3:
200
+ _b.trys.push([3, 8, 9, 10]);
220
201
  objsInfo_1 = __values(objsInfo), objsInfo_1_1 = objsInfo_1.next();
221
- _c.label = 5;
222
- case 5:
223
- if (!!objsInfo_1_1.done) return [3 /*break*/, 8];
202
+ _b.label = 4;
203
+ case 4:
204
+ if (!!objsInfo_1_1.done) return [3 /*break*/, 7];
224
205
  objInfo = objsInfo_1_1.value;
225
206
  return [5 /*yield**/, _loop_1(objInfo)];
207
+ case 5:
208
+ _b.sent();
209
+ _b.label = 6;
226
210
  case 6:
227
- _c.sent();
228
- _c.label = 7;
229
- case 7:
230
211
  objsInfo_1_1 = objsInfo_1.next();
231
- return [3 /*break*/, 5];
232
- case 8: return [3 /*break*/, 11];
233
- case 9:
234
- e_1_1 = _c.sent();
212
+ return [3 /*break*/, 4];
213
+ case 7: return [3 /*break*/, 10];
214
+ case 8:
215
+ e_1_1 = _b.sent();
235
216
  e_1 = { error: e_1_1 };
236
- return [3 /*break*/, 11];
237
- case 10:
217
+ return [3 /*break*/, 10];
218
+ case 9:
238
219
  try {
239
- if (objsInfo_1_1 && !objsInfo_1_1.done && (_b = objsInfo_1.return)) _b.call(objsInfo_1);
220
+ if (objsInfo_1_1 && !objsInfo_1_1.done && (_a = objsInfo_1.return)) _a.call(objsInfo_1);
240
221
  }
241
222
  finally { if (e_1) throw e_1.error; }
242
223
  return [7 /*endfinally*/];
243
- case 11: return [2 /*return*/, vaults];
224
+ case 10: return [2 /*return*/, vaults];
244
225
  }
245
226
  });
246
227
  });
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.0",
5
+ "version": "0.4.2",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.5.0",
8
8
  "@mysten/sui.js": "^0.20.0",