Yield Witch v2 contest - MadWookie's results

Fixed-rate borrowing and lending on Ethereum

General Information

Platform: Code4rena

Start Date: 14/07/2022

Pot Size: $25,000 USDC

Total HM: 2

Participants: 63

Period: 3 days

Judge: PierrickGT

Total Solo HM: 1

Id: 147

League: ETH

Yield

Findings Distribution

Researcher Performance

Rank: 46/63

Findings: 1

Award: $20.07

🌟 Selected for report: 0

🚀 Solo Findings: 0

Gas Report

1. Order require() statements from least expensive to most expensive.

This lowers average gas used on instances of reverts.
Move this statement to the beginning of cancel(), saving around 2000 gas on average.

require(cauldron.level(vaultId) >= 0, "Undercollateralized");

File:Witch.sol#L256

2. Boolean storage variables are more expensive than uint256

Consider changing these to uint256 and perform casting to bool when necessary.

mapping(address => bool) public otherWitches;

File:Witch.sol#L68


mapping(bytes6 => mapping(bytes6 => bool)) public ignoredPairs;

File:Witch.sol#L69

3. Caching a struct to memory and only using once is more expensive than directly reading from storage

In this case I'm not sure the technical reason for why this is cheaper since _calcAuction() needs a memory struct so it must be converted anyways.
In my testing I found not caching debt before _calcAuction() function call saves 42 gas on average.

DataTypes.Debt memory debt = cauldron.debt(series.baseId, vault.ilkId);

File:Witch.sol#L192

4. +=-= costs more gas than = +\ = -.

saves 25 gas on average

limits_.sum += auction_.ink;

File:Witch.sol#L204

next two save 4 gas on average

limits_.sum -= auction_.ink;

File:Witch.sol#L430


auction_.art -= artIn.u128();

File:Witch.sol#L450

5. Functions guaranteed to revert when called by normal users can be marked payable

This saves gas by removing the msg.value > 0 check.
This appears to be pretty common at this point so I don't believe it degrades readability.

point()

File:Witch.sol#L83

setLine()

File:Witch.sol#L95

setLimit()

File:Witch.sol#L126

setAnotherWitch()

File:Witch.sol#L141

setIgnoredPair()

File:Witch.sol#L150

setAuctioneerReward()

File:Witch.sol#L161

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