File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ struct Validator {
9
9
bool jailed;
10
10
string moniker;
11
11
uint64 commission;
12
+ uint64 apy;
12
13
}
13
14
14
15
struct Delegation {
@@ -25,7 +26,9 @@ contract HubReader {
25
26
}
26
27
27
28
/*
28
- * @dev Get validators by offset and limit (pagination)
29
+ * @dev Get validators by offset and limit (pagination), this is an intense function that execution might revert if limit is too large
30
+ * for some node, the best way to call it is to use a batch JSON RPC calls with proper pagination (e.g. 15 or 20 validators per call)
31
+
29
32
* @param offset The offset to query validators
30
33
* @param limit The limit to query validators
31
34
*
@@ -55,9 +58,14 @@ contract HubReader {
55
58
operatorAddress: operatorAddrs[i],
56
59
moniker: moniker,
57
60
commission: rate,
58
- jailed: jailed
61
+ jailed: jailed,
62
+ apy: 0
59
63
});
60
64
}
65
+ uint64 [] memory apys = this .getAPYs (operatorAddrs, block .timestamp );
66
+ for (uint256 i = 0 ; i < validatorCount; i++ ) {
67
+ validators[i].apy = apys[i];
68
+ }
61
69
return validators;
62
70
}
63
71
@@ -123,11 +131,14 @@ contract HubReader {
123
131
operatorAddrs[i],
124
132
dayIndex
125
133
);
134
+ if (total == 0 ) {
135
+ continue ;
136
+ }
126
137
uint256 reward = stakeHub.getValidatorRewardRecord (
127
138
operatorAddrs[i],
128
139
dayIndex
129
140
);
130
- if (total == 0 || reward == 0 ) {
141
+ if (reward == 0 ) {
131
142
continue ;
132
143
}
133
144
apys[i] = uint64 ((reward * 365 * 10000 ) / total);
You can’t perform that action at this time.
0 commit comments