@typus/typus-sdk 1.0.34 → 1.0.35
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/leader-board.js +3 -2
- package/lib/utils/tools.d.ts +1 -0
- package/lib/utils/tools.js +13 -5
- package/lib/utils/typus-dov-single/portfolio-vault.d.ts +1 -0
- package/lib/utils/typus-dov-single/portfolio-vault.js +167 -144
- package/lib/utils/typus-dov-single/view-function.d.ts +10 -0
- package/lib/utils/typus-dov-single/view-function.js +65 -1
- package/package.json +82 -82
|
@@ -68,7 +68,7 @@ var depositorRequestData = {
|
|
|
68
68
|
};
|
|
69
69
|
function getDepositorLeaderBoard(start, end, step) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
var jsonData, response, data, samples, leader_board;
|
|
71
|
+
var jsonData, response, data, samples, len_1, leader_board;
|
|
72
72
|
return __generator(this, function (_a) {
|
|
73
73
|
switch (_a.label) {
|
|
74
74
|
case 0:
|
|
@@ -94,11 +94,12 @@ function getDepositorLeaderBoard(start, end, step) {
|
|
|
94
94
|
case 2:
|
|
95
95
|
data = _a.sent();
|
|
96
96
|
samples = data.results[0].matrix.samples;
|
|
97
|
+
len_1 = samples.reduce(function (acc, curr) { return (acc > curr.values.length ? acc : curr.values.length); }, 0);
|
|
97
98
|
leader_board = samples
|
|
98
99
|
.map(function (element) {
|
|
99
100
|
// console.log("metric:", element.metric, "values: ", element.values);
|
|
100
101
|
// console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
|
|
101
|
-
var sum = element.values.reduce(function (acc, curr) { return acc + curr.value / 1000000000 /
|
|
102
|
+
var sum = element.values.reduce(function (acc, curr) { return acc + curr.value / 1000000000 / len_1; }, 0);
|
|
102
103
|
return {
|
|
103
104
|
user: element.metric.labels.user,
|
|
104
105
|
score: sum,
|
package/lib/utils/tools.d.ts
CHANGED
package/lib/utils/tools.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.U64FromBytes = void 0;
|
|
3
|
+
exports.AddressFromBytes = exports.U64FromBytes = void 0;
|
|
4
4
|
function U64FromBytes(x) {
|
|
5
|
-
var
|
|
5
|
+
var u64 = BigInt(0);
|
|
6
6
|
for (var i = 0; i < x.length; i++) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
u64 = u64 << BigInt(8);
|
|
8
|
+
u64 += BigInt(x[i]);
|
|
9
9
|
}
|
|
10
|
-
return
|
|
10
|
+
return u64;
|
|
11
11
|
}
|
|
12
12
|
exports.U64FromBytes = U64FromBytes;
|
|
13
|
+
function AddressFromBytes(x) {
|
|
14
|
+
var address = "0x";
|
|
15
|
+
for (var i = 0; i < x.length; i++) {
|
|
16
|
+
address = address.concat(x[i].toString(16));
|
|
17
|
+
}
|
|
18
|
+
return address;
|
|
19
|
+
}
|
|
20
|
+
exports.AddressFromBytes = AddressFromBytes;
|
|
@@ -42,6 +42,7 @@ var dutch_1 = require("../typus-framework/dutch");
|
|
|
42
42
|
function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vault_registry, index) {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
44
44
|
var portfolioVaultIds, portfolioVaults, depositVaultIds, bidVaultIds;
|
|
45
|
+
var _this = this;
|
|
45
46
|
return __generator(this, function (_a) {
|
|
46
47
|
switch (_a.label) {
|
|
47
48
|
case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: registry })];
|
|
@@ -53,150 +54,172 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
53
54
|
ids: portfolioVaultIds,
|
|
54
55
|
options: { showContent: true },
|
|
55
56
|
})];
|
|
56
|
-
case 2:
|
|
57
|
-
portfolioVaults = (_a.sent())
|
|
57
|
+
case 2: return [4 /*yield*/, (_a.sent())
|
|
58
58
|
.filter(function (portfolioVault) { return portfolioVault.error == undefined; })
|
|
59
|
-
.reduce(function (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
.reduce(function (promise, portfolioVault) { return __awaiter(_this, void 0, void 0, function () {
|
|
60
|
+
var map, vaultId, auctionDelayTsMs, typeArgs, assets, deliveryInfo, info, config, auction, authority;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0: return [4 /*yield*/, promise];
|
|
64
|
+
case 1:
|
|
65
|
+
map = _a.sent();
|
|
66
|
+
vaultId = portfolioVault.data.content.fields.id.id;
|
|
67
|
+
auctionDelayTsMs = "0";
|
|
68
|
+
return [4 /*yield*/, provider
|
|
69
|
+
.getDynamicFieldObject({
|
|
70
|
+
parentId: vaultId,
|
|
71
|
+
name: {
|
|
72
|
+
type: "vector<u8>",
|
|
73
|
+
value: [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],
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
.then(function (result) {
|
|
77
|
+
if (result.error == undefined) {
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
auctionDelayTsMs = result.data.content.fields.value;
|
|
80
|
+
}
|
|
81
|
+
})];
|
|
82
|
+
case 2:
|
|
83
|
+
_a.sent();
|
|
84
|
+
typeArgs = new RegExp(".*<(.*), (.*), (.*)>").exec(portfolioVault.data.content.type).slice(1, 4);
|
|
85
|
+
assets = typeArgs.map(function (x) { return x.split("::")[2]; });
|
|
86
|
+
deliveryInfo =
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
portfolioVault.data.content.fields.info.fields.delivery_info
|
|
89
|
+
? {
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
round: portfolioVault.data.content.fields.info.fields.delivery_info.fields.round,
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
price: portfolioVault.data.content.fields.info.fields.delivery_info.fields.price,
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
size: portfolioVault.data.content.fields.info.fields.delivery_info.fields.size,
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
premium: portfolioVault.data.content.fields.info.fields.delivery_info.fields.premium,
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
tsMs: portfolioVault.data.content.fields.info.fields.delivery_info.fields.ts_ms,
|
|
100
|
+
}
|
|
101
|
+
: undefined;
|
|
102
|
+
info = {
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
index: portfolioVault.data.content.fields.info.fields.index,
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
creator: portfolioVault.data.content.fields.info.fields.creator,
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
createTsMs: portfolioVault.data.content.fields.info.fields.create_ts_ms,
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
round: portfolioVault.data.content.fields.info.fields.round,
|
|
111
|
+
deliveryInfo: deliveryInfo,
|
|
112
|
+
};
|
|
113
|
+
config = {
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
optionType: portfolioVault.data.content.fields.config.fields.option_type,
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
period: portfolioVault.data.content.fields.config.fields.period,
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
activationTsMs: portfolioVault.data.content.fields.config.fields.activation_ts_ms,
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
expirationTsMs: portfolioVault.data.content.fields.config.fields.expiration_ts_ms,
|
|
122
|
+
auctionDelayTsMs: auctionDelayTsMs,
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
dTokenDecimal: portfolioVault.data.content.fields.config.fields.d_token_decimal,
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
bTokenDecimal: portfolioVault.data.content.fields.config.fields.b_token_decimal,
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
oTokenDecimal: portfolioVault.data.content.fields.config.fields.o_token_decimal,
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
lotSize: portfolioVault.data.content.fields.config.fields.lot_size,
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
capacity: portfolioVault.data.content.fields.config.fields.capacity,
|
|
133
|
+
// @ts-ignore
|
|
134
|
+
leverage: portfolioVault.data.content.fields.config.fields.leverage,
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
hasNext: portfolioVault.data.content.fields.config.fields.has_next,
|
|
137
|
+
activeVaultConfig: {
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
payoffConfigs: portfolioVault.data.content.fields.config.fields.active_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
|
+
}),
|
|
147
|
+
// @ts-ignore
|
|
148
|
+
strikeIncrement: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.strike_increment,
|
|
149
|
+
// @ts-ignore
|
|
150
|
+
decaySpeed: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.decay_speed,
|
|
151
|
+
// @ts-ignore
|
|
152
|
+
initialPrice: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.initial_price,
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
finalPrice: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.final_price,
|
|
155
|
+
// @ts-ignore
|
|
156
|
+
auctionDurationInMs: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.auction_duration_in_ms,
|
|
157
|
+
},
|
|
158
|
+
warmupVaultConfig: {
|
|
159
|
+
// @ts-ignore
|
|
160
|
+
payoffConfigs: portfolioVault.data.content.fields.config.fields.warmup_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
|
+
}),
|
|
168
|
+
// @ts-ignore
|
|
169
|
+
strikeIncrement: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.strike_increment,
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
decaySpeed: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.decay_speed,
|
|
172
|
+
// @ts-ignore
|
|
173
|
+
initialPrice: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.initial_price,
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
finalPrice: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.final_price,
|
|
176
|
+
// @ts-ignore
|
|
177
|
+
auctionDurationInMs: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.auction_duration_in_ms,
|
|
178
|
+
},
|
|
179
|
+
upcomingVaultConfig: {
|
|
180
|
+
// @ts-ignore
|
|
181
|
+
payoffConfigs: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.payoff_configs.map(function (x) {
|
|
182
|
+
return ({
|
|
183
|
+
strikePct: x.fields.strike_pct,
|
|
184
|
+
weight: x.fields.weight,
|
|
185
|
+
isBuyer: x.fields.is_buyer,
|
|
186
|
+
strike: x.fields.strike,
|
|
187
|
+
});
|
|
188
|
+
}),
|
|
189
|
+
// @ts-ignore
|
|
190
|
+
strikeIncrement: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.strike_increment,
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
decaySpeed: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.decay_speed,
|
|
193
|
+
// @ts-ignore
|
|
194
|
+
initialPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.initial_price,
|
|
195
|
+
// @ts-ignore
|
|
196
|
+
finalPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.final_price,
|
|
197
|
+
auctionDurationInMs:
|
|
198
|
+
// @ts-ignore
|
|
199
|
+
portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.auction_duration_in_ms,
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
auction = portfolioVault.data.content.fields.auction ? (0, dutch_1.parseAuction)(portfolioVault.data.content.fields.auction) : undefined;
|
|
203
|
+
authority = portfolioVault.data.content.fields.authority.fields.whitelist.fields.id.id;
|
|
204
|
+
map[info.index] = {
|
|
205
|
+
vaultId: vaultId,
|
|
206
|
+
typeArgs: typeArgs,
|
|
207
|
+
assets: assets,
|
|
208
|
+
info: info,
|
|
209
|
+
config: config,
|
|
210
|
+
depositVault: {},
|
|
211
|
+
bidVault: {},
|
|
212
|
+
auction: auction,
|
|
213
|
+
authority: authority,
|
|
214
|
+
};
|
|
215
|
+
return [2 /*return*/, map];
|
|
80
216
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
index: portfolioVault.data.content.fields.info.fields.index,
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
creator: portfolioVault.data.content.fields.info.fields.creator,
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
createTsMs: portfolioVault.data.content.fields.info.fields.create_ts_ms,
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
round: portfolioVault.data.content.fields.info.fields.round,
|
|
91
|
-
deliveryInfo: deliveryInfo,
|
|
92
|
-
};
|
|
93
|
-
var config = {
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
optionType: portfolioVault.data.content.fields.config.fields.option_type,
|
|
96
|
-
// @ts-ignore
|
|
97
|
-
period: portfolioVault.data.content.fields.config.fields.period,
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
activationTsMs: portfolioVault.data.content.fields.config.fields.activation_ts_ms,
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
expirationTsMs: portfolioVault.data.content.fields.config.fields.expiration_ts_ms,
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
dTokenDecimal: portfolioVault.data.content.fields.config.fields.d_token_decimal,
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
bTokenDecimal: portfolioVault.data.content.fields.config.fields.b_token_decimal,
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
oTokenDecimal: portfolioVault.data.content.fields.config.fields.o_token_decimal,
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
lotSize: portfolioVault.data.content.fields.config.fields.lot_size,
|
|
110
|
-
// @ts-ignore
|
|
111
|
-
capacity: portfolioVault.data.content.fields.config.fields.capacity,
|
|
112
|
-
// @ts-ignore
|
|
113
|
-
leverage: portfolioVault.data.content.fields.config.fields.leverage,
|
|
114
|
-
// @ts-ignore
|
|
115
|
-
hasNext: portfolioVault.data.content.fields.config.fields.has_next,
|
|
116
|
-
activeVaultConfig: {
|
|
117
|
-
// @ts-ignore
|
|
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
|
-
}),
|
|
126
|
-
// @ts-ignore
|
|
127
|
-
strikeIncrement: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.strike_increment,
|
|
128
|
-
// @ts-ignore
|
|
129
|
-
decaySpeed: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.decay_speed,
|
|
130
|
-
// @ts-ignore
|
|
131
|
-
initialPrice: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.initial_price,
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
finalPrice: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.final_price,
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
auctionDurationInMs: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.auction_duration_in_ms,
|
|
136
|
-
},
|
|
137
|
-
warmupVaultConfig: {
|
|
138
|
-
// @ts-ignore
|
|
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
|
-
}),
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
strikeIncrement: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.strike_increment,
|
|
149
|
-
// @ts-ignore
|
|
150
|
-
decaySpeed: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.decay_speed,
|
|
151
|
-
// @ts-ignore
|
|
152
|
-
initialPrice: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.initial_price,
|
|
153
|
-
// @ts-ignore
|
|
154
|
-
finalPrice: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.final_price,
|
|
155
|
-
// @ts-ignore
|
|
156
|
-
auctionDurationInMs: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.auction_duration_in_ms,
|
|
157
|
-
},
|
|
158
|
-
upcomingVaultConfig: {
|
|
159
|
-
// @ts-ignore
|
|
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
|
-
}),
|
|
168
|
-
// @ts-ignore
|
|
169
|
-
strikeIncrement: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.strike_increment,
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
decaySpeed: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.decay_speed,
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
initialPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.initial_price,
|
|
174
|
-
// @ts-ignore
|
|
175
|
-
finalPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.final_price,
|
|
176
|
-
auctionDurationInMs:
|
|
177
|
-
// @ts-ignore
|
|
178
|
-
portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.auction_duration_in_ms,
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
// @ts-ignore
|
|
182
|
-
var auction = portfolioVault.data.content.fields.auction ? (0, dutch_1.parseAuction)(portfolioVault.data.content.fields.auction) : undefined;
|
|
183
|
-
// @ts-ignore
|
|
184
|
-
var authority = portfolioVault.data.content.fields.authority.fields.whitelist.fields.id.id;
|
|
185
|
-
map[info.index] = {
|
|
186
|
-
vaultId: vaultId,
|
|
187
|
-
typeArgs: typeArgs,
|
|
188
|
-
assets: assets,
|
|
189
|
-
info: info,
|
|
190
|
-
config: config,
|
|
191
|
-
depositVault: {},
|
|
192
|
-
bidVault: {},
|
|
193
|
-
auction: auction,
|
|
194
|
-
authority: authority,
|
|
195
|
-
};
|
|
196
|
-
return map;
|
|
197
|
-
}, {});
|
|
198
|
-
return [4 /*yield*/, provider.getDynamicFields({ parentId: deposit_vault_registry })];
|
|
217
|
+
});
|
|
218
|
+
}); }, Promise.resolve({}))];
|
|
199
219
|
case 3:
|
|
220
|
+
portfolioVaults = _a.sent();
|
|
221
|
+
return [4 /*yield*/, provider.getDynamicFields({ parentId: deposit_vault_registry })];
|
|
222
|
+
case 4:
|
|
200
223
|
depositVaultIds = (_a.sent()).data
|
|
201
224
|
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
202
225
|
.map(function (x) { return x.objectId; });
|
|
@@ -204,7 +227,7 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
204
227
|
ids: depositVaultIds,
|
|
205
228
|
options: { showContent: true },
|
|
206
229
|
})];
|
|
207
|
-
case
|
|
230
|
+
case 5:
|
|
208
231
|
(_a.sent())
|
|
209
232
|
.filter(function (depositVault) { return depositVault.error == undefined; })
|
|
210
233
|
.forEach(function (depositVault) {
|
|
@@ -217,7 +240,7 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
217
240
|
portfolioVaults[index].depositVault = vault;
|
|
218
241
|
});
|
|
219
242
|
return [4 /*yield*/, provider.getDynamicFields({ parentId: bid_vault_registry })];
|
|
220
|
-
case
|
|
243
|
+
case 6:
|
|
221
244
|
bidVaultIds = (_a.sent()).data
|
|
222
245
|
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
223
246
|
.map(function (x) { return x.objectId; });
|
|
@@ -225,7 +248,7 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
225
248
|
ids: bidVaultIds,
|
|
226
249
|
options: { showContent: true },
|
|
227
250
|
})];
|
|
228
|
-
case
|
|
251
|
+
case 7:
|
|
229
252
|
(_a.sent())
|
|
230
253
|
.filter(function (bidVault) { return bidVault.error == undefined; })
|
|
231
254
|
.forEach(function (bidVault) {
|
|
@@ -5,6 +5,16 @@ export interface UserShare {
|
|
|
5
5
|
depositVaultUserShare: DepositVaultUserShare;
|
|
6
6
|
bidVaultUserShare: BidVaultUserShare;
|
|
7
7
|
}
|
|
8
|
+
export interface UserBid {
|
|
9
|
+
index: string;
|
|
10
|
+
price: string;
|
|
11
|
+
size: string;
|
|
12
|
+
ts_ms: string;
|
|
13
|
+
balance: string;
|
|
14
|
+
bidder: string;
|
|
15
|
+
}
|
|
8
16
|
export declare function getUserShares(provider: JsonRpcProvider, packageId: string, registry: string, indexes: string[], user: string): Promise<Map<string, UserShare>>;
|
|
9
17
|
export declare function getAuctionMaxSize(provider: JsonRpcProvider, packageId: string, typeArguments: string[], registry: string, index: string, priceOracle: string): Promise<BigInt>;
|
|
10
18
|
export declare function getMaxLossPerUnit(provider: JsonRpcProvider, packageId: string, typeArguments: string[], registry: string, index: string, priceOracle: string): Promise<BigInt>;
|
|
19
|
+
export declare function getAuctionTotalBidSize(provider: JsonRpcProvider, packageId: string, typeArguments: string[], registry: string, index: string): Promise<BigInt>;
|
|
20
|
+
export declare function getAuctionBids(provider: JsonRpcProvider, packageId: string, typeArguments: string[], registry: string, index: string): Promise<UserBid[]>;
|
|
@@ -52,7 +52,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
52
52
|
return ar;
|
|
53
53
|
};
|
|
54
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.getMaxLossPerUnit = exports.getAuctionMaxSize = exports.getUserShares = void 0;
|
|
55
|
+
exports.getAuctionBids = exports.getAuctionTotalBidSize = exports.getMaxLossPerUnit = exports.getAuctionMaxSize = exports.getUserShares = void 0;
|
|
56
56
|
var sui_js_1 = require("@mysten/sui.js");
|
|
57
57
|
var tools_1 = require("../tools");
|
|
58
58
|
var constants_1 = require("../../constants");
|
|
@@ -194,3 +194,67 @@ function getMaxLossPerUnit(provider, packageId, typeArguments, registry, index,
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
exports.getMaxLossPerUnit = getMaxLossPerUnit;
|
|
197
|
+
function getAuctionTotalBidSize(provider, packageId, typeArguments, registry, index) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var transactionBlock, target, transactionBlockArguments, bytes;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
switch (_a.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
transactionBlock = new sui_js_1.TransactionBlock();
|
|
204
|
+
target = "".concat(packageId, "::typus_dov_single::get_auction_total_bid_size");
|
|
205
|
+
transactionBlockArguments = [transactionBlock.pure(registry), transactionBlock.pure(index)];
|
|
206
|
+
transactionBlock.moveCall({
|
|
207
|
+
target: target,
|
|
208
|
+
typeArguments: typeArguments,
|
|
209
|
+
arguments: transactionBlockArguments,
|
|
210
|
+
});
|
|
211
|
+
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transactionBlock, sender: constants_1.SENDER })];
|
|
212
|
+
case 1:
|
|
213
|
+
bytes = (_a.sent()).results[0].returnValues[0][0];
|
|
214
|
+
return [2 /*return*/, (0, tools_1.U64FromBytes)(bytes.reverse())];
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
exports.getAuctionTotalBidSize = getAuctionTotalBidSize;
|
|
220
|
+
function getAuctionBids(provider, packageId, typeArguments, registry, index) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
+
var transactionBlock, target, transactionBlockArguments, bytes, result, user_bid_bytes, index_1, price, size, ts_ms, balance, bidder;
|
|
223
|
+
return __generator(this, function (_a) {
|
|
224
|
+
switch (_a.label) {
|
|
225
|
+
case 0:
|
|
226
|
+
transactionBlock = new sui_js_1.TransactionBlock();
|
|
227
|
+
target = "".concat(packageId, "::typus_dov_single::get_auction_bids");
|
|
228
|
+
transactionBlockArguments = [transactionBlock.pure(registry), transactionBlock.pure(index)];
|
|
229
|
+
transactionBlock.moveCall({
|
|
230
|
+
target: target,
|
|
231
|
+
typeArguments: typeArguments,
|
|
232
|
+
arguments: transactionBlockArguments,
|
|
233
|
+
});
|
|
234
|
+
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transactionBlock, sender: constants_1.SENDER })];
|
|
235
|
+
case 1:
|
|
236
|
+
bytes = (_a.sent()).results[0].returnValues[0][0];
|
|
237
|
+
result = [];
|
|
238
|
+
while (bytes.length > 72) {
|
|
239
|
+
user_bid_bytes = bytes.splice(bytes.length - 72, 72);
|
|
240
|
+
index_1 = (0, tools_1.U64FromBytes)(user_bid_bytes.splice(0, 8).reverse()).toString();
|
|
241
|
+
price = (0, tools_1.U64FromBytes)(user_bid_bytes.splice(0, 8).reverse()).toString();
|
|
242
|
+
size = (0, tools_1.U64FromBytes)(user_bid_bytes.splice(0, 8).reverse()).toString();
|
|
243
|
+
ts_ms = (0, tools_1.U64FromBytes)(user_bid_bytes.splice(0, 8).reverse()).toString();
|
|
244
|
+
balance = (0, tools_1.U64FromBytes)(user_bid_bytes.splice(0, 8).reverse()).toString();
|
|
245
|
+
bidder = (0, tools_1.AddressFromBytes)(user_bid_bytes.splice(0, 32));
|
|
246
|
+
result.push({
|
|
247
|
+
index: index_1,
|
|
248
|
+
price: price,
|
|
249
|
+
size: size,
|
|
250
|
+
ts_ms: ts_ms,
|
|
251
|
+
balance: balance,
|
|
252
|
+
bidder: bidder,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return [2 /*return*/, result];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
exports.getAuctionBids = getAuctionBids;
|
package/package.json
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
2
|
+
"name": "@typus/typus-sdk",
|
|
3
|
+
"author": "Typus",
|
|
4
|
+
"description": "typus sdk",
|
|
5
|
+
"version": "1.0.35",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@mysten/sui.js": "^0.34.0",
|
|
8
|
+
"@types/node": "^17.0.0",
|
|
9
|
+
"bignumber.js": "^9.1.1",
|
|
10
|
+
"bs58": "^4.0.1",
|
|
11
|
+
"builtin-modules": "^1.1.1",
|
|
12
|
+
"chai": "^4.3.7",
|
|
13
|
+
"decimal.js": "^10.3.1",
|
|
14
|
+
"diff": "^4.0.2",
|
|
15
|
+
"dotenv": "^10.0.0",
|
|
16
|
+
"encrypt-with-password": "^1.0.0",
|
|
17
|
+
"escape-string-regexp": "^1.0.5",
|
|
18
|
+
"esprima": "^4.0.1",
|
|
19
|
+
"fetch": "^1.1.0",
|
|
20
|
+
"fs.realpath": "^1.0.0",
|
|
21
|
+
"function-bind": "^1.1.1",
|
|
22
|
+
"glob": "^7.2.0",
|
|
23
|
+
"has": "^1.0.3",
|
|
24
|
+
"has-flag": "^3.0.0",
|
|
25
|
+
"inflight": "^1.0.6",
|
|
26
|
+
"inherits": "^2.0.4",
|
|
27
|
+
"is-core-module": "^2.8.0",
|
|
28
|
+
"js-sha3": "^0.8.0",
|
|
29
|
+
"js-tokens": "^4.0.0",
|
|
30
|
+
"js-yaml": "^3.14.1",
|
|
31
|
+
"math-erf": "^1.0.0",
|
|
32
|
+
"minimatch": "^3.0.4",
|
|
33
|
+
"minimist": "^1.2.5",
|
|
34
|
+
"mkdirp": "^0.5.5",
|
|
35
|
+
"mocha": "^10.1.0",
|
|
36
|
+
"moment": "^2.29.4",
|
|
37
|
+
"node-cron": "^3.0.2",
|
|
38
|
+
"once": "^1.4.0",
|
|
39
|
+
"path-is-absolute": "^1.0.1",
|
|
40
|
+
"path-parse": "^1.0.7",
|
|
41
|
+
"random-bigint": "^0.0.1",
|
|
42
|
+
"resolve": "^1.20.0",
|
|
43
|
+
"rxjs": "^7.5.5",
|
|
44
|
+
"semver": "^5.7.1",
|
|
45
|
+
"sprintf-js": "^1.0.3",
|
|
46
|
+
"superstruct": "^0.16.0",
|
|
47
|
+
"supports-color": "^5.5.0",
|
|
48
|
+
"ts-mocha": "^10.0.0",
|
|
49
|
+
"tslib": "^1.14.1",
|
|
50
|
+
"tsutils": "^2.29.0",
|
|
51
|
+
"typed-rpc": "^3.0.0",
|
|
52
|
+
"wrappy": "^1.0.2",
|
|
53
|
+
"ws": "^8.11.0",
|
|
54
|
+
"xmlhttprequest": "^1.8.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/bs58": "^4.0.1",
|
|
58
|
+
"@types/expect": "^24.3.0",
|
|
59
|
+
"@types/mocha": "^9.0.0",
|
|
60
|
+
"@types/rx": "^4.1.2",
|
|
61
|
+
"prettier": "^2.5.1",
|
|
62
|
+
"tslint": "^6.1.3",
|
|
63
|
+
"tslint-config-prettier": "^1.18.0",
|
|
64
|
+
"typescript": "^4.5.4"
|
|
65
|
+
},
|
|
66
|
+
"main": "lib/index.js",
|
|
67
|
+
"files": [
|
|
68
|
+
"lib"
|
|
69
|
+
],
|
|
70
|
+
"types": "lib/index.d.ts",
|
|
71
|
+
"scripts": {
|
|
72
|
+
"test": "rm -rf lib && tsc && ts-mocha test/test*.ts",
|
|
73
|
+
"build": "rm -rf lib && tsc"
|
|
74
|
+
},
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "git+https://github.com/Typus-Lab/typus-sdk.git"
|
|
78
|
+
},
|
|
79
|
+
"license": "ISC",
|
|
80
|
+
"bugs": {
|
|
81
|
+
"url": "https://github.com/Typus-Lab/typus-sdk/issues"
|
|
82
|
+
},
|
|
83
|
+
"homepage": "https://github.com/Typus-Lab/typus-sdk#readme"
|
|
84
84
|
}
|