Skip to content

Conversation

@0xdanielvigo
Copy link

@0xdanielvigo 0xdanielvigo commented Oct 25, 2025

This PR focuses on improving gas efficiency across the vaults smart contracts by applying several optimization techniques, including:

  • Setting variables to constant or immutable when applicable.
  • Replacing revert strings with custom errors.
  • Using unchecked in calculations that will not underflow / overflow.

These changes aim to reduce overall gas usage while maintaining readability and functionality.

@0xdanielvigo 0xdanielvigo changed the title Increased gas efficiency in Beefy smart contracts Increased gas efficiency in Beefy vaults smart contracts Oct 30, 2025
Copy link
Author

@0xdanielvigo 0xdanielvigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added custom reverts and unchecked blocks since they are more gas efficient also when setting the optimizer to true or when using --via-ir.

In withdraw functions such as BeefyVaultV7::withdraw() i directly assigned _after to r, because it avoids unnecessary calculations and thus saves gas.
NOTE: r = b + (_after - b) is the same thing as doing r = _after.

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.

1 participant