Canto Liquidity Mining Protocol - hihen's results

Execution layer for original work.

General Information

Platform: Code4rena

Start Date: 03/10/2023

Pot Size: $24,500 USDC

Total HM: 6

Participants: 62

Period: 3 days

Judge: LSDan

Total Solo HM: 3

Id: 288

League: ETH

Canto

Findings Distribution

Researcher Performance

Rank: 20/62

Findings: 1

Award: $92.09

Gas:
grade-a

🌟 Selected for report: 0

šŸš€ Solo Findings: 0

Findings Information

Awards

92.085 USDC - $92.09

Labels

bug
G (Gas Optimization)
grade-a
sufficient quality report
G-08

External Links

Summary

Total 12 instances over 3 issueswith 382 gas saved:

IDIssueInstancesGas
[G‑01]Use unchecked block for safe subtractions4340
[G‑02]Do not cache state variables that are used only once26
[G‑03]Using assembly to check for zero can save gas636

Gas Optimizations

[G‑01] Use unchecked block for safe subtractions

If it can be confirmed that the subtraction operation will not overflow, using an unchecked block can save gas. For example, require(x <= y); z = y - x; can be optimized to require(x <= y); unchecked { z = y - x; }.

There are 4 instances:

/// @audit checked on line 50
56:                         : block.timestamp - time

/// @audit checked on line 94
101:                             : block.timestamp - time

/// @audit checked on line 207
213:                         : block.timestamp - time

/// @audit checked on line 237
243:                         : block.timestamp - time

[G‑02] Do not cache state variables that are used only once

It's cheaper to access the state variable directly if it is accessed only once. This can save the 3 gas cost of the extra stack allocation.

There are 2 instances:

169:         CurveMath.CurveState memory curve = curves_[poolIdx];

261:         CurveMath.CurveState memory curve = curves_[poolIdx];

[G‑03] Using assembly to check for zero can save gas

Using assembly to check for zero can save gas by allowing more direct access to the evm and reducing some of the overhead associated with high-level operations in solidity.

There are 6 instances:

47:         if (lastAccrued != 0) {

86:         if (lastAccrued != 0) {

114:                         if (tickTracking.exitTimestamp == 0) {

142:                     if (tickTracking_[poolIdx][i][numTickTracking - 1].exitTimestamp == 0) {

204:         if (lastAccrued != 0) {

233:         if (lastAccrued != 0) {

#0 - c4-pre-sort

2023-10-09T17:16:48Z

141345 marked the issue as sufficient quality report

#1 - c4-judge

2023-10-18T23:44:07Z

dmvt 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