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

Gas optimization on BadgerYieldSource #108

Closed
code423n4 opened this issue Jun 24, 2021 · 1 comment
Closed

Gas optimization on BadgerYieldSource #108

code423n4 opened this issue Jun 24, 2021 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Handle

shw

Vulnerability details

Impact

The redeemToken function in BadgerYieldSource can be designed as more gas-efficient by reusing local variables.

Proof of Concept

Variables badgerSett and badger in the BadgerYieldSource are currently declared private. However, a similar implementation, SushiYieldSource, declares sushiBar and sushiAddr public. Suppose the badgerSett and badger in BadgerYieldSource are needed to be declared public. In that case, the redeemToken function can be more gas-efficient by reading these two state variables into local variables first and then reusing them, as written in the redeemToken function of SushiYieldSource contract.

Referenced code:
BadgerYieldSource.sol#L15-L16
BadgerYieldSource.sol#L57-L81
SushiYieldSource.sol#L17-L18
SushiYieldSource.sol#L66-L92

Recommended Mitigation Steps

Let badgerSett and badger be public and re-write the redeemToken function in the BadgerYieldSource contract.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jun 24, 2021
code423n4 added a commit that referenced this issue Jun 24, 2021
@asselstine asselstine added the duplicate This issue or pull request already exists label Jun 24, 2021
@asselstine
Copy link
Collaborator

See #38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

2 participants