For variables with values changing multiple times in a for
loop, it is significantly cheaper to initialize these variables outside of the loop. This is because, an SSTORE (storage write) operation that goes from 0 to non-zero is 22k gas units, while non-zero to non-zero is only 5k units. Initializing these variables inside the loop would cost 22k gas on every iteration, while initializing the variables outside the loop would only cost 22k gas on the first iteration, and 5k gas on subsequent iterations.
See summary
There are 12 instances of this.
Foundry
Consider initializing the variables outside the for
loop. As an example, the borrow
function could be rewritten like:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.