@typus/typus-sdk 0.4.5 → 0.4.7

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 (151) hide show
  1. package/package.json +3 -3
  2. package/lib/constants.d.ts +0 -29
  3. package/lib/constants.js +0 -37
  4. package/lib/scripts/getSubVault.d.ts +0 -0
  5. package/lib/scripts/getSubVault.js +0 -6
  6. package/lib/scripts/sui.d.ts +0 -1
  7. package/lib/scripts/sui.js +0 -187
  8. package/lib/test/eventListener.d.ts +0 -5
  9. package/lib/test/eventListener.js +0 -277
  10. package/lib/test/getBidData.d.ts +0 -1
  11. package/lib/test/getBidData.js +0 -53
  12. package/lib/test/getMakersShares.d.ts +0 -1
  13. package/lib/test/getMakersShares.js +0 -52
  14. package/lib/test/getUsersShares.d.ts +0 -1
  15. package/lib/test/getUsersShares.js +0 -52
  16. package/lib/test/getVaultData.d.ts +0 -1
  17. package/lib/test/getVaultData.js +0 -53
  18. package/lib/test/testClaim.d.ts +0 -1
  19. package/lib/test/testClaim.js +0 -81
  20. package/lib/test/testCrypto.d.ts +0 -1
  21. package/lib/test/testCrypto.js +0 -54
  22. package/lib/test/testDeposit.d.ts +0 -1
  23. package/lib/test/testDeposit.js +0 -73
  24. package/lib/test/testDepositV2.d.ts +0 -0
  25. package/lib/test/testDepositV2.js +0 -62
  26. package/lib/test/testMint.d.ts +0 -1
  27. package/lib/test/testMint.js +0 -136
  28. package/lib/test/testNewAuction.d.ts +0 -1
  29. package/lib/test/testNewAuction.js +0 -93
  30. package/lib/test/testNewVault.d.ts +0 -1
  31. package/lib/test/testNewVault.js +0 -152
  32. package/lib/test/testOracle.d.ts +0 -1
  33. package/lib/test/testOracle.js +0 -93
  34. package/lib/test/testSettle.d.ts +0 -1
  35. package/lib/test/testSettle.js +0 -589
  36. package/lib/test/testSubscribeEvent.d.ts +0 -1
  37. package/lib/test/testSubscribeEvent.js +0 -97
  38. package/lib/test/testUnsubscribe.d.ts +0 -1
  39. package/lib/test/testUnsubscribe.js +0 -87
  40. package/lib/test/testWithdraw.d.ts +0 -1
  41. package/lib/test/testWithdraw.js +0 -70
  42. package/lib/utils/auction/getBid.d.ts +0 -2
  43. package/lib/utils/auction/getBid.js +0 -79
  44. package/lib/utils/auction/sealedAuction.d.ts +0 -33
  45. package/lib/utils/auction/sealedAuction.js +0 -64
  46. package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.d.ts +0 -1
  47. package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.js +0 -60
  48. package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  49. package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.js +0 -60
  50. package/lib/utils/authorized/getAuthorizedDeliveryTx.d.ts +0 -1
  51. package/lib/utils/authorized/getAuthorizedDeliveryTx.js +0 -60
  52. package/lib/utils/authorized/getAuthorizedEvolutionTx.d.ts +0 -1
  53. package/lib/utils/authorized/getAuthorizedEvolutionTx.js +0 -63
  54. package/lib/utils/authorized/getAuthorizedLastEvolutionTx.d.ts +0 -1
  55. package/lib/utils/authorized/getAuthorizedLastEvolutionTx.js +0 -62
  56. package/lib/utils/authorized/getAuthorizedNewAuctionTx.d.ts +0 -1
  57. package/lib/utils/authorized/getAuthorizedNewAuctionTx.js +0 -61
  58. package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.d.ts +0 -1
  59. package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.js +0 -77
  60. package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.d.ts +0 -1
  61. package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.js +0 -60
  62. package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  63. package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.js +0 -60
  64. package/lib/utils/authorized/getAuthorizedSettleTx.d.ts +0 -1
  65. package/lib/utils/authorized/getAuthorizedSettleTx.js +0 -61
  66. package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.d.ts +0 -1
  67. package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.js +0 -65
  68. package/lib/utils/coveredCall/createPriceOracle.d.ts +0 -1
  69. package/lib/utils/coveredCall/createPriceOracle.js +0 -92
  70. package/lib/utils/coveredCall/createTimeOracle.d.ts +0 -1
  71. package/lib/utils/coveredCall/createTimeOracle.js +0 -91
  72. package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  73. package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.js +0 -61
  74. package/lib/utils/coveredCall/getClaimAllTx.d.ts +0 -1
  75. package/lib/utils/coveredCall/getClaimAllTx.js +0 -59
  76. package/lib/utils/coveredCall/getClaimTx.d.ts +0 -1
  77. package/lib/utils/coveredCall/getClaimTx.js +0 -59
  78. package/lib/utils/coveredCall/getDeliveryTx.d.ts +0 -1
  79. package/lib/utils/coveredCall/getDeliveryTx.js +0 -61
  80. package/lib/utils/coveredCall/getDepositTx.d.ts +0 -1
  81. package/lib/utils/coveredCall/getDepositTx.js +0 -65
  82. package/lib/utils/coveredCall/getEvolutionTx.d.ts +0 -1
  83. package/lib/utils/coveredCall/getEvolutionTx.js +0 -64
  84. package/lib/utils/coveredCall/getLastEvolutionTx.d.ts +0 -1
  85. package/lib/utils/coveredCall/getLastEvolutionTx.js +0 -63
  86. package/lib/utils/coveredCall/getMakerClaimAllTx.d.ts +0 -1
  87. package/lib/utils/coveredCall/getMakerClaimAllTx.js +0 -59
  88. package/lib/utils/coveredCall/getMakerClaimTx.d.ts +0 -1
  89. package/lib/utils/coveredCall/getMakerClaimTx.js +0 -59
  90. package/lib/utils/coveredCall/getNewAuctionTx.d.ts +0 -1
  91. package/lib/utils/coveredCall/getNewAuctionTx.js +0 -66
  92. package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +0 -1
  93. package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +0 -64
  94. package/lib/utils/coveredCall/getNewBidTx.d.ts +0 -1
  95. package/lib/utils/coveredCall/getNewBidTx.js +0 -62
  96. package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +0 -1
  97. package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +0 -77
  98. package/lib/utils/coveredCall/getNewManagerTx.d.ts +0 -1
  99. package/lib/utils/coveredCall/getNewManagerTx.js +0 -59
  100. package/lib/utils/coveredCall/getRefundTx.d.ts +0 -1
  101. package/lib/utils/coveredCall/getRefundTx.js +0 -59
  102. package/lib/utils/coveredCall/getRemoveBidTx.d.ts +0 -1
  103. package/lib/utils/coveredCall/getRemoveBidTx.js +0 -60
  104. package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  105. package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.js +0 -61
  106. package/lib/utils/coveredCall/getRemoveManagerTx.d.ts +0 -1
  107. package/lib/utils/coveredCall/getRemoveManagerTx.js +0 -58
  108. package/lib/utils/coveredCall/getRollOverTx.d.ts +0 -1
  109. package/lib/utils/coveredCall/getRollOverTx.js +0 -60
  110. package/lib/utils/coveredCall/getSettleTx.d.ts +0 -1
  111. package/lib/utils/coveredCall/getSettleTx.js +0 -62
  112. package/lib/utils/coveredCall/getSettleWithRollOverTx.d.ts +0 -1
  113. package/lib/utils/coveredCall/getSettleWithRollOverTx.js +0 -62
  114. package/lib/utils/coveredCall/getSubscribeTx.d.ts +0 -1
  115. package/lib/utils/coveredCall/getSubscribeTx.js +0 -60
  116. package/lib/utils/coveredCall/getUnsubscribeTx.d.ts +0 -1
  117. package/lib/utils/coveredCall/getUnsubscribeTx.js +0 -63
  118. package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.d.ts +0 -1
  119. package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.js +0 -66
  120. package/lib/utils/coveredCall/getUpdatePayoffConfigTx.d.ts +0 -1
  121. package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +0 -62
  122. package/lib/utils/coveredCall/getWithdrawTx.d.ts +0 -1
  123. package/lib/utils/coveredCall/getWithdrawTx.js +0 -60
  124. package/lib/utils/fetchData.d.ts +0 -83
  125. package/lib/utils/fetchData.js +0 -205
  126. package/lib/utils/getCreateTokenRegistryTx.d.ts +0 -1
  127. package/lib/utils/getCreateTokenRegistryTx.js +0 -59
  128. package/lib/utils/getMakersShares.d.ts +0 -7
  129. package/lib/utils/getMakersShares.js +0 -147
  130. package/lib/utils/getMintTx.d.ts +0 -1
  131. package/lib/utils/getMintTx.js +0 -62
  132. package/lib/utils/getNewOracleTx.d.ts +0 -1
  133. package/lib/utils/getNewOracleTx.js +0 -59
  134. package/lib/utils/getNewTimeOracleTx.d.ts +0 -1
  135. package/lib/utils/getNewTimeOracleTx.js +0 -56
  136. package/lib/utils/getTypeArgumentFromToken.d.ts +0 -1
  137. package/lib/utils/getTypeArgumentFromToken.js +0 -70
  138. package/lib/utils/getUpdateOracleTx.d.ts +0 -1
  139. package/lib/utils/getUpdateOracleTx.js +0 -64
  140. package/lib/utils/getUpdateTimeOracleTx.d.ts +0 -1
  141. package/lib/utils/getUpdateTimeOracleTx.js +0 -60
  142. package/lib/utils/getUsersShares.d.ts +0 -8
  143. package/lib/utils/getUsersShares.js +0 -146
  144. package/lib/utils/getVaultData.d.ts +0 -3
  145. package/lib/utils/getVaultData.js +0 -251
  146. package/lib/utils/getVaultIndexInRegistry.d.ts +0 -1
  147. package/lib/utils/getVaultIndexInRegistry.js +0 -60
  148. package/lib/utils/isObjAvailable.d.ts +0 -1
  149. package/lib/utils/isObjAvailable.js +0 -66
  150. package/lib/utils/loadUsersDepositData.d.ts +0 -8
  151. package/lib/utils/loadUsersDepositData.js +0 -157
@@ -1,251 +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
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.getVaultBidPrice = exports.getVaultDataFromRegistry = void 0;
51
- var sui_js_1 = require("@mysten/sui.js");
52
- var constants_1 = require("../constants");
53
- var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
54
- function getVaultDataFromRegistry(registry) {
55
- return __awaiter(this, void 0, void 0, function () {
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) {
60
- case 0:
61
- console.log("registry: " + registry);
62
- return [4 /*yield*/, provider.getObjectsOwnedByObject(registry)];
63
- case 1:
64
- coveredCallVaults = _b.sent();
65
- coveredCallVaultsId = coveredCallVaults.map(function (e) { return e.objectId; });
66
- return [4 /*yield*/, provider.getObjectBatch(coveredCallVaultsId)];
67
- case 2:
68
- objsInfo = _b.sent();
69
- vaults = [];
70
- timeOracle = constants_1.TIME_ORACLE;
71
- _loop_1 = function (objInfo) {
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;
73
- return __generator(this, function (_c) {
74
- switch (_c.label) {
75
- case 0:
76
- if (objInfo.status != "Exists") {
77
- console.log("obj not exist");
78
- return [2 /*return*/, "continue"];
79
- }
80
- vaultId = objInfo.details.data.fields.id.id;
81
- vaultIdx = objInfo.details.data.fields.name;
82
- type = objInfo.details.data.fields.value.type;
83
- asset = constants_1.TOKEN_NAME.find(function (e) { return type.includes(e); });
84
- if (!asset) {
85
- console.log("can't find token");
86
- asset = "";
87
- }
88
- config = objInfo.details.data.fields.value.fields.config.fields;
89
- vault = objInfo.details.data.fields.value.fields.vault.fields;
90
- prev = objInfo.details.data.fields.value.fields.prev;
91
- prev = (prev != null) ? prev : null;
92
- vaultConfig = config.vault_config.fields;
93
- vaultConfigRes = {
94
- strikeOtmPct: vaultConfig.strike_otm_pct,
95
- strikeIncrement: vaultConfig.strike_increment,
96
- decaySpeed: vaultConfig.decay_speed,
97
- initialPrice: vaultConfig.initial_price,
98
- finalPrice: vaultConfig.final_price,
99
- auctionDurationInMs: vaultConfig.auction_duration_in_ms,
100
- };
101
- nextVaultConfig = config.next_vault_config.fields;
102
- nextVaultConfigRes = {
103
- strikeOtmPct: nextVaultConfig.strike_otm_pct,
104
- strikeIncrement: nextVaultConfig.strike_increment,
105
- decaySpeed: nextVaultConfig.decay_speed,
106
- initialPrice: nextVaultConfig.initial_price,
107
- finalPrice: nextVaultConfig.final_price,
108
- auctionDurationInMs: nextVaultConfig.auction_duration_in_ms,
109
- };
110
- payoffConfig = config.payoff_config.fields;
111
- payoffConfigRes = {
112
- exposureRatio: (payoffConfig.exposure_ratio),
113
- premiumRoi: (payoffConfig.premium_roi),
114
- strike: ((payoffConfig.strike) / (Math.pow(10, constants_1.PRICE_DECIMAL))).toString(),
115
- };
116
- configRes = {
117
- period: config.period,
118
- activationTsMs: config.activation_ts_ms,
119
- expirationTsMs: config.expiration_ts_ms,
120
- tokenDecimal: config.token_decimal,
121
- shareDecimal: config.share_decimal,
122
- capacity: (Number(config.capacity) / (Math.pow(10, constants_1.TOKEN_DECIMAL))).toString(),
123
- vaultConfig: vaultConfigRes,
124
- nextVaultConfig: nextVaultConfigRes,
125
- payoffConfig: payoffConfigRes,
126
- };
127
- maker = {
128
- balance: (vault.maker_sub_vault.fields.balance),
129
- shareSupply: (vault.maker_sub_vault.fields.share_supply),
130
- };
131
- regular = {
132
- balance: (vault.regular_sub_vault.fields.balance),
133
- shareSupply: (vault.regular_sub_vault.fields.share_supply),
134
- };
135
- rolling = {
136
- balance: (vault.rolling_sub_vault.fields.balance),
137
- shareSupply: (vault.rolling_sub_vault.fields.share_supply),
138
- };
139
- vaultRes = {
140
- ableToDeposit: vault.able_to_deposit,
141
- ableToWithdraw: vault.able_to_withdraw,
142
- makerSubVault: maker,
143
- regularSubVault: regular,
144
- rollingSubVault: rolling,
145
- };
146
- auctionRes = void 0;
147
- vaultBidPrice = void 0;
148
- if (!objInfo.details.data.fields.value.fields.auction) return [3 /*break*/, 2];
149
- auction = objInfo.details.data.fields.value.fields.auction.fields;
150
- priceConfig = auction.price_config.fields;
151
- priceConfigRes = {
152
- decaySpeed: (priceConfig.decay_speed),
153
- initialPrice: (priceConfig.initial_price),
154
- finalPrice: (priceConfig.final_price),
155
- };
156
- auctionRes = {
157
- startTsMs: (auction.start_ts_ms),
158
- endTsMs: (auction.end_ts_ms),
159
- priceConfig: priceConfigRes,
160
- index: (auction.index),
161
- };
162
- return [4 /*yield*/, getVaultBidPrice(auctionRes)];
163
- case 1:
164
- vaultBidPrice = _c.sent();
165
- console.log("get auction in " + vaultId);
166
- return [3 /*break*/, 3];
167
- case 2:
168
- console.log("No auction " + vaultId);
169
- auctionRes = {};
170
- vaultBidPrice = 0;
171
- _c.label = 3;
172
- case 3:
173
- next = objInfo.details.data.fields.value.fields.next;
174
- totalBidSize = objInfo.details.data.fields.value.fields.total_bid_size;
175
- deliveryInfo = objInfo.details.data.fields.value.fields.delivery_info ? objInfo.details.data.fields.value.fields.delivery_info.fields : null;
176
- owner = objInfo.details.data.fields.value.fields.owner;
177
- tvl = Number(vault.regular_sub_vault.fields.balance) + Number(vault.rolling_sub_vault.fields.balance);
178
- res = {
179
- vaultId: vaultId,
180
- vaultIdx: vaultIdx.toString(),
181
- asset: asset,
182
- config: configRes,
183
- vault: vaultRes,
184
- auction: auctionRes,
185
- prev: (prev) ? prev.toString() : null,
186
- next: next,
187
- totalBidSize: totalBidSize,
188
- deliveryInfo: deliveryInfo,
189
- owner: owner,
190
- tvl: tvl.toString(),
191
- vaultBidPrice: vaultBidPrice.toString(),
192
- };
193
- vaults.push(res);
194
- return [2 /*return*/];
195
- }
196
- });
197
- };
198
- _b.label = 3;
199
- case 3:
200
- _b.trys.push([3, 8, 9, 10]);
201
- objsInfo_1 = __values(objsInfo), objsInfo_1_1 = objsInfo_1.next();
202
- _b.label = 4;
203
- case 4:
204
- if (!!objsInfo_1_1.done) return [3 /*break*/, 7];
205
- objInfo = objsInfo_1_1.value;
206
- return [5 /*yield**/, _loop_1(objInfo)];
207
- case 5:
208
- _b.sent();
209
- _b.label = 6;
210
- case 6:
211
- objsInfo_1_1 = objsInfo_1.next();
212
- return [3 /*break*/, 4];
213
- case 7: return [3 /*break*/, 10];
214
- case 8:
215
- e_1_1 = _b.sent();
216
- e_1 = { error: e_1_1 };
217
- return [3 /*break*/, 10];
218
- case 9:
219
- try {
220
- if (objsInfo_1_1 && !objsInfo_1_1.done && (_a = objsInfo_1.return)) _a.call(objsInfo_1);
221
- }
222
- finally { if (e_1) throw e_1.error; }
223
- return [7 /*endfinally*/];
224
- case 10: return [2 /*return*/, vaults];
225
- }
226
- });
227
- });
228
- }
229
- exports.getVaultDataFromRegistry = getVaultDataFromRegistry;
230
- function getVaultBidPrice(auction) {
231
- return __awaiter(this, void 0, void 0, function () {
232
- var current, initialPrice, finalPrice, decaySpeed, start, end;
233
- return __generator(this, function (_a) {
234
- current = Date.now();
235
- initialPrice = Number(auction.priceConfig.initialPrice);
236
- finalPrice = Number(auction.priceConfig.finalPrice);
237
- decaySpeed = Number(auction.priceConfig.decaySpeed);
238
- start = Number(auction.startTsMs);
239
- end = Number(auction.endTsMs);
240
- /// decayed_price =
241
- /// initial_price -
242
- /// (initial_price - final_price) *
243
- /// (1 - remaining_time / auction_duration) ^ decay_speed
244
- // 1 - remaining_time / auction_duration => 1 - (end - current) / (end - start) => (current - start) / (end - start)
245
- return [2 /*return*/, initialPrice -
246
- (initialPrice - finalPrice) *
247
- (((current - start) / (end - start)) ^ decaySpeed)];
248
- });
249
- });
250
- }
251
- exports.getVaultBidPrice = getVaultBidPrice;
@@ -1 +0,0 @@
1
- export declare function getVaultIndexInregistry(registry: string): Promise<number>;
@@ -1,60 +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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getVaultIndexInregistry = void 0;
40
- var sui_js_1 = require("@mysten/sui.js");
41
- var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
42
- function getVaultIndexInregistry(registry) {
43
- return __awaiter(this, void 0, void 0, function () {
44
- var txn, index;
45
- return __generator(this, function (_a) {
46
- switch (_a.label) {
47
- case 0: return [4 /*yield*/, provider.getObject(registry)];
48
- case 1:
49
- txn = _a.sent();
50
- if (txn.status != "Exists") {
51
- console.log("obj not exists");
52
- return [2 /*return*/, -1];
53
- }
54
- index = txn.details.data.fields.name;
55
- return [2 /*return*/, index];
56
- }
57
- });
58
- });
59
- }
60
- exports.getVaultIndexInregistry = getVaultIndexInregistry;
@@ -1 +0,0 @@
1
- export declare function isObjAvailable(obj: string): Promise<Boolean>;
@@ -1,66 +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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.isObjAvailable = void 0;
40
- var sui_js_1 = require("@mysten/sui.js");
41
- var rpc = new sui_js_1.JsonRpcProvider('https://fullnode.devnet.sui.io:443');
42
- var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
43
- function isObjAvailable(obj) {
44
- return __awaiter(this, void 0, void 0, function () {
45
- var tmp, e_1;
46
- return __generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0:
49
- _a.trys.push([0, 2, , 3]);
50
- return [4 /*yield*/, provider.getObject(obj)];
51
- case 1:
52
- tmp = _a.sent();
53
- if (tmp.status == "Exists")
54
- return [2 /*return*/, true];
55
- else
56
- return [2 /*return*/, false];
57
- return [3 /*break*/, 3];
58
- case 2:
59
- e_1 = _a.sent();
60
- return [2 /*return*/, false];
61
- case 3: return [2 /*return*/];
62
- }
63
- });
64
- });
65
- }
66
- exports.isObjAvailable = isObjAvailable;
@@ -1,8 +0,0 @@
1
- export interface UserDepositData {
2
- coveredCallVault: string;
3
- subVault: string;
4
- subVaultType: string;
5
- linkedListNode: string;
6
- balance: number;
7
- }
8
- export declare function loadUsersDepositData(registry: string): Promise<Map<string, UserDepositData[]>>;
@@ -1,157 +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
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.loadUsersDepositData = void 0;
51
- var fetchData_1 = require("./fetchData");
52
- function loadUsersDepositData(registry) {
53
- return __awaiter(this, void 0, void 0, function () {
54
- var usersDepositData, coveredCallVaults, coveredCallVaults_1, coveredCallVaults_1_1, coveredCallVault, tableUnderCoveredCallVault, subVaults, _a, _b, _i, subVaultType, tableUnderSubVault, linkedListNodes, linkedListNodes_1, linkedListNodes_1_1, linkedListNode, userData, userDepositData, userDepositDatas, e_1_1, e_2_1;
55
- var e_2, _c, e_1, _d;
56
- return __generator(this, function (_e) {
57
- switch (_e.label) {
58
- case 0:
59
- usersDepositData = new Map();
60
- return [4 /*yield*/, (0, fetchData_1.getCoveredCallVaultsFromRegistry)(registry)];
61
- case 1:
62
- coveredCallVaults = _e.sent();
63
- _e.label = 2;
64
- case 2:
65
- _e.trys.push([2, 19, 20, 21]);
66
- coveredCallVaults_1 = __values(coveredCallVaults), coveredCallVaults_1_1 = coveredCallVaults_1.next();
67
- _e.label = 3;
68
- case 3:
69
- if (!!coveredCallVaults_1_1.done) return [3 /*break*/, 18];
70
- coveredCallVault = coveredCallVaults_1_1.value;
71
- return [4 /*yield*/, (0, fetchData_1.getTableFromCoveredCallVault)(coveredCallVault.objectId)
72
- //from table find sub vault
73
- ];
74
- case 4:
75
- tableUnderCoveredCallVault = _e.sent();
76
- return [4 /*yield*/, (0, fetchData_1.getSubVaultsFromTable)(tableUnderCoveredCallVault)
77
- //from sub vault find table
78
- ];
79
- case 5:
80
- subVaults = _e.sent();
81
- _a = [];
82
- for (_b in subVaults)
83
- _a.push(_b);
84
- _i = 0;
85
- _e.label = 6;
86
- case 6:
87
- if (!(_i < _a.length)) return [3 /*break*/, 17];
88
- subVaultType = _a[_i];
89
- return [4 /*yield*/, (0, fetchData_1.getTableUnderSubVault)(subVaults[subVaultType])
90
- //from table find linked list node
91
- ];
92
- case 7:
93
- tableUnderSubVault = _e.sent();
94
- return [4 /*yield*/, (0, fetchData_1.getLinkedListNodesFromTable)(tableUnderSubVault)
95
- //from linkedListNode find user data
96
- ];
97
- case 8:
98
- linkedListNodes = _e.sent();
99
- _e.label = 9;
100
- case 9:
101
- _e.trys.push([9, 14, 15, 16]);
102
- linkedListNodes_1 = (e_1 = void 0, __values(linkedListNodes)), linkedListNodes_1_1 = linkedListNodes_1.next();
103
- _e.label = 10;
104
- case 10:
105
- if (!!linkedListNodes_1_1.done) return [3 /*break*/, 13];
106
- linkedListNode = linkedListNodes_1_1.value;
107
- return [4 /*yield*/, (0, fetchData_1.getUserDataFromLinkedListNode)(linkedListNode.objectId)];
108
- case 11:
109
- userData = _e.sent();
110
- userDepositData = {
111
- coveredCallVault: coveredCallVault.objectId,
112
- subVault: subVaults[subVaultType],
113
- subVaultType: subVaultType,
114
- linkedListNode: linkedListNode.objectId,
115
- balance: (userData.value) ? userData.value.fields.value : 0
116
- };
117
- userDepositDatas = (usersDepositData.get(userData.name) == undefined) ? [] : usersDepositData.get(userData.name);
118
- userDepositDatas.push(userDepositData);
119
- usersDepositData.set(userData.name, userDepositDatas);
120
- _e.label = 12;
121
- case 12:
122
- linkedListNodes_1_1 = linkedListNodes_1.next();
123
- return [3 /*break*/, 10];
124
- case 13: return [3 /*break*/, 16];
125
- case 14:
126
- e_1_1 = _e.sent();
127
- e_1 = { error: e_1_1 };
128
- return [3 /*break*/, 16];
129
- case 15:
130
- try {
131
- if (linkedListNodes_1_1 && !linkedListNodes_1_1.done && (_d = linkedListNodes_1.return)) _d.call(linkedListNodes_1);
132
- }
133
- finally { if (e_1) throw e_1.error; }
134
- return [7 /*endfinally*/];
135
- case 16:
136
- _i++;
137
- return [3 /*break*/, 6];
138
- case 17:
139
- coveredCallVaults_1_1 = coveredCallVaults_1.next();
140
- return [3 /*break*/, 3];
141
- case 18: return [3 /*break*/, 21];
142
- case 19:
143
- e_2_1 = _e.sent();
144
- e_2 = { error: e_2_1 };
145
- return [3 /*break*/, 21];
146
- case 20:
147
- try {
148
- if (coveredCallVaults_1_1 && !coveredCallVaults_1_1.done && (_c = coveredCallVaults_1.return)) _c.call(coveredCallVaults_1);
149
- }
150
- finally { if (e_2) throw e_2.error; }
151
- return [7 /*endfinally*/];
152
- case 21: return [2 /*return*/, usersDepositData];
153
- }
154
- });
155
- });
156
- }
157
- exports.loadUsersDepositData = loadUsersDepositData;