@typus/typus-sdk 1.8.0 → 1.8.2
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.
|
@@ -408,7 +408,7 @@ exports.oracle = {
|
|
|
408
408
|
MBLUB: "0x826253a1dde9907e28f465df8b2a19ba5994b4b069abad98658532785940338a",
|
|
409
409
|
TYPUS: "0x73bb8651018bced7e737557fc9e4a7cf02ae28345b645566d0fd4df2da183048",
|
|
410
410
|
NS: "0x4481ebc6a26ac72abb9ecbedba60fcba87440f1306c125c1bdf61d1248af4482",
|
|
411
|
-
JPY: "
|
|
411
|
+
JPY: "0x58033b4a91375217a14db8efebad37000057f343e3b93be4efb028d4081d6824",
|
|
412
412
|
XAU: "0x172101af6fbaab02b2663ed7c502152431fed5d76ac865ac3ccad134c92d91db",
|
|
413
413
|
TBTC: "0x383cb3519e51c62d84ec54e2fca3438c43a83967738b364c20f0f2a662a668d5",
|
|
414
414
|
},
|
|
@@ -1,75 +1,42 @@
|
|
|
1
1
|
import { TypusConfig } from "../../src/utils";
|
|
2
|
-
import { TypusBidReceipt } from "../../src/auto-bid/view-function";
|
|
3
2
|
export interface Vault {
|
|
4
3
|
id: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
mainToken: string;
|
|
5
|
+
hedgeToken: string;
|
|
6
|
+
rewardTokens: string[];
|
|
7
|
+
info: Map<string, string>;
|
|
8
|
+
config: Map<string, string>;
|
|
9
|
+
mainTokenShare: KeyedBigVector;
|
|
10
|
+
mainTokenShareSupply: string[];
|
|
11
|
+
hedgeTokenShare: KeyedBigVector;
|
|
12
|
+
hedgeTokenShareSupply: string[];
|
|
13
|
+
rewardTokenShare: KeyedBigVector;
|
|
14
|
+
rewardTokenShareSupply: string[];
|
|
15
|
+
u64Padding: Map<string, string>;
|
|
16
|
+
bcsPadding: Map<string, number[]>;
|
|
13
17
|
}
|
|
14
|
-
export interface
|
|
15
|
-
index: string;
|
|
16
|
-
round: string;
|
|
17
|
-
portfolio_vault_index: string;
|
|
18
|
-
refresh_ts_ms: string;
|
|
19
|
-
status: string;
|
|
20
|
-
lending_enabled: string;
|
|
21
|
-
price_mbp: string;
|
|
22
|
-
mbp_incentivised: string;
|
|
23
|
-
fixed_incentivised: string;
|
|
24
|
-
token_decimal: string;
|
|
25
|
-
lending_apr_mbp: string;
|
|
26
|
-
creation_ts_ms: string;
|
|
27
|
-
dov_vault_index_add_one_up: string;
|
|
28
|
-
}
|
|
29
|
-
export interface Config {
|
|
30
|
-
capacity: string;
|
|
31
|
-
lot_size: string;
|
|
32
|
-
min_size: string;
|
|
33
|
-
fee_bp: string;
|
|
34
|
-
utilization_rate_bp: string;
|
|
35
|
-
exp_per_hour_bp: string;
|
|
36
|
-
incentive_mbp: string;
|
|
37
|
-
incentive_fixed: string;
|
|
38
|
-
point_per_hour_bp: string;
|
|
39
|
-
exercise_fee_bp: string;
|
|
40
|
-
exit_fee_bp: string;
|
|
41
|
-
exit_fee_amount: string;
|
|
42
|
-
}
|
|
43
|
-
export interface ShareSupply {
|
|
44
|
-
active_share: string;
|
|
45
|
-
deactivating_share: string;
|
|
46
|
-
inactive_share: string;
|
|
47
|
-
warmup_share: string;
|
|
48
|
-
snapshot_share: string;
|
|
49
|
-
reward_share: string[];
|
|
50
|
-
}
|
|
51
|
-
export interface BigVector {
|
|
18
|
+
export interface KeyedBigVector {
|
|
52
19
|
id: string;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
20
|
+
keyType: string;
|
|
21
|
+
valueType: string;
|
|
22
|
+
sliceIdx: string;
|
|
23
|
+
sliceSize: number;
|
|
56
24
|
length: string;
|
|
57
25
|
}
|
|
58
|
-
export declare function getBigVectorData(config: TypusConfig, bigVector: BigVector): Promise<any[]>;
|
|
59
26
|
export declare function getVaultData(config: TypusConfig, input: {
|
|
60
27
|
indexes: string[];
|
|
61
28
|
}): Promise<{
|
|
62
|
-
[key: string]: [Vault
|
|
29
|
+
[key: string]: [Vault];
|
|
63
30
|
}>;
|
|
64
31
|
export interface Share {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
32
|
+
index: string;
|
|
33
|
+
mainTokenShare: string[];
|
|
34
|
+
hedgeTokenShare: string[];
|
|
35
|
+
rewardTokenShare: string[];
|
|
69
36
|
}
|
|
70
37
|
export declare function getShareData(config: TypusConfig, input: {
|
|
71
38
|
user: string;
|
|
72
39
|
indexes: string[];
|
|
73
40
|
}): Promise<{
|
|
74
|
-
[key: string]: Share
|
|
41
|
+
[key: string]: Share;
|
|
75
42
|
}>;
|
|
@@ -36,7 +36,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getBigVectorData = getBigVectorData;
|
|
40
39
|
exports.getVaultData = getVaultData;
|
|
41
40
|
exports.getShareData = getShareData;
|
|
42
41
|
var transactions_1 = require("@mysten/sui/transactions");
|
|
@@ -44,39 +43,6 @@ var client_1 = require("@mysten/sui/client");
|
|
|
44
43
|
var bcs_1 = require("@mysten/bcs");
|
|
45
44
|
var utils_1 = require("../../src/utils");
|
|
46
45
|
var constants_1 = require("../../src/constants");
|
|
47
|
-
function getBigVectorData(config, bigVector) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
-
var provider, results, i, df, result;
|
|
50
|
-
var _a;
|
|
51
|
-
return __generator(this, function (_b) {
|
|
52
|
-
switch (_b.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
55
|
-
results = [];
|
|
56
|
-
i = 0;
|
|
57
|
-
_b.label = 1;
|
|
58
|
-
case 1:
|
|
59
|
-
if (!(i <= Number(bigVector.slice_idx))) return [3 /*break*/, 4];
|
|
60
|
-
return [4 /*yield*/, provider.getDynamicFieldObject({
|
|
61
|
-
parentId: bigVector.id,
|
|
62
|
-
name: {
|
|
63
|
-
type: "u64",
|
|
64
|
-
value: "".concat(i),
|
|
65
|
-
},
|
|
66
|
-
})];
|
|
67
|
-
case 2:
|
|
68
|
-
df = _b.sent();
|
|
69
|
-
result = (_a = df.data) === null || _a === void 0 ? void 0 : _a.content.fields.value.fields.vector.map(function (x) { return x.fields; });
|
|
70
|
-
results = results.concat(result);
|
|
71
|
-
_b.label = 3;
|
|
72
|
-
case 3:
|
|
73
|
-
i++;
|
|
74
|
-
return [3 /*break*/, 1];
|
|
75
|
-
case 4: return [2 /*return*/, results];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
46
|
function getVaultData(config, input) {
|
|
81
47
|
return __awaiter(this, void 0, void 0, function () {
|
|
82
48
|
var provider, transaction, results, bytes, reader, result;
|
|
@@ -86,9 +52,9 @@ function getVaultData(config, input) {
|
|
|
86
52
|
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
87
53
|
transaction = new transactions_1.Transaction();
|
|
88
54
|
transaction.moveCall({
|
|
89
|
-
target: "".concat(config.package.
|
|
90
|
-
typeArguments: [
|
|
91
|
-
arguments: [transaction.object(config.registry.
|
|
55
|
+
target: "".concat(config.package.hedge.hedge, "::view_function::get_vault_data_bcs"),
|
|
56
|
+
typeArguments: [],
|
|
57
|
+
arguments: [transaction.object(config.registry.hedge), transaction.pure.vector("u64", input.indexes)],
|
|
92
58
|
});
|
|
93
59
|
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transaction, sender: constants_1.SENDER })];
|
|
94
60
|
case 1:
|
|
@@ -99,111 +65,80 @@ function getVaultData(config, input) {
|
|
|
99
65
|
reader.readVec(function (reader) {
|
|
100
66
|
reader.readULEB();
|
|
101
67
|
var id = (0, utils_1.AddressFromBytes)(reader.readBytes(32));
|
|
102
|
-
var
|
|
103
|
-
var
|
|
68
|
+
var mainToken = String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB())));
|
|
69
|
+
var hedgeToken = String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB())));
|
|
70
|
+
var rewardTokens = reader.readVec(function (reader) {
|
|
104
71
|
return String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB())));
|
|
105
72
|
});
|
|
106
|
-
var
|
|
107
|
-
|
|
73
|
+
var info = new Map();
|
|
74
|
+
reader.readVec(function (reader) {
|
|
75
|
+
info.set(String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))), reader.read64());
|
|
108
76
|
});
|
|
109
|
-
var
|
|
110
|
-
|
|
77
|
+
var config = new Map();
|
|
78
|
+
reader.readVec(function (reader) {
|
|
79
|
+
config.set(String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))), reader.read64());
|
|
111
80
|
});
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
price_mbp: infoArray[6],
|
|
120
|
-
mbp_incentivised: infoArray[7],
|
|
121
|
-
fixed_incentivised: infoArray[8],
|
|
122
|
-
token_decimal: infoArray[9],
|
|
123
|
-
lending_apr_mbp: infoArray[10],
|
|
124
|
-
creation_ts_ms: infoArray[11],
|
|
125
|
-
dov_vault_index_add_one_up: infoArray[12],
|
|
126
|
-
};
|
|
127
|
-
var config = {
|
|
128
|
-
capacity: configArray[0],
|
|
129
|
-
lot_size: configArray[1],
|
|
130
|
-
min_size: configArray[2],
|
|
131
|
-
fee_bp: configArray[3],
|
|
132
|
-
utilization_rate_bp: configArray[4],
|
|
133
|
-
exp_per_hour_bp: configArray[5],
|
|
134
|
-
incentive_mbp: configArray[6],
|
|
135
|
-
incentive_fixed: configArray[7],
|
|
136
|
-
point_per_hour_bp: configArray[8],
|
|
137
|
-
exercise_fee_bp: configArray[9],
|
|
138
|
-
exit_fee_bp: configArray[10],
|
|
139
|
-
exit_fee_amount: configArray[11],
|
|
81
|
+
var mainTokenShare = {
|
|
82
|
+
id: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
|
|
83
|
+
keyType: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))),
|
|
84
|
+
valueType: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))),
|
|
85
|
+
sliceIdx: reader.read64(), // slice_idx
|
|
86
|
+
sliceSize: reader.read32(), // slice_size
|
|
87
|
+
length: reader.read64(), // length
|
|
140
88
|
};
|
|
141
|
-
|
|
142
|
-
|
|
89
|
+
var mainTokenShareSupply = reader.readVec(function (reader) {
|
|
90
|
+
return reader.read64();
|
|
91
|
+
});
|
|
92
|
+
var hedgeTokenShare = {
|
|
143
93
|
id: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
94
|
+
keyType: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))),
|
|
95
|
+
valueType: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))),
|
|
96
|
+
sliceIdx: reader.read64(), // slice_idx
|
|
97
|
+
sliceSize: reader.read32(), // slice_size
|
|
147
98
|
length: reader.read64(), // length
|
|
148
99
|
};
|
|
149
|
-
var
|
|
100
|
+
var hedgeTokenShareSupply = reader.readVec(function (reader) {
|
|
150
101
|
return reader.read64();
|
|
151
102
|
});
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
103
|
+
var rewardTokenShare = {
|
|
104
|
+
id: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
|
|
105
|
+
keyType: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))),
|
|
106
|
+
valueType: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))),
|
|
107
|
+
sliceIdx: reader.read64(), // slice_idx
|
|
108
|
+
sliceSize: reader.read32(), // slice_size
|
|
109
|
+
length: reader.read64(), // length
|
|
159
110
|
};
|
|
160
|
-
var
|
|
111
|
+
var rewardTokenShareSupply = reader.readVec(function (reader) {
|
|
161
112
|
return reader.read64();
|
|
162
113
|
});
|
|
163
|
-
var
|
|
164
|
-
|
|
114
|
+
var u64Padding = new Map();
|
|
115
|
+
reader.readVec(function (reader) {
|
|
116
|
+
u64Padding.set(String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))), reader.read64());
|
|
117
|
+
});
|
|
118
|
+
var bcsPadding = new Map();
|
|
119
|
+
reader.readVec(function (reader) {
|
|
120
|
+
bcsPadding.set(String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))), reader.readVec(function (reader) {
|
|
121
|
+
return reader.read8();
|
|
122
|
+
}));
|
|
165
123
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
metadata: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))),
|
|
185
|
-
u64_padding: reader.readVec(function (reader) {
|
|
186
|
-
return reader.read64();
|
|
187
|
-
}),
|
|
188
|
-
},
|
|
189
|
-
];
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
result[info.index] = [
|
|
193
|
-
{
|
|
194
|
-
id: id,
|
|
195
|
-
depositToken: depositToken,
|
|
196
|
-
rewardToken: rewardToken,
|
|
197
|
-
info: info,
|
|
198
|
-
config: config,
|
|
199
|
-
share: bigVector,
|
|
200
|
-
shareSupply: shareSupply,
|
|
201
|
-
u64Padding: u64Padding,
|
|
202
|
-
bcsPadding: bcsPadding,
|
|
203
|
-
},
|
|
204
|
-
null,
|
|
205
|
-
];
|
|
206
|
-
}
|
|
124
|
+
result[info["index"]] = [
|
|
125
|
+
{
|
|
126
|
+
id: id,
|
|
127
|
+
mainToken: mainToken,
|
|
128
|
+
hedgeToken: hedgeToken,
|
|
129
|
+
rewardTokens: rewardTokens,
|
|
130
|
+
info: info,
|
|
131
|
+
config: config,
|
|
132
|
+
mainTokenShare: mainTokenShare,
|
|
133
|
+
mainTokenShareSupply: mainTokenShareSupply,
|
|
134
|
+
hedgeTokenShare: hedgeTokenShare,
|
|
135
|
+
hedgeTokenShareSupply: hedgeTokenShareSupply,
|
|
136
|
+
rewardTokenShare: rewardTokenShare,
|
|
137
|
+
rewardTokenShareSupply: rewardTokenShareSupply,
|
|
138
|
+
u64Padding: u64Padding,
|
|
139
|
+
bcsPadding: bcsPadding,
|
|
140
|
+
},
|
|
141
|
+
];
|
|
207
142
|
});
|
|
208
143
|
return [2 /*return*/, result];
|
|
209
144
|
}
|
|
@@ -219,10 +154,10 @@ function getShareData(config, input) {
|
|
|
219
154
|
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
220
155
|
transaction = new transactions_1.Transaction();
|
|
221
156
|
transaction.moveCall({
|
|
222
|
-
target: "".concat(config.package.
|
|
157
|
+
target: "".concat(config.package.hedge.hedge, "::view_function::get_user_share_data_bcs"),
|
|
223
158
|
typeArguments: [],
|
|
224
159
|
arguments: [
|
|
225
|
-
transaction.object(config.registry.
|
|
160
|
+
transaction.object(config.registry.hedge),
|
|
226
161
|
transaction.pure.address(input.user),
|
|
227
162
|
transaction.pure.vector("u64", input.indexes),
|
|
228
163
|
],
|
|
@@ -233,34 +168,21 @@ function getShareData(config, input) {
|
|
|
233
168
|
bytes = results[results.length - 1].returnValues[0][0];
|
|
234
169
|
reader = new bcs_1.BcsReader(new Uint8Array(bytes));
|
|
235
170
|
result = {};
|
|
236
|
-
reader.readVec(function (reader
|
|
237
|
-
reader.
|
|
238
|
-
var
|
|
239
|
-
|
|
240
|
-
|
|
171
|
+
reader.readVec(function (reader) {
|
|
172
|
+
reader.readULEB();
|
|
173
|
+
var index = reader.read64();
|
|
174
|
+
result[index] = {
|
|
175
|
+
index: index,
|
|
176
|
+
mainTokenShare: reader.readVec(function (reader) {
|
|
241
177
|
return reader.read64();
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
};
|
|
251
|
-
return {
|
|
252
|
-
user: user,
|
|
253
|
-
share: shareSupply,
|
|
254
|
-
u64Padding: reader.readVec(function (reader) {
|
|
255
|
-
return reader.read64();
|
|
256
|
-
}),
|
|
257
|
-
bcsPadding: reader.readVec(function (reader) {
|
|
258
|
-
return reader.read8();
|
|
259
|
-
}),
|
|
260
|
-
};
|
|
261
|
-
});
|
|
262
|
-
var index = input.indexes.pop();
|
|
263
|
-
result[index] = share;
|
|
178
|
+
}),
|
|
179
|
+
hedgeTokenShare: reader.readVec(function (reader) {
|
|
180
|
+
return reader.read64();
|
|
181
|
+
}),
|
|
182
|
+
rewardTokenShare: reader.readVec(function (reader) {
|
|
183
|
+
return reader.read64();
|
|
184
|
+
}),
|
|
185
|
+
};
|
|
264
186
|
});
|
|
265
187
|
return [2 /*return*/, result];
|
|
266
188
|
}
|
|
@@ -290,5 +290,7 @@ var pythId = {
|
|
|
290
290
|
eba0732395fae9dec4bae12e52760b35fc1c5671e2da8b449c9af4efe5d54341: "WAL",
|
|
291
291
|
"4279e31cc369bbcc2faf022b382b080e32a8e689ff20fbc530d2a603eb6cd98b": "HYPE",
|
|
292
292
|
ec5d399846a9209f3fe5881d70aae9268c94339ff9817e8d18ff19fa05eea1c8: "XRP",
|
|
293
|
+
e67d98cc1fbd94f569d5ba6c3c3c759eb3ffc5d2b28e64538a53ae13efad8fd1: "HAEDAL",
|
|
294
|
+
ef2c98c804ba503c6a707e38be4dfbb16683775f195b091252bf24693042fd52: "USDJPY",
|
|
293
295
|
};
|
|
294
296
|
// getPythLatestPrice();
|