Platform: Code4rena
Start Date: 08/05/2023
Pot Size: $90,500 USDC
Total HM: 17
Participants: 102
Period: 7 days
Judge: 0xean
Total Solo HM: 4
Id: 236
League: ETH
Rank: 67/102
Findings: 1
Award: $56.63
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: brgltd
Also found by: 0x73696d616f, 0xAce, 0xSmartContract, 0xWaitress, 0xkazim, 0xnev, Aymen0909, BGSecurity, Bauchibred, Cayo, ChrisTina, Franfran, IceBear, Infect3d, Kose, Lilyjjo, PNS, RaymondFam, Sathish9098, Team_Rocket, Udsen, YakuzaKiawe, YoungWolves, berlin-101, bin2chen, btk, codeslide, fatherOfBlocks, frazerch, kodyvim, koxuan, lfzkoala, lukris02, matrix_0wl, nadin, naman1778, sashik_eth, tnevler, volodya, wonjun, yjrwkk
56.6347 USDC - $56.63
Context:
emit BadDebtRecovered(badDebtOld, badDebtNew);
L496Description:
in all contracts more often "old" and "new" placed at the beginning of variable names. Examples:
emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);
L791emit NewMinLiquidatableCollateral(oldMinLiquidatableCollateral, newMinLiquidatableCollateral);
L917emit NewProtocolSeizeShare(oldProtocolSeizeShareMantissa, newProtocolSeizeShareMantissa_);
L319Recommendation:
Change variable name of "badDebtOld" and "badDebtNew" to "oldBadDebt" and "newBadDebt".
Context:
require(newComptroller.isComptroller(), "marker method returned false");
L1141Context:
Description:
Scientific notation should be used for better code readability.
Context:
function setCloseFactor(uint256 newCloseFactorMantissa) external {
L702function setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external {
L779function setMinLiquidatableCollateral(uint256 newMinLiquidatableCollateral) external {
L912function setPriceOracle(PriceOracle newOracle) external onlyOwner {
L961function _setComptroller(ComptrollerInterface newComptroller) internal {
L1138function _setShortfallContract(address shortfall_) internal {
L1398function _setProtocolShareReserve(address payable protocolShareReserve_) internal {
L1407function _setShortfallContract(Shortfall shortfall_) internal {
L421function _setProtocolShareReserve(address payable protocolShareReserve_) internal {
L430function setPoolRegistry(address _poolRegistry) external onlyOwner {
L99function setPancakeSwapRouter(address pancakeSwapRouter_) external onlyOwner {
L126function setMinAmountToConvert(uint256 minAmountToConvert_) external {
L137function setPoolRegistry(address _poolRegistry) external onlyOwner {
L53function _setMaxLoopsLimit(uint256 limit) internal {
L25Recommendation:
Example how to fix require(_newOwner != owner, " Same address");
Context:
function setCloseFactor(uint256 newCloseFactorMantissa) external {
L702function setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external {
L779function setMinLiquidatableCollateral(uint256 newMinLiquidatableCollateral) external {
L912function setPriceOracle(PriceOracle newOracle) external onlyOwner {
L961function _setComptroller(ComptrollerInterface newComptroller) internal {
L1138function _setShortfallContract(address shortfall_) internal {
L1398function _setProtocolShareReserve(address payable protocolShareReserve_) internal {
L1407function _setShortfallContract(Shortfall shortfall_) internal {
L421function _setProtocolShareReserve(address payable protocolShareReserve_) internal {
L430function setPoolRegistry(address _poolRegistry) external onlyOwner {
L99function setPancakeSwapRouter(address pancakeSwapRouter_) external onlyOwner {
L126function setMinAmountToConvert(uint256 minAmountToConvert_) external {
L137function setPoolRegistry(address _poolRegistry) external onlyOwner {
L53function _setMaxLoopsLimit(uint256 limit) internal {
L25Description:
It is a good practice to give time for users to react and adjust to critical changes. It also indicates that the project is legitimate (less risk of a malicious owner making a sandwich attack on a user).
Context:
All contracts.
Recommendation:
Example:
Instead of import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
You can do your imports like this:
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"
;
Context:
function updateMarketBorrowIndex(
L453function updateMarketSupplyIndex(
L475function calculateBorrowerReward(
L495function calculateSupplierReward(
L516IRiskFund private riskFund;
L51uint256 private incentiveBps;
L57uint256 private constant MAX_BPS = 10000;
L60Comptroller private comptroller;
L52address private pancakeSwapRouter;
L29uint256 private minAmountToConvert;
L30address private convertibleBaseAsset;
L31address private shortfall;
L32uint256 internal constant borrowRateMaxMantissa = 0.0005e16;
L53uint256 internal constant reserveFactorMaxMantissa = 1e18;
L56uint256 internal initialExchangeRateMantissa;
L69mapping(address => uint256) internal accountTokens;
L107mapping(address => mapping(address => uint256)) internal transferAllowances;
L110mapping(address => BorrowSnapshot) internal accountBorrows;
L113uint256 internal constant expScale = 1e18;
L20uint256 internal constant doubleScale = 1e36;
L21uint256 internal constant halfExpScale = expScale / 2;
L22uint256 internal constant mantissaOne = expScale;
L23function truncate(Exp memory exp) internal pure returns (uint256) {
L29function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {
L38function mul_ScalarTruncateAddUInt(
L47function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {
L59function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {
L63function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {
L68function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {
L73function add_(Double memory a, Double memory b) internal pure returns (Double memory) {
L77function add_(uint256 a, uint256 b) internal pure returns (uint256) {
L81function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {
L85function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {
L89function sub_(uint256 a, uint256 b) internal pure returns (uint256) {
L93function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {
L97function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {
L101function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {
L105function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {
L109function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {
L113function mul_(uint256 a, Double memory b) internal pure returns (uint256) {
L117function mul_(uint256 a, uint256 b) internal pure returns (uint256) {
L121function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {
L125function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {
L129function div_(uint256 a, Exp memory b) internal pure returns (uint256) {
L133function div_(Double memory a, Double memory b) internal pure returns (Double memory) {
L137function div_(Double memory a, uint256 b) internal pure returns (Double memory) {
L141function div_(uint256 a, Double memory b) internal pure returns (uint256) {
L145function div_(uint256 a, uint256 b) internal pure returns (uint256) {
L149function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {
L153uint256 private constant BASE = 1e18;
L13RewardsDistributor[] internal rewardsDistributors;
L98mapping(address => bool) internal rewardsDistributorExists;
L101uint256 internal constant NO_ERROR = 0;
L103uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05
L106uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9
L109uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9
L112address private protocolIncome;
L15address private riskFund;
L16uint256 private constant protocolSharePercentage = 70;
L18uint256 private constant baseUnit = 100;
L19uint256 private constant BASE = 1e18;
L12mapping(address => uint256) internal assetsReserves;
L13mapping(address => mapping(address => uint256)) internal poolsAssetsReserves;
L17address internal poolRegistry;
L20Description:
Internal and private functions, state variables, constants, and immutables should starting with an underscore.
Context:
function initialize(uint256 loopLimit, address accessControlManager) external initializer {
L138function initialize(
L59function initialize(
L131function initialize(
L111function initialize(
L164function initialize(
L73function initialize(address _protocolIncome, address _riskFund) external initializer {
L39Recommendation:
Define an initialize event and emit that at the end of initialize() function.
Context:
event AmountOutMinUpdated(uint256 oldAmountOutMin, uint256 newAmountOutMin);
L47Description:
There is the event defined that is never emitted and it can be removed.
#0 - c4-judge
2023-05-18T18:36:24Z
0xean marked the issue as grade-b