@typus/typus-sdk 0.4.1 → 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,16 +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 TIME_ORACLE = "0x1480773700cdeecfbac028f5345ec8f472750ef8";
7
- export declare const COVERED_CALL_PACKAGE = "0x00d18316601f16439dec0a6b3e40ef861fc84ee4";
8
- export declare const COVERED_CALL_REGISTRY = "0xe3960d9dc8e39328e514d42d3318c5878145c27e";
9
- export declare const COVERED_CALL_MANAGER = "0xfe26a77c66f4ae0314e1510921f8dea9be01db9c";
10
- export declare const USER_SHARE_TABLE = "0x4d98c1efa4aef5b02e8fe27bca6ac4d8dde62935";
11
- export declare const USER_REFUND_TABLE = "0x3e80b4c0f7d1b05a73d180487aa2bbf5e3c77792";
12
- export declare const MAKER_SHARE_TABLE = "0xef0dabd3f82d4cc09c440a61f095a977d72ade05";
13
- 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";
14
17
  export declare const TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
15
18
  export declare const PRICE_DECIMAL = 8;
16
19
  export declare const TOKEN_DECIMAL = 9;
package/lib/constants.js CHANGED
@@ -1,23 +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.TIME_ORACLE = 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";
11
- exports.TIME_ORACLE = "0x1480773700cdeecfbac028f5345ec8f472750ef8";
13
+ exports.ORACLE_PACKAGE = "0xcba43b3a1672f3c782e2167fc64710799009d5bb";
14
+ exports.TIME_ORACLE = "0x55031e1edc517a4b16543c1c081ba33a59ffd084";
12
15
  //publish from typus-dov/cover_call
13
- exports.COVERED_CALL_PACKAGE = "0x00d18316601f16439dec0a6b3e40ef861fc84ee4";
14
- exports.COVERED_CALL_REGISTRY = "0xe3960d9dc8e39328e514d42d3318c5878145c27e";
15
- exports.COVERED_CALL_MANAGER = "0xfe26a77c66f4ae0314e1510921f8dea9be01db9c";
16
- exports.USER_SHARE_TABLE = "0x4d98c1efa4aef5b02e8fe27bca6ac4d8dde62935";
17
- exports.USER_REFUND_TABLE = "0x3e80b4c0f7d1b05a73d180487aa2bbf5e3c77792";
18
- 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";
19
22
  //publish from typus-dov/typus-dov
20
- exports.DOV_PACKAGE = "0xdbb42109c373ded4b97016230e5d065fb96813b8";
23
+ exports.DOV_PACKAGE = "0x49e71a735dc6bdf7327e6c663d04a3e7f68bafd0";
21
24
  exports.TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
22
25
  exports.PRICE_DECIMAL = 8;
23
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 = " auction is live now!";
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
  });
@@ -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
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.1",
5
+ "version": "0.4.2",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.5.0",
8
8
  "@mysten/sui.js": "^0.20.0",