@typus/typus-sdk 1.0.59 → 1.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { PortfolioVault } from "./portfolio-vault";
|
|
2
|
-
export declare function getDb(functionNames: string[], vaultIndex?: string | undefined): Promise<any>;
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function getDelivery(vaultIndex?: string | undefined): Promise<void>;
|
|
5
|
-
export declare function getSettle(vaultIndex?: string | undefined): Promise<void>;
|
|
6
|
-
export declare function getShowMap(portfolioVaults: Map<string, PortfolioVault>, vaultIndex?: string | undefined): Promise<Map<string, Map<string, Show>>>;
|
|
2
|
+
export declare function getDb(apiUrl: string, functionNames: string[], vaultIndex?: string | undefined): Promise<any>;
|
|
3
|
+
export declare function getShowMap(apiUrl: string, portfolioVaults: Map<string, PortfolioVault>, vaultIndex?: string | undefined): Promise<Map<string, Map<string, Show>>>;
|
|
7
4
|
interface Show {
|
|
8
5
|
ProjectedAPY: number;
|
|
9
6
|
ActivationDate: Date;
|
|
@@ -36,35 +36,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getShowMap = exports.
|
|
40
|
-
|
|
41
|
-
if (vaultIndex === void 0) { vaultIndex = undefined; }
|
|
42
|
-
return ({
|
|
43
|
-
collection: "typus_dov_single",
|
|
44
|
-
database: "mainnet_1_0_0",
|
|
45
|
-
dataSource: "typus",
|
|
46
|
-
filter: {
|
|
47
|
-
function: { $in: functionNames },
|
|
48
|
-
index: vaultIndex,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
var apiUrl = "https://data.mongodb-api.com/app/data-dwhde/endpoint/data/v1/action/find";
|
|
53
|
-
var headers = {
|
|
54
|
-
"api-key": "ZnJu3wGqGoYotyvHl5Qis0UvUJRDJkBBwIsRaHdmBuzfy4jyPBH1LzazIfOO0GSm",
|
|
55
|
-
"Content-Type": "application/json",
|
|
56
|
-
};
|
|
57
|
-
function getDb(functionNames, vaultIndex) {
|
|
39
|
+
exports.getShowMap = exports.getDb = void 0;
|
|
40
|
+
function getDb(apiUrl, functionNames, vaultIndex) {
|
|
58
41
|
if (vaultIndex === void 0) { vaultIndex = undefined; }
|
|
59
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
60
43
|
var jsonData, response, data;
|
|
61
44
|
return __generator(this, function (_a) {
|
|
62
45
|
switch (_a.label) {
|
|
63
46
|
case 0:
|
|
64
|
-
jsonData = JSON.stringify(
|
|
47
|
+
jsonData = JSON.stringify({ functionNames: functionNames, vaultIndex: vaultIndex });
|
|
65
48
|
return [4 /*yield*/, fetch(apiUrl, {
|
|
66
49
|
method: "POST",
|
|
67
|
-
headers:
|
|
50
|
+
headers: { "Content-Type": "application/json" },
|
|
68
51
|
body: jsonData,
|
|
69
52
|
})];
|
|
70
53
|
case 1:
|
|
@@ -73,65 +56,21 @@ function getDb(functionNames, vaultIndex) {
|
|
|
73
56
|
return [4 /*yield*/, response.json()];
|
|
74
57
|
case 2:
|
|
75
58
|
data = _a.sent();
|
|
76
|
-
return [2 /*return*/, data
|
|
59
|
+
return [2 /*return*/, data];
|
|
77
60
|
case 3: return [2 /*return*/];
|
|
78
61
|
}
|
|
79
62
|
});
|
|
80
63
|
});
|
|
81
64
|
}
|
|
82
65
|
exports.getDb = getDb;
|
|
83
|
-
function
|
|
84
|
-
if (vaultIndex === void 0) { vaultIndex = undefined; }
|
|
85
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
return __generator(this, function (_a) {
|
|
87
|
-
switch (_a.label) {
|
|
88
|
-
case 0: return [4 /*yield*/, getDb(["NewAuction"], vaultIndex)];
|
|
89
|
-
case 1:
|
|
90
|
-
_a.sent();
|
|
91
|
-
return [2 /*return*/];
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
exports.getNewAuction = getNewAuction;
|
|
97
|
-
function getDelivery(vaultIndex) {
|
|
98
|
-
if (vaultIndex === void 0) { vaultIndex = undefined; }
|
|
99
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
-
return __generator(this, function (_a) {
|
|
101
|
-
switch (_a.label) {
|
|
102
|
-
case 0: return [4 /*yield*/, getDb(["Delivery"], vaultIndex)];
|
|
103
|
-
case 1:
|
|
104
|
-
_a.sent();
|
|
105
|
-
return [2 /*return*/];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
exports.getDelivery = getDelivery;
|
|
111
|
-
function getSettle(vaultIndex) {
|
|
112
|
-
if (vaultIndex === void 0) { vaultIndex = undefined; }
|
|
113
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
var settleEvents;
|
|
115
|
-
return __generator(this, function (_a) {
|
|
116
|
-
switch (_a.label) {
|
|
117
|
-
case 0: return [4 /*yield*/, getDb(["Settle"], vaultIndex)];
|
|
118
|
-
case 1:
|
|
119
|
-
settleEvents = _a.sent();
|
|
120
|
-
console.log(settleEvents);
|
|
121
|
-
return [2 /*return*/];
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
exports.getSettle = getSettle;
|
|
127
|
-
function getShowMap(portfolioVaults, vaultIndex) {
|
|
66
|
+
function getShowMap(apiUrl, portfolioVaults, vaultIndex) {
|
|
128
67
|
if (vaultIndex === void 0) { vaultIndex = undefined; }
|
|
129
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
130
69
|
var events, groupEventMap, showMap;
|
|
131
70
|
var _this = this;
|
|
132
71
|
return __generator(this, function (_a) {
|
|
133
72
|
switch (_a.label) {
|
|
134
|
-
case 0: return [4 /*yield*/, getDb(["NewAuction", "Delivery", "Settle"], vaultIndex)];
|
|
73
|
+
case 0: return [4 /*yield*/, getDb(apiUrl, ["NewAuction", "Delivery", "Settle"], vaultIndex)];
|
|
135
74
|
case 1:
|
|
136
75
|
events = _a.sent();
|
|
137
76
|
return [4 /*yield*/, events.reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -241,7 +180,9 @@ function groupEventToShow(groupEvent, portfolioVault) {
|
|
|
241
180
|
deliveryEvent = groupEvent.deliveryEvent;
|
|
242
181
|
settleEvent = groupEvent.settleEvent;
|
|
243
182
|
PaidToDepositors = Number(deliveryEvent.premium_value) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal));
|
|
244
|
-
portfolio_payoff = settleEvent.portfolio_payoff_is_neg
|
|
183
|
+
portfolio_payoff = settleEvent.portfolio_payoff_is_neg
|
|
184
|
+
? Number(-settleEvent.portfolio_payoff)
|
|
185
|
+
: Number(settleEvent.portfolio_payoff);
|
|
245
186
|
PaidToBidders = portfolio_payoff / Math.pow(10, Number(portfolioVault.config.oTokenDecimal));
|
|
246
187
|
switch (portfolioVault.config.period) {
|
|
247
188
|
case 0:
|
|
@@ -364,7 +364,7 @@ function getAdditionalConfigs(provider, packageId, additional_config_registry, i
|
|
|
364
364
|
.at(0);
|
|
365
365
|
var oracle_id = reader
|
|
366
366
|
.readVec(function (reader) {
|
|
367
|
-
return reader.
|
|
367
|
+
return (0, tools_1.AddressFromBytes)(reader.readBytes(32));
|
|
368
368
|
})
|
|
369
369
|
.at(0);
|
|
370
370
|
result[index] = {
|