Clearpool: CPOOL to CLEAR Token Swap
Cantina Security Report
Organization
- @clearpool
Engagement Type
Cantina Reviews
Period
-
Findings
Low Risk
1 findings
1 fixed
0 acknowledged
Informational
2 findings
1 fixed
1 acknowledged
Low Risk1 finding
owner and layerzero's delegate are not updated atomically
Severity
- Severity: Low
Submitted by
Om Parikh
Description
the
ownerand lz'sdelegateis same address_admin. howevertransferOwnershipand/orrenounceOwnershipdoesn't change it when updating owner.In several cases, old delegate can change config before
acceptOwnershiptransaction and may cause side effects, such as: `clear.transferOwnership(...)->endpoint.setConfig(CLEAR, ...)->clear.acceptOwnership(...)->clear.setDelegate(newOwner);
same is also true for
renounceOwnership.Recommendation
- override
acceptOwnershipto handle it atomically
+ /// @notice Accepts ownership and atomically transfers the LayerZero+ /// Endpoint delegate to the new owner.+ function acceptOwnership() public override {+ super.acceptOwnership();+ setDelegate(owner());+ }- since
renounceOwnershipcreates partial ownerless system, it can be mitigated by not allowing to renounce.
+ error OwnershipRenouncementDisabled();++ /// @notice Ownership renouncement is disabled because CLEAR requires+ /// an owner for minting, LayerZero configuration, and swapper control.+ function renounceOwnership() public pure override {+ revert OwnershipRenouncementDisabled();+ }
Informational2 findings
Code Style
State
- Acknowledged
Severity
- Severity: Informational
Submitted by
Red Swan
Description
Across
CLEAR.solandCPoolToClearSwapper.sol, several stylistic inconsistencies and missing NatSpec documentation items were identified:-
Non-Standard Immutable Naming (
UPPER_SNAKE_CASE):- According to the Solidity Style Guide, immutable variables and constants should follow
UPPER_SNAKE_CASE. - In
CLEAR.sol,swapperis declared in camelCase. - In
CPoolToClearSwapper.sol,oldCpoolandclearare declared in camelCase.
- According to the Solidity Style Guide, immutable variables and constants should follow
-
Function Ordering Violations in
CLEAR.sol:- The Solidity style convention recommends grouping functions by visibility:
external,public,internal, andprivate, with view/pure functions placed at the end of each section. - In
CLEAR.sol, the internal hook_updateprecedes the public functionsnoncesandtransferOwnership.
- The Solidity style convention recommends grouping functions by visibility:
-
Incomplete NatSpec Documentation:
- Constructors: Missing
@paramtags inCLEAR.sol(_lzEndpoint,_admin,_oldCpool) andCPoolToClearSwapper.sol(_oldCpool). - Internal / Helper Functions:
_checkClearOwnerinCPoolToClearSwapper.sollacks NatSpec documentation entirely. - Overrides: Overridden methods in
CLEAR.sol(_update,nonces,transferOwnership,_transferOwnership) omit@inheritdocor explanatory@devannotations detailing custom behavior (e.g., the recipient exclusion guard in_update).
- Constructors: Missing
-
Shadowing and Header Formatting Nits:
- Variable Shadowing: In
CLEAR.sol, theownerparameter ofnonces(address owner)shadowsOwnable.owner(). - Fragmented
@devTags: The file header ofCLEAR.solcontains six separate@devtags rather than a consolidated documentation block or@custom:tags. - Wordy NatSpec: Functions repeatedly prefix
@noticedescriptions with "This function allows...", which can be streamlined.
- Variable Shadowing: In
Recommendation
If code style is important, consider making the changes described above.
Upgrade to newer solc version
Severity
- Severity: Informational
Submitted by
Om Parikh
Description
Consider upgrading from current
0.8.28solc version to current or close to current version as there are multiple known bugs in older version.Recommendation
- pragma solidity 0.8.28;+ pragma solidity 0.8.37;