Light ModeLight
Light ModeDark

One Bug Per Day

One H/M every day from top Wardens

Checkmark

Join over 1125 wardens!

Checkmark

Receive the email at any hour!

Ad

Lack of update when modifying pool fee

mediumCode4rena

Lines of code

https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/FeeManager/FeeManager.sol#L135 https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/FeeManager/FeeManager.sol#L108 https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseLending.sol#L97 https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/MainHelper.sol#L500

Vulnerability details

Vulnerability Details:

The FeeManager contract allows the master address to modify the pool fee, this can be done to a single pool using the setPoolFee function or multiple pools at once using the setPoolFeeBulk function. This fee is used in the the syncPool modifier, specifically the _updatePseudoTotalAmounts function which updates the interest amounts of the borrow and lending pools.

solidity
function setPoolFee( address _poolToken, uint256 _newFee ) external onlyMaster { _checkValue( _newFee ); WISE_LENDING.setPoolFee( _poolToken, _newFee ); emit PoolFeeChanged( _poolToken, _newFee, block.timestamp ); }

The issue is that the setPoolFee function modifies the pool fee without invoking the syncPool modifier beforehand. Consequently, the next sync operation incorrectly applies the updated pool fee to the period between the previous call and the change in the pool fee. Although the impact of changing the fee for a single pool may be minimal, using the setPoolFeeBulk function to alter fees for multiple pools could have a bigger impact.

Impact:

Severity: Medium. Depending on whether the pool fee is increased or decreased, the protocol or its users may end up paying additional fees or receiving reduced fees.

Likelihood: Low. This situation arises solely in instances where there is a change in the pool fee.

Tools Used:

Manual analysis

Recommendation:

Add the following code to update fees accurately before implementing changes.

solidity
function setPoolFee( address _poolToken, uint256 _newFee ) external onlyMaster { WISE_LENDING.syncManually(_poolToken); //add here _checkValue( _newFee ); WISE_LENDING.setPoolFee( _poolToken, _newFee ); emit PoolFeeChanged( _poolToken, _newFee, block.timestamp ); }

Assessed type

Context