/**
* @notice This method allows eligible VE shareholders to claim their revenue rewards by account.
* @param account Address of shareholder that is claiming rewards.
*/
function claimETH(address account) external returns (uint256 amount) {
require(account == msg.sender, "RevenueStreamETH: Not authorized");
uint256 cycle = currentCycle();
uint256[] memory cyclesClaimable;
uint256[] memory amountsClaimable;
uint256 num;
(amount, cyclesClaimable, amountsClaimable, num) = _claimable(account);
require(amount > 0, "no claimable amount");
lastClaim[account] = cycle;
for (uint256 i; i < num;) {
revenueClaimed[cyclesClaimable[i]] += amountsClaimable[i];
unchecked {
++i;
}
}
(bool sent,) = payable(msg.sender).call{value: amount}("");
if (!sent) revert ETHTransferFailed(msg.sender, amount);
emit RevenueClaimed(msg.sender, account, cycle, amount);
}
Recommendation:
We advise the code of the internal functions referenced to immediately update the revenueClaimed and expiredRevClaimed values, thereby rendering the arrays as well as lengths yielded redundant and significantly optimizing the overall function flows.
RSE-02C: Inefficient Claim/Expiry Processing System
Description:
The
RevenueStreamETH::claimETH
andRevenueStreamETH::skimExpiredRevenue
functions are significantly inefficient as they will maintain multiple arrays within theirRevenueStreamETH::_claimable
andRevenueStreamETH::_checkForExpiredRevenue
functions respectively that will be iterated once again redundantly.Example:
Recommendation:
We advise the code of the
internal
functions referenced to immediately update therevenueClaimed
andexpiredRevClaimed
values, thereby rendering the arrays as well as lengths yielded redundant and significantly optimizing the overall function flows.