<x> / 2 is the same as <x> >> 1. While the compiler uses the SHR opcode to accomplish both,
the version that uses division incurs an overhead of 20 gas
due to JUMPs to and from a compiler utility function that introduces checks which can
be avoided by using unchecked {} around the division by two
There are 6 instances of this issue:
_share = _supplied * _delta / 1e18 should use right shift >> operator to save gas.
fees = (debt * borrowerFee) / 10000 should use right shift >> operator to save gas.
govFee = (borrowerFee * loan.collateral) / 10000 should use right shift >> operator to save gas.
fee = (borrowerFee * (debt - debtToPay)) / 10000 should use right shift >> operator to save gas.
interest = (l.interestRate _ l.debt _ timeElapsed) / 10000 / 31536000 should use right shift >> operator to save gas.
fees = (lenderFee * interest) / 10000 should use right shift >> operator to save gas.
Using bit shifting (>> operator) replace division divided by constant.
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.