BasicSpell.doCutRewardsFee uses depositFee instead of withdraw fee
The function that deducts a fee from farming rewards uses the deposit fee rate instead of the withdraw fee rate. This causes the wrong fee amount to be taken from rewards.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-02-blueberry-judging/issues/82
Found by
rvierdiiev
Summary
BasicSpell.doCutRewardsFee uses depositFee instead of withdraw fee
Vulnerability Detail
https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/spell/BasicSpell.sol#L65-L79
function doCutRewardsFee(address token) internal {
if (bank.config().treasury() == address(0)) revert NO_TREASURY_SET();
uint256 balance = IERC20Upgradeable(token).balanceOf(address(this));
if (balance > 0) {
uint256 fee = (balance * bank.config().depositFee()) / DENOMINATOR;
IERC20Upgradeable(token).safeTransfer(
bank.config().treasury(),
fee
);
balance -= fee;
IERC20Upgradeable(token).safeTransfer(bank.EXECUTOR(), balance);
}
}
This function is called in order to get fee from ICHI rewards, collected by farming.
But currently it takes bank.config().depositFee() instead of bank.config().withdrawFee().
Impact
Wrong fee amount is taken.
Code Snippet
https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/spell/BasicSpell.sol#L65-L79
Tool used
Manual Review
Recommendation
Take withdraw fee from rewards.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The wrong fee amount is taken from rewards, which could result in users being overcharged or undercharged.
What the attacker needed
None
The fix
The function should use the withdraw fee instead of the deposit fee when cutting rewards.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract has a function that takes a fee from rewards earned by farming. It mistakenly uses the deposit fee percentage instead of the withdraw fee percentage. This means the fee charged is incorrect, which could be too high or too low.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.