@typus/typus-sdk 0.5.2 → 0.5.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.
- package/lib/constants.d.ts +9 -9
- package/lib/constants.js +10 -10
- package/lib/scripts/sui.js +4 -4
- package/lib/test/eventListener.d.ts +4 -4
- package/lib/test/eventListener.js +131 -67
- package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedDeliveryTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedEvolutionTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedLastEvolutionTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedNewAuctionTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedSettleTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedUpdateCapacityTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.js +1 -1
- package/lib/utils/authorized/getAuthorizedUpdateVaultConfigTx.js +1 -1
- package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.js +1 -1
- package/lib/utils/coveredCall/getClaimAllTx.js +1 -1
- package/lib/utils/coveredCall/getClaimTx.js +1 -1
- package/lib/utils/coveredCall/getCloseAuctionTx.js +1 -1
- package/lib/utils/coveredCall/getCloseVaultTx.js +1 -1
- package/lib/utils/coveredCall/getDeliveryTx.js +1 -1
- package/lib/utils/coveredCall/getDepositTx.js +1 -1
- package/lib/utils/coveredCall/getEvolutionTx.js +1 -1
- package/lib/utils/coveredCall/getLastEvolutionTx.js +1 -1
- package/lib/utils/coveredCall/getMakerClaimAllTx.js +1 -1
- package/lib/utils/coveredCall/getMakerClaimTx.js +1 -1
- package/lib/utils/coveredCall/getNewAuctionTx.js +1 -1
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +1 -1
- package/lib/utils/coveredCall/getNewBidTx.js +1 -1
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +1 -1
- package/lib/utils/coveredCall/getNewManagerTx.js +1 -1
- package/lib/utils/coveredCall/getRefundTx.js +1 -1
- package/lib/utils/coveredCall/getRemoveBidTx.js +1 -1
- package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.js +1 -1
- package/lib/utils/coveredCall/getRemoveManagerTx.js +1 -1
- package/lib/utils/coveredCall/getRollOverTx.js +1 -1
- package/lib/utils/coveredCall/getSettleTx.js +1 -1
- package/lib/utils/coveredCall/getSettleWithRollOverTx.js +1 -1
- package/lib/utils/coveredCall/getSubscribeTx.js +1 -1
- package/lib/utils/coveredCall/getUnsubscribeTx.js +1 -1
- package/lib/utils/coveredCall/getUpdateCapacityTx.js +1 -1
- package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.js +1 -1
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +1 -1
- package/lib/utils/coveredCall/getUpdateVaultConfigTx.js +1 -1
- package/lib/utils/coveredCall/getWithdrawTx.js +1 -1
- package/lib/utils/fetchData.d.ts +1 -0
- package/lib/utils/getCreateTokenRegistryTx.js +1 -1
- package/lib/utils/getMintTx.js +1 -1
- package/lib/utils/getNewOracleTx.js +1 -1
- package/lib/utils/getNewTimeOracleTx.js +1 -1
- package/lib/utils/getUpdateOracleTx.js +1 -1
- package/lib/utils/getUpdateTimeOracleTx.js +1 -1
- package/lib/utils/getUsersShares.d.ts +1 -1
- package/lib/utils/getUsersShares.js +8 -4
- package/lib/utils/getVaultData.js +5 -3
- package/package.json +4 -3
package/lib/constants.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export declare const TOKEN_PACKAGE = "
|
|
1
|
+
export declare const TOKEN_PACKAGE = "0xcb6f5de70c65b988556b93988a58a57919584e56";
|
|
2
2
|
export declare const TOKEN_REGISTRY_BTC = "0x7325b75b85ee45e78204a9dcf7800a397259eb3d";
|
|
3
3
|
export declare const TOKEN_REGISTRY_ETH = "0x475d3b10d29c03d85dfa707b5479955729216d4d";
|
|
4
4
|
export declare const TOKEN_REGISTRY_SUI = "0x3b87b3f0403f527d28fd1301074a12446f43817a";
|
|
5
5
|
export declare const TOKEN_REGISTRY_APT = "0xf1a947ebc2643942bf3f2ecbd6b583c0f8dc3baf";
|
|
6
6
|
export declare const TOKEN_REGISTRY_DOGE = "0x4dbe73f8a744008bc20d12aaa0d4fc8f01692358";
|
|
7
7
|
export declare const TOKEN_REGISTRY_USDC = "0x82e0a1473c6c4d4f713a0ac5957e0c7a2278ed1e";
|
|
8
|
-
export declare const ORACLE_PACKAGE = "
|
|
9
|
-
export declare const TIME_ORACLE = "
|
|
10
|
-
export declare const COVERED_CALL_PACKAGE = "
|
|
11
|
-
export declare const COVERED_CALL_REGISTRY = "
|
|
12
|
-
export declare const COVERED_CALL_MANAGER = "
|
|
13
|
-
export declare const USER_SHARE_TABLE = "
|
|
14
|
-
export declare const USER_REFUND_TABLE = "
|
|
15
|
-
export declare const MAKER_SHARE_TABLE = "
|
|
8
|
+
export declare const ORACLE_PACKAGE = "0xddfa73b1bf15da6f72da9346a16051b7b90db1a6";
|
|
9
|
+
export declare const TIME_ORACLE = "0xb4a661b1493812476558de89af2092245b2d893f";
|
|
10
|
+
export declare const COVERED_CALL_PACKAGE = "0xdeb0b9cdc1f0da4196382a40bae55f6087c55626";
|
|
11
|
+
export declare const COVERED_CALL_REGISTRY = "0x01212ccf4f2011efb2c0be14ed538960def8e104";
|
|
12
|
+
export declare const COVERED_CALL_MANAGER = "0xb058fa60c70f6844d952b5f9115101bfb3cd59e6";
|
|
13
|
+
export declare const USER_SHARE_TABLE = "0xd2c1ddb7e80dc6fe494ca4d2fcc32700eb37e098";
|
|
14
|
+
export declare const USER_REFUND_TABLE = "0xc5683c6c8485b5ded986298dd4d15069a020b143";
|
|
15
|
+
export declare const MAKER_SHARE_TABLE = "0x27387549841398c0792fd8472657df030294c3f0";
|
|
16
16
|
export declare const DOV_PACKAGE = "0x49e71a735dc6bdf7327e6c663d04a3e7f68bafd0";
|
|
17
17
|
export declare const TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
|
|
18
18
|
export declare const PRICE_DECIMAL = 8;
|
package/lib/constants.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TESTNET_RPC_ENDPOINT = 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 = "
|
|
5
|
+
exports.TOKEN_PACKAGE = "0xcb6f5de70c65b988556b93988a58a57919584e56";
|
|
6
6
|
exports.TOKEN_REGISTRY_BTC = "0x7325b75b85ee45e78204a9dcf7800a397259eb3d";
|
|
7
7
|
exports.TOKEN_REGISTRY_ETH = "0x475d3b10d29c03d85dfa707b5479955729216d4d";
|
|
8
8
|
exports.TOKEN_REGISTRY_SUI = "0x3b87b3f0403f527d28fd1301074a12446f43817a";
|
|
@@ -10,15 +10,15 @@ exports.TOKEN_REGISTRY_APT = "0xf1a947ebc2643942bf3f2ecbd6b583c0f8dc3baf";
|
|
|
10
10
|
exports.TOKEN_REGISTRY_DOGE = "0x4dbe73f8a744008bc20d12aaa0d4fc8f01692358";
|
|
11
11
|
exports.TOKEN_REGISTRY_USDC = "0x82e0a1473c6c4d4f713a0ac5957e0c7a2278ed1e";
|
|
12
12
|
//publish from typus-oracle
|
|
13
|
-
exports.ORACLE_PACKAGE = "
|
|
14
|
-
exports.TIME_ORACLE = '
|
|
13
|
+
exports.ORACLE_PACKAGE = "0xddfa73b1bf15da6f72da9346a16051b7b90db1a6";
|
|
14
|
+
exports.TIME_ORACLE = '0xb4a661b1493812476558de89af2092245b2d893f';
|
|
15
15
|
//publish from typus-dov/cover_call
|
|
16
|
-
exports.COVERED_CALL_PACKAGE = "
|
|
17
|
-
exports.COVERED_CALL_REGISTRY = "
|
|
18
|
-
exports.COVERED_CALL_MANAGER = "
|
|
19
|
-
exports.USER_SHARE_TABLE = "
|
|
20
|
-
exports.USER_REFUND_TABLE = "
|
|
21
|
-
exports.MAKER_SHARE_TABLE = "
|
|
16
|
+
exports.COVERED_CALL_PACKAGE = "0xdeb0b9cdc1f0da4196382a40bae55f6087c55626";
|
|
17
|
+
exports.COVERED_CALL_REGISTRY = "0x01212ccf4f2011efb2c0be14ed538960def8e104";
|
|
18
|
+
exports.COVERED_CALL_MANAGER = "0xb058fa60c70f6844d952b5f9115101bfb3cd59e6";
|
|
19
|
+
exports.USER_SHARE_TABLE = "0xd2c1ddb7e80dc6fe494ca4d2fcc32700eb37e098";
|
|
20
|
+
exports.USER_REFUND_TABLE = "0xc5683c6c8485b5ded986298dd4d15069a020b143";
|
|
21
|
+
exports.MAKER_SHARE_TABLE = "0x27387549841398c0792fd8472657df030294c3f0";
|
|
22
22
|
//publish from typus-dov/typus-dov
|
|
23
23
|
exports.DOV_PACKAGE = "0x49e71a735dc6bdf7327e6c663d04a3e7f68bafd0";
|
|
24
24
|
exports.TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
|
|
@@ -27,7 +27,7 @@ exports.TOKEN_DECIMAL = 9;
|
|
|
27
27
|
exports.DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
|
|
28
28
|
exports.FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
|
|
29
29
|
exports.TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
|
|
30
|
-
exports.TOKEN_NAME = ["BTC", "ETH", "SUI", "USDC", "USDT"
|
|
30
|
+
exports.TOKEN_NAME = ["BTC", "ETH", "SUI", "USDC", "USDT"];
|
|
31
31
|
exports.TOKEN_NAME_TO_MODULE = {
|
|
32
32
|
"BTC": "btc",
|
|
33
33
|
"ETH": "eth",
|
package/lib/scripts/sui.js
CHANGED
|
@@ -82,7 +82,7 @@ function readJsonFile(filePath) {
|
|
|
82
82
|
// console.log("test for transferObject()")
|
|
83
83
|
// const transferTxn = await signer.transferObject({
|
|
84
84
|
// objectId: obj1,
|
|
85
|
-
// gasBudget:
|
|
85
|
+
// gasBudget: 100000,
|
|
86
86
|
// recipient: receiver,
|
|
87
87
|
// });
|
|
88
88
|
// console.log('transferTxn', transferTxn);
|
|
@@ -100,7 +100,7 @@ function readJsonFile(filePath) {
|
|
|
100
100
|
// 'An NFT created by the wallet Command Line Tool',
|
|
101
101
|
// 'ipfs://bafkreibngqhl3gaa7daob4i2vccziay2jjlp435cf66vhono7nrvww53ty',
|
|
102
102
|
// ],
|
|
103
|
-
// gasBudget:
|
|
103
|
+
// gasBudget: 100000,
|
|
104
104
|
// });
|
|
105
105
|
// console.log('moveCallTxn', moveCallTxn);
|
|
106
106
|
// })();
|
|
@@ -135,7 +135,7 @@ function readJsonFile(filePath) {
|
|
|
135
135
|
// );
|
|
136
136
|
// const publishTxn = await signer.publish({
|
|
137
137
|
// compiledModules: modulesInBytes,
|
|
138
|
-
// gasBudget:
|
|
138
|
+
// gasBudget: 100000,
|
|
139
139
|
// });
|
|
140
140
|
// console.log('publishTxn', publishTxn);
|
|
141
141
|
// })();
|
|
@@ -180,7 +180,7 @@ function readJsonFile(filePath) {
|
|
|
180
180
|
// true,
|
|
181
181
|
// coin
|
|
182
182
|
// ],
|
|
183
|
-
// gasBudget:
|
|
183
|
+
// gasBudget: 100000,
|
|
184
184
|
// }
|
|
185
185
|
// const moveCallTxn = await signer.executeMoveCall(txn);
|
|
186
186
|
// console.log('moveCallTxn', moveCallTxn);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function getBidEventsCranker(type: string, renewSec: number,
|
|
3
|
-
export declare function getNewAuctionEventsCranker(type: string, renewSec: number,
|
|
4
|
-
export declare function getEndAuctionEventsCranker(type: string, renewSec: number,
|
|
1
|
+
import { JsonRpcProvider } from '@mysten/sui.js';
|
|
2
|
+
export declare function getBidEventsCranker(type: string, renewSec: number, provider: JsonRpcProvider): Promise<void>;
|
|
3
|
+
export declare function getNewAuctionEventsCranker(type: string, renewSec: number, provider: JsonRpcProvider): Promise<void>;
|
|
4
|
+
export declare function getEndAuctionEventsCranker(type: string, renewSec: number, provider: JsonRpcProvider): Promise<void>;
|
|
5
5
|
export declare function sendEventToTelegramChannel(text: any): Promise<void>;
|
|
@@ -35,6 +35,17 @@ 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 __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
|
+
};
|
|
38
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
51
|
};
|
|
@@ -46,14 +57,15 @@ var getVaultData_1 = require("../utils/getVaultData");
|
|
|
46
57
|
var node_cron_1 = __importDefault(require("node-cron"));
|
|
47
58
|
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
|
|
48
59
|
var moment_1 = __importDefault(require("moment"));
|
|
49
|
-
var
|
|
60
|
+
var decimal_js_1 = __importDefault(require("decimal.js"));
|
|
61
|
+
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
50
62
|
var apiToken = process.env.API_TOKEN;
|
|
51
63
|
var chatId = process.env.CHAT_ID;
|
|
52
64
|
/*
|
|
53
65
|
「https://api.telegram.org/botTOKEN/getUpdates」,change TOKEN to token from botFather
|
|
54
66
|
*/
|
|
55
67
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
-
var bidTypes, newAuctionType, endAuctionType, renewSec
|
|
68
|
+
var bidTypes, newAuctionType, endAuctionType, renewSec;
|
|
57
69
|
return __generator(this, function (_a) {
|
|
58
70
|
switch (_a.label) {
|
|
59
71
|
case 0:
|
|
@@ -63,26 +75,24 @@ var chatId = process.env.CHAT_ID;
|
|
|
63
75
|
constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::sui::SUI>",
|
|
64
76
|
];
|
|
65
77
|
newAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewAuction";
|
|
66
|
-
endAuctionType = constants_1.
|
|
78
|
+
endAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::Delivery<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>";
|
|
67
79
|
renewSec = 10;
|
|
68
|
-
|
|
69
|
-
case 1:
|
|
70
|
-
vault = _a.sent();
|
|
80
|
+
// let vault = await getVaultDataFromRegistry(COVERED_CALL_REGISTRY, provider);
|
|
71
81
|
bidTypes.map(function (bidType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
82
|
return __generator(this, function (_a) {
|
|
73
83
|
switch (_a.label) {
|
|
74
|
-
case 0: return [4 /*yield*/, getBidEventsCranker(bidType, renewSec,
|
|
84
|
+
case 0: return [4 /*yield*/, getBidEventsCranker(bidType, renewSec, provider)]; //new_bid
|
|
75
85
|
case 1:
|
|
76
86
|
_a.sent(); //new_bid
|
|
77
87
|
return [2 /*return*/];
|
|
78
88
|
}
|
|
79
89
|
});
|
|
80
90
|
}); });
|
|
81
|
-
return [4 /*yield*/, getNewAuctionEventsCranker(newAuctionType, renewSec,
|
|
82
|
-
case
|
|
91
|
+
return [4 /*yield*/, getNewAuctionEventsCranker(newAuctionType, renewSec, provider)]; //evolution
|
|
92
|
+
case 1:
|
|
83
93
|
_a.sent(); //evolution
|
|
84
|
-
return [4 /*yield*/, getEndAuctionEventsCranker(endAuctionType, renewSec,
|
|
85
|
-
case
|
|
94
|
+
return [4 /*yield*/, getEndAuctionEventsCranker(endAuctionType, renewSec, provider)];
|
|
95
|
+
case 2:
|
|
86
96
|
_a.sent();
|
|
87
97
|
return [2 /*return*/];
|
|
88
98
|
}
|
|
@@ -116,9 +126,13 @@ function generateBidId(vault) {
|
|
|
116
126
|
.unix(Number(time) / 1000)
|
|
117
127
|
.format("DDMMMYY");
|
|
118
128
|
var bidId = "".concat(v.asset, "-").concat(expiration, "-").concat(v.config.payoffConfig.strike, "-C");
|
|
129
|
+
var period = (v.config.period);
|
|
130
|
+
var vaultIdx = v.vaultIdx;
|
|
119
131
|
var obj = {
|
|
120
132
|
bidFormat: bidId,
|
|
121
|
-
bidTime: Number(time)
|
|
133
|
+
bidTime: Number(time),
|
|
134
|
+
period: period,
|
|
135
|
+
vaultIdx: vaultIdx,
|
|
122
136
|
};
|
|
123
137
|
return obj;
|
|
124
138
|
});
|
|
@@ -126,14 +140,14 @@ function generateBidId(vault) {
|
|
|
126
140
|
});
|
|
127
141
|
});
|
|
128
142
|
}
|
|
129
|
-
function getBidEventsCranker(type, renewSec,
|
|
143
|
+
function getBidEventsCranker(type, renewSec, provider) {
|
|
130
144
|
return __awaiter(this, void 0, void 0, function () {
|
|
131
145
|
var res;
|
|
132
146
|
var _this = this;
|
|
133
147
|
return __generator(this, function (_a) {
|
|
134
148
|
res = [];
|
|
135
149
|
node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
136
|
-
var events, newRes, newBid, format_1, bidIds_1, telegramText;
|
|
150
|
+
var events, newRes, newBidHappened, newBid, format_1, vault, bidIds_1, telegramText;
|
|
137
151
|
var _this = this;
|
|
138
152
|
return __generator(this, function (_a) {
|
|
139
153
|
switch (_a.label) {
|
|
@@ -141,9 +155,8 @@ function getBidEventsCranker(type, renewSec, vault) {
|
|
|
141
155
|
case 1:
|
|
142
156
|
events = _a.sent();
|
|
143
157
|
newRes = events.data;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
console.log("there are " + (newRes.length - res.length).toString() + " new bids");
|
|
158
|
+
newBidHappened = newRes.length != res.length;
|
|
159
|
+
if (!newBidHappened) return [3 /*break*/, 4];
|
|
147
160
|
newBid = newRes.filter(function (_a) {
|
|
148
161
|
var id1 = _a.timestamp;
|
|
149
162
|
return !res.some(function (_a) {
|
|
@@ -151,29 +164,22 @@ function getBidEventsCranker(type, renewSec, vault) {
|
|
|
151
164
|
return id2 === id1;
|
|
152
165
|
});
|
|
153
166
|
});
|
|
154
|
-
console.log("new bid amount: " + newBid.length);
|
|
155
167
|
format_1 = "";
|
|
156
|
-
return [4 /*yield*/,
|
|
168
|
+
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY, provider)];
|
|
157
169
|
case 2:
|
|
170
|
+
vault = _a.sent();
|
|
171
|
+
return [4 /*yield*/, generateBidId(vault)];
|
|
172
|
+
case 3:
|
|
158
173
|
bidIds_1 = _a.sent();
|
|
159
|
-
// [
|
|
160
|
-
// 'ETH-18Jan23-1750-C',
|
|
161
|
-
// 'BTC-18Jan23-21800-C',
|
|
162
|
-
// 'ETH-17Jan23-1750-C',
|
|
163
|
-
// 'SUI-18Jan23-9-C'
|
|
164
|
-
// ]
|
|
165
|
-
// console.log(bidIds)
|
|
166
174
|
newBid.map(function (e) { return __awaiter(_this, void 0, void 0, function () {
|
|
167
|
-
var bidId, size;
|
|
175
|
+
var newBidVaultIdx, bidId, size, period;
|
|
168
176
|
return __generator(this, function (_a) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
var asset = bidId.bidFormat.split("-")[0];
|
|
172
|
-
return e.event.moveEvent.type.includes(bidId.bidFormat.split("-")[0]);
|
|
173
|
-
});
|
|
177
|
+
newBidVaultIdx = e.event.moveEvent.fields.index;
|
|
178
|
+
bidId = bidIds_1.find(function (bidId) { return bidId.vaultIdx == newBidVaultIdx; });
|
|
174
179
|
if (bidId) {
|
|
175
180
|
size = (Number(e.event.moveEvent.fields.size) / (Math.pow(10, constants_1.TOKEN_DECIMAL))).toString();
|
|
176
|
-
|
|
181
|
+
period = (bidId.period == "0") ? "Daily " : (bidId.period == "1") ? "Weekly " : (bidId.period == "2") ? "Monthly " : "- ";
|
|
182
|
+
format_1 += period + bidId.bidFormat + " is bid with " + size + " " + bidId.bidFormat.split("-")[0] + "! \n";
|
|
177
183
|
}
|
|
178
184
|
else {
|
|
179
185
|
console.log("can't get bidId in getBidEventsCranker");
|
|
@@ -185,8 +191,8 @@ function getBidEventsCranker(type, renewSec, vault) {
|
|
|
185
191
|
console.log(telegramText);
|
|
186
192
|
sendEventToTelegramChannel(telegramText);
|
|
187
193
|
res = newRes;
|
|
188
|
-
_a.label =
|
|
189
|
-
case
|
|
194
|
+
_a.label = 4;
|
|
195
|
+
case 4: return [2 /*return*/];
|
|
190
196
|
}
|
|
191
197
|
});
|
|
192
198
|
}); });
|
|
@@ -195,40 +201,62 @@ function getBidEventsCranker(type, renewSec, vault) {
|
|
|
195
201
|
});
|
|
196
202
|
}
|
|
197
203
|
exports.getBidEventsCranker = getBidEventsCranker;
|
|
198
|
-
function getNewAuctionEventsCranker(type, renewSec,
|
|
204
|
+
function getNewAuctionEventsCranker(type, renewSec, provider) {
|
|
199
205
|
return __awaiter(this, void 0, void 0, function () {
|
|
200
206
|
var res;
|
|
201
207
|
var _this = this;
|
|
202
208
|
return __generator(this, function (_a) {
|
|
203
209
|
res = [];
|
|
204
210
|
node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
205
|
-
var events, newRes, format_2, bidIds, telegramText;
|
|
206
|
-
var
|
|
207
|
-
return __generator(this, function (
|
|
208
|
-
switch (
|
|
211
|
+
var events, newRes, format_2, vault, bidIds, _loop_1, TOKEN_NAME_1, TOKEN_NAME_1_1, asset, telegramText;
|
|
212
|
+
var e_1, _a;
|
|
213
|
+
return __generator(this, function (_b) {
|
|
214
|
+
switch (_b.label) {
|
|
209
215
|
case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
|
|
210
216
|
case 1:
|
|
211
|
-
events =
|
|
217
|
+
events = _b.sent();
|
|
212
218
|
newRes = events.data;
|
|
213
219
|
return [4 /*yield*/, twoObjArrAreSame(newRes, res)];
|
|
214
220
|
case 2:
|
|
215
|
-
if (!!(
|
|
216
|
-
format_2 = "";
|
|
217
|
-
return [4 /*yield*/,
|
|
221
|
+
if (!!(_b.sent())) return [3 /*break*/, 5];
|
|
222
|
+
format_2 = "Typus Auction is live! Bid now! \n";
|
|
223
|
+
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY, provider)];
|
|
218
224
|
case 3:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
225
|
+
vault = _b.sent();
|
|
226
|
+
return [4 /*yield*/, generateBidId(vault)];
|
|
227
|
+
case 4:
|
|
228
|
+
bidIds = _b.sent();
|
|
229
|
+
_loop_1 = function (asset) {
|
|
230
|
+
var targetBids = bidIds.filter(function (bidId) {
|
|
231
|
+
return bidId.bidFormat.toString().includes(asset);
|
|
224
232
|
});
|
|
225
|
-
|
|
233
|
+
if (targetBids.length) {
|
|
234
|
+
format_2 += asset + " Options \n";
|
|
235
|
+
targetBids.map(function (bidId) {
|
|
236
|
+
var period = (bidId.period == "0") ? "Daily " : (bidId.period == "1") ? "Weekly " : (bidId.period == "2") ? "Monthly " : "- ";
|
|
237
|
+
format_2 += "\t" + period + "Covered Call-" + bidId.bidFormat + " \n";
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
try {
|
|
242
|
+
for (TOKEN_NAME_1 = __values(constants_1.TOKEN_NAME), TOKEN_NAME_1_1 = TOKEN_NAME_1.next(); !TOKEN_NAME_1_1.done; TOKEN_NAME_1_1 = TOKEN_NAME_1.next()) {
|
|
243
|
+
asset = TOKEN_NAME_1_1.value;
|
|
244
|
+
_loop_1(asset);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
248
|
+
finally {
|
|
249
|
+
try {
|
|
250
|
+
if (TOKEN_NAME_1_1 && !TOKEN_NAME_1_1.done && (_a = TOKEN_NAME_1.return)) _a.call(TOKEN_NAME_1);
|
|
251
|
+
}
|
|
252
|
+
finally { if (e_1) throw e_1.error; }
|
|
253
|
+
}
|
|
226
254
|
telegramText = format_2;
|
|
227
255
|
console.log(telegramText);
|
|
228
256
|
sendEventToTelegramChannel(telegramText);
|
|
229
257
|
res = newRes;
|
|
230
|
-
|
|
231
|
-
case
|
|
258
|
+
_b.label = 5;
|
|
259
|
+
case 5: return [2 /*return*/];
|
|
232
260
|
}
|
|
233
261
|
});
|
|
234
262
|
}); });
|
|
@@ -237,40 +265,76 @@ function getNewAuctionEventsCranker(type, renewSec, vault) {
|
|
|
237
265
|
});
|
|
238
266
|
}
|
|
239
267
|
exports.getNewAuctionEventsCranker = getNewAuctionEventsCranker;
|
|
240
|
-
function getEndAuctionEventsCranker(type, renewSec,
|
|
268
|
+
function getEndAuctionEventsCranker(type, renewSec, provider) {
|
|
241
269
|
return __awaiter(this, void 0, void 0, function () {
|
|
242
270
|
var res;
|
|
243
271
|
var _this = this;
|
|
244
272
|
return __generator(this, function (_a) {
|
|
245
273
|
res = [];
|
|
246
274
|
node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
247
|
-
var events, newRes, format_3, bidIds, telegramText;
|
|
275
|
+
var events, newRes, format_3, vault_1, bidIds, _loop_2, TOKEN_NAME_2, TOKEN_NAME_2_1, asset, telegramText;
|
|
276
|
+
var e_2, _a;
|
|
248
277
|
var _this = this;
|
|
249
|
-
return __generator(this, function (
|
|
250
|
-
switch (
|
|
278
|
+
return __generator(this, function (_b) {
|
|
279
|
+
switch (_b.label) {
|
|
251
280
|
case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
|
|
252
281
|
case 1:
|
|
253
|
-
events =
|
|
282
|
+
events = _b.sent();
|
|
254
283
|
newRes = events.data;
|
|
255
284
|
return [4 /*yield*/, twoObjArrAreSame(newRes, res)];
|
|
256
285
|
case 2:
|
|
257
|
-
if (!!(
|
|
286
|
+
if (!!(_b.sent())) return [3 /*break*/, 5];
|
|
258
287
|
format_3 = "";
|
|
259
|
-
return [4 /*yield*/,
|
|
288
|
+
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY, provider)];
|
|
260
289
|
case 3:
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
290
|
+
vault_1 = _b.sent();
|
|
291
|
+
return [4 /*yield*/, generateBidId(vault_1)];
|
|
292
|
+
case 4:
|
|
293
|
+
bidIds = _b.sent();
|
|
294
|
+
_loop_2 = function (asset) {
|
|
295
|
+
var targetBids = bidIds.filter(function (bidId) {
|
|
296
|
+
return bidId.bidFormat.toString().includes(asset);
|
|
266
297
|
});
|
|
267
|
-
|
|
298
|
+
if (targetBids.length) {
|
|
299
|
+
targetBids.map(function (bidId) { return __awaiter(_this, void 0, void 0, function () {
|
|
300
|
+
var vaultIdx, targetVault, totalAuctioned, clearingPrice, period;
|
|
301
|
+
return __generator(this, function (_a) {
|
|
302
|
+
vaultIdx = bidId.vaultIdx;
|
|
303
|
+
targetVault = vault_1.find(function (e) { return e.vaultIdx == vaultIdx; });
|
|
304
|
+
totalAuctioned = "-";
|
|
305
|
+
clearingPrice = "-";
|
|
306
|
+
if (targetVault === null || targetVault === void 0 ? void 0 : targetVault.deliveryInfo) {
|
|
307
|
+
// console.log(targetVault.deliveryInfo)
|
|
308
|
+
totalAuctioned = (new decimal_js_1.default(targetVault === null || targetVault === void 0 ? void 0 : targetVault.deliveryInfo.deliverySize).div(new decimal_js_1.default(Math.pow(10, constants_1.TOKEN_DECIMAL)))).toFixed(2);
|
|
309
|
+
clearingPrice = (new decimal_js_1.default(targetVault === null || targetVault === void 0 ? void 0 : targetVault.deliveryInfo.deliveryPrice).div(new decimal_js_1.default(Math.pow(10, 5)))).toFixed(4);
|
|
310
|
+
}
|
|
311
|
+
period = (bidId.period == "0") ? "Daily " : (bidId.period == "1") ? "Weekly " : (bidId.period == "2") ? "Monthly " : "- ";
|
|
312
|
+
format_3 += period + "Covered Call-" + bidId.bidFormat + " auction is closed! Total auctioned " + totalAuctioned +
|
|
313
|
+
" " + asset + " at a clearing price of " + clearingPrice + " " + asset + " \n";
|
|
314
|
+
return [2 /*return*/];
|
|
315
|
+
});
|
|
316
|
+
}); });
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
try {
|
|
320
|
+
for (TOKEN_NAME_2 = __values(constants_1.TOKEN_NAME), TOKEN_NAME_2_1 = TOKEN_NAME_2.next(); !TOKEN_NAME_2_1.done; TOKEN_NAME_2_1 = TOKEN_NAME_2.next()) {
|
|
321
|
+
asset = TOKEN_NAME_2_1.value;
|
|
322
|
+
_loop_2(asset);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
326
|
+
finally {
|
|
327
|
+
try {
|
|
328
|
+
if (TOKEN_NAME_2_1 && !TOKEN_NAME_2_1.done && (_a = TOKEN_NAME_2.return)) _a.call(TOKEN_NAME_2);
|
|
329
|
+
}
|
|
330
|
+
finally { if (e_2) throw e_2.error; }
|
|
331
|
+
}
|
|
268
332
|
telegramText = format_3;
|
|
269
333
|
console.log(telegramText);
|
|
270
334
|
sendEventToTelegramChannel(telegramText);
|
|
271
335
|
res = newRes;
|
|
272
|
-
|
|
273
|
-
case
|
|
336
|
+
_b.label = 5;
|
|
337
|
+
case 5: return [2 /*return*/];
|
|
274
338
|
}
|
|
275
339
|
});
|
|
276
340
|
}); });
|
package/lib/utils/fetchData.d.ts
CHANGED
package/lib/utils/getMintTx.js
CHANGED
|
@@ -4,6 +4,6 @@ export interface UserShare {
|
|
|
4
4
|
isRolling: boolean;
|
|
5
5
|
share: number;
|
|
6
6
|
user: string;
|
|
7
|
-
depositAmount:
|
|
7
|
+
depositAmount: string;
|
|
8
8
|
}
|
|
9
9
|
export declare function getUsersShares(userShareTable: string, registry: string, provider: JsonRpcProvider): Promise<UserShare[]>;
|
|
@@ -46,8 +46,12 @@ var __values = (this && this.__values) || function(o) {
|
|
|
46
46
|
};
|
|
47
47
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
48
|
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
49
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
53
|
exports.getUsersShares = void 0;
|
|
54
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
51
55
|
function getSubVaultsData(registry, provider) {
|
|
52
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
53
57
|
var subVaultsData, coveredCallVaults, coveredCallVaultsId, objsInfo, objsInfo_1, objsInfo_1_1, objInfo, vaultId, vault, subVaultData;
|
|
@@ -121,9 +125,9 @@ function getUsersShares(userShareTable, registry, provider) {
|
|
|
121
125
|
var share = Number(x.details.data.fields.value);
|
|
122
126
|
//user deposit amount = (user share/total share) * total balance
|
|
123
127
|
var depositAmount = isRolling ?
|
|
124
|
-
(share
|
|
125
|
-
(share
|
|
126
|
-
|
|
128
|
+
(new bignumber_js_1.default(share).div(new bignumber_js_1.default((_a = subVaultsData.get(index)) === null || _a === void 0 ? void 0 : _a.isRollingTotalSupply)).multipliedBy((_b = subVaultsData.get(index)) === null || _b === void 0 ? void 0 : _b.isRollingTotalBalance)) :
|
|
129
|
+
(new bignumber_js_1.default(share).div(new bignumber_js_1.default((_c = subVaultsData.get(index)) === null || _c === void 0 ? void 0 : _c.regularTotalSupply)).multipliedBy((_d = subVaultsData.get(index)) === null || _d === void 0 ? void 0 : _d.regularTotalBalance));
|
|
130
|
+
var depositAmountRes = depositAmount.toNumber().toFixed(0);
|
|
127
131
|
var res = {
|
|
128
132
|
coveredCallVaultIndex: index,
|
|
129
133
|
//@ts-ignore
|
|
@@ -132,7 +136,7 @@ function getUsersShares(userShareTable, registry, provider) {
|
|
|
132
136
|
share: share,
|
|
133
137
|
//@ts-ignore
|
|
134
138
|
user: x.details.data.fields.name.fields.user,
|
|
135
|
-
depositAmount:
|
|
139
|
+
depositAmount: depositAmountRes,
|
|
136
140
|
};
|
|
137
141
|
return res;
|
|
138
142
|
});
|
|
@@ -118,6 +118,7 @@ function getVaultDataFromRegistry(registry, provider) {
|
|
|
118
118
|
tokenDecimal: config.token_decimal,
|
|
119
119
|
shareDecimal: config.share_decimal,
|
|
120
120
|
capacity: (Number(config.capacity) / (Math.pow(10, constants_1.TOKEN_DECIMAL))).toString(),
|
|
121
|
+
leverage: config.leverage,
|
|
121
122
|
vaultConfig: vaultConfigRes,
|
|
122
123
|
nextVaultConfig: nextVaultConfigRes,
|
|
123
124
|
payoffConfig: payoffConfigRes,
|
|
@@ -157,13 +158,14 @@ function getVaultDataFromRegistry(registry, provider) {
|
|
|
157
158
|
priceConfig: priceConfigRes,
|
|
158
159
|
index: (auction.index),
|
|
159
160
|
};
|
|
160
|
-
return [4 /*yield*/, getVaultBidPrice(auctionRes)
|
|
161
|
+
return [4 /*yield*/, getVaultBidPrice(auctionRes)
|
|
162
|
+
// console.log("get auction in " + vaultId)
|
|
163
|
+
];
|
|
161
164
|
case 1:
|
|
162
165
|
vaultBidPrice = _c.sent();
|
|
163
|
-
console.log("get auction in " + vaultId);
|
|
164
166
|
return [3 /*break*/, 3];
|
|
165
167
|
case 2:
|
|
166
|
-
console.log("No auction " + vaultId)
|
|
168
|
+
// console.log("No auction " + vaultId)
|
|
167
169
|
auctionRes = {};
|
|
168
170
|
vaultBidPrice = 0;
|
|
169
171
|
_c.label = 3;
|
package/package.json
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
"name": "@typus/typus-sdk",
|
|
3
3
|
"author": "Typus",
|
|
4
4
|
"description": "typus sdk",
|
|
5
|
-
"version": "0.5.
|
|
5
|
+
"version": "0.5.4",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@mysten/bcs": "^0.5.0",
|
|
8
|
-
"@mysten/sui.js": "^0.
|
|
8
|
+
"@mysten/sui.js": "^0.26.1",
|
|
9
9
|
"@types/node": "^17.0.0",
|
|
10
|
+
"bignumber.js": "^9.1.1",
|
|
10
11
|
"bs58": "^4.0.1",
|
|
11
12
|
"builtin-modules": "^1.1.1",
|
|
12
13
|
"chai": "^4.3.7",
|
|
@@ -80,4 +81,4 @@
|
|
|
80
81
|
"url": "https://github.com/Typus-Lab/typus-sdk/issues"
|
|
81
82
|
},
|
|
82
83
|
"homepage": "https://github.com/Typus-Lab/typus-sdk#readme"
|
|
83
|
-
}
|
|
84
|
+
}
|