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

fix/90 prevent locking user funds in _withdrawFromVault #7

Merged
merged 1 commit into from
Jul 13, 2021

Conversation

@PierrickGT PierrickGT self-assigned this Jul 5, 2021
@PierrickGT PierrickGT changed the base branch from master to fixes/c4-audit July 5, 2021 14:41
@@ -191,7 +191,7 @@ contract YearnV2YieldSource is IYieldSource, ERC20Upgradeable, OwnableUpgradeabl
}
uint256 currentBalance = token.balanceOf(address(this));

return previousBalance.sub(currentBalance);
return currentBalance > previousBalance ? currentBalance.sub(previousBalance) : 0;
Copy link

@PierrickGT PierrickGT Jul 5, 2021

Choose a reason for hiding this comment

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

Do we really need this ternary operator?
Cause if currentBalance is equal to previousBalance, it will inevitably return 0.
Also vault.withdraw(yShares); on line 190 should be vault.withdraw(yShares, address(this));, vault shares need to be minted to the yield source contract and not the sender.
https://yearn.github.io/yearn-devdocs/v2/smart-contracts/vault#withdraw-2

Choose a reason for hiding this comment

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

Agreed....I don't think the check is needed. It might be needed if there were rounding errors, but it doesn't appear possible as it's just a token balance.

@PierrickGT PierrickGT merged commit 796edf2 into fixes/c4-audit Jul 13, 2021
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.

3 participants