20,000 USDC
View results
Submission Details
Severity: gas
Valid

x += y/x -= y costs more gas than x = x + y/x = x - y for state variables

Vulnerability Details

Total Instances: 14

Gas Savings: 14 * 20 = 280

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L263

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L388

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L490

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L637

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L314

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L400

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L502

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L575

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L633

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L698

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L726

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Staking.sol#L41

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Staking.sol#L89

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Staking.sol#L48

Tools Used

Manual

Recommendations

  1. Use x = x + y/x = x - y rather than x += y/x -= y

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.