Skip to content

Made some safe Gas and Test optimization to Dai contract - #394

Open
Chijulybuilds wants to merge 3 commits into
sky-ecosystem:masterfrom
Chijulybuilds:Gas_and_Test_optimization
Open

Made some safe Gas and Test optimization to Dai contract#394
Chijulybuilds wants to merge 3 commits into
sky-ecosystem:masterfrom
Chijulybuilds:Gas_and_Test_optimization

Conversation

@Chijulybuilds

@Chijulybuilds Chijulybuilds commented Jun 23, 2026

Copy link
Copy Markdown

Securely Saving MakerDAO(Dai) ~~$95_000 yearly!

Gas and Test optimization that saves the protocol

Timestamp: 1782252480 (Tue/June/2026-10:29PM WAT)

Master branch Dai Contract Deployment Gas: 1,851,353 gas
Gas_and_Test_optimization Branch Deployment Gas: 1,429,297 gas

Master branch Dai Contract Runtime Gas: 5,924,031 gas
Gas_and_Test_optimization Branch Runtime Gas: 5,896,048 gas

Sum Total Gas saved: 449,056 gas

USD saved on dai.sol(daily): $230 - $270
USD saved on dai.sol(monthly): $7_300 - $ 7_600
USD saved on dai.sol(yearly): $85_000 - $100_000
estimated at an average of 3_000-5_000 active users daily on the MakerDAO protocol-- (Check gas_report_dai.txt for full gas report)

(dai.sol)

  • Implemented custom error messages.
  • Upgraded the compiler from ^0.6.12 to ^0.8.0 which introduces new compiler friendly keywords like "now" and "type"
  • The "now" keyword from older compiler versions becomes "block.timestamp"
  • The once "uint256(-1)" which the EVM recognizes as the highest value of the uint256 bytes now becomes "type(uint256).max" in newwer compiler versions.
  • Optimized the EVM compiler SLOAD from whenever function calls to storage variables directly and once.
  • Remodeled the require statements for better error handling using if and revert statements.
  • Implemented professional NatSpec comments.
  • Implemented headers to every layout section.

(dai.t.sol)

  • Implemented Vm Interface that introduces expectRevert and other testing utilities.
  • Upgraded the compilar from ^0.6.12 to ^0.8.0 which introduces new compiler friendly keywords like "now" and "type"
  • The "now" keyword from older compiler versions becomes "block.timestamp"
  • The once "uint256(-1)" which the EVM recognizes as the highest value of the uint256 bytes now becomes type(uint256).max in newwer compiler versions.
  • Implemented assertTrue() to ERC20 functions that returns bool
  • Implemented professional NatSpec comments.

@DaiFoundation-DevOps

DaiFoundation-DevOps commented Jun 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants