Unnecessary SLOAD
s in Auction
#33
Labels
bug
Warden finding
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
pants
Vulnerability details
The functions
Auction.bondForRebalance()
,Auction.settleAuction()
,Auction.bondBurn()
andAuction.withdrawBounty()
read values from storage multiple times instead of caching them in local variables:Auction.bondForRebalance()
readsbondAmount
twice.Auction.settleAuction()
readsbondBlock
twice,basket
8 times andfactory
twice.Auction.bondBurn()
readsbasket
twice andbondAmount
twice.Auction.withdrawBounty()
readsbounty.token
twice andbounty.amount
twice.Impact
Storage reads are much more expensive than reading local variables.
Tool Used
Manual code review.
Recommended Mitigation Steps
Read these values from storage once, cache them in local variables and then read them again from the local variables.
The text was updated successfully, but these errors were encountered: