Swivel v3 contest - Waze's results

The Capital-Efficient Protocol For Fixed-Rate Lending.

General Information

Platform: Code4rena

Start Date: 12/07/2022

Pot Size: $35,000 USDC

Total HM: 13

Participants: 78

Period: 3 days

Judge: 0xean

Total Solo HM: 6

Id: 135

League: ETH

Swivel

Findings Distribution

Researcher Performance

Rank: 45/78

Findings: 2

Award: $71.15

🌟 Selected for report: 0

🚀 Solo Findings: 0

#1 add immutable to AaveAddr

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Swivel/Swivel.sol#L33

State aaveAddr was call on constructor so it should be add immutable to initialize the state. it makes the state have a value and the cost are cheaper.

#2 missing natspec comment parameter a

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/VaultTracker/VaultTracker.sol#L248

natspect comment of param a was missing so give explanation about a to the comment natspec. it can increase readibility

#3 Missing natspect comment parameter holder

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Creator/ZcToken.sol#L120

natspect comment of param holder was missing so give explanation about holder to the comment natspec. it can increase readibility

Awards

26.8888 USDC - $26.89

Labels

bug
duplicate
G (Gas Optimization)
wontfix

External Links

#1 visibility

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Swivel/Swivel.sol#L25-L27

change visibility from public to private or internal can save gas. so i recommend to change it.

#2 use storage instead of memory

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Swivel/Swivel.sol#L248

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L91

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L116

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L132

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L149

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L177

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L216

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L228

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L248

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L266

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L284

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/VaultTracker/VaultTracker.sol#L52

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/VaultTracker/VaultTracker.sol#L115

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/VaultTracker/VaultTracker.sol#L155-L156

Use storage instead of memory to reduce the gas fee. i suggest to change from e.g

Hash.Order memory order = o[i];

to

Hash.Order storage order = o[i];

apply to others.

#3 use calldata instead memory

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Swivel/Swivel.sol#L495

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Marketplace/MarketPlace.sol#L64-L69

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Creator/Creator.sol#L36-L7

In the external functions where the function argument is read-only, the function() has an inputed parameter that using memory, if this function didnt change the parameter, its cheaper to use calldata then memory. so we suggest to change it. e.g

function setFee(uint16[] memory i, uint16[] memory d) external authorized(admin) returns (bool) {

to

function setFee(uint16[] calldata i, uint16[] calldata d) external authorized(admin) returns (bool) {

apply to others.

#4 remove max

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/Swivel/Swivel.sol#L549-L562

And add type(uint256).max change max

uint256 max = 2**256 - 1; // remove this uint256 when; for (uint256 i; i < len;) { when = approvals[u[i]]; if (when == 0) { revert Exception(16, 0, 0, address(0), address(0)); } if (block.timestamp < when) { revert Exception(17, block.timestamp, when, address(0), address(0)); } approvals[u[i]] = 0; IErc20 uToken = IErc20(u[i]); Safe.approve(uToken, c[i], max); //change max

To

uint256 when; for (uint256 i; i < len;) { when = approvals[u[i]]; if (when == 0) { revert Exception(16, 0, 0, address(0), address(0)); } if (block.timestamp < when) { revert Exception(17, block.timestamp, when, address(0), address(0)); } approvals[u[i]] = 0; IErc20 uToken = IErc20(u[i]); Safe.approve(uToken, c[i], type(uint256).max);
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