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

Approval glitches on vaults deposit #188

Open
Ivshti opened this issue Nov 20, 2020 · 0 comments
Open

Approval glitches on vaults deposit #188

Ivshti opened this issue Nov 20, 2020 · 0 comments

Comments

@Ivshti
Copy link

Ivshti commented Nov 20, 2020

When you deposit funds into vaults (reproduced with 3crv and ycrv), the default is an infinite approval.

However, if the user tweaks the approval to only approve the deposited amount, subsequent deposits will fail in a couple of ways

  1. There may not be enough approved left to complete the deposit
  2. yearn will try to approve the infinite amount again, which will always result in a failed tx if there's leftover approved amount (apparently ycrv/3crv require approval to be set to 0 before setting it to a nonzero value again to prevent frontrunning)

Suggestions:

  1. check the approved amount beforehand, if it's nonzero but less than the required, send a tx that sets it to zero before the one that sets it to infinity
  2. do not use infinite approvals and approve the exact amount instead, that way it's unlikely that users would tweak it
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