_requireCallerIsTMLorSP() is unnecessary as it's being used only once. Therefore it can be inlined in returnFromPool() to make the code simpler and save gas.
Recommendation
Change to:
function returnFromPool(address _poolAddress, address _receiver, uint256 _amount) external override {
require(
msg.sender == stabilityPoolAddress || msg.sender == troveManagerLiquidationsAddress,
"YUSD: Caller is neither TroveManagerLiquidator nor StabilityPool");
_transfer(_poolAddress, _receiver, _amount);
}
Other examples include:
TroveManagerRedemptions.sol#_getRedemptionFee() can be inlined in TroveManagerRedemptions.sol#redeemCollateral()
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-12-yetifinance/blob/5f5bf61209b722ba568623d8446111b1ea5cb61c/packages/contracts/contracts/YUSDToken.sol#L297-L301
https://github.com/code-423n4/2021-12-yetifinance/blob/5f5bf61209b722ba568623d8446111b1ea5cb61c/packages/contracts/contracts/YUSDToken.sol#L128-L131
_requireCallerIsTMLorSP()
is unnecessary as it's being used only once. Therefore it can be inlined inreturnFromPool()
to make the code simpler and save gas.Recommendation
Change to:
Other examples include:
TroveManagerRedemptions.sol#_getRedemptionFee()
can be inlined inTroveManagerRedemptions.sol#redeemCollateral()