Category: Coding Mistakes
Incorrect return value in claimableRewardAfterBoost
Informational Severity
Informational Impact
Medium Likelihood
Description
There are two issues in the return value of the function claimableRewardAfterBoost
:
function claimableRewardAfterBoost(
address account,
address boostDelegate,
IRewards rewardContract
) external view returns (uint256 adjustedAmount, uint256 feeToDelegate) {
uint256 amount = rewardContract.claimableReward(account);
uint256 week = getWeek();
uint256 totalWeekly = weeklyEmissions[week];
address claimant = boostDelegate == address(0) ? account : boostDelegate;
uint256 previousAmount = accountWeeklyEarned[claimant][week];
uint256 fee;
if (boostDelegate != address(0)) {
Delegation memory data = boostDelegation[boostDelegate];
if (!data.isEnabled) return (0, 0);
fee = data.feePct;
if (fee == type(uint16).max) {
try data.callback.getFeePct(claimant, amount, previousAmount, totalWeekly) returns (uint256) {} catch {
return (0, 0);
}
}
if (fee >= 10000) return (0, 0);
}
adjustedAmount = boostCalculator.getBoostedAmount(claimant, amount, previousAmount, totalWeekly);
fee = (adjustedAmount * fee) / 10000;
return (adjustedAmount, fee);
}
According to the comments of the
claimableRewardAfterBoost
function, the returned valueadjustedAmount
is the amount received after boost and delegate fees. Butfee
is not deducted from theadjustedAmount
before this value is returned.
As a fee equaling 10,000 is acceptable by the contract, the function should not return (0,0) when the fee is equal to 10,000.
Impact
Incorrect values will be reported to the users.
Recommendations
Consider implementing the following changes.
- if (fee >= 10000) return (0, 0);
+ if (fee > 10000) return (0, 0);
}
adjustedAmount = boostCalculator.getBoostedAmount(claimant, amount, previousAmount, totalWeekly);
fee = (adjustedAmount * fee) / 10000;
+ adjustedAmount -= fee;
return (adjustedAmount, fee);
Remediation
This issue has been acknowledged by Prisma Finance, and a fix was implemented in commits and .