Events will contain the wrong timestamp in the future
1
[L‑03]
Integer overflow due to casting will cause contract accounting to break
1
Total: 3 instances over 3 issues
Non-critical Issues
Issue
Instances
[N‑01]
Incomplete documentation
1
[N‑02]
Timestamps in events are redundant
1
[N‑03]
constants should be defined rather than using magic numbers
8
[N‑04]
Redundant cast
2
[N‑05]
Typos
6
[N‑06]
NatSpec is incomplete
1
[N‑07]
Event is missing indexed fields
6
[N‑08]
Duplicated require()/revert() checks should be refactored to a modifier or function
2
Total: 27 instances over 8 issues
Low Risk Issues
[L‑01] setLine() parameters inconsistently followed
In setLine() there's a require() that ensures that the initial offer is either equal to zero, or greater than 1%. It stands to reason that therefore, offers less than 1% are considered dust and are not actionable. If this is the case, then in the else-block on line 589, does not follow this same dust-skipping logic when initialProportion is set to zero, and will waste time offering proportions that nobody will take. This may lead to auctions taking longer than necessary, and more funds being lost. It is incorrect state handling and therefore of Low risk. If there was some other meaning behind the conditions, there should be a require() enforcing it
[L‑02] Events will contain the wrong timestamp in the future
While the timestamp field in the event might not affect on-chain processing, it will impact off-chain tools that have to parse it. This is incorrect state handling and therefore of Low risk
[L‑03] Integer overflow due to casting will cause contract accounting to break
When block.timestamp becomes larger than type(uint32).max, the cast on line 582 will overflow, causing the elapsed time calculation to be extremely large and wrong if the auction start time was before the wrap. This will cause the proportion to be greater than 100%, and will allow a liquidator to earn a massive fee. Comments in code are not sufficient to prevent client fund loss, and relying on Google calendar is obviously not either. This should be a Medium, but I'm guessing the sponsor will argue that it's already documented here in the code (though it needs to be in the README.md and in Yield's risks documentation), so it's not worth while to write up the whole thing just to have it downgraded by a judge that decides not to follow that rule.
There is 1 instance of this issue:
File: contracts/Witch.sol
575 // If the world has not turned to ashes and darkness, auctions will malfunction on
576 // the 7th of February 2106, at 06:28:16 GMT
577 // TODO: Replace this contract before then 😰
578 // UPDATE: Added reminder to Google calendar ✅
579 uint256 elapsed;
580 uint256 proportionNow;
581 unchecked {
582 elapsed = uint32(block.timestamp) - uint256(auction_.start); // Overflow on block.timestamp is fine
583: }
File: contracts/Witch.sol
/// @audit overriden
213: /// Useful as a method so it can be overriden by specialised witches that may need to do extra accounting or notify 3rd parties
/// @audit repayed
220: /// @dev Calculates the auction initial values, the 2 non-trivial values are how much art must be repayed
/// @audit overriden
267: /// Useful as a method so it can be overriden by specialised witches that may need to do extra accounting or notify 3rd parties
/// @audit differente
385: /// @dev transfers funds from the ilkJoin to the liquidator (and potentially the auctioneer if they're differente people)
/// @audit overriden
462: /// Useful as a method so it can be overriden by specialised witches that may need to do extra accounting or notify 3rd parties
/// @audit quoutes
520: /// @dev quoutes hoy much ink a liquidator is expected to get if it repays an `artIn` amount
Index event fields make the field more quickly accessible to off-chain tools that parse events. However, note that each index field costs extra gas during emission, so it's not necessarily best to index the maximum allowed per event (threefields). Each event should use three indexed fields if there are three or more fields, and gas usage is not particularly of concern for the events in question
Summary
Low Risk Issues
setLine()
parameters inconsistently followedTotal: 3 instances over 3 issues
Non-critical Issues
constant
s should be defined rather than using magic numbersindexed
fieldsrequire()
/revert()
checks should be refactored to a modifier or functionTotal: 27 instances over 8 issues
Low Risk Issues
[L‑01]
setLine()
parameters inconsistently followedIn
setLine()
there's a require() that ensures that the initial offer is either equal to zero, or greater than 1%. It stands to reason that therefore, offers less than 1% are considered dust and are not actionable. If this is the case, then in theelse
-block on line 589, does not follow this same dust-skipping logic wheninitialProportion
is set to zero, and will waste time offering proportions that nobody will take. This may lead to auctions taking longer than necessary, and more funds being lost. It is incorrect state handling and therefore of Low risk. If there was some other meaning behind the conditions, there should be arequire()
enforcing itThere is 1 instance of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L584-L592
[L‑02] Events will contain the wrong timestamp in the future
While the timestamp field in the event might not affect on-chain processing, it will impact off-chain tools that have to parse it. This is incorrect state handling and therefore of Low risk
There is 1 instance of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L217
[L‑03] Integer overflow due to casting will cause contract accounting to break
When
block.timestamp
becomes larger thantype(uint32).max
, the cast on line 582 will overflow, causing the elapsed time calculation to be extremely large and wrong if the auction start time was before the wrap. This will cause the proportion to be greater than 100%, and will allow a liquidator to earn a massive fee. Comments in code are not sufficient to prevent client fund loss, and relying on Google calendar is obviously not either. This should be a Medium, but I'm guessing the sponsor will argue that it's already documented here in the code (though it needs to be in theREADME.md
and in Yield's risks documentation), so it's not worth while to write up the whole thing just to have it downgraded by a judge that decides not to follow that rule.There is 1 instance of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L575-L583
Non-critical Issues
[N‑01] Incomplete documentation
The infinite duration comment should be in NatSpec, not a normal comment hidden in the code
There is 1 instance of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L584
[N‑02] Timestamps in events are redundant
block.timestamp
andblock.number
are added to event information by default so adding them manually wastes gas and is redundantThere is 1 instance of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L217
[N‑03]
constant
s should be defined rather than using magic numbersEven assembly can benefit from using readable constants instead of hex/numeric literals
There are 8 instances of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L102
[N‑04] Redundant cast
The type of the variable is the same as the type to which the variable is being cast
There are 2 instances of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L590
[N‑05] Typos
There are 6 instances of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L213
[N‑06] NatSpec is incomplete
There is 1 instance of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L174-L178
[N‑07] Event is missing
indexed
fieldsIndex event fields make the field more quickly accessible to off-chain tools that parse events. However, note that each index field costs extra gas during emission, so it's not necessarily best to index the maximum allowed per event (threefields). Each
event
should use threeindexed
fields if there are three or more fields, and gas usage is not particularly of concern for the events in questionThere are 6 instances of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L33-L38
[N‑08] Duplicated
require()
/revert()
checks should be refactored to a modifier or functionThe compiler will inline the function, which will avoid
JUMP
instructions usually associated with functionsThere are 2 instances of this issue:
https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L300