Platform: Code4rena
Start Date: 12/04/2023
Pot Size: $60,500 USDC
Total HM: 21
Participants: 199
Period: 7 days
Judge: hansfriese
Total Solo HM: 5
Id: 231
League: ETH
Rank: 117/199
Findings: 1
Award: $22.60
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: juancito
Also found by: 0xAgro, 0xNorman, 0xSmartContract, 0xStalin, 0xTheC0der, 0xWaitress, 0xhacksmithh, 0xnev, 3dgeville, 8olidity, Arz, Aymen0909, BGSecurity, BRONZEDISC, Bauchibred, Bauer, BenRai, ChainHunters, ChrisTina, CodeFoxInc, DedOhWale, DishWasher, EloiManuel, IceBear, Inspex, Jorgect, Kaysoft, LeoGold, LewisBroadhurst, Madalad, MiloTruck, MohammedRizwan, Nyx, Polaris_tow, RaymondFam, SaharDevep, SanketKogekar, Sathish9098, SolidityATL, Udsen, W0RR1O, aria, ayden, berlin-101, bin2chen, catellatech, codeslide, crc32, decade, descharre, evmboi32, eyexploit, fatherOfBlocks, georgits, giovannidisiena, joestakey, karanctf, kodyvim, ltyu, lukris02, m9800, matrix_0wl, mov, mrpathfindr, nadin, niser93, p0wd3r, parlayan_yildizlar_takimi, pavankv, pontifex, qpzm, ravikiranweb3, rbserver, santipu_, shealtielanz, slvDev, tnevler, wonjun, xmxanuel, yixxas
22.6007 USDC - $22.60
Context:
totalVotesAtAnchor = uint192(totalVotes() - roundingLoss - lostVotes);
L146voteAnchor[to] = uint64(anchorTime() - recipientVotes / newbalance); // new example anchor is only 21 / 11 = 1 block in the past
L161Description:
While Solidity 0.8.x checks for overflows on arithmetic operations, it does not do so for casting.
Recommendation:
Use OpenZeppelin’s SafeCast library to prevent unexpected overflows.
Context:
IPositionFactory private immutable POSITION_FACTORY; // position contract to clone
L28 (Local and State Variable should use mixedCase)uint256 public immutable MIN_APPLICATION_PERIOD; // for example 10 days
L26 (Local and State Variable should use mixedCase)function DOMAIN_SEPARATOR() public view returns (bytes32) {
L61 (Functions should use mixedCase)Description:
The above codes don't follow Solidity's standard naming convention.
Context:
function collateralBalance() internal view returns (uint256){
L169function mintInternal(address target, uint256 amount, uint256 collateral_) internal {
L193function restrictMinting(uint256 period) internal {
L202function repayInternal(uint256 burnable) internal {
L232function notifyRepaidInternal(uint256 amount) internal {
L240function internalWithdrawCollateral(address target, uint256 amount) internal returns (uint256) {
L268function checkCollateral(uint256 collateralReserve, uint256 atPrice) internal view {
L282function emitUpdate() internal {
L286IPositionFactory private immutable POSITION_FACTORY; // position contract to clone
L28function minBid(Challenge storage challenge) internal view returns (uint256) {
L188function returnCollateral(Challenge storage challenge, bool postpone) internal {
L287uint256 private minterReserveE6;
L39function allowanceInternal(address owner, address spender) internal view override returns (uint256) {
L102function mintInternal(address target, uint256 amount) internal {
L49function burnInternal(address zchfHolder, address target, uint256 amount) internal {
L67function createClone(address target) internal returns (address result) {
L37uint256 internal constant ONE_DEC18 = 10**18;
L10uint256 internal constant THRESH_DEC18 = 10000000000000000;//0.01
L11function setOwner(address newOwner) internal {
L39function requireOwner(address sender) internal view {
L45uint256 private constant MINIMUM_EQUITY = 1000 * ONE_DEC18;
L41uint32 private constant QUORUM = 300;
L46uint8 private constant BLOCK_TIME_RESOLUTION_BITS = 24;
L51uint192 private totalVotesAtAnchor; // Total number of votes at the anchor time, see comment on the um
L75uint64 private totalVotesAnchorTime; // 40 Bit for the block number, 24 Bit sub-block time resolution
L76mapping (address => uint64) private voteAnchor; // 40 Bit for the block number, 24 Bit sub-block time resolution
L88function adjustTotalVotes(address from, uint256 amount, uint256 roundingLoss) internal {
L144function adjustRecipientVoteAnchor(address to, uint256 amount) internal returns (uint256){
L157function anchorTime() internal view returns (uint64){
L172function canVoteFor(address delegate, address owner) internal view returns (bool) {
L225function calculateSharesInternal(uint256 capitalBefore, uint256 investment) internal view returns (uint256) {
L266uint256 internal constant INFINITY = (1 << 255);
L47function allowanceInternal(address owner, address spender) internal view virtual returns (uint256) {
L97Description:
Internal and private functions, state variables, constants, and immutables should starting with an underscore.
Context:
function initializeClone(address owner, uint256 _price, uint256 _limit, uint256 _coll, uint256 _mint) external onlyHub {
L76function notifyChallengeSucceeded(address _bidder, uint256 _bid, uint256 _size) external onlyHub returns (address, uint256, uint256, uint256, uint32) {
L329function clonePosition(address position, uint256 _initialCollateral, uint256 _initialMint) public validPos(position) returns (address) {
L124function launchChallenge(address _positionAddr, uint256 _collateralAmount) external validPos(_positionAddr) returns (uint256) {
L140function suggestMinter(address _minter, uint256 _applicationPeriod, uint256 _applicationFee, string calldata _message) override external {
L83function burnFrom(address payer, uint256 targetTotalBurnAmount, uint32 _reservePPM) external override minterOnly returns (uint256) {
L223function calculateFreedAmount(uint256 amountExcludingReserve /* 41 */, uint32 reservePPM /* 20% */) public view returns (uint256){
L235function burnWithReserve(uint256 _amountExcludingReserve, uint32 _reservePPM) external override minterOnly returns (uint256) {
L251Description:
According to official solidity documentation:
Context:
function notifyChallengeSucceeded(address _bidder, uint256 _bid, uint256 _size) external onlyHub returns (address, uint256, uint256, uint256, uint32) {
L329Description:
According to official solidity documentation multiline output parameters and return statements should follow the same style recommended for wrapping long lines found in the Maximum Line Length section.
Recommendation:
Example:
function thisFunctionNameIsReallyLong( address a, address b, address c ) public returns ( address someAddressName, uint256 LongArgument, uint256 Argument ) { doSomething() return ( veryLongReturnArg1, veryLongReturnArg2, veryLongReturnArg3 ); }
Context:
modifier alive() {
L366 (modifiers must be before all functions)modifier noCooldown() {
L373 (modifiers must be before all functions)modifier noChallenge() {
L380 (modifiers must be before all functions)modifier onlyHub() {
L387 (modifiers must be before all functions)modifier validPos(address position) {
L115 (modifiers must be before all functions)modifier minterOnly() {
L266 (modifiers must be before all functions)modifier onlyOwner() {
L49 (modifiers must be before all functions)Description: According to official solidity documentation inside each contract, library or interface, use the following order:
Context:
function adjustTotalVotes(address from, uint256 amount, uint256 roundingLoss) internal {
L144 (param roundingLoss is missing)#0 - 0xA5DF
2023-04-27T10:04:03Z
L1 is dupe #393
#1 - c4-judge
2023-05-16T16:35:13Z
hansfriese marked the issue as grade-b