@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.
- package/lib/config.json +20 -0
- package/lib/constants.d.ts +12 -16
- package/lib/constants.js +17 -17
- package/lib/test/authorized/testAuthorizedNewPortfolioVault.js +82 -0
- package/lib/test/{testClaim.js → authorized/testAuthorizedUpdateUpcomingVaultConfig.js} +20 -31
- package/lib/test/authorized/testAuthorizedUpdateWarmupVaultConfig.js +68 -0
- package/lib/test/getBidData.js +1 -1
- package/lib/test/getVaultData.js +2 -2
- package/lib/test/getWhiteListFromRegistry.js +2 -2
- package/lib/test/helper/getAuctionMaxSize.js +76 -0
- package/lib/test/helper/getUserStatus.js +75 -0
- package/lib/test/testCrypto.js +1 -1
- package/lib/test/testMint.js +2 -2
- package/lib/test/testSubscribeEvent.js +1 -1
- package/lib/test/{testWithdraw.js → user/testClaim.js} +15 -18
- package/lib/test/{getMakersShares.js → user/testCompound.js} +21 -7
- package/lib/test/{testUnsubscribe.js → user/testDeposit.js} +29 -38
- package/lib/test/{getUsersShares.js → user/testHarvest.js} +21 -7
- package/lib/test/user/testNewBid.js +77 -0
- package/lib/test/user/testUnsubscribe.d.ts +1 -0
- package/lib/test/user/testUnsubscribe.js +69 -0
- package/lib/test/user/testWithdraw.d.ts +1 -0
- package/lib/test/{testDeposit.js → user/testWithdraw.js} +16 -20
- package/lib/utils/auction/getBid.js +1 -1
- package/lib/utils/fetchData.d.ts +72 -60
- package/lib/utils/fetchData.js +27 -199
- package/lib/utils/getMintTx.js +1 -1
- package/lib/utils/getTypeArgumentFromToken.js +1 -1
- package/lib/utils/getVaultData.d.ts +3 -2
- package/lib/utils/getVaultData.js +139 -159
- package/lib/utils/getWhiteListFromRegistry.js +1 -2
- package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.d.ts +4 -0
- package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.js +63 -0
- package/lib/utils/portfolio/authorized/getAuthorizedDeliveryTx.d.ts +1 -0
- package/lib/utils/{authorized → portfolio/authorized}/getAuthorizedDeliveryTx.js +10 -5
- package/lib/utils/portfolio/authorized/getAuthorizedNewPortfolioVaultTx.d.ts +38 -0
- package/lib/utils/{authorized/getAuthorizedNewCoveredCallVaultTx.js → portfolio/authorized/getAuthorizedNewPortfolioVaultTx.js} +53 -13
- package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.d.ts +4 -0
- package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.js +63 -0
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateCapacityTx.d.ts +1 -0
- package/lib/utils/{authorized → portfolio/authorized}/getAuthorizedUpdateCapacityTx.js +9 -5
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.d.ts +4 -0
- package/lib/utils/{authorized/getAuthorizedUpdateVaultConfigTx.js → portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.js} +13 -7
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.d.ts +1 -0
- package/lib/utils/{authorized/getAuthorizedUpdateNextVaultConfigTx.js → portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.js} +7 -8
- package/lib/utils/portfolio/helper/getAuctionMaxSize.d.ts +8 -0
- package/lib/utils/{coveredCall/getLastEvolutionTx.js → portfolio/helper/getAuctionMaxSize.js} +14 -11
- package/lib/utils/portfolio/helper/getUserStatus.d.ts +29 -0
- package/lib/utils/portfolio/helper/getUserStatus.js +104 -0
- package/lib/utils/portfolio/manager/getAddAuthorizedUserTx.d.ts +8 -0
- package/lib/utils/{getUpdateTimeOracleTx.js → portfolio/manager/getAddAuthorizedUserTx.js} +15 -8
- package/lib/utils/portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.d.ts +10 -0
- package/lib/utils/{coveredCall/getUpdateNextVaultConfigTx.js → portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.js} +17 -13
- package/lib/utils/portfolio/manager/getCloseAuctionTx.d.ts +1 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getCloseAuctionTx.js +6 -5
- package/lib/utils/portfolio/manager/getCloseVaultTx.d.ts +1 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getCloseVaultTx.js +4 -4
- package/lib/utils/portfolio/manager/getDeliveryTx.d.ts +1 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getDeliveryTx.js +5 -4
- package/lib/utils/portfolio/manager/getEvolutionTx.d.ts +15 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getEvolutionTx.js +18 -4
- package/lib/utils/portfolio/manager/getNewManagerTx.d.ts +8 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getNewManagerTx.js +11 -4
- package/lib/utils/portfolio/manager/getNewPortfolioVaultTx.d.ts +38 -0
- package/lib/utils/{coveredCall/getNewCoveredCallVaultTx.js → portfolio/manager/getNewPortfolioVaultTx.js} +52 -13
- package/lib/utils/portfolio/manager/getRemoveAuthorizedUserTx.d.ts +8 -0
- package/lib/utils/{coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.js → portfolio/manager/getRemoveAuthorizedUserTx.js} +14 -8
- package/lib/utils/{coveredCall → portfolio/manager}/getRemoveManagerTx.d.ts +5 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getRemoveManagerTx.js +7 -2
- package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.d.ts +10 -0
- package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.js +70 -0
- package/lib/utils/portfolio/manager/getUpdateCapacityTx.d.ts +1 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getUpdateCapacityTx.js +4 -4
- package/lib/utils/portfolio/user/getClaimAndHarvestTx.d.ts +9 -0
- package/lib/utils/portfolio/user/getClaimAndHarvestTx.js +67 -0
- package/lib/utils/portfolio/user/getClaimTx.d.ts +9 -0
- package/lib/utils/{coveredCall → portfolio/user}/getClaimTx.js +12 -4
- package/lib/utils/portfolio/user/getCompoundTx.d.ts +9 -0
- package/lib/utils/{coveredCall/getAddCoveredCallVaultAuthorizedUserTx.js → portfolio/user/getCompoundTx.js} +15 -9
- package/lib/utils/portfolio/user/getDepositTx.d.ts +11 -0
- package/lib/utils/{coveredCall → portfolio/user}/getDepositTx.js +15 -9
- package/lib/utils/portfolio/user/getHarvestTx.d.ts +9 -0
- package/lib/utils/{coveredCall/getClaimAllTx.js → portfolio/user/getHarvestTx.js} +15 -7
- package/lib/utils/portfolio/user/getNewBidTx.d.ts +13 -0
- package/lib/utils/{coveredCall → portfolio/user}/getNewBidTx.js +21 -8
- package/lib/utils/portfolio/user/getUnsubscribeTx.d.ts +10 -0
- package/lib/utils/{coveredCall → portfolio/user}/getUnsubscribeTx.js +14 -8
- package/lib/utils/portfolio/user/getWithdrawTx.d.ts +10 -0
- package/lib/utils/{coveredCall → portfolio/user}/getWithdrawTx.js +13 -4
- package/package.json +2 -2
- package/lib/test/eventListener.d.ts +0 -5
- package/lib/test/eventListener.js +0 -395
- package/lib/test/testDepositV2.d.ts +0 -0
- package/lib/test/testDepositV2.js +0 -64
- package/lib/test/testNewAuction.js +0 -94
- package/lib/test/testNewVault.js +0 -153
- package/lib/test/testOracle.js +0 -94
- package/lib/test/testSettle.js +0 -590
- package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedDeliveryTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedEvolutionTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedEvolutionTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedLastEvolutionTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedLastEvolutionTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedNewAuctionTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedNewAuctionTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedSettleTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedSettleTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedUpdateCapacityTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedUpdateVaultConfigTx.d.ts +0 -1
- package/lib/utils/coveredCall/createPriceOracle.d.ts +0 -1
- package/lib/utils/coveredCall/createPriceOracle.js +0 -93
- package/lib/utils/coveredCall/createTimeOracle.d.ts +0 -1
- package/lib/utils/coveredCall/createTimeOracle.js +0 -92
- package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/coveredCall/getClaimAllTx.d.ts +0 -1
- package/lib/utils/coveredCall/getClaimTx.d.ts +0 -1
- package/lib/utils/coveredCall/getCloseAuctionTx.d.ts +0 -1
- package/lib/utils/coveredCall/getCloseVaultTx.d.ts +0 -1
- package/lib/utils/coveredCall/getDeliveryTx.d.ts +0 -1
- package/lib/utils/coveredCall/getDepositTx.d.ts +0 -1
- package/lib/utils/coveredCall/getEvolutionTx.d.ts +0 -1
- package/lib/utils/coveredCall/getLastEvolutionTx.d.ts +0 -1
- package/lib/utils/coveredCall/getMakerClaimAllTx.d.ts +0 -1
- package/lib/utils/coveredCall/getMakerClaimAllTx.js +0 -59
- package/lib/utils/coveredCall/getMakerClaimTx.d.ts +0 -1
- package/lib/utils/coveredCall/getMakerClaimTx.js +0 -59
- package/lib/utils/coveredCall/getNewAuctionTx.d.ts +0 -1
- package/lib/utils/coveredCall/getNewAuctionTx.js +0 -66
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +0 -1
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +0 -64
- package/lib/utils/coveredCall/getNewBidTx.d.ts +0 -1
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +0 -1
- package/lib/utils/coveredCall/getNewManagerTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRefundTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRefundTx.js +0 -59
- package/lib/utils/coveredCall/getRemoveBidTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRemoveBidTx.js +0 -60
- package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRollOverTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRollOverTx.js +0 -60
- package/lib/utils/coveredCall/getSettleTx.d.ts +0 -1
- package/lib/utils/coveredCall/getSettleTx.js +0 -62
- package/lib/utils/coveredCall/getSettleWithRollOverTx.d.ts +0 -1
- package/lib/utils/coveredCall/getSettleWithRollOverTx.js +0 -62
- package/lib/utils/coveredCall/getSubscribeTx.d.ts +0 -1
- package/lib/utils/coveredCall/getSubscribeTx.js +0 -60
- package/lib/utils/coveredCall/getUnsubscribeTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdateCapacityTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +0 -62
- package/lib/utils/coveredCall/getUpdateVaultConfigTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdateVaultConfigTx.js +0 -65
- package/lib/utils/coveredCall/getWithdrawTx.d.ts +0 -1
- package/lib/utils/getCreateTokenRegistryTx.d.ts +0 -1
- package/lib/utils/getCreateTokenRegistryTx.js +0 -59
- package/lib/utils/getMakersShares.d.ts +0 -8
- package/lib/utils/getMakersShares.js +0 -145
- package/lib/utils/getNewOracleTx.d.ts +0 -1
- package/lib/utils/getNewOracleTx.js +0 -59
- package/lib/utils/getNewTimeOracleTx.d.ts +0 -1
- package/lib/utils/getNewTimeOracleTx.js +0 -56
- package/lib/utils/getUpdateOracleTx.d.ts +0 -1
- package/lib/utils/getUpdateOracleTx.js +0 -64
- package/lib/utils/getUpdateTimeOracleTx.d.ts +0 -1
- package/lib/utils/getUsersShares.d.ts +0 -9
- package/lib/utils/getUsersShares.js +0 -148
- package/lib/utils/getVaultIndexInRegistry.d.ts +0 -1
- package/lib/utils/getVaultIndexInRegistry.js +0 -61
- package/lib/utils/isObjAvailable.d.ts +0 -0
- package/lib/utils/isObjAvailable.js +0 -14
- package/lib/utils/loadUsersDepositData.d.ts +0 -8
- package/lib/utils/loadUsersDepositData.js +0 -157
- /package/lib/test/{getMakersShares.d.ts → authorized/testAuthorizedNewPortfolioVault.d.ts} +0 -0
- /package/lib/test/{getUsersShares.d.ts → authorized/testAuthorizedUpdateUpcomingVaultConfig.d.ts} +0 -0
- /package/lib/test/{testClaim.d.ts → authorized/testAuthorizedUpdateWarmupVaultConfig.d.ts} +0 -0
- /package/lib/test/{testDeposit.d.ts → helper/getAuctionMaxSize.d.ts} +0 -0
- /package/lib/test/{testNewAuction.d.ts → helper/getUserStatus.d.ts} +0 -0
- /package/lib/test/{testNewVault.d.ts → user/testClaim.d.ts} +0 -0
- /package/lib/test/{testOracle.d.ts → user/testCompound.d.ts} +0 -0
- /package/lib/test/{testSettle.d.ts → user/testDeposit.d.ts} +0 -0
- /package/lib/test/{testUnsubscribe.d.ts → user/testHarvest.d.ts} +0 -0
- /package/lib/test/{testWithdraw.d.ts → user/testNewBid.d.ts} +0 -0
package/lib/utils/fetchData.js
CHANGED
|
@@ -1,206 +1,34 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.
|
|
3
|
+
exports.parseSubVault = exports.parsePayoffConfig = exports.parseVaultConfig = void 0;
|
|
51
4
|
var sui_js_1 = require("@mysten/sui.js");
|
|
52
|
-
var
|
|
53
|
-
var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
|
|
5
|
+
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
54
6
|
var decode = function (str) { return Buffer.from(str, 'base64').toString('binary'); };
|
|
55
|
-
|
|
56
|
-
function
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
coveredCallVaults = (_a.sent()).data;
|
|
66
|
-
console.log("under the registry, there are " + coveredCallVaults.length + " covered call vaults");
|
|
67
|
-
return [2 /*return*/, coveredCallVaults];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
exports.getCoveredCallVaultsFromRegistry = getCoveredCallVaultsFromRegistry;
|
|
73
|
-
function getTableFromCoveredCallVault(coveredCallVault) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
-
var tmp, tableUnderCoveredCallVault;
|
|
76
|
-
return __generator(this, function (_a) {
|
|
77
|
-
switch (_a.label) {
|
|
78
|
-
case 0:
|
|
79
|
-
console.log("coveredCallVault: " + coveredCallVault);
|
|
80
|
-
return [4 /*yield*/, provider.getObject(coveredCallVault)];
|
|
81
|
-
case 1:
|
|
82
|
-
tmp = _a.sent();
|
|
83
|
-
if (tmp.status != "Exists") {
|
|
84
|
-
console.log("obj not exists");
|
|
85
|
-
return [2 /*return*/];
|
|
86
|
-
}
|
|
87
|
-
tableUnderCoveredCallVault = tmp.details.data.fields.value.fields.vault.fields.sub_vaults.fields.id.id;
|
|
88
|
-
console.log("table : " + tableUnderCoveredCallVault);
|
|
89
|
-
return [2 /*return*/, tableUnderCoveredCallVault];
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
exports.getTableFromCoveredCallVault = getTableFromCoveredCallVault;
|
|
95
|
-
function getSubVaultsFromTable(tableUnderCoveredCallVault) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
-
var subVaults, result, subVaults_1, subVaults_1_1, subVault, txn, name_1, e_1_1;
|
|
98
|
-
var e_1, _a;
|
|
99
|
-
return __generator(this, function (_b) {
|
|
100
|
-
switch (_b.label) {
|
|
101
|
-
case 0: return [4 /*yield*/, provider.getDynamicFields(tableUnderCoveredCallVault)];
|
|
102
|
-
case 1:
|
|
103
|
-
subVaults = (_b.sent()).data;
|
|
104
|
-
console.log("there are " + subVaults.length + " sub vault under table, representing rolling, regular and maker");
|
|
105
|
-
result = {};
|
|
106
|
-
_b.label = 2;
|
|
107
|
-
case 2:
|
|
108
|
-
_b.trys.push([2, 7, 8, 9]);
|
|
109
|
-
subVaults_1 = __values(subVaults), subVaults_1_1 = subVaults_1.next();
|
|
110
|
-
_b.label = 3;
|
|
111
|
-
case 3:
|
|
112
|
-
if (!!subVaults_1_1.done) return [3 /*break*/, 6];
|
|
113
|
-
subVault = subVaults_1_1.value;
|
|
114
|
-
return [4 /*yield*/, provider.getObject(subVault.objectId)];
|
|
115
|
-
case 4:
|
|
116
|
-
txn = _b.sent();
|
|
117
|
-
if (txn.status != "Exists") {
|
|
118
|
-
console.log("obj not exists");
|
|
119
|
-
return [2 /*return*/, {}];
|
|
120
|
-
}
|
|
121
|
-
name_1 = decode(txn.details.data.fields.name) //rolling / regular / maker
|
|
122
|
-
;
|
|
123
|
-
//@ts-ignore
|
|
124
|
-
result[name_1] = txn.details.data.fields.id.id;
|
|
125
|
-
_b.label = 5;
|
|
126
|
-
case 5:
|
|
127
|
-
subVaults_1_1 = subVaults_1.next();
|
|
128
|
-
return [3 /*break*/, 3];
|
|
129
|
-
case 6: return [3 /*break*/, 9];
|
|
130
|
-
case 7:
|
|
131
|
-
e_1_1 = _b.sent();
|
|
132
|
-
e_1 = { error: e_1_1 };
|
|
133
|
-
return [3 /*break*/, 9];
|
|
134
|
-
case 8:
|
|
135
|
-
try {
|
|
136
|
-
if (subVaults_1_1 && !subVaults_1_1.done && (_a = subVaults_1.return)) _a.call(subVaults_1);
|
|
137
|
-
}
|
|
138
|
-
finally { if (e_1) throw e_1.error; }
|
|
139
|
-
return [7 /*endfinally*/];
|
|
140
|
-
case 9:
|
|
141
|
-
console.log("sub vaults:");
|
|
142
|
-
console.log(result);
|
|
143
|
-
return [2 /*return*/, result];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
exports.getSubVaultsFromTable = getSubVaultsFromTable;
|
|
149
|
-
function getTableUnderSubVault(subVault) {
|
|
150
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
-
var tmp, table;
|
|
152
|
-
return __generator(this, function (_a) {
|
|
153
|
-
switch (_a.label) {
|
|
154
|
-
case 0:
|
|
155
|
-
console.log("sub vault: " + subVault);
|
|
156
|
-
return [4 /*yield*/, provider.getObject(subVault)];
|
|
157
|
-
case 1:
|
|
158
|
-
tmp = _a.sent();
|
|
159
|
-
if (tmp.status != "Exists") {
|
|
160
|
-
console.log("obj not exists");
|
|
161
|
-
return [2 /*return*/, ""];
|
|
162
|
-
}
|
|
163
|
-
table = tmp.details.data.fields.value.fields.user_shares.fields.nodes.fields.id.id;
|
|
164
|
-
console.log("table under sub vault: ", table);
|
|
165
|
-
return [2 /*return*/, table];
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
});
|
|
7
|
+
function parseVaultConfig(vaultConfigF) {
|
|
8
|
+
var payoffConfigs = vaultConfigF.payoff_configs.map(function (x) { return parsePayoffConfig(x); });
|
|
9
|
+
return {
|
|
10
|
+
payoffConfigs: payoffConfigs,
|
|
11
|
+
strikeIncrement: vaultConfigF.strike_increment,
|
|
12
|
+
decaySpeed: vaultConfigF.decay_speed,
|
|
13
|
+
initialPrice: vaultConfigF.initial_price,
|
|
14
|
+
finalPrice: vaultConfigF.final_price,
|
|
15
|
+
auctionDurationInMs: vaultConfigF.auction_duration_in_ms,
|
|
16
|
+
};
|
|
169
17
|
}
|
|
170
|
-
exports.
|
|
171
|
-
function
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
linkedListNodes = (_a.sent()).data;
|
|
179
|
-
console.log("there are " + linkedListNodes.length + " linked list nodes in table");
|
|
180
|
-
return [2 /*return*/, linkedListNodes];
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
});
|
|
18
|
+
exports.parseVaultConfig = parseVaultConfig;
|
|
19
|
+
function parsePayoffConfig(payoffConfigF) {
|
|
20
|
+
return {
|
|
21
|
+
strikePct: payoffConfigF.strike_pct,
|
|
22
|
+
weight: payoffConfigF.weight,
|
|
23
|
+
isBuyer: payoffConfigF.is_buyer,
|
|
24
|
+
strike: payoffConfigF.strike,
|
|
25
|
+
};
|
|
184
26
|
}
|
|
185
|
-
exports.
|
|
186
|
-
function
|
|
187
|
-
return
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
case 0: return [4 /*yield*/, provider.getObject(linkedListNode)];
|
|
192
|
-
case 1:
|
|
193
|
-
tmp = _a.sent();
|
|
194
|
-
if (tmp.status != "Exists") {
|
|
195
|
-
console.log("obj not exists");
|
|
196
|
-
return [2 /*return*/];
|
|
197
|
-
}
|
|
198
|
-
usersData = tmp.details.data.fields;
|
|
199
|
-
console.log("users data from linked list node:");
|
|
200
|
-
console.log(usersData);
|
|
201
|
-
return [2 /*return*/, usersData];
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
});
|
|
27
|
+
exports.parsePayoffConfig = parsePayoffConfig;
|
|
28
|
+
function parseSubVault(subVaultF) {
|
|
29
|
+
return {
|
|
30
|
+
balance: subVaultF.balance,
|
|
31
|
+
shareSupply: subVaultF.share_supply,
|
|
32
|
+
};
|
|
205
33
|
}
|
|
206
|
-
exports.
|
|
34
|
+
exports.parseSubVault = parseSubVault;
|
package/lib/utils/getMintTx.js
CHANGED
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
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
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
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
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JsonRpcProvider } from '@mysten/sui.js';
|
|
2
|
-
import {
|
|
3
|
-
export declare function getVaultDataFromRegistry(registry: string, provider: JsonRpcProvider): Promise<
|
|
2
|
+
import { PortfolioVault, Auction } from "./fetchData";
|
|
3
|
+
export declare function getVaultDataFromRegistry(registry: string, provider: JsonRpcProvider): Promise<PortfolioVault[]>;
|
|
4
4
|
export declare function getVaultBidPrice(auction: Auction): Promise<number>;
|
|
5
|
+
export declare function getNodesKeyFromLinkedList(linkedList: string, provider: JsonRpcProvider): Promise<string[]>;
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
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
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -47,18 +47,16 @@ var __values = (this && this.__values) || function(o) {
|
|
|
47
47
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.getVaultBidPrice = exports.getVaultDataFromRegistry = void 0;
|
|
51
|
-
var
|
|
50
|
+
exports.getNodesKeyFromLinkedList = exports.getVaultBidPrice = exports.getVaultDataFromRegistry = void 0;
|
|
51
|
+
var fetchData_1 = require("./fetchData");
|
|
52
52
|
// const provider = new JsonRpcProvider(TESTNET_RPC_ENDPOINT);//for read only operations
|
|
53
53
|
function getVaultDataFromRegistry(registry, provider) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
-
var coveredCallVaults, coveredCallVaultsId, objsInfo, vaults,
|
|
55
|
+
var coveredCallVaults, coveredCallVaultsId, objsInfo, vaults, objsInfo_1, objsInfo_1_1, objInfo, vaultId, type, typeArgs, assets, deliveryInfo, fields, infoF, info, config, configRes, depositVaultF, depositVault, bidVaultF, bidVault, auctionRes, vaultBidPrice, auction, priceConfig, priceConfigRes, tvl, authority, res, e_1_1;
|
|
56
56
|
var e_1, _a;
|
|
57
57
|
return __generator(this, function (_b) {
|
|
58
58
|
switch (_b.label) {
|
|
59
|
-
case 0:
|
|
60
|
-
console.log("registry: " + registry);
|
|
61
|
-
return [4 /*yield*/, provider.getDynamicFields(registry)];
|
|
59
|
+
case 0: return [4 /*yield*/, provider.getDynamicFields(registry)];
|
|
62
60
|
case 1:
|
|
63
61
|
coveredCallVaults = (_b.sent()).data;
|
|
64
62
|
coveredCallVaultsId = coveredCallVaults.map(function (e) { return e.objectId; });
|
|
@@ -66,174 +64,142 @@ function getVaultDataFromRegistry(registry, provider) {
|
|
|
66
64
|
case 2:
|
|
67
65
|
objsInfo = _b.sent();
|
|
68
66
|
vaults = [];
|
|
69
|
-
_loop_1 = function (objInfo) {
|
|
70
|
-
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;
|
|
71
|
-
return __generator(this, function (_c) {
|
|
72
|
-
switch (_c.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
if (objInfo.status != "Exists") {
|
|
75
|
-
console.log("obj not exist");
|
|
76
|
-
return [2 /*return*/, "continue"];
|
|
77
|
-
}
|
|
78
|
-
vaultId = objInfo.details.data.fields.id.id;
|
|
79
|
-
vaultIdx = objInfo.details.data.fields.name;
|
|
80
|
-
type = objInfo.details.data.fields.value.type;
|
|
81
|
-
asset = constants_1.TOKEN_NAME.find(function (e) { return type.includes(e); });
|
|
82
|
-
if (!asset) {
|
|
83
|
-
console.log("can't find token");
|
|
84
|
-
asset = "";
|
|
85
|
-
}
|
|
86
|
-
config = objInfo.details.data.fields.value.fields.config.fields;
|
|
87
|
-
vault = objInfo.details.data.fields.value.fields.vault.fields;
|
|
88
|
-
prev = objInfo.details.data.fields.value.fields.prev;
|
|
89
|
-
prev = (prev != null) ? prev : null;
|
|
90
|
-
vaultConfig = config.vault_config.fields;
|
|
91
|
-
vaultConfigRes = {
|
|
92
|
-
strikeOtmPct: vaultConfig.strike_otm_pct,
|
|
93
|
-
strikeIncrement: vaultConfig.strike_increment,
|
|
94
|
-
decaySpeed: vaultConfig.decay_speed,
|
|
95
|
-
initialPrice: vaultConfig.initial_price,
|
|
96
|
-
finalPrice: vaultConfig.final_price,
|
|
97
|
-
auctionDurationInMs: vaultConfig.auction_duration_in_ms,
|
|
98
|
-
};
|
|
99
|
-
nextVaultConfig = config.next_vault_config.fields;
|
|
100
|
-
nextVaultConfigRes = {
|
|
101
|
-
strikeOtmPct: nextVaultConfig.strike_otm_pct,
|
|
102
|
-
strikeIncrement: nextVaultConfig.strike_increment,
|
|
103
|
-
decaySpeed: nextVaultConfig.decay_speed,
|
|
104
|
-
initialPrice: nextVaultConfig.initial_price,
|
|
105
|
-
finalPrice: nextVaultConfig.final_price,
|
|
106
|
-
auctionDurationInMs: nextVaultConfig.auction_duration_in_ms,
|
|
107
|
-
};
|
|
108
|
-
payoffConfig = config.payoff_config.fields;
|
|
109
|
-
payoffConfigRes = {
|
|
110
|
-
exposureRatio: (payoffConfig.exposure_ratio),
|
|
111
|
-
premiumRoi: (payoffConfig.premium_roi),
|
|
112
|
-
strike: ((payoffConfig.strike) / (Math.pow(10, constants_1.PRICE_DECIMAL))).toString(),
|
|
113
|
-
};
|
|
114
|
-
configRes = {
|
|
115
|
-
period: config.period,
|
|
116
|
-
activationTsMs: config.activation_ts_ms,
|
|
117
|
-
expirationTsMs: config.expiration_ts_ms,
|
|
118
|
-
tokenDecimal: config.token_decimal,
|
|
119
|
-
shareDecimal: config.share_decimal,
|
|
120
|
-
capacity: (Number(config.capacity) / (Math.pow(10, constants_1.TOKEN_DECIMAL))).toString(),
|
|
121
|
-
leverage: config.leverage,
|
|
122
|
-
vaultConfig: vaultConfigRes,
|
|
123
|
-
nextVaultConfig: nextVaultConfigRes,
|
|
124
|
-
payoffConfig: payoffConfigRes,
|
|
125
|
-
};
|
|
126
|
-
maker = {
|
|
127
|
-
balance: (vault.maker_sub_vault.fields.balance),
|
|
128
|
-
shareSupply: (vault.maker_sub_vault.fields.share_supply),
|
|
129
|
-
};
|
|
130
|
-
regular = {
|
|
131
|
-
balance: (vault.regular_sub_vault.fields.balance),
|
|
132
|
-
shareSupply: (vault.regular_sub_vault.fields.share_supply),
|
|
133
|
-
};
|
|
134
|
-
rolling = {
|
|
135
|
-
balance: (vault.rolling_sub_vault.fields.balance),
|
|
136
|
-
shareSupply: (vault.rolling_sub_vault.fields.share_supply),
|
|
137
|
-
};
|
|
138
|
-
vaultRes = {
|
|
139
|
-
ableToDeposit: vault.able_to_deposit,
|
|
140
|
-
ableToWithdraw: vault.able_to_withdraw,
|
|
141
|
-
makerSubVault: maker,
|
|
142
|
-
regularSubVault: regular,
|
|
143
|
-
rollingSubVault: rolling,
|
|
144
|
-
};
|
|
145
|
-
auctionRes = void 0;
|
|
146
|
-
vaultBidPrice = void 0;
|
|
147
|
-
if (!objInfo.details.data.fields.value.fields.auction) return [3 /*break*/, 2];
|
|
148
|
-
auction = objInfo.details.data.fields.value.fields.auction.fields;
|
|
149
|
-
priceConfig = auction.price_config.fields;
|
|
150
|
-
priceConfigRes = {
|
|
151
|
-
decaySpeed: (priceConfig.decay_speed),
|
|
152
|
-
initialPrice: (priceConfig.initial_price),
|
|
153
|
-
finalPrice: (priceConfig.final_price),
|
|
154
|
-
};
|
|
155
|
-
auctionRes = {
|
|
156
|
-
startTsMs: (auction.start_ts_ms),
|
|
157
|
-
endTsMs: (auction.end_ts_ms),
|
|
158
|
-
priceConfig: priceConfigRes,
|
|
159
|
-
index: (auction.index),
|
|
160
|
-
};
|
|
161
|
-
return [4 /*yield*/, getVaultBidPrice(auctionRes)
|
|
162
|
-
// console.log("get auction in " + vaultId)
|
|
163
|
-
];
|
|
164
|
-
case 1:
|
|
165
|
-
vaultBidPrice = _c.sent();
|
|
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 = void 0;
|
|
176
|
-
//@ts-ignore
|
|
177
|
-
if (objInfo.details.data.fields.value.fields.delivery_info) {
|
|
178
|
-
deliveryInfo = {
|
|
179
|
-
//@ts-ignore
|
|
180
|
-
deliveryPrice: objInfo.details.data.fields.value.fields.delivery_info.fields.delivery_price,
|
|
181
|
-
//@ts-ignore
|
|
182
|
-
deliverySize: objInfo.details.data.fields.value.fields.delivery_info.fields.delivery_size,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
deliveryInfo = {};
|
|
187
|
-
}
|
|
188
|
-
owner = objInfo.details.data.fields.value.fields.owner;
|
|
189
|
-
tvl = Number(vault.regular_sub_vault.fields.balance) + Number(vault.rolling_sub_vault.fields.balance);
|
|
190
|
-
res = {
|
|
191
|
-
vaultId: vaultId,
|
|
192
|
-
vaultIdx: vaultIdx.toString(),
|
|
193
|
-
asset: asset,
|
|
194
|
-
config: configRes,
|
|
195
|
-
vault: vaultRes,
|
|
196
|
-
auction: auctionRes,
|
|
197
|
-
prev: (prev) ? prev.toString() : null,
|
|
198
|
-
next: next,
|
|
199
|
-
totalBidSize: totalBidSize,
|
|
200
|
-
deliveryInfo: deliveryInfo,
|
|
201
|
-
owner: owner,
|
|
202
|
-
tvl: tvl.toString(),
|
|
203
|
-
vaultBidPrice: vaultBidPrice.toString(),
|
|
204
|
-
};
|
|
205
|
-
vaults.push(res);
|
|
206
|
-
return [2 /*return*/];
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
67
|
_b.label = 3;
|
|
211
68
|
case 3:
|
|
212
|
-
_b.trys.push([3,
|
|
69
|
+
_b.trys.push([3, 11, 12, 13]);
|
|
213
70
|
objsInfo_1 = __values(objsInfo), objsInfo_1_1 = objsInfo_1.next();
|
|
214
71
|
_b.label = 4;
|
|
215
72
|
case 4:
|
|
216
|
-
if (!!objsInfo_1_1.done) return [3 /*break*/,
|
|
73
|
+
if (!!objsInfo_1_1.done) return [3 /*break*/, 10];
|
|
217
74
|
objInfo = objsInfo_1_1.value;
|
|
218
|
-
|
|
75
|
+
if (objInfo.status != "Exists") {
|
|
76
|
+
console.log("obj not exist");
|
|
77
|
+
return [3 /*break*/, 9];
|
|
78
|
+
}
|
|
79
|
+
vaultId = objInfo.details.data.fields.id.id;
|
|
80
|
+
type = objInfo.details.data.fields.value.type;
|
|
81
|
+
type = type.split("<")[1];
|
|
82
|
+
type = type.split(">")[0];
|
|
83
|
+
typeArgs = type.split(", ");
|
|
84
|
+
assets = typeArgs.map(function (x) { return x.split("::")[2]; });
|
|
85
|
+
deliveryInfo = void 0;
|
|
86
|
+
//@ts-ignore
|
|
87
|
+
if (objInfo.details.data.fields.value.fields.delivery_info) {
|
|
88
|
+
fields = objInfo.details.data.fields.value.fields.delivery_info.fields;
|
|
89
|
+
deliveryInfo = {
|
|
90
|
+
round: fields.round,
|
|
91
|
+
price: fields.price,
|
|
92
|
+
size: fields.size,
|
|
93
|
+
premium: fields.premium,
|
|
94
|
+
tsMs: fields.ts_ms,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
deliveryInfo = {};
|
|
99
|
+
}
|
|
100
|
+
infoF = objInfo.details.data.fields.value.fields.info.fields;
|
|
101
|
+
info = {
|
|
102
|
+
index: infoF.index,
|
|
103
|
+
creator: infoF.creator,
|
|
104
|
+
createTsMs: infoF.create_ts_ms,
|
|
105
|
+
round: infoF.round,
|
|
106
|
+
deliveryInfo: deliveryInfo
|
|
107
|
+
};
|
|
108
|
+
config = objInfo.details.data.fields.value.fields.config.fields;
|
|
109
|
+
configRes = {
|
|
110
|
+
optionType: config.option_type,
|
|
111
|
+
period: config.period,
|
|
112
|
+
activationTsMs: config.activation_ts_ms,
|
|
113
|
+
expirationTsMs: config.expiration_ts_ms,
|
|
114
|
+
dTokenDecimal: config.d_token_decimal,
|
|
115
|
+
bTokenDecimal: config.b_token_decimal,
|
|
116
|
+
oTokenDecimal: config.o_token_decimal,
|
|
117
|
+
lotSize: config.lot_size,
|
|
118
|
+
capacity: (Number(config.capacity) / (Math.pow(10, config.d_token_decimal))).toString(),
|
|
119
|
+
leverage: config.leverage,
|
|
120
|
+
hasNext: config.has_next,
|
|
121
|
+
activeVaultConfig: (0, fetchData_1.parseVaultConfig)(config.active_vault_config.fields),
|
|
122
|
+
warmupVaultConfig: (0, fetchData_1.parseVaultConfig)(config.warmup_vault_config.fields),
|
|
123
|
+
upcomingVaultConfig: (0, fetchData_1.parseVaultConfig)(config.upcoming_vault_config.fields),
|
|
124
|
+
};
|
|
125
|
+
depositVaultF = objInfo.details.data.fields.value.fields.deposit_vault.fields;
|
|
126
|
+
depositVault = {
|
|
127
|
+
activeSubVault: (0, fetchData_1.parseSubVault)(depositVaultF.active_sub_vault.fields),
|
|
128
|
+
deactivatingSubVault: (0, fetchData_1.parseSubVault)(depositVaultF.deactivating_sub_vault.fields),
|
|
129
|
+
inactiveSubVault: (0, fetchData_1.parseSubVault)(depositVaultF.inactive_sub_vault.fields),
|
|
130
|
+
warmupSubVault: (0, fetchData_1.parseSubVault)(depositVaultF.warmup_sub_vault.fields),
|
|
131
|
+
hasNext: depositVaultF.has_next
|
|
132
|
+
};
|
|
133
|
+
bidVaultF = objInfo.details.data.fields.value.fields.bid_vault.fields;
|
|
134
|
+
bidVault = {
|
|
135
|
+
bidderSubVault: (0, fetchData_1.parseSubVault)(bidVaultF.bidder_sub_vault.fields),
|
|
136
|
+
premiumSubVault: (0, fetchData_1.parseSubVault)(bidVaultF.premium_sub_vault.fields),
|
|
137
|
+
performanceFeeSubVault: (0, fetchData_1.parseSubVault)(bidVaultF.performance_fee_sub_vault.fields),
|
|
138
|
+
};
|
|
139
|
+
auctionRes = void 0;
|
|
140
|
+
vaultBidPrice = void 0;
|
|
141
|
+
if (!objInfo.details.data.fields.value.fields.auction) return [3 /*break*/, 6];
|
|
142
|
+
auction = objInfo.details.data.fields.value.fields.auction.fields;
|
|
143
|
+
priceConfig = auction.price_config.fields;
|
|
144
|
+
priceConfigRes = {
|
|
145
|
+
decaySpeed: (priceConfig.decay_speed),
|
|
146
|
+
initialPrice: (priceConfig.initial_price),
|
|
147
|
+
finalPrice: (priceConfig.final_price),
|
|
148
|
+
};
|
|
149
|
+
auctionRes = {
|
|
150
|
+
startTsMs: (auction.start_ts_ms),
|
|
151
|
+
endTsMs: (auction.end_ts_ms),
|
|
152
|
+
priceConfig: priceConfigRes,
|
|
153
|
+
index: (auction.index),
|
|
154
|
+
totalBidSize: auction.total_bid_size,
|
|
155
|
+
ableToRemoveBid: auction.able_to_remove_bid,
|
|
156
|
+
};
|
|
157
|
+
return [4 /*yield*/, getVaultBidPrice(auctionRes)
|
|
158
|
+
// console.log("get auction in " + vaultId)
|
|
159
|
+
];
|
|
219
160
|
case 5:
|
|
220
|
-
_b.sent();
|
|
221
|
-
|
|
161
|
+
vaultBidPrice = _b.sent();
|
|
162
|
+
return [3 /*break*/, 7];
|
|
222
163
|
case 6:
|
|
164
|
+
// console.log("No auction " + vaultId)
|
|
165
|
+
auctionRes = {};
|
|
166
|
+
vaultBidPrice = 0;
|
|
167
|
+
_b.label = 7;
|
|
168
|
+
case 7:
|
|
169
|
+
tvl = Number(depositVault.activeSubVault.balance) + Number(depositVault.warmupSubVault.balance);
|
|
170
|
+
return [4 /*yield*/, getNodesKeyFromLinkedList(objInfo.details.data.fields.value.fields.authority, provider)];
|
|
171
|
+
case 8:
|
|
172
|
+
authority = _b.sent();
|
|
173
|
+
res = {
|
|
174
|
+
vaultId: vaultId,
|
|
175
|
+
typeArgs: typeArgs,
|
|
176
|
+
assets: assets,
|
|
177
|
+
info: info,
|
|
178
|
+
config: configRes,
|
|
179
|
+
depositVault: depositVault,
|
|
180
|
+
bidVault: bidVault,
|
|
181
|
+
auction: auctionRes,
|
|
182
|
+
authority: authority,
|
|
183
|
+
tvl: tvl.toString(),
|
|
184
|
+
vaultBidPrice: vaultBidPrice.toString(),
|
|
185
|
+
};
|
|
186
|
+
vaults.push(res);
|
|
187
|
+
_b.label = 9;
|
|
188
|
+
case 9:
|
|
223
189
|
objsInfo_1_1 = objsInfo_1.next();
|
|
224
190
|
return [3 /*break*/, 4];
|
|
225
|
-
case
|
|
226
|
-
case
|
|
191
|
+
case 10: return [3 /*break*/, 13];
|
|
192
|
+
case 11:
|
|
227
193
|
e_1_1 = _b.sent();
|
|
228
194
|
e_1 = { error: e_1_1 };
|
|
229
|
-
return [3 /*break*/,
|
|
230
|
-
case
|
|
195
|
+
return [3 /*break*/, 13];
|
|
196
|
+
case 12:
|
|
231
197
|
try {
|
|
232
198
|
if (objsInfo_1_1 && !objsInfo_1_1.done && (_a = objsInfo_1.return)) _a.call(objsInfo_1);
|
|
233
199
|
}
|
|
234
200
|
finally { if (e_1) throw e_1.error; }
|
|
235
201
|
return [7 /*endfinally*/];
|
|
236
|
-
case
|
|
202
|
+
case 13: return [2 /*return*/, vaults];
|
|
237
203
|
}
|
|
238
204
|
});
|
|
239
205
|
});
|
|
@@ -249,7 +215,7 @@ function getVaultBidPrice(auction) {
|
|
|
249
215
|
decaySpeed = Number(auction.priceConfig.decaySpeed);
|
|
250
216
|
start = Number(auction.startTsMs);
|
|
251
217
|
end = Number(auction.endTsMs);
|
|
252
|
-
/// decayed_price =
|
|
218
|
+
/// decayed_price =
|
|
253
219
|
/// initial_price -
|
|
254
220
|
/// (initial_price - final_price) *
|
|
255
221
|
/// (1 - remaining_time / auction_duration) ^ decay_speed
|
|
@@ -261,3 +227,17 @@ function getVaultBidPrice(auction) {
|
|
|
261
227
|
});
|
|
262
228
|
}
|
|
263
229
|
exports.getVaultBidPrice = getVaultBidPrice;
|
|
230
|
+
function getNodesKeyFromLinkedList(linkedList, provider) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
var linkedListNodes;
|
|
233
|
+
return __generator(this, function (_a) {
|
|
234
|
+
switch (_a.label) {
|
|
235
|
+
case 0: return [4 /*yield*/, provider.getDynamicFields(linkedList.fields.whitelist.fields.nodes.fields.id.id)];
|
|
236
|
+
case 1:
|
|
237
|
+
linkedListNodes = (_a.sent()).data.map(function (d) { return d.name; });
|
|
238
|
+
return [2 /*return*/, linkedListNodes];
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
exports.getNodesKeyFromLinkedList = getNodesKeyFromLinkedList;
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
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
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -37,7 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getWhiteListFromRegistry = void 0;
|
|
40
|
-
// const provider = new JsonRpcProvider(TESTNET_RPC_ENDPOINT);//for read only operations
|
|
41
40
|
function getWhiteListFromRegistry(registry, provider) {
|
|
42
41
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
42
|
var whiteLists, tmp, whiteListsTable, whiteListsNodes, whiteListsTableId, tmp2;
|