@typus/typus-sdk 1.0.75 → 1.0.77
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/token.js
CHANGED
|
@@ -11,9 +11,9 @@ function typeArgsToAssets(typeArgs) {
|
|
|
11
11
|
var typeArgs = x.split("::");
|
|
12
12
|
switch ((0, sui_js_1.normalizeSuiAddress)(typeArgs[0])) {
|
|
13
13
|
case "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881":
|
|
14
|
-
return "
|
|
14
|
+
return "WBTC";
|
|
15
15
|
case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
|
|
16
|
-
return "
|
|
16
|
+
return "WETH";
|
|
17
17
|
case "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8":
|
|
18
18
|
return "SOL";
|
|
19
19
|
case "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf":
|
|
@@ -22,10 +22,10 @@ function typeArgsToAssets(typeArgs) {
|
|
|
22
22
|
return "USDT";
|
|
23
23
|
case config_json_1.default.TOKEN_PACKAGE:
|
|
24
24
|
if (typeArgs[2] == "BTC") {
|
|
25
|
-
return "
|
|
25
|
+
return "WBTC";
|
|
26
26
|
}
|
|
27
27
|
else if (typeArgs[2] == "ETH") {
|
|
28
|
-
return "
|
|
28
|
+
return "WETH";
|
|
29
29
|
}
|
|
30
30
|
return typeArgs[2];
|
|
31
31
|
default:
|
|
@@ -182,7 +182,7 @@ exports.getShowMap = getShowMap;
|
|
|
182
182
|
function groupEventToShow(groupEvent, portfolioVault) {
|
|
183
183
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
184
184
|
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
-
var PaidToDepositors, portfolio_payoff, PaidToBidders, exp, result;
|
|
185
|
+
var PaidToDepositors, portfolio_payoff, PaidToBidders, exp, ActivationTsMs, SettlementTsMs, result;
|
|
186
186
|
return __generator(this, function (_r) {
|
|
187
187
|
PaidToDepositors = Number((_a = groupEvent.deliveryEvent) === null || _a === void 0 ? void 0 : _a.premium_value) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal));
|
|
188
188
|
portfolio_payoff = ((_b = groupEvent.settleEvent) === null || _b === void 0 ? void 0 : _b.portfolio_payoff_is_neg)
|
|
@@ -200,19 +200,21 @@ function groupEventToShow(groupEvent, portfolioVault) {
|
|
|
200
200
|
exp = 12;
|
|
201
201
|
break;
|
|
202
202
|
}
|
|
203
|
+
ActivationTsMs = Number((_e = groupEvent.newAuctionEvent) === null || _e === void 0 ? void 0 : _e.timestamp_ms);
|
|
204
|
+
SettlementTsMs = Number((_f = groupEvent.settleEvent) === null || _f === void 0 ? void 0 : _f.timestamp_ms);
|
|
203
205
|
result = {
|
|
204
206
|
// newAuctionEvent
|
|
205
|
-
NewAuctionTx: (
|
|
206
|
-
ActivationDate: new Date(
|
|
207
|
-
StrikePrice: (
|
|
207
|
+
NewAuctionTx: (_g = groupEvent.newAuctionEvent) === null || _g === void 0 ? void 0 : _g.tx_digest,
|
|
208
|
+
ActivationDate: new Date(ActivationTsMs - (ActivationTsMs % 3600000)),
|
|
209
|
+
StrikePrice: (_h = groupEvent.newAuctionEvent) === null || _h === void 0 ? void 0 : _h.vault_config.payoffConfigs.map(function (payoffConfig) { return Number(payoffConfig.strike) / Math.pow(10, 8); }),
|
|
208
210
|
// deliveryEvent
|
|
209
|
-
DeliveryTx: (
|
|
210
|
-
ProjectedAPY: Math.pow((1 + (1.01 * Number((
|
|
211
|
-
Filled: Number((
|
|
211
|
+
DeliveryTx: (_j = groupEvent.deliveryEvent) === null || _j === void 0 ? void 0 : _j.tx_digest,
|
|
212
|
+
ProjectedAPY: Math.pow((1 + (1.01 * Number((_k = groupEvent.deliveryEvent) === null || _k === void 0 ? void 0 : _k.delivery_price)) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal))), exp) - 1,
|
|
213
|
+
Filled: Number((_l = groupEvent.deliveryEvent) === null || _l === void 0 ? void 0 : _l.delivery_size) / Number((_m = groupEvent.deliveryEvent) === null || _m === void 0 ? void 0 : _m.max_size),
|
|
212
214
|
PaidToDepositors: PaidToDepositors,
|
|
213
215
|
// settleEvent
|
|
214
|
-
SettleTx: (
|
|
215
|
-
SettlementTime: new Date(
|
|
216
|
+
SettleTx: (_o = groupEvent.settleEvent) === null || _o === void 0 ? void 0 : _o.tx_digest,
|
|
217
|
+
SettlementTime: new Date(SettlementTsMs - (SettlementTsMs % 3600000)),
|
|
216
218
|
SettlePrice: Number((_p = groupEvent.settleEvent) === null || _p === void 0 ? void 0 : _p.oracle_price) / Math.pow(10, 8),
|
|
217
219
|
Return: Number((_q = groupEvent.settleEvent) === null || _q === void 0 ? void 0 : _q.share_price) / Math.pow(10, 8) - 1,
|
|
218
220
|
PaidToBidders: PaidToBidders,
|
|
@@ -59,6 +59,8 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
59
59
|
})];
|
|
60
60
|
case 2: return [4 /*yield*/, (_a.sent())
|
|
61
61
|
.filter(function (portfolioVault) { return portfolioVault.error == undefined; })
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
.filter(function (portfolioVault) { return !portfolioVault.data.content.type.includes("0x2::balance::Balance"); })
|
|
62
64
|
.reduce(function (promise, portfolioVault) { return __awaiter(_this, void 0, void 0, function () {
|
|
63
65
|
var map, vaultId, auctionDelayTsMs, typeArgs, assets, deliveryInfo, info, config, auction, authority;
|
|
64
66
|
return __generator(this, function (_a) {
|
|
@@ -66,6 +68,7 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
66
68
|
case 0: return [4 /*yield*/, promise];
|
|
67
69
|
case 1:
|
|
68
70
|
map = _a.sent();
|
|
71
|
+
console.log(JSON.stringify(portfolioVault, null, 4));
|
|
69
72
|
vaultId = portfolioVault.data.content.fields.id.id;
|
|
70
73
|
auctionDelayTsMs = "0";
|
|
71
74
|
typeArgs = new RegExp(".*<(.*), (.*), (.*)>").exec(portfolioVault.data.content.type).slice(1, 4);
|
|
@@ -261,7 +264,9 @@ function getPortfolioVaultAuctionDelayTsMs(provider, portfolio_vault) {
|
|
|
261
264
|
parentId: portfolio_vault.vaultId,
|
|
262
265
|
name: {
|
|
263
266
|
type: "vector<u8>",
|
|
264
|
-
value: [
|
|
267
|
+
value: [
|
|
268
|
+
97, 117, 99, 116, 105, 111, 110, 95, 115, 116, 97, 114, 116, 95, 100, 101, 108, 97, 121, 95, 116, 115, 95, 109, 115,
|
|
269
|
+
],
|
|
265
270
|
},
|
|
266
271
|
})
|
|
267
272
|
.then(function (result) {
|