@typus/typus-sdk 0.6.2 → 1.0.0

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.
Files changed (193) hide show
  1. package/lib/config.json +20 -0
  2. package/lib/constants.d.ts +12 -16
  3. package/lib/constants.js +17 -17
  4. package/lib/test/authorized/testAuthorizedNewPortfolioVault.js +82 -0
  5. package/lib/test/{testClaim.js → authorized/testAuthorizedUpdateUpcomingVaultConfig.js} +20 -31
  6. package/lib/test/authorized/testAuthorizedUpdateWarmupVaultConfig.js +68 -0
  7. package/lib/test/getBidData.js +1 -1
  8. package/lib/test/getVaultData.js +2 -2
  9. package/lib/test/getWhiteListFromRegistry.js +2 -2
  10. package/lib/test/helper/getAuctionMaxSize.js +76 -0
  11. package/lib/test/helper/getUserStatus.js +75 -0
  12. package/lib/test/testCrypto.js +1 -1
  13. package/lib/test/testMint.js +2 -2
  14. package/lib/test/testSubscribeEvent.js +1 -1
  15. package/lib/test/{testWithdraw.js → user/testClaim.js} +15 -18
  16. package/lib/test/{getMakersShares.js → user/testCompound.js} +21 -7
  17. package/lib/test/{testUnsubscribe.js → user/testDeposit.js} +29 -38
  18. package/lib/test/{getUsersShares.js → user/testHarvest.js} +21 -7
  19. package/lib/test/user/testNewBid.js +77 -0
  20. package/lib/test/user/testUnsubscribe.d.ts +1 -0
  21. package/lib/test/user/testUnsubscribe.js +69 -0
  22. package/lib/test/user/testWithdraw.d.ts +1 -0
  23. package/lib/test/{testDeposit.js → user/testWithdraw.js} +16 -20
  24. package/lib/utils/auction/getBid.js +1 -1
  25. package/lib/utils/fetchData.d.ts +72 -60
  26. package/lib/utils/fetchData.js +27 -199
  27. package/lib/utils/getMintTx.js +1 -1
  28. package/lib/utils/getTypeArgumentFromToken.js +1 -1
  29. package/lib/utils/getVaultData.d.ts +3 -2
  30. package/lib/utils/getVaultData.js +139 -159
  31. package/lib/utils/getWhiteListFromRegistry.js +1 -2
  32. package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.d.ts +4 -0
  33. package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.js +63 -0
  34. package/lib/utils/portfolio/authorized/getAuthorizedDeliveryTx.d.ts +1 -0
  35. package/lib/utils/{authorized → portfolio/authorized}/getAuthorizedDeliveryTx.js +10 -5
  36. package/lib/utils/portfolio/authorized/getAuthorizedNewPortfolioVaultTx.d.ts +38 -0
  37. package/lib/utils/{authorized/getAuthorizedNewCoveredCallVaultTx.js → portfolio/authorized/getAuthorizedNewPortfolioVaultTx.js} +53 -13
  38. package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.d.ts +4 -0
  39. package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.js +63 -0
  40. package/lib/utils/portfolio/authorized/getAuthorizedUpdateCapacityTx.d.ts +1 -0
  41. package/lib/utils/{authorized → portfolio/authorized}/getAuthorizedUpdateCapacityTx.js +9 -5
  42. package/lib/utils/portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.d.ts +4 -0
  43. package/lib/utils/{authorized/getAuthorizedUpdateVaultConfigTx.js → portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.js} +13 -7
  44. package/lib/utils/portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.d.ts +1 -0
  45. package/lib/utils/{authorized/getAuthorizedUpdateNextVaultConfigTx.js → portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.js} +7 -8
  46. package/lib/utils/portfolio/helper/getAuctionMaxSize.d.ts +8 -0
  47. package/lib/utils/{coveredCall/getLastEvolutionTx.js → portfolio/helper/getAuctionMaxSize.js} +14 -11
  48. package/lib/utils/portfolio/helper/getUserStatus.d.ts +29 -0
  49. package/lib/utils/portfolio/helper/getUserStatus.js +104 -0
  50. package/lib/utils/portfolio/manager/getAddAuthorizedUserTx.d.ts +8 -0
  51. package/lib/utils/{getUpdateTimeOracleTx.js → portfolio/manager/getAddAuthorizedUserTx.js} +15 -8
  52. package/lib/utils/portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.d.ts +10 -0
  53. package/lib/utils/{coveredCall/getUpdateNextVaultConfigTx.js → portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.js} +17 -13
  54. package/lib/utils/portfolio/manager/getCloseAuctionTx.d.ts +1 -0
  55. package/lib/utils/{coveredCall → portfolio/manager}/getCloseAuctionTx.js +6 -5
  56. package/lib/utils/portfolio/manager/getCloseVaultTx.d.ts +1 -0
  57. package/lib/utils/{coveredCall → portfolio/manager}/getCloseVaultTx.js +4 -4
  58. package/lib/utils/portfolio/manager/getDeliveryTx.d.ts +1 -0
  59. package/lib/utils/{coveredCall → portfolio/manager}/getDeliveryTx.js +5 -4
  60. package/lib/utils/portfolio/manager/getEvolutionTx.d.ts +15 -0
  61. package/lib/utils/{coveredCall → portfolio/manager}/getEvolutionTx.js +18 -4
  62. package/lib/utils/portfolio/manager/getNewManagerTx.d.ts +8 -0
  63. package/lib/utils/{coveredCall → portfolio/manager}/getNewManagerTx.js +11 -4
  64. package/lib/utils/portfolio/manager/getNewPortfolioVaultTx.d.ts +38 -0
  65. package/lib/utils/{coveredCall/getNewCoveredCallVaultTx.js → portfolio/manager/getNewPortfolioVaultTx.js} +52 -13
  66. package/lib/utils/portfolio/manager/getRemoveAuthorizedUserTx.d.ts +8 -0
  67. package/lib/utils/{coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.js → portfolio/manager/getRemoveAuthorizedUserTx.js} +14 -8
  68. package/lib/utils/{coveredCall → portfolio/manager}/getRemoveManagerTx.d.ts +5 -0
  69. package/lib/utils/{coveredCall → portfolio/manager}/getRemoveManagerTx.js +7 -2
  70. package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.d.ts +10 -0
  71. package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.js +70 -0
  72. package/lib/utils/portfolio/manager/getUpdateCapacityTx.d.ts +1 -0
  73. package/lib/utils/{coveredCall → portfolio/manager}/getUpdateCapacityTx.js +4 -4
  74. package/lib/utils/portfolio/user/getClaimAndHarvestTx.d.ts +9 -0
  75. package/lib/utils/portfolio/user/getClaimAndHarvestTx.js +67 -0
  76. package/lib/utils/portfolio/user/getClaimTx.d.ts +9 -0
  77. package/lib/utils/{coveredCall → portfolio/user}/getClaimTx.js +12 -4
  78. package/lib/utils/portfolio/user/getCompoundTx.d.ts +9 -0
  79. package/lib/utils/{coveredCall/getAddCoveredCallVaultAuthorizedUserTx.js → portfolio/user/getCompoundTx.js} +15 -9
  80. package/lib/utils/portfolio/user/getDepositTx.d.ts +11 -0
  81. package/lib/utils/{coveredCall → portfolio/user}/getDepositTx.js +15 -9
  82. package/lib/utils/portfolio/user/getHarvestTx.d.ts +9 -0
  83. package/lib/utils/{coveredCall/getClaimAllTx.js → portfolio/user/getHarvestTx.js} +15 -7
  84. package/lib/utils/portfolio/user/getNewBidTx.d.ts +13 -0
  85. package/lib/utils/{coveredCall → portfolio/user}/getNewBidTx.js +21 -8
  86. package/lib/utils/portfolio/user/getUnsubscribeTx.d.ts +10 -0
  87. package/lib/utils/{coveredCall → portfolio/user}/getUnsubscribeTx.js +14 -8
  88. package/lib/utils/portfolio/user/getWithdrawTx.d.ts +10 -0
  89. package/lib/utils/{coveredCall → portfolio/user}/getWithdrawTx.js +13 -4
  90. package/package.json +2 -2
  91. package/lib/test/eventListener.d.ts +0 -5
  92. package/lib/test/eventListener.js +0 -395
  93. package/lib/test/testDepositV2.d.ts +0 -0
  94. package/lib/test/testDepositV2.js +0 -64
  95. package/lib/test/testNewAuction.js +0 -94
  96. package/lib/test/testNewVault.js +0 -153
  97. package/lib/test/testOracle.js +0 -94
  98. package/lib/test/testSettle.js +0 -590
  99. package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.d.ts +0 -1
  100. package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.js +0 -56
  101. package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  102. package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.js +0 -56
  103. package/lib/utils/authorized/getAuthorizedDeliveryTx.d.ts +0 -1
  104. package/lib/utils/authorized/getAuthorizedEvolutionTx.d.ts +0 -1
  105. package/lib/utils/authorized/getAuthorizedEvolutionTx.js +0 -56
  106. package/lib/utils/authorized/getAuthorizedLastEvolutionTx.d.ts +0 -1
  107. package/lib/utils/authorized/getAuthorizedLastEvolutionTx.js +0 -56
  108. package/lib/utils/authorized/getAuthorizedNewAuctionTx.d.ts +0 -1
  109. package/lib/utils/authorized/getAuthorizedNewAuctionTx.js +0 -56
  110. package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.d.ts +0 -1
  111. package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.d.ts +0 -1
  112. package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.js +0 -56
  113. package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  114. package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.js +0 -56
  115. package/lib/utils/authorized/getAuthorizedSettleTx.d.ts +0 -1
  116. package/lib/utils/authorized/getAuthorizedSettleTx.js +0 -56
  117. package/lib/utils/authorized/getAuthorizedUpdateCapacityTx.d.ts +0 -1
  118. package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.d.ts +0 -1
  119. package/lib/utils/authorized/getAuthorizedUpdateVaultConfigTx.d.ts +0 -1
  120. package/lib/utils/coveredCall/createPriceOracle.d.ts +0 -1
  121. package/lib/utils/coveredCall/createPriceOracle.js +0 -93
  122. package/lib/utils/coveredCall/createTimeOracle.d.ts +0 -1
  123. package/lib/utils/coveredCall/createTimeOracle.js +0 -92
  124. package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  125. package/lib/utils/coveredCall/getClaimAllTx.d.ts +0 -1
  126. package/lib/utils/coveredCall/getClaimTx.d.ts +0 -1
  127. package/lib/utils/coveredCall/getCloseAuctionTx.d.ts +0 -1
  128. package/lib/utils/coveredCall/getCloseVaultTx.d.ts +0 -1
  129. package/lib/utils/coveredCall/getDeliveryTx.d.ts +0 -1
  130. package/lib/utils/coveredCall/getDepositTx.d.ts +0 -1
  131. package/lib/utils/coveredCall/getEvolutionTx.d.ts +0 -1
  132. package/lib/utils/coveredCall/getLastEvolutionTx.d.ts +0 -1
  133. package/lib/utils/coveredCall/getMakerClaimAllTx.d.ts +0 -1
  134. package/lib/utils/coveredCall/getMakerClaimAllTx.js +0 -59
  135. package/lib/utils/coveredCall/getMakerClaimTx.d.ts +0 -1
  136. package/lib/utils/coveredCall/getMakerClaimTx.js +0 -59
  137. package/lib/utils/coveredCall/getNewAuctionTx.d.ts +0 -1
  138. package/lib/utils/coveredCall/getNewAuctionTx.js +0 -66
  139. package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +0 -1
  140. package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +0 -64
  141. package/lib/utils/coveredCall/getNewBidTx.d.ts +0 -1
  142. package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +0 -1
  143. package/lib/utils/coveredCall/getNewManagerTx.d.ts +0 -1
  144. package/lib/utils/coveredCall/getRefundTx.d.ts +0 -1
  145. package/lib/utils/coveredCall/getRefundTx.js +0 -59
  146. package/lib/utils/coveredCall/getRemoveBidTx.d.ts +0 -1
  147. package/lib/utils/coveredCall/getRemoveBidTx.js +0 -60
  148. package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  149. package/lib/utils/coveredCall/getRollOverTx.d.ts +0 -1
  150. package/lib/utils/coveredCall/getRollOverTx.js +0 -60
  151. package/lib/utils/coveredCall/getSettleTx.d.ts +0 -1
  152. package/lib/utils/coveredCall/getSettleTx.js +0 -62
  153. package/lib/utils/coveredCall/getSettleWithRollOverTx.d.ts +0 -1
  154. package/lib/utils/coveredCall/getSettleWithRollOverTx.js +0 -62
  155. package/lib/utils/coveredCall/getSubscribeTx.d.ts +0 -1
  156. package/lib/utils/coveredCall/getSubscribeTx.js +0 -60
  157. package/lib/utils/coveredCall/getUnsubscribeTx.d.ts +0 -1
  158. package/lib/utils/coveredCall/getUpdateCapacityTx.d.ts +0 -1
  159. package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.d.ts +0 -1
  160. package/lib/utils/coveredCall/getUpdatePayoffConfigTx.d.ts +0 -1
  161. package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +0 -62
  162. package/lib/utils/coveredCall/getUpdateVaultConfigTx.d.ts +0 -1
  163. package/lib/utils/coveredCall/getUpdateVaultConfigTx.js +0 -65
  164. package/lib/utils/coveredCall/getWithdrawTx.d.ts +0 -1
  165. package/lib/utils/getCreateTokenRegistryTx.d.ts +0 -1
  166. package/lib/utils/getCreateTokenRegistryTx.js +0 -59
  167. package/lib/utils/getMakersShares.d.ts +0 -8
  168. package/lib/utils/getMakersShares.js +0 -145
  169. package/lib/utils/getNewOracleTx.d.ts +0 -1
  170. package/lib/utils/getNewOracleTx.js +0 -59
  171. package/lib/utils/getNewTimeOracleTx.d.ts +0 -1
  172. package/lib/utils/getNewTimeOracleTx.js +0 -56
  173. package/lib/utils/getUpdateOracleTx.d.ts +0 -1
  174. package/lib/utils/getUpdateOracleTx.js +0 -64
  175. package/lib/utils/getUpdateTimeOracleTx.d.ts +0 -1
  176. package/lib/utils/getUsersShares.d.ts +0 -9
  177. package/lib/utils/getUsersShares.js +0 -148
  178. package/lib/utils/getVaultIndexInRegistry.d.ts +0 -1
  179. package/lib/utils/getVaultIndexInRegistry.js +0 -61
  180. package/lib/utils/isObjAvailable.d.ts +0 -0
  181. package/lib/utils/isObjAvailable.js +0 -14
  182. package/lib/utils/loadUsersDepositData.d.ts +0 -8
  183. package/lib/utils/loadUsersDepositData.js +0 -157
  184. /package/lib/test/{getMakersShares.d.ts → authorized/testAuthorizedNewPortfolioVault.d.ts} +0 -0
  185. /package/lib/test/{getUsersShares.d.ts → authorized/testAuthorizedUpdateUpcomingVaultConfig.d.ts} +0 -0
  186. /package/lib/test/{testClaim.d.ts → authorized/testAuthorizedUpdateWarmupVaultConfig.d.ts} +0 -0
  187. /package/lib/test/{testDeposit.d.ts → helper/getAuctionMaxSize.d.ts} +0 -0
  188. /package/lib/test/{testNewAuction.d.ts → helper/getUserStatus.d.ts} +0 -0
  189. /package/lib/test/{testNewVault.d.ts → user/testClaim.d.ts} +0 -0
  190. /package/lib/test/{testOracle.d.ts → user/testCompound.d.ts} +0 -0
  191. /package/lib/test/{testSettle.d.ts → user/testDeposit.d.ts} +0 -0
  192. /package/lib/test/{testUnsubscribe.d.ts → user/testHarvest.d.ts} +0 -0
  193. /package/lib/test/{testWithdraw.d.ts → user/testNewBid.d.ts} +0 -0
@@ -1,395 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.sendEventToTelegramChannel = exports.getEndAuctionEventsCranker = exports.getNewAuctionEventsCranker = exports.getBidEventsCranker = void 0;
54
- var constants_1 = require("../constants");
55
- var sui_js_1 = require("@mysten/sui.js");
56
- var getVaultData_1 = require("../utils/getVaultData");
57
- var node_cron_1 = __importDefault(require("node-cron"));
58
- var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
59
- var moment_1 = __importDefault(require("moment"));
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
62
- var apiToken = process.env.API_TOKEN;
63
- var chatId = process.env.CHAT_ID;
64
- /*
65
- 「https://api.telegram.org/botTOKEN/getUpdates」,change TOKEN to token from botFather
66
- */
67
- (function () { return __awaiter(void 0, void 0, void 0, function () {
68
- var bidTypes, newAuctionType, endAuctionType, renewSec;
69
- return __generator(this, function (_a) {
70
- switch (_a.label) {
71
- case 0:
72
- bidTypes = [
73
- constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>",
74
- constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::btc::BTC>",
75
- constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::sui::SUI>",
76
- ];
77
- newAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewAuction";
78
- endAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::Delivery<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>";
79
- renewSec = 30;
80
- // let vault = await getVaultDataFromRegistry(COVERED_CALL_REGISTRY, provider);
81
- bidTypes.map(function (bidType) { return __awaiter(void 0, void 0, void 0, function () {
82
- return __generator(this, function (_a) {
83
- switch (_a.label) {
84
- case 0: return [4 /*yield*/, getBidEventsCranker(bidType, renewSec, provider)]; //new_bid
85
- case 1:
86
- _a.sent(); //new_bid
87
- return [2 /*return*/];
88
- }
89
- });
90
- }); });
91
- return [4 /*yield*/, getNewAuctionEventsCranker(newAuctionType, renewSec, provider)]; //evolution
92
- case 1:
93
- _a.sent(); //evolution
94
- return [4 /*yield*/, getEndAuctionEventsCranker(endAuctionType, renewSec, provider)];
95
- case 2:
96
- _a.sent();
97
- return [2 /*return*/];
98
- }
99
- });
100
- }); })();
101
- function twoObjArrAreSame(x, y) {
102
- return __awaiter(this, void 0, void 0, function () {
103
- return __generator(this, function (_a) {
104
- if (JSON.stringify(x) === JSON.stringify(y)) {
105
- return [2 /*return*/, true];
106
- }
107
- else {
108
- return [2 /*return*/, false];
109
- }
110
- return [2 /*return*/];
111
- });
112
- });
113
- }
114
- function generateBidId(vault) {
115
- return __awaiter(this, void 0, void 0, function () {
116
- var liveVault, res;
117
- return __generator(this, function (_a) {
118
- liveVault = vault === null || vault === void 0 ? void 0 : vault.filter(function (v) {
119
- var start = moment_1.default.unix(Number(v.config.activationTsMs) / 1000);
120
- var settled = v.vault.ableToDeposit === false && v.vault.ableToWithdraw === true;
121
- return start.isBefore((0, moment_1.default)()) && !settled;
122
- });
123
- res = liveVault.map(function (v) {
124
- var time = v.config.expirationTsMs;
125
- var expiration = moment_1.default
126
- .unix(Number(time) / 1000)
127
- .format("DDMMMYY");
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;
131
- var obj = {
132
- bidFormat: bidId,
133
- bidTime: Number(time),
134
- period: period,
135
- vaultIdx: vaultIdx,
136
- };
137
- return obj;
138
- });
139
- return [2 /*return*/, res];
140
- });
141
- });
142
- }
143
- function getBidEventsCranker(type, renewSec, provider) {
144
- return __awaiter(this, void 0, void 0, function () {
145
- var res, isFirstTime;
146
- var _this = this;
147
- return __generator(this, function (_a) {
148
- res = [];
149
- isFirstTime = true;
150
- node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
151
- var events, newRes, newBidHappened, newBid, format_1, vault, bidIds_1, telegramText;
152
- var _this = this;
153
- return __generator(this, function (_a) {
154
- switch (_a.label) {
155
- case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
156
- case 1:
157
- events = _a.sent();
158
- newRes = events.data;
159
- newBidHappened = newRes.length != res.length;
160
- if (!newBidHappened) return [3 /*break*/, 4];
161
- newBid = newRes.filter(function (_a) {
162
- var id1 = _a.timestamp;
163
- return !res.some(function (_a) {
164
- var id2 = _a.timestamp;
165
- return id2 === id1;
166
- });
167
- });
168
- format_1 = "";
169
- return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY, provider)];
170
- case 2:
171
- vault = _a.sent();
172
- return [4 /*yield*/, generateBidId(vault)];
173
- case 3:
174
- bidIds_1 = _a.sent();
175
- newBid.map(function (e) { return __awaiter(_this, void 0, void 0, function () {
176
- var newBidVaultIdx, bidId, size, period;
177
- return __generator(this, function (_a) {
178
- newBidVaultIdx = e.event.moveEvent.fields.index;
179
- bidId = bidIds_1.find(function (bidId) { return bidId.vaultIdx == newBidVaultIdx; });
180
- if (bidId) {
181
- size = (Number(e.event.moveEvent.fields.size) / (Math.pow(10, constants_1.TOKEN_DECIMAL))).toString();
182
- period = (bidId.period == "0") ? "Daily " : (bidId.period == "1") ? "Weekly " : (bidId.period == "2") ? "Monthly " : "- ";
183
- format_1 += period + bidId.bidFormat + " is bid with " + size + " " + bidId.bidFormat.split("-")[0] + "! \n";
184
- }
185
- return [2 /*return*/];
186
- });
187
- }); });
188
- telegramText = format_1;
189
- console.log(telegramText);
190
- if (!isFirstTime) {
191
- sendEventToTelegramChannel(telegramText);
192
- }
193
- else {
194
- isFirstTime = false;
195
- }
196
- res = newRes;
197
- _a.label = 4;
198
- case 4: return [2 /*return*/];
199
- }
200
- });
201
- }); });
202
- return [2 /*return*/];
203
- });
204
- });
205
- }
206
- exports.getBidEventsCranker = getBidEventsCranker;
207
- function getNewAuctionEventsCranker(type, renewSec, provider) {
208
- return __awaiter(this, void 0, void 0, function () {
209
- var res, bidIds, isFirstTime;
210
- var _this = this;
211
- return __generator(this, function (_a) {
212
- res = [];
213
- bidIds = [];
214
- isFirstTime = true;
215
- node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
216
- var events, newRes, format_2, vault, newBidIds, _loop_1, TOKEN_NAME_1, TOKEN_NAME_1_1, asset, telegramText;
217
- var e_1, _a;
218
- return __generator(this, function (_b) {
219
- switch (_b.label) {
220
- case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
221
- case 1:
222
- events = _b.sent();
223
- newRes = events.data;
224
- console.log("new Res in getNewAuctionEventsCranker:");
225
- console.log(newRes);
226
- return [4 /*yield*/, twoObjArrAreSame(newRes, res)];
227
- case 2:
228
- if (!!(_b.sent())) return [3 /*break*/, 5];
229
- format_2 = "Typus Auction is live! ";
230
- format_2 += '<a href="https://devnet.typus.finance/auction">Bid now </a>' + "! \n";
231
- return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY, provider)];
232
- case 3:
233
- vault = _b.sent();
234
- return [4 /*yield*/, generateBidId(vault)];
235
- case 4:
236
- newBidIds = _b.sent();
237
- //compare newBidIds to bidIds
238
- newBidIds = newBidIds.filter(function (e) {
239
- return !bidIds.find(function (tmp) { return tmp.bidFormat == e.bidFormat; });
240
- });
241
- _loop_1 = function (asset) {
242
- var targetBids = newBidIds.filter(function (bidId) {
243
- return bidId.bidFormat.toString().includes(asset);
244
- });
245
- if (targetBids.length) {
246
- format_2 += "* " + asset + " Options \n";
247
- targetBids.map(function (bidId) {
248
- var period = (bidId.period == "0") ? "Daily " : (bidId.period == "1") ? "Weekly " : (bidId.period == "2") ? "Monthly " : "- ";
249
- format_2 += "\t" + period + "Covered Call-" + bidId.bidFormat + " \n";
250
- format_2 += " \n";
251
- });
252
- }
253
- };
254
- try {
255
- 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()) {
256
- asset = TOKEN_NAME_1_1.value;
257
- _loop_1(asset);
258
- }
259
- }
260
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
261
- finally {
262
- try {
263
- if (TOKEN_NAME_1_1 && !TOKEN_NAME_1_1.done && (_a = TOKEN_NAME_1.return)) _a.call(TOKEN_NAME_1);
264
- }
265
- finally { if (e_1) throw e_1.error; }
266
- }
267
- telegramText = format_2;
268
- console.log(telegramText);
269
- if (!isFirstTime) {
270
- sendEventToTelegramChannel(telegramText);
271
- }
272
- else {
273
- isFirstTime = false;
274
- }
275
- res = newRes;
276
- bidIds = newBidIds;
277
- _b.label = 5;
278
- case 5: return [2 /*return*/];
279
- }
280
- });
281
- }); });
282
- return [2 /*return*/];
283
- });
284
- });
285
- }
286
- exports.getNewAuctionEventsCranker = getNewAuctionEventsCranker;
287
- function getEndAuctionEventsCranker(type, renewSec, provider) {
288
- return __awaiter(this, void 0, void 0, function () {
289
- var res, bidIds, isFirstTime;
290
- var _this = this;
291
- return __generator(this, function (_a) {
292
- res = [];
293
- bidIds = [];
294
- isFirstTime = true;
295
- node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
296
- var events, newRes, format_3, vault_1, newBidIds, _loop_2, TOKEN_NAME_2, TOKEN_NAME_2_1, asset, telegramText;
297
- var e_2, _a;
298
- var _this = this;
299
- return __generator(this, function (_b) {
300
- switch (_b.label) {
301
- case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
302
- case 1:
303
- events = _b.sent();
304
- newRes = events.data;
305
- console.log("new Res in getEndAuctionEventsCranker:");
306
- console.log(newRes);
307
- return [4 /*yield*/, twoObjArrAreSame(newRes, res)];
308
- case 2:
309
- if (!!(_b.sent())) return [3 /*break*/, 5];
310
- format_3 = "";
311
- return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY, provider)];
312
- case 3:
313
- vault_1 = _b.sent();
314
- return [4 /*yield*/, generateBidId(vault_1)];
315
- case 4:
316
- newBidIds = _b.sent();
317
- console.log("new bid ids before filter:");
318
- console.log(newBidIds);
319
- //compare newBidIds to bidIds
320
- newBidIds = newBidIds.filter(function (e) {
321
- return !bidIds.find(function (tmp) { return tmp.bidFormat == e.bidFormat; });
322
- });
323
- // console.log("new bid ids after filter:")
324
- console.log(newBidIds);
325
- _loop_2 = function (asset) {
326
- var targetBids = newBidIds.filter(function (bidId) {
327
- return bidId.bidFormat.toString().includes(asset);
328
- });
329
- if (targetBids.length) {
330
- targetBids.map(function (bidId) { return __awaiter(_this, void 0, void 0, function () {
331
- var vaultIdx, targetVault, totalAuctioned, clearingPrice, period;
332
- return __generator(this, function (_a) {
333
- vaultIdx = bidId.vaultIdx;
334
- targetVault = vault_1.find(function (e) { return e.vaultIdx == vaultIdx; });
335
- totalAuctioned = "-";
336
- clearingPrice = "-";
337
- if (JSON.stringify(targetVault === null || targetVault === void 0 ? void 0 : targetVault.deliveryInfo) != '{}') {
338
- 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);
339
- 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);
340
- }
341
- period = (bidId.period == "0") ? "Daily " : (bidId.period == "1") ? "Weekly " : (bidId.period == "2") ? "Monthly " : "- ";
342
- format_3 += "* " + period + "Covered Call-" + bidId.bidFormat + " auction is closed! Total auctioned " + totalAuctioned +
343
- " " + asset + " at a clearing price of " + clearingPrice + " " + asset + " \n";
344
- format_3 += " \n";
345
- return [2 /*return*/];
346
- });
347
- }); });
348
- }
349
- };
350
- try {
351
- 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()) {
352
- asset = TOKEN_NAME_2_1.value;
353
- _loop_2(asset);
354
- }
355
- }
356
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
357
- finally {
358
- try {
359
- if (TOKEN_NAME_2_1 && !TOKEN_NAME_2_1.done && (_a = TOKEN_NAME_2.return)) _a.call(TOKEN_NAME_2);
360
- }
361
- finally { if (e_2) throw e_2.error; }
362
- }
363
- telegramText = format_3;
364
- console.log(telegramText);
365
- if (!isFirstTime) {
366
- sendEventToTelegramChannel(telegramText);
367
- }
368
- else {
369
- isFirstTime = false;
370
- }
371
- res = newRes;
372
- bidIds = newBidIds;
373
- _b.label = 5;
374
- case 5: return [2 /*return*/];
375
- }
376
- });
377
- }); });
378
- return [2 /*return*/];
379
- });
380
- });
381
- }
382
- exports.getEndAuctionEventsCranker = getEndAuctionEventsCranker;
383
- function sendEventToTelegramChannel(text) {
384
- return __awaiter(this, void 0, void 0, function () {
385
- var urlString, request;
386
- return __generator(this, function (_a) {
387
- urlString = "https://api.telegram.org/bot".concat(apiToken, "/sendMessage?chat_id=").concat(chatId, "&text=").concat(text, "&parse_mode=HTML");
388
- request = new XMLHttpRequest();
389
- request.open("GET", urlString);
390
- request.send();
391
- return [2 /*return*/];
392
- });
393
- });
394
- }
395
- exports.sendEventToTelegramChannel = sendEventToTelegramChannel;
File without changes
@@ -1,64 +0,0 @@
1
- "use strict";
2
- // import { getNewSharkFinVaultTx } from "../utils/getNewSharkFinVaultTx"
3
- // import { getDepositTx } from "../utils/coveredCall/getDepositTx"
4
- // import { SHARKFIN_PACKAGE, SHARKFIN_REGISTRY, TEST_MNEMONIC, TOKEN_REGISTRY } from "../constants"
5
- // import { JsonRpcProvider, Ed25519Keypair, RawSigner, Network } from '@mysten/sui.js';
6
- // import { expect } from 'chai';
7
- // import * as assert from "assert";
8
- // const provider = new JsonRpcProvider(TESTNET_RPC_ENDPOINT);//for read only operations
9
- // const keypair = Ed25519Keypair.deriveKeypair(TEST_MNEMONIC);
10
- // const signer = new RawSigner(keypair, provider);
11
- // /*
12
- // after deposit, token object balance will decrease, and new vault "deposit" in fields will increase
13
- // */
14
- // describe('deposit', async () => {
15
- // //init
16
- // let depositAmount = 123;
17
- // let typeArgument = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC" //0x27b3674c685046f66cad1d5496d2967894fa5329:TOKEN_PACKAGE
18
- // let expiration = 1671344789
19
- // let bullish = true
20
- // let lowBarrierPrice = 1
21
- // let highBarrierPrice = 10
22
- // let isRolling = true;
23
- // let token = "0xdb85a3efc1706010fa9530ef3b8a8a5cf4b290b7"
24
- // console.log("test for deposit, try to deposit " + token + " for " + depositAmount + " ...")
25
- // it('Check registry', async () => {
26
- // try {
27
- // await provider.getObject(SHARKFIN_REGISTRY)
28
- // assert.ok("Get registry successfully");
29
- // } catch (e) {
30
- // assert.fail("Wrong registry")
31
- // }
32
- // })
33
- // it('Create new vault in registry', async () => {
34
- // try {
35
- // let newSharkFinVaultTx: any = await getNewSharkFinVaultTx(
36
- // gasBudget: number, SHARKFIN_PACKAGE, SHARKFIN_REGISTRY, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice);
37
- // let moveCallTxn = await signer.executeMoveCall(newSharkFinVaultTx);
38
- // console.log(moveCallTxn)
39
- // assert.ok("Create new vault in registry successfully");
40
- // } catch (e) {
41
- // assert.fail("Can't create new vault in registry")
42
- // }
43
- // })
44
- // it('Check vault number after create new vault', async () => {
45
- // try {
46
- // let registry = await provider.getObject(SHARKFIN_REGISTRY)
47
- // //@ts-ignore
48
- // let numOfVaultBeforeCreateVault = registry.details.data.fields.num_of_vault
49
- // // console.log("numOfVaultBeforeCreateVault: " + numOfVaultBeforeCreateVault)
50
- // let newSharkFinVaultTx: any = await getNewSharkFinVaultTx(
51
- // gasBudget: number, SHARKFIN_PACKAGE, SHARKFIN_REGISTRY, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice);
52
- // await signer.executeMoveCall(newSharkFinVaultTx);
53
- // registry = await provider.getObject(SHARKFIN_REGISTRY)
54
- // //@ts-ignore
55
- // let numOfVaultAfterCreateVault = registry.details.data.fields.num_of_vault
56
- // // console.log("numOfVaultAfterCreateVault: " + numOfVaultAfterCreateVault)
57
- // assert.ok(numOfVaultAfterCreateVault == numOfVaultBeforeCreateVault + 1, "wrong vault number");
58
- // } catch (e) {
59
- // assert.fail("Error in check vault number after create new vault")
60
- // }
61
- // })
62
- // it('Deposit to new vault', async () => {
63
- // })
64
- // })
@@ -1,94 +0,0 @@
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 __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
- Object.defineProperty(exports, "__esModule", { value: true });
55
- var getNewAuctionTx_1 = require("../utils/coveredCall/getNewAuctionTx");
56
- var constants_1 = require("../constants");
57
- var getTypeArgumentFromToken_1 = require("../utils/getTypeArgumentFromToken");
58
- var sui_js_1 = require("@mysten/sui.js");
59
- var createPriceOracle_1 = require("../utils/coveredCall/createPriceOracle");
60
- var createTimeOracle_1 = require("../utils/coveredCall/createTimeOracle");
61
- var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
62
- var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
63
- var signer = new sui_js_1.RawSigner(keypair, provider);
64
- (function () { return __awaiter(void 0, void 0, void 0, function () {
65
- var token, typeArgument, vaultIndex, _a, priceOracle, priceOracleManager, _b, timeOracle, timeOracleManager, activationTsMs, expirationTsMs, gasBudget, newAuctionTx, a;
66
- return __generator(this, function (_c) {
67
- switch (_c.label) {
68
- case 0:
69
- token = constants_1.TEST_MINT_TOKEN // minted token
70
- ;
71
- return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token, provider)];
72
- case 1:
73
- typeArgument = _c.sent();
74
- vaultIndex = 0;
75
- return [4 /*yield*/, (0, createPriceOracle_1.createPriceOracle)(typeArgument)];
76
- case 2:
77
- _a = __read.apply(void 0, [_c.sent(), 2]), priceOracle = _a[0], priceOracleManager = _a[1];
78
- return [4 /*yield*/, (0, createTimeOracle_1.createTimeOracle)()];
79
- case 3:
80
- _b = __read.apply(void 0, [_c.sent(), 2]), timeOracle = _b[0], timeOracleManager = _b[1];
81
- activationTsMs = 1671992000000;
82
- expirationTsMs = 1;
83
- gasBudget = 100000;
84
- return [4 /*yield*/, (0, getNewAuctionTx_1.getNewAuctionTx)(gasBudget, constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, vaultIndex.toString(), priceOracle, timeOracle)];
85
- case 4:
86
- newAuctionTx = _c.sent();
87
- return [4 /*yield*/, signer.executeMoveCall(newAuctionTx)];
88
- case 5:
89
- a = _c.sent();
90
- console.log(a);
91
- return [2 /*return*/];
92
- }
93
- });
94
- }); })();