Platform: Code4rena
Start Date: 29/03/2022
Pot Size: $30,000 USDC
Total HM: 6
Participants: 24
Period: 3 days
Judge: HardlyDifficult
Total Solo HM: 4
Id: 101
League: ETH
Rank: 21/24
Findings: 1
Award: $45.87
🌟 Selected for report: 0
🚀 Solo Findings: 0
45.8731 USDC - $45.87
This known issue was set before at :

https://github.com/code-423n4/2021-12-sublime-findings/issues/39


using new compiler will set Optimizer improvement for Safemath, Custom error, etc. it would be saving more gas by using it.


##Occurance

PooledCreditLine.sol LenderPool.sol
 twitterVerifier.sol

SafeERC20
to saving more gas

This implementation can be saving more gas 


##POC


by not declaring :
using SafeErc20 for IERC20
;


 and change into
SafeERC20.safeTransferFrom(IERC20(_borrowAsset), msg.sender, address(this), _amountToLend);



3. Rewrite struct order for saving more gas


this implementation below can be used for saving more gas


##Tool Used Manual Review
##POC
struct PooledCreditLineConstants { uint128 borrowLimit; uint128 borrowRate; uint256 startsAt; uint256 endsAt; uint256 defaultsAt; uint256 gracePenaltyRate; uint256 idealCollateralRatio; address borrower; address borrowAsset; address collateralAsset; address borrowAssetStrategy; address collateralAssetStrategy; }
this implementation with the same logic, can be used for saving more gas (+- 12 gas)
##Tool Used Remix
##POC
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; pragma abicoder v2; contract foo{ function isWithinLimits( uint256 _value, uint256 _min, uint256 _max ) internal pure returns (bool) { if (_min != 0 && _max != 0) { // If both min and max limits exist return (_value >= _min && _value <= _max); } else if (_min != 0) { // if only min limit exists return (_value >= _min); } else if (_max != 0) { // if only max limit exists return (_value <= _max); } else { // if both min and max limits don't exist return true; } } } // 67066
change to
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; pragma abicoder v2; contract foo{ function isWithinLimits( uint256 _value, uint256 _min, uint256 _max ) internal pure returns (bool) { if (_min != 0 && _max != 0) { return (_value >= _min && _value <= _max); } else if ( _min != 0 || _max != 0 ) { return (_value >= _min || _value <= _max); } else { // if both min and max limits don't exist return true; } } } // 67054
##POC
IVerification public immutable verification;
#0 - ritik99
2022-04-12T19:11:51Z
All except the first suggestions are valid. The first suggestion isn't valid for us because one of our dependencies is currently not compatible with v0.8 (see #67 )