@typus/typus-sdk 1.2.43 → 1.2.44
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/utils/price.js
CHANGED
|
@@ -138,7 +138,7 @@ function getPythLatestPrice() {
|
|
|
138
138
|
exports.getPythLatestPrice = getPythLatestPrice;
|
|
139
139
|
function getLatestPriceUSD() {
|
|
140
140
|
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
-
var prices, _a, _b, pair, currentTimestampInSeconds, minuteAgo, res, price, e_2_1;
|
|
141
|
+
var prices, _a, _b, pair, currentTimestampInSeconds, minuteAgo, res, price, result, e_2_1;
|
|
142
142
|
var e_2, _c;
|
|
143
143
|
return __generator(this, function (_d) {
|
|
144
144
|
switch (_d.label) {
|
|
@@ -148,7 +148,7 @@ function getLatestPriceUSD() {
|
|
|
148
148
|
_d.label = 2;
|
|
149
149
|
case 2:
|
|
150
150
|
_d.trys.push([2, 7, 8, 9]);
|
|
151
|
-
_a = __values(["SUIFUD", "SUIBUCK", "SUIAFSUI"]), _b = _a.next();
|
|
151
|
+
_a = __values(["SUIFUD", "SUIBUCK", "SUIAFSUI", "SCASUI", "USDYUSDC"]), _b = _a.next();
|
|
152
152
|
_d.label = 3;
|
|
153
153
|
case 3:
|
|
154
154
|
if (!!_b.done) return [3 /*break*/, 6];
|
|
@@ -159,7 +159,17 @@ function getLatestPriceUSD() {
|
|
|
159
159
|
case 4:
|
|
160
160
|
res = _d.sent();
|
|
161
161
|
price = res.at(-1).price;
|
|
162
|
-
|
|
162
|
+
result = void 0;
|
|
163
|
+
if (pair.startsWith("SUI")) {
|
|
164
|
+
result = prices.get("SUI") / Number(price);
|
|
165
|
+
}
|
|
166
|
+
else if (pair.endsWith("SUI")) {
|
|
167
|
+
result = prices.get("SUI") * Number(price);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
result = Number(price);
|
|
171
|
+
}
|
|
172
|
+
prices.set(pair.replace("SUI", ""), result);
|
|
163
173
|
_d.label = 5;
|
|
164
174
|
case 5:
|
|
165
175
|
_b = _a.next();
|
|
@@ -249,9 +249,9 @@ function getVaultHistoryFromDB(index, startTs, endTs) {
|
|
|
249
249
|
vaultHistory = {
|
|
250
250
|
vaultIndex: index_1,
|
|
251
251
|
round: round,
|
|
252
|
-
ActivationDate: new Date(Number(data.activation_date)
|
|
252
|
+
ActivationDate: new Date(Number(data.activation_date)),
|
|
253
253
|
MaxSize: data.max_size,
|
|
254
|
-
SettlementTime: new Date(Number(data.settle_date)
|
|
254
|
+
SettlementTime: new Date(Number(data.settle_date)),
|
|
255
255
|
StrikePrice: data.strikes || undefined,
|
|
256
256
|
SettlePrice: data.settle_price,
|
|
257
257
|
Return: data.return,
|