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 allowance validation when staking in gauges #3595

Merged
merged 4 commits into from
Jun 30, 2023

Conversation

timjrobinson
Copy link
Contributor

@timjrobinson timjrobinson commented Jun 30, 2023

This adds the post allowance validation from #3515 back into BalActionSteps.

It had a bug previously where no one was able to stake their BPT because we didn't think they had allowed it to be spent. This happened because the allowances query only checks spenders of the vault, wstETH and veBAL. It doesn't check if a gauge can spend a users BPT.

The bug was fixed by allowing injecting of new spenders, and injecting the gauge into the spenders list before the user stakes their BPT.

I renamed allowanceContracts to spenders as that's how the ERC20 standard refers to them, it made it less confusing to understand, and they might not be contracts (you can allow normal EOA's to be a spender of your tokens).

This also fixes a minor bug we didn't notice before: Users had to re-allow their BPT every time they staked previously, now they don't have to do that.

This could be made faster by not re-fetching all allowances after the injection and only fetching the allowances of that gauge, but that could come in a future PR.

Testing

  • Invest in a pool
  • Try and stake those BPT. It should work correctly.
  • Unstake and restake the BPT, if you allowed max previously it should not ask for an approval again.
  • Check normal swaps allowances work correctly.

@vercel
Copy link

vercel bot commented Jun 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
beta-app-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 30, 2023 1:25pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
app-v2 ⬜️ Ignored (Inspect) Jun 30, 2023 1:25pm

@timjrobinson timjrobinson changed the base branch from master to develop June 30, 2023 03:41
@timjrobinson timjrobinson changed the base branch from develop to master June 30, 2023 03:41
When staking a user must allow a gauge to spend their token. However
when we check for user allowances we only check for tokens the vault
can spend, not the allowances for gauges. By allowing injecting a
spender we can inject the gauge into the spenders list which then
fetches allowances for it when then makes it able to correctly tell if
the user has allowed the gauge to spend their BPT.

This fixes the post approval check always failing when staking BPT.
@timjrobinson timjrobinson changed the title Re-add allowance validation Fix allowance validation when staking in gauges Jun 30, 2023
@timjrobinson timjrobinson force-pushed the revert-3557-hotfix/remove-post-validation branch from 74042b5 to 9808a6e Compare June 30, 2023 05:57
@timjrobinson timjrobinson changed the base branch from master to develop June 30, 2023 05:57
@garethfuller garethfuller merged commit 36436a7 into develop Jun 30, 2023
@garethfuller garethfuller deleted the revert-3557-hotfix/remove-post-validation branch June 30, 2023 13:29
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