@typus/typus-sdk 1.4.78 → 1.4.79
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.
|
@@ -10,13 +10,13 @@ export declare function getVeTypus(config: TypusConfig, input: {
|
|
|
10
10
|
user: string;
|
|
11
11
|
}): Promise<VeTypus[]>;
|
|
12
12
|
export interface VeTypusInfo {
|
|
13
|
-
veTypusAmount: string;
|
|
14
|
-
veTypus: VeTypus[];
|
|
15
13
|
totalVeTypusAmount: string;
|
|
16
14
|
totalStakedTypusAmount: string;
|
|
17
15
|
averageLockUpTime: string;
|
|
16
|
+
veTypusAmount: string;
|
|
17
|
+
veTypus: VeTypus[];
|
|
18
18
|
}
|
|
19
19
|
export declare function fetchVeTypusInfo(config: TypusConfig, input: {
|
|
20
|
-
user: string;
|
|
21
20
|
tsMs: string;
|
|
21
|
+
user?: string;
|
|
22
22
|
}): Promise<VeTypusInfo>;
|
|
@@ -76,60 +76,72 @@ function getVeTypus(config, input) {
|
|
|
76
76
|
}
|
|
77
77
|
function fetchVeTypusInfo(config, input) {
|
|
78
78
|
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var provider, transactionBlock, results, reader,
|
|
79
|
+
var provider, transactionBlock, results, reader, totalVeTypusAmount, totalStakedTypusAmount, averageLockUpTime, reader_1, veTypus, veTypusAmount;
|
|
80
80
|
return __generator(this, function (_a) {
|
|
81
81
|
switch (_a.label) {
|
|
82
82
|
case 0:
|
|
83
83
|
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
84
84
|
transactionBlock = new transactions_1.TransactionBlock();
|
|
85
|
-
transactionBlock.moveCall({
|
|
86
|
-
target: "".concat(config.package.launch.veTypus, "::ve_typus::get_ve_typus_bcs"),
|
|
87
|
-
arguments: [transactionBlock.object(config.registry.launch.veTypus), transactionBlock.pure(input.user)],
|
|
88
|
-
});
|
|
89
|
-
transactionBlock.moveCall({
|
|
90
|
-
target: "".concat(config.package.launch.veTypus, "::ve_typus::get_ve_typus"),
|
|
91
|
-
arguments: [
|
|
92
|
-
transactionBlock.object(config.registry.launch.veTypus),
|
|
93
|
-
transactionBlock.pure(input.user),
|
|
94
|
-
transactionBlock.pure(input.tsMs),
|
|
95
|
-
],
|
|
96
|
-
});
|
|
97
85
|
transactionBlock.moveCall({
|
|
98
86
|
target: "".concat(config.package.launch.veTypus, "::ve_typus::get_report"),
|
|
99
87
|
arguments: [transactionBlock.object(config.registry.launch.veTypus), transactionBlock.pure(input.tsMs)],
|
|
100
88
|
});
|
|
89
|
+
if (input.user) {
|
|
90
|
+
transactionBlock.moveCall({
|
|
91
|
+
target: "".concat(config.package.launch.veTypus, "::ve_typus::get_ve_typus_bcs"),
|
|
92
|
+
arguments: [transactionBlock.object(config.registry.launch.veTypus), transactionBlock.pure(input.user)],
|
|
93
|
+
});
|
|
94
|
+
transactionBlock.moveCall({
|
|
95
|
+
target: "".concat(config.package.launch.veTypus, "::ve_typus::get_ve_typus"),
|
|
96
|
+
arguments: [
|
|
97
|
+
transactionBlock.object(config.registry.launch.veTypus),
|
|
98
|
+
transactionBlock.pure(input.user),
|
|
99
|
+
transactionBlock.pure(input.tsMs),
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
}
|
|
101
103
|
return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: constants_1.SENDER, transactionBlock: transactionBlock })];
|
|
102
104
|
case 1:
|
|
103
105
|
results = (_a.sent()).results;
|
|
104
106
|
reader = new bcs_1.BcsReader(new Uint8Array(results[0].returnValues[0][0]));
|
|
105
107
|
reader.readULEB();
|
|
106
|
-
veTypus = reader.readVec(function (reader) {
|
|
107
|
-
reader.readULEB();
|
|
108
|
-
return {
|
|
109
|
-
id: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
|
|
110
|
-
balance: reader.read64(),
|
|
111
|
-
lockUpPeriod: reader.read64(),
|
|
112
|
-
createTsMs: reader.read64(),
|
|
113
|
-
updateTsMs: reader.read64(),
|
|
114
|
-
};
|
|
115
|
-
});
|
|
116
|
-
// @ts-ignore
|
|
117
|
-
reader = new bcs_1.BcsReader(new Uint8Array(results[1].returnValues[0][0]));
|
|
118
|
-
veTypusAmount = reader.read64();
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
reader = new bcs_1.BcsReader(new Uint8Array(results[2].returnValues[0][0]));
|
|
121
|
-
reader.readULEB();
|
|
122
108
|
totalVeTypusAmount = reader.read64();
|
|
123
109
|
totalStakedTypusAmount = reader.read64();
|
|
124
110
|
averageLockUpTime = ((BigInt(totalVeTypusAmount) * BigInt(4 * 365 * 24 * 60 * 60 * 1000)) /
|
|
125
111
|
BigInt(totalStakedTypusAmount)).toString();
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
112
|
+
if (input.user) {
|
|
113
|
+
reader_1 = new bcs_1.BcsReader(new Uint8Array(results[1].returnValues[0][0]));
|
|
114
|
+
reader_1.readULEB();
|
|
115
|
+
veTypus = reader_1.readVec(function (reader) {
|
|
116
|
+
reader.readULEB();
|
|
117
|
+
return {
|
|
118
|
+
id: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
|
|
119
|
+
balance: reader.read64(),
|
|
120
|
+
lockUpPeriod: reader.read64(),
|
|
121
|
+
createTsMs: reader.read64(),
|
|
122
|
+
updateTsMs: reader.read64(),
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
reader_1 = new bcs_1.BcsReader(new Uint8Array(results[2].returnValues[0][0]));
|
|
127
|
+
veTypusAmount = reader_1.read64();
|
|
128
|
+
return [2 /*return*/, {
|
|
129
|
+
totalVeTypusAmount: totalVeTypusAmount,
|
|
130
|
+
totalStakedTypusAmount: totalStakedTypusAmount,
|
|
131
|
+
averageLockUpTime: averageLockUpTime,
|
|
132
|
+
veTypusAmount: veTypusAmount,
|
|
133
|
+
veTypus: veTypus,
|
|
134
|
+
}];
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
return [2 /*return*/, {
|
|
139
|
+
totalVeTypusAmount: totalVeTypusAmount,
|
|
140
|
+
totalStakedTypusAmount: totalStakedTypusAmount,
|
|
141
|
+
averageLockUpTime: averageLockUpTime,
|
|
142
|
+
}];
|
|
143
|
+
}
|
|
144
|
+
return [2 /*return*/];
|
|
133
145
|
}
|
|
134
146
|
});
|
|
135
147
|
});
|