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

Improve gas costs by reducing the use of state variables when possible #2

Open
cleanunicorn opened this issue Jul 27, 2021 · 0 comments

Comments

@cleanunicorn
Copy link
Member

cleanunicorn commented Jul 27, 2021

Description

The owner can call setCap to set a new limit for the accepted funds.

After the cap was updated, an event is emitted.

https://github.com/monoceros-alpha/review-opyn-perp-vault-templates-2021-07/blob/518e4f6d174cae6ee75e316ad56789aaeb695069/code/contracts/core/OpynPerpVault.sol#L198-L201

When the event is emitted, the storage variable is used. This forces an expensive SLOAD operation.

Recommendation

Use the argument received in the method when emitting the event instead of the storage variable.

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

No branches or pull requests

1 participant