Badger-Finance / badger-multisig

Badger DAO's EVM multisig operations.
GNU Affero General Public License v3.0
52 stars 33 forks source link

Update AutonomousDripper.sol: Optimized gas costs #1433

Closed 0xScratch closed 9 months ago

0xScratch commented 1 year ago

This PR aims for two main changes:

  1. Optimized for loop: Well, the way these 'for' loops were structured in this smart contract were quite normal but kind of taking more gas than it needed to execute. Changing i++ to ++i, and using the unchecked block alone can play a lot of effect. For more info, refer this -> https://gist.github.com/grGred/9bab8b9bad0cd42fc23d4e31e7347144#for-loops-improvement. This convo might help -> https://github.com/lurk-lab/solidity-verifier/pull/31
  2. Changes uint256 count = 0; to uint256 count;: Usually, default values of unsigned integers are 0 itself, thus there's no need to initialize any unsigned integer to 0. This same change takes effect in case of bool dripped = false; to bool dripped;
gosuto-inzasheru commented 10 months ago

thanks @Aryan9592! can i ask you to move this pr to this repo: https://github.com/Badger-Finance/badger-infra/blob/main/contracts/refillers/AutonomousDripper.sol ?

it is where the original source of the contract lives :)

0xScratch commented 10 months ago

Okay

sajanrajdev commented 9 months ago

Closing as it will be handled within the Dripper's repo.