Yield Witch v2 contest - kyteg'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: 20/63

Findings: 2

Award: $57.91

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

39.0585 USDC - $39.06

Labels

bug
QA (Quality Assurance)

External Links

Typos in comments

There are 7 instances of this issue:

FILE: contracts/Witch.sol 213: /// Useful as a method so it can be overriden by specialised witches that may need to do extra accounting or notify 3rd parties

"overriden" should be "overridden". https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L213

FILE: contracts/Witch.sol 220: /// @dev Calculates the auction initial values, the 2 non-trivial values are how much art must be repayed

"repayed" should be "repaid". https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L220

FILE: contracts/Witch.sol 267: /// Useful as a method so it can be overriden by specialised witches that may need to do extra accounting or notify 3rd parties

"overriden" should be "overridden". https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L267

FILE: contracts/Witch.sol 385: /// @dev transfers funds from the ilkJoin to the liquidator (and potentially the auctioneer if they're differente people)

"differente" should be "different" https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L385

FILE: contracts/Witch.sol 462: /// Useful as a method so it can be overriden by specialised witches that may need to do extra accounting or notify 3rd parties

"overriden" should be "overridden". https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L267

FILE: contracts/Witch.sol 497: / 12 \ First lets check how much time `t` is left on the auction

"lets" should be "let's" https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L497

FILE: contracts/Witch.sol 520: /// @dev quoutes hoy much ink a liquidator is expected to get if it repays an `artIn` amount

"quoutes hoy" should be "quotes how" https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L520

#0 - alcueca

2022-07-22T14:16:43Z

Thanks

Summary

IssueInstances
Use custom errors instead of revert()/require() to save gas17
internal functions that are only called once can be inlined to save gas1
Use != 0 instead of > 0 for a uint6

Gas Optimisations

Use custom errors instead of revert()/require() to save gas

Custom errors are available from solidity version 0.8.4. The instances below match or exceed that version. Saves about 200 gas per instance when the contract reverts.

There are 17 instances of this issue:

FILE: contracts/Witch.sol 84: require(param == "ladle", "Unrecognized");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L84

FILE: contracts/Witch.sol 102: require(initialOffer <= 1e18, "InitialOffer above 100%");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L102

FILE: contracts/Witch.sol 103: require(proportion <= 1e18, "Proportion above 100%");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L103

FILE: contracts/Witch.sol 104 require( 105 initialOffer == 0 || initialOffer >= 0.01e18, 106 "InitialOffer below 1%" 107: );

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L104-L107

FILE: contracts/Witch.sol 108: require(proportion >= 0.01e18, "Proportion below 1%");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L108

FILE: contracts/Witch.sol 189: require(cauldron.level(vaultId) < 0, "Not undercollateralized");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L189

FILE: contracts/Witch.sol 200: require(limits_.sum <= limits_.max, "Collateral limit reached");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L200

FILE: contracts/Witch.sol 255: require(auction_.start > 0, "Vault not under auction");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L255

FILE: contracts/Witch.sol 256: require(cauldron.level(vaultId) >= 0, "Undercollateralized");;

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L256

FILE: contracts/Witch.sol 300: require(auction_.start > 0, "Vault not under auction");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L300

FILE: contracts/Witch.sol 313: require(liquidatorCut >= minInkOut, "Not enough bought");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L313

FILE: contracts/Witch.sol 328: require(baseJoin != IJoin(address(0)), "Join not found");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L328

FILE: contracts/Witch.sol 358: require(auction_.start > 0, "Vault not under auction");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L358

FILE: contracts/Witch.sol 365: require(liquidatorCut >= minInkOut, "Not enough bought");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L365

FILE: contracts/Witch.sol 395: require(ilkJoin != IJoin(address(0)), "Join not found");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L395

FILE: contracts/Witch.sol 416: require(auction_.start > 0, "Vault not under auction");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L416

FILE: contracts/Witch.sol 437 require( 438 auction_.art - artIn >= debt.min * (10**debt.dec), 439 "Leaves dust" 440: );

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L437-L440

internal functions that are only called once can be inlined to save gas

Depending on the function contents, this will save 20~40 gas by omiting two JUMP operations and stack operations needed for the function call.

There is 1 instance of this issue:

FILE: contracts/Witch.sol 214: function _auctionStarted(bytes12 vaultId) internal virtual {

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L214

Use != 0 instead of > 0 for a uint

uint can never be below 0, so != 0 and > 0 are equivalent.

See: https://github.com/byterocket/c4-common-issues/blob/main/0-Gas-Optimizations.md/#g003---use--0-instead-of--0-for-unsigned-integer-comparison

There are 6 instances of this issue:

FILE: contracts/Witch.sol 255: require(auction_.start > 0, "Vault not under auction");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L255

FILE: contracts/Witch.sol 300: require(auction_.start > 0, "Vault not under auction");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L300

FILE: contracts/Witch.sol 358: require(auction_.start > 0, "Vault not under auction");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L358

FILE: contracts/Witch.sol 393: if (liquidatorCut > 0) {

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L393

FILE: contracts/Witch.sol 398: if (auctioneerCut > 0) {

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L398

FILE: contracts/Witch.sol 416: require(auction_.start > 0, "Vault not under auction");

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L416

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