File tree 1 file changed +12
-12
lines changed
1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -174,27 +174,27 @@ contract StakingRewardsV2 is
174
174
175
175
/// @inheritdoc IStakingRewardsV2
176
176
function totalSupply () public view returns (uint256 ) {
177
- uint256 length = totalSupplyCheckpoints.length ;
178
- unchecked {
179
- return length == 0 ? 0 : totalSupplyCheckpoints[length - 1 ].value;
180
- }
177
+ return _getLatestValueFromCheckpoints (totalSupplyCheckpoints);
181
178
}
182
179
183
180
/// @inheritdoc IStakingRewardsV2
184
181
function balanceOf (address _account ) public view returns (uint256 ) {
185
- Checkpoint[] storage checkpoints = balancesCheckpoints[_account];
186
- uint256 length = checkpoints.length ;
187
- unchecked {
188
- return length == 0 ? 0 : checkpoints[length - 1 ].value;
189
- }
182
+ return _getLatestValueFromCheckpoints (balancesCheckpoints[_account]);
190
183
}
191
184
192
185
/// @inheritdoc IStakingRewardsV2
193
186
function escrowedBalanceOf (address _account ) public view returns (uint256 ) {
194
- Checkpoint[] storage checkpoints = escrowedBalancesCheckpoints[_account];
195
- uint256 length = checkpoints.length ;
187
+ return _getLatestValueFromCheckpoints (escrowedBalancesCheckpoints[_account]);
188
+ }
189
+
190
+ function _getLatestValueFromCheckpoints (Checkpoint[] storage _checkpoints )
191
+ internal
192
+ view
193
+ returns (uint256 )
194
+ {
195
+ uint256 length = _checkpoints.length ;
196
196
unchecked {
197
- return length == 0 ? 0 : checkpoints [length - 1 ].value;
197
+ return length == 0 ? 0 : _checkpoints [length - 1 ].value;
198
198
}
199
199
}
200
200
You can’t perform that action at this time.
0 commit comments