@typus/typus-sdk 1.0.33 → 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.d.ts +1 -1
- package/lib/utils/leader-board.js +69 -69
- 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 +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function getDepositorLeaderBoard(start?: string, end?: string, step?: number): Promise<LeaderBoard[]>;
|
|
2
|
-
export declare function getBidderLeaderBoard(
|
|
2
|
+
export declare function getBidderLeaderBoard(startTimestamp?: string, end?: string): Promise<LeaderBoard[]>;
|
|
3
3
|
interface LeaderBoard {
|
|
4
4
|
user: string;
|
|
5
5
|
score: number;
|
|
@@ -37,56 +37,38 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getBidderLeaderBoard = exports.getDepositorLeaderBoard = void 0;
|
|
40
|
-
var apiUrl = "https://app.sentio.xyz/api/v1/
|
|
40
|
+
var apiUrl = "https://app.sentio.xyz/api/v1/insights/wayne/typus/query";
|
|
41
41
|
var headers = {
|
|
42
42
|
"api-key": "oBOW8DsO1izVrINCy6Tmxga9YcWeOL87O",
|
|
43
43
|
"Content-Type": "application/json",
|
|
44
44
|
};
|
|
45
45
|
var depositorRequestData = {
|
|
46
|
+
timeRange: {
|
|
47
|
+
start: "-7d",
|
|
48
|
+
end: "now",
|
|
49
|
+
step: 3600,
|
|
50
|
+
},
|
|
51
|
+
limit: 200,
|
|
46
52
|
queries: [
|
|
47
53
|
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
query: "callPortfolioCompound",
|
|
61
|
-
alias: "",
|
|
62
|
-
id: "b",
|
|
63
|
-
labelSelector: {},
|
|
64
|
-
aggregate: {
|
|
65
|
-
op: "SUM",
|
|
66
|
-
grouping: ["user"],
|
|
54
|
+
metricsQuery: {
|
|
55
|
+
query: "depositTvl",
|
|
56
|
+
alias: "",
|
|
57
|
+
id: "a",
|
|
58
|
+
labelSelector: {
|
|
59
|
+
// user: "0x823bd0c4d601d625b1b1555dbe17da495db71070a4365205467838aecc32cbad",
|
|
60
|
+
},
|
|
61
|
+
aggregate: {
|
|
62
|
+
op: "SUM",
|
|
63
|
+
grouping: ["user"],
|
|
64
|
+
},
|
|
67
65
|
},
|
|
68
|
-
functions: [],
|
|
69
|
-
disabled: true,
|
|
70
66
|
},
|
|
71
67
|
],
|
|
72
|
-
formulas: [
|
|
73
|
-
{
|
|
74
|
-
expression: "a+b",
|
|
75
|
-
alias: "Score",
|
|
76
|
-
id: "A",
|
|
77
|
-
disabled: false,
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
timeRange: {
|
|
81
|
-
start: "now",
|
|
82
|
-
end: "now",
|
|
83
|
-
step: 1,
|
|
84
|
-
},
|
|
85
|
-
samplesLimit: 200,
|
|
86
68
|
};
|
|
87
69
|
function getDepositorLeaderBoard(start, end, step) {
|
|
88
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
-
var jsonData, response, data, samples, leader_board;
|
|
71
|
+
var jsonData, response, data, samples, len_1, leader_board;
|
|
90
72
|
return __generator(this, function (_a) {
|
|
91
73
|
switch (_a.label) {
|
|
92
74
|
case 0:
|
|
@@ -112,11 +94,18 @@ function getDepositorLeaderBoard(start, end, step) {
|
|
|
112
94
|
case 2:
|
|
113
95
|
data = _a.sent();
|
|
114
96
|
samples = data.results[0].matrix.samples;
|
|
115
|
-
|
|
97
|
+
len_1 = samples.reduce(function (acc, curr) { return (acc > curr.values.length ? acc : curr.values.length); }, 0);
|
|
98
|
+
leader_board = samples
|
|
99
|
+
.map(function (element) {
|
|
116
100
|
// console.log("metric:", element.metric, "values: ", element.values);
|
|
117
101
|
// console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
|
|
118
|
-
|
|
119
|
-
|
|
102
|
+
var sum = element.values.reduce(function (acc, curr) { return acc + curr.value / 1000000000 / len_1; }, 0);
|
|
103
|
+
return {
|
|
104
|
+
user: element.metric.labels.user,
|
|
105
|
+
score: sum,
|
|
106
|
+
};
|
|
107
|
+
})
|
|
108
|
+
.filter(function (element) { return element.score != 0; });
|
|
120
109
|
leader_board.sort(function (a, b) { return b.score - a.score; });
|
|
121
110
|
// console.log(leader_board);
|
|
122
111
|
return [2 /*return*/, leader_board];
|
|
@@ -127,43 +116,42 @@ function getDepositorLeaderBoard(start, end, step) {
|
|
|
127
116
|
}
|
|
128
117
|
exports.getDepositorLeaderBoard = getDepositorLeaderBoard;
|
|
129
118
|
var bidderRequestData = {
|
|
119
|
+
timeRange: {
|
|
120
|
+
start: "-7d",
|
|
121
|
+
end: "now",
|
|
122
|
+
step: 3600,
|
|
123
|
+
},
|
|
124
|
+
limit: 200,
|
|
130
125
|
queries: [
|
|
131
126
|
{
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
127
|
+
metricsQuery: {
|
|
128
|
+
query: "totalNewBid",
|
|
129
|
+
alias: "",
|
|
130
|
+
id: "a",
|
|
131
|
+
labelSelector: {},
|
|
132
|
+
aggregate: {
|
|
133
|
+
op: "SUM",
|
|
134
|
+
grouping: ["user"],
|
|
135
|
+
},
|
|
136
|
+
functions: [],
|
|
137
|
+
disabled: false,
|
|
139
138
|
},
|
|
140
|
-
|
|
141
|
-
disabled: false,
|
|
139
|
+
dataSource: "METRICS",
|
|
142
140
|
},
|
|
143
141
|
],
|
|
144
|
-
formulas: [],
|
|
145
|
-
timeRange: {
|
|
146
|
-
start: "now",
|
|
147
|
-
end: "now",
|
|
148
|
-
step: 1,
|
|
149
|
-
},
|
|
150
|
-
samplesLimit: 200,
|
|
151
142
|
};
|
|
152
|
-
function getBidderLeaderBoard(
|
|
143
|
+
function getBidderLeaderBoard(startTimestamp, end) {
|
|
153
144
|
return __awaiter(this, void 0, void 0, function () {
|
|
154
145
|
var jsonData, response, data, samples, leader_board;
|
|
155
146
|
return __generator(this, function (_a) {
|
|
156
147
|
switch (_a.label) {
|
|
157
148
|
case 0:
|
|
158
|
-
if (
|
|
159
|
-
bidderRequestData.timeRange.start =
|
|
149
|
+
if (startTimestamp) {
|
|
150
|
+
bidderRequestData.timeRange.start = startTimestamp;
|
|
160
151
|
}
|
|
161
152
|
if (end) {
|
|
162
153
|
bidderRequestData.timeRange.end = end;
|
|
163
154
|
}
|
|
164
|
-
if (step) {
|
|
165
|
-
bidderRequestData.timeRange.step = step;
|
|
166
|
-
}
|
|
167
155
|
jsonData = JSON.stringify(bidderRequestData);
|
|
168
156
|
return [4 /*yield*/, fetch(apiUrl, {
|
|
169
157
|
method: "POST",
|
|
@@ -177,11 +165,22 @@ function getBidderLeaderBoard(start, end, step) {
|
|
|
177
165
|
case 2:
|
|
178
166
|
data = _a.sent();
|
|
179
167
|
samples = data.results[0].matrix.samples;
|
|
180
|
-
leader_board = samples
|
|
168
|
+
leader_board = samples
|
|
169
|
+
.map(function (element) {
|
|
181
170
|
// console.log("metric:", element.metric, "values: ", element.values);
|
|
182
171
|
// console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
|
|
183
|
-
|
|
184
|
-
|
|
172
|
+
var a = 0;
|
|
173
|
+
var log_0 = element.values.at(0);
|
|
174
|
+
if (log_0.timestamp == startTimestamp) {
|
|
175
|
+
a = log_0.value;
|
|
176
|
+
}
|
|
177
|
+
var b = element.values.at(-1).value;
|
|
178
|
+
return {
|
|
179
|
+
user: element.metric.labels.user,
|
|
180
|
+
score: (b - a) / 1000000000,
|
|
181
|
+
};
|
|
182
|
+
})
|
|
183
|
+
.filter(function (element) { return element.score != 0; });
|
|
185
184
|
leader_board.sort(function (a, b) { return b.score - a.score; });
|
|
186
185
|
// console.log(leader_board);
|
|
187
186
|
return [2 /*return*/, leader_board];
|
|
@@ -191,7 +190,8 @@ function getBidderLeaderBoard(start, end, step) {
|
|
|
191
190
|
});
|
|
192
191
|
}
|
|
193
192
|
exports.getBidderLeaderBoard = getBidderLeaderBoard;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
194
|
+
return __generator(this, function (_a) {
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
});
|
|
197
|
+
}); })();
|
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
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@typus/typus-sdk",
|
|
3
3
|
"author": "Typus",
|
|
4
4
|
"description": "typus sdk",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.35",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@mysten/sui.js": "^0.
|
|
7
|
+
"@mysten/sui.js": "^0.34.0",
|
|
8
8
|
"@types/node": "^17.0.0",
|
|
9
9
|
"bignumber.js": "^9.1.1",
|
|
10
10
|
"bs58": "^4.0.1",
|