@typus/typus-sdk 1.0.11 → 1.0.12
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.
|
@@ -38,13 +38,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var sui_js_1 = require("@mysten/sui.js");
|
|
40
40
|
var portfolio_vault_1 = require("../../utils/portfolio/multiple-collateral/portfolio-vault");
|
|
41
|
-
var connection = new sui_js_1.Connection({
|
|
41
|
+
var connection = new sui_js_1.Connection({
|
|
42
|
+
fullnode: 'https://rpc-testnet.suiscan.xyz:443',
|
|
43
|
+
});
|
|
42
44
|
// const connection = new Connection({ fullnode: "https://fullnode.testnet.sui.io:443" });
|
|
43
45
|
var provider = new sui_js_1.JsonRpcProvider(connection); //for read only operations
|
|
44
|
-
var registry =
|
|
45
|
-
var token_deposit_vault_registry =
|
|
46
|
-
var usd_deposit_vault_registry =
|
|
47
|
-
var bid_vault_registry =
|
|
46
|
+
var registry = '0x5083936779bd8bbc26f374baf90981ad5af8f57fe22920105aa47d4e012364de';
|
|
47
|
+
var token_deposit_vault_registry = '0x5a2a467af76e2fc84e98336478224ae81c222e5a8162af4a575302867edbcb56';
|
|
48
|
+
var usd_deposit_vault_registry = '0xe33913a1152396ea7efb726d1333e54efae3e48fe1ae3fd8ea5a9d5cfeae3f2f';
|
|
49
|
+
var bid_vault_registry = '0xd492fe560cba6f9aa061d4f4dbdfb48f13f5d1536a1583b2cf583b5a1e944fc6';
|
|
48
50
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
51
|
var result;
|
|
50
52
|
return __generator(this, function (_a) {
|
|
@@ -52,7 +54,7 @@ var bid_vault_registry = "0xd492fe560cba6f9aa061d4f4dbdfb48f13f5d1536a1583b2cf58
|
|
|
52
54
|
case 0: return [4 /*yield*/, (0, portfolio_vault_1.getPortfolioVaults)(provider, registry, token_deposit_vault_registry, usd_deposit_vault_registry, bid_vault_registry)];
|
|
53
55
|
case 1:
|
|
54
56
|
result = _a.sent();
|
|
55
|
-
console.log(JSON.stringify(result, function (_, v) { return typeof v === 'bigint' ? "".concat(v) : v; }, 2));
|
|
57
|
+
console.log(JSON.stringify(result, function (_, v) { return (typeof v === 'bigint' ? "".concat(v) : v); }, 2));
|
|
56
58
|
return [2 /*return*/];
|
|
57
59
|
}
|
|
58
60
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { JsonRpcProvider } from
|
|
2
|
-
import { DepositVault, BidVault } from
|
|
3
|
-
import { Auction } from
|
|
1
|
+
import { JsonRpcProvider } from '@mysten/sui.js';
|
|
2
|
+
import { DepositVault, BidVault } from '../../typus-framework/vault';
|
|
3
|
+
import { Auction } from '../../typus-framework/dutch';
|
|
4
4
|
export interface PortfolioVault {
|
|
5
5
|
vaultId: string;
|
|
6
6
|
typeArgs: string[];
|
|
@@ -44,11 +44,10 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
44
44
|
var portfolioVaultIds, portfolioVaults, depositVaultIds, depositVaults, bidVaultIds, bidVaults;
|
|
45
45
|
return __generator(this, function (_a) {
|
|
46
46
|
switch (_a.label) {
|
|
47
|
-
case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: registry
|
|
47
|
+
case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: registry })];
|
|
48
48
|
case 1:
|
|
49
|
-
portfolioVaultIds = (_a.sent())
|
|
50
|
-
.
|
|
51
|
-
.filter(function (x) { return index ? x.name.value == index : true; })
|
|
49
|
+
portfolioVaultIds = (_a.sent()).data
|
|
50
|
+
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
52
51
|
.map(function (x) { return x.objectId; });
|
|
53
52
|
return [4 /*yield*/, provider.multiGetObjects({
|
|
54
53
|
ids: portfolioVaultIds,
|
|
@@ -62,22 +61,24 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
62
61
|
// @ts-ignore
|
|
63
62
|
var vaultId = portfolioVault.data.content.fields.id.id;
|
|
64
63
|
// @ts-ignore
|
|
65
|
-
var typeArgs =
|
|
66
|
-
var assets = typeArgs.map(function (x) { return x.split(
|
|
64
|
+
var typeArgs = new RegExp('.*<(.*), (.*), (.*)>').exec(portfolioVault.data.content.type).slice(1, 4);
|
|
65
|
+
var assets = typeArgs.map(function (x) { return x.split('::')[2]; });
|
|
67
66
|
var deliveryInfo =
|
|
68
67
|
// @ts-ignore
|
|
69
|
-
portfolioVault.data.content.fields.info.fields.delivery_info
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
portfolioVault.data.content.fields.info.fields.delivery_info
|
|
69
|
+
? {
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
round: portfolioVault.data.content.fields.info.fields.delivery_info.fields.round,
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
price: portfolioVault.data.content.fields.info.fields.delivery_info.fields.price,
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
size: portfolioVault.data.content.fields.info.fields.delivery_info.fields.size,
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
premium: portfolioVault.data.content.fields.info.fields.delivery_info.fields.premium,
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
tsMs: portfolioVault.data.content.fields.info.fields.delivery_info.fields.ts_ms,
|
|
80
|
+
}
|
|
81
|
+
: undefined;
|
|
81
82
|
var info = {
|
|
82
83
|
// @ts-ignore
|
|
83
84
|
index: portfolioVault.data.content.fields.info.fields.index,
|
|
@@ -91,7 +92,7 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
91
92
|
};
|
|
92
93
|
var config = {
|
|
93
94
|
// @ts-ignore
|
|
94
|
-
optionType: portfolioVault.data.content.fields.config.fields.
|
|
95
|
+
optionType: portfolioVault.data.content.fields.config.fields.option_type,
|
|
95
96
|
// @ts-ignore
|
|
96
97
|
period: portfolioVault.data.content.fields.config.fields.period,
|
|
97
98
|
// @ts-ignore
|
|
@@ -114,13 +115,14 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
114
115
|
hasNext: portfolioVault.data.content.fields.config.fields.has_next,
|
|
115
116
|
activeVaultConfig: {
|
|
116
117
|
// @ts-ignore
|
|
117
|
-
payoffConfigs: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.payoff_configs
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
payoffConfigs: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.payoff_configs.map(function (x) {
|
|
119
|
+
return ({
|
|
120
|
+
strikePct: x.fields.strike_pct,
|
|
121
|
+
weight: x.fields.weight,
|
|
122
|
+
isBuyer: x.fields.is_buyer,
|
|
123
|
+
strike: x.fields.strike,
|
|
124
|
+
});
|
|
125
|
+
}),
|
|
124
126
|
// @ts-ignore
|
|
125
127
|
strikeIncrement: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.strike_increment,
|
|
126
128
|
// @ts-ignore
|
|
@@ -134,13 +136,14 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
134
136
|
},
|
|
135
137
|
warmupVaultConfig: {
|
|
136
138
|
// @ts-ignore
|
|
137
|
-
payoffConfigs: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.payoff_configs
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
payoffConfigs: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.payoff_configs.map(function (x) {
|
|
140
|
+
return ({
|
|
141
|
+
strikePct: x.fields.strike_pct,
|
|
142
|
+
weight: x.fields.weight,
|
|
143
|
+
isBuyer: x.fields.is_buyer,
|
|
144
|
+
strike: x.fields.strike,
|
|
145
|
+
});
|
|
146
|
+
}),
|
|
144
147
|
// @ts-ignore
|
|
145
148
|
strikeIncrement: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.strike_increment,
|
|
146
149
|
// @ts-ignore
|
|
@@ -154,14 +157,14 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
154
157
|
},
|
|
155
158
|
upcomingVaultConfig: {
|
|
156
159
|
// @ts-ignore
|
|
157
|
-
payoffConfigs: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.payoff_configs
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
payoffConfigs: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.payoff_configs.map(function (x) {
|
|
161
|
+
return ({
|
|
162
|
+
strikePct: x.fields.strike_pct,
|
|
163
|
+
weight: x.fields.weight,
|
|
164
|
+
isBuyer: x.fields.is_buyer,
|
|
165
|
+
strike: x.fields.strike,
|
|
166
|
+
});
|
|
167
|
+
}),
|
|
165
168
|
// @ts-ignore
|
|
166
169
|
strikeIncrement: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.strike_increment,
|
|
167
170
|
// @ts-ignore
|
|
@@ -170,8 +173,9 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
170
173
|
initialPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.initial_price,
|
|
171
174
|
// @ts-ignore
|
|
172
175
|
finalPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.final_price,
|
|
176
|
+
auctionDurationInMs:
|
|
173
177
|
// @ts-ignore
|
|
174
|
-
|
|
178
|
+
portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.auction_duration_in_ms,
|
|
175
179
|
},
|
|
176
180
|
};
|
|
177
181
|
// @ts-ignore
|
|
@@ -191,11 +195,10 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
191
195
|
};
|
|
192
196
|
return map;
|
|
193
197
|
}, {});
|
|
194
|
-
return [4 /*yield*/, provider.getDynamicFields({ parentId: deposit_vault_registry
|
|
198
|
+
return [4 /*yield*/, provider.getDynamicFields({ parentId: deposit_vault_registry })];
|
|
195
199
|
case 3:
|
|
196
|
-
depositVaultIds = (_a.sent())
|
|
197
|
-
.
|
|
198
|
-
.filter(function (x) { return index ? x.name.value == index : true; })
|
|
200
|
+
depositVaultIds = (_a.sent()).data
|
|
201
|
+
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
199
202
|
.map(function (x) { return x.objectId; });
|
|
200
203
|
return [4 /*yield*/, provider.multiGetObjects({
|
|
201
204
|
ids: depositVaultIds,
|
|
@@ -213,11 +216,10 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
213
216
|
portfolioVaults[index].tokenTvl = tvl;
|
|
214
217
|
portfolioVaults[index].depositVault = vault;
|
|
215
218
|
});
|
|
216
|
-
return [4 /*yield*/, provider.getDynamicFields({ parentId: bid_vault_registry
|
|
219
|
+
return [4 /*yield*/, provider.getDynamicFields({ parentId: bid_vault_registry })];
|
|
217
220
|
case 5:
|
|
218
|
-
bidVaultIds = (_a.sent())
|
|
219
|
-
.
|
|
220
|
-
.filter(function (x) { return index ? x.name.value == index : true; })
|
|
221
|
+
bidVaultIds = (_a.sent()).data
|
|
222
|
+
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
221
223
|
.map(function (x) { return x.objectId; });
|
|
222
224
|
return [4 /*yield*/, provider.multiGetObjects({
|
|
223
225
|
ids: bidVaultIds,
|