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: 74/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
// Percentage of funds not sent to the RiskFund contract when the funds are released, following the project Tokenomics uint256 private constant protocolSharePercentage = 70; uint256 private constant baseUnit = 100;
Since the unit is used to calculate the ratio to send to protocolIncome / riskFund, right now with 2 decimals if the protocolIncome would have at worst, a floor down of 1%. It is advised to raise the decimals to at least 4-5 so the protocolIncome would not get impacted by division math.
uint256 protocolIncomeAmount = mul_( Exp({ mantissa: amount }), div_(Exp({ mantissa: protocolSharePercentage * expScale }), baseUnit) ).mantissa;
for (uint256 i; i < marketsCount; ++i) { VToken vToken = VToken(address(auction.markets[i])); IERC20Upgradeable erc20 = IERC20Upgradeable(address(vToken.underlying())); if (auction.auctionType == AuctionType.LARGE_POOL_DEBT) { if (auction.highestBidder != address(0)) { uint256 previousBidAmount = ((auction.marketDebt[auction.markets[i]] * auction.highestBidBps) / MAX_BPS); erc20.safeTransfer(auction.highestBidder, previousBidAmount); } uint256 currentBidAmount = ((auction.marketDebt[auction.markets[i]] * bidBps) / MAX_BPS); erc20.safeTransferFrom(msg.sender, address(this), currentBidAmount);
Recommendation
+++ if (auction.marketDebt[auction.markets[i]] >0) ....
--- \n
https://github.com/code-423n4/2023-05-venus/blob/main/contracts/Comptroller.sol#L930-L940
function addRewardsDistributor(RewardsDistributor _rewardsDistributor) external onlyOwner { require(!rewardsDistributorExists[address(_rewardsDistributor)], "already exists"); uint256 rewardsDistributorsLength = rewardsDistributors.length; @> for (uint256 i; i < rewardsDistributorsLength; ++i) { address rewardToken = address(rewardsDistributors[i].rewardToken()); require( rewardToken != address(_rewardsDistributor.rewardToken()), "distributor already exists with this reward" ); } uint256 rewardsDistributorsLen = rewardsDistributors.length; @>
Recommendation remove rewardsDistributorsLen on the second occurrence.
#0 - c4-judge
2023-05-18T18:45:22Z
0xean marked the issue as grade-b