Summary
The deposit function in the StabilityPool contract contains redundant state update calls through both _update() and _mintRAACRewards() functions, which perform the same operations, leading to unnecessary gas consumption.
Vulnerability Details
function deposit(uint256 amount) external nonReentrant whenNotPaused validAmount(amount) {
_update(); <==@found
rToken.safeTransferFrom(msg.sender, address(this), amount);
uint256 deCRVUSDAmount = calculateDeCRVUSDAmount(amount);
deToken.mint(msg.sender, deCRVUSDAmount);
userDeposits[msg.sender] += amount;
_mintRAACRewards(); <==@found
emit Deposit(msg.sender, amount, deCRVUSDAmount);
}
Impact
Tools Used
Recommendations
Remove one of the redundant calls, preferably keep _mintRAACRewards() as it's more descriptive:
function deposit(uint256 amount) external nonReentrant whenNotPaused validAmount(amount) {
- _update();
rToken.safeTransferFrom(msg.sender, address(this), amount);
uint256 deCRVUSDAmount = calculateDeCRVUSDAmount(amount);
deToken.mint(msg.sender, deCRVUSDAmount);
userDeposits[msg.sender] += amount;
_mintRAACRewards();
emit Deposit(msg.sender, amount, deCRVUSDAmount);
}