Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define immutable variable TOTAL_SUPPLY of Royalty Vault #294

Open
kingster-will opened this issue Nov 6, 2024 · 0 comments
Open

Define immutable variable TOTAL_SUPPLY of Royalty Vault #294

kingster-will opened this issue Nov 6, 2024 · 0 comments

Comments

@kingster-will
Copy link

          `uint256 totalSupply = totalSupply();` reads state and is a step where we could save on gas by replacing with an immutable variable of the vault - ie. `TOTAL_SUPPLY`

And then can eliminate uint256 totalSupply = totalSupply(); and use TOTAL_SUPPLY directly

Given all vaults have the same total supply and it stays constant over the lifetime of the vault (no minting and no burning) - this is possible to do to save gas on every royalty token transfer.

PS: optionally can also override totalSupply() and have it return TOTAL_SUPPLY but it is not entirely necessary

Originally posted by @Spablob in #291 (comment)

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

No branches or pull requests

1 participant