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

Unnecessary update of amount #18

Open
code423n4 opened this issue Jul 5, 2021 · 0 comments
Open

Unnecessary update of amount #18

code423n4 opened this issue Jul 5, 2021 · 0 comments

Comments

@code423n4
Copy link
Contributor

Handle

gpersoon

Vulnerability details

Impact

In several functions of BaseVaultAdaptor a value is stored in the variable amount at the end of the function.
However this variable is never used afterwards so the storage is unnecessary and just uses gas.

Proof of Concept

// https://github.com/code-423n4/2021-06-gro/blob/main/contracts/vaults/BaseVaultAdaptor.sol#L165
function withdraw(uint256 amount) external override {
..
if (!_withdrawFromAdapter(amount, msg.sender)) {
amount = _withdraw(calculateShare(amount), msg.sender);

function withdraw(uint256 amount, address recipient) external override {
...
    if (!_withdrawFromAdapter(amount, recipient)) {
        amount = _withdraw(calculateShare(amount), recipient);

function withdrawToAdapter(uint256 amount) external onlyOwner {
    amount = _withdraw(calculateShare(amount), address(this));
}

function withdrawByStrategyOrder(

..
if (!_withdrawFromAdapter(amount, recipient)) {
amount = _withdrawByStrategyOrder(calculateShare(amount), recipient, reversed);

function withdrawByStrategyIndex(

...
if (!_withdrawFromAdapter(amount, recipient)) {
amount = _withdrawByStrategyIndex(calculateShare(amount), recipient, strategyIndex);

Tools Used

Recommended Mitigation Steps

Replace
amount = _withdraw***(...);
with
_withdraw***(...);

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jul 5, 2021
code423n4 added a commit that referenced this issue Jul 5, 2021
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

2 participants