veRWA - windhustler's results

Incentivization Primitive for Real World Assets on Canto

General Information

Platform: Code4rena

Start Date: 07/08/2023

Pot Size: $36,500 USDC

Total HM: 11

Participants: 125

Period: 3 days

Judge: alcueca

Total Solo HM: 4

Id: 274

League: ETH

Canto

Findings Distribution

Researcher Performance

Rank: 59/125

Findings: 1

Award: $9.82

QA:
grade-a

🌟 Selected for report: 0

🚀 Solo Findings: 0

VotingEscrow.sol

  • LockAction.INCREASE_TIME and LockAction.QUIT are not used anywhere in the contract. They can be removed.

  • _checkpoint function consider splitting the whole function into checkpoint individual and checkpoint global functions. This makes the code more readable and since the global state is not used anywhere except for the view functions it makes sense to split it.

  • userOldPoint.slope and userNewPoint.slope calculations result in loss of precision. Consider multiplying the delegated amount with a multiplier(scaling before division) and using it as such through the codebase. And then dividing it back when needed to preserve accuracy. See Uniswap's approach.

  • Remove redundant code Setting the userPointHistory[_addr][uEpoch + 1] twice is redundant since there is no else statement, the second assignment will always be executed.

  • lastPoint can be written more concisely and save some gas as:

Point memory lastPoint;
if (epoch > 0) {
    lastPoint = pointHistory[epoch];
} else {
    lastPoint = Point({bias: 0, slope: 0, ts: block.timestamp, blk: block.number});
}
require(locked_.amount == 0, "Lock exists");
// Update lock and voting power (checkpoint)
locked_.amount = int128(int256(_value));

GaugeController.sol

struct VotedSlope {
        uint256 slope;
        uint240 end; // Max value is restricted by some time in the future so uint240 is enough.
        uint16 power; // Max value is 10000 so uint16 is enough.
    }
time_sum = (block.timestamp / WEEK) * WEEK;
if (t > block.timestamp) {
    time_sum = t;
    break;
}
if (t > block.timestamp) {
    time_weight[_gauge_addr] = t;
    break;
}

#0 - c4-judge

2023-08-22T13:59:17Z

alcueca marked the issue as grade-a

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter