dudesahn
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Yearn GUSD Vaults Write-up ## Problem #1: yGUSD share price is broken and vault is drained Transaction in question, on [bloxy](https://bloxy.info/tx/0x307f83320e88d369d41799cbb64d05b36edd14ee927a3ffb7927e64f656d596a#). I also used tenderly to trace it, which was very helpful as well. **Cause:** `earn` and `withdrawAll` calls on the [yvCurve-GUSD Vault](https://etherscan.io/address/0xcc7e70a958917cce67b4b87a8c30e6297451ae98#readContract) affect share price on the [yGUSD Vault](https://etherscan.io/token/0xec0d8d3ed5477106c6d4ea27d90a60e594693c90). This occurs because: - `getPricePerFullShare` on yGUSD calls `balance` - `balance` calls `balanceOf` from the [Controller](https://etherscan.io/address/0x9e65ad11b299ca0abefc2799ddb6314ef2d91080#code) - The controller's `balanceOf` calls `balanceOf` from the [StrategyCurveGUSDProxy](https://etherscan.io/address/0xc8327d8e1094a94466e05a2cc1f10fa70a1df119) (this Vault's strategy) - The strategy's `balanceOf` calls and adds `balanceOfPoolInWant` and `balanceOfWant`. - `balanceOfPoolInWant` calls `balanceOfPool` - The strategy's `balanceOfPool` calls `balanceOf` in the [StrategyProxy](https://etherscan.io/address/0xc17adf949f524213a540609c386035d7d685b16f#readContract) contract - The StrategyProxy's `balanceOf` calls the gauge balance for Yearn's veCRV voter address ([CurveYCRVVoter](https://etherscan.io/address/0xf147b8125d2ef93fb6965db97d6746952a133934#code)). Yearn stakes LP tokens for Curve pools in the [GUSD gauge](https://etherscan.io/address/0xc5cfada84e902ad92dd40194f0883ad49639b023#readContract) to earn CRV emissions. Both the yGUSD and yvCurve-GUSD Vaults ultimately deposit their LP tokens in the same gauge from the same address, so yGUSD saw the LP tokens yvCurve-GUSD deposited and thought those were its own, rapidly increasing the share price because no new yGUSD tokens were minted. Currently, there are 7,371.81 outstanding yGUSD shares and only 1,357.33 GUSD in the vault. The current share price is ~37.76. **Proposed Solution:** If we can just shut everything down completely, and send users the funds directly, that is easiest. Here's the [list]((https://docs.google.com/spreadsheets/d/1nNReLgKgAxJXq3QZ0LLEtokQipBB8_Ophig5_NSOkWk/edit?usp=sharing)) of holders of yGUSD. **Edit Jan 6th—share price is back to 0, all funds removed from v2 strat.** If that's not possible, then I would suggest we deploy a new strategy with a hard-coded values for `balanceOf`. Simply put, we are breaking the connection between yGUSD and the GUSD Curve gauge. Hard-code the `balanceOf` value to 1.77, and seed the vault with the appropriate amount of GUSD from treasury. Based on users with [outstanding shares](https://docs.google.com/spreadsheets/d/1nNReLgKgAxJXq3QZ0LLEtokQipBB8_Ophig5_NSOkWk/edit?usp=sharing), only two users deposited with average share prices above 1.77 (almost all were at 1.76xx). For one user, 0xddb7ffb26e58c9c71673f1f3965293dcfc860586, they already received more than their share, as they originally withdrew all shares (and [drained the vault](https://etherscan.io/token/0xec0d8d3ed5477106c6d4ea27d90a60e594693c90?a=0xddb7ffb26e58c9c71673f1f3965293dcfc860586)), getting ~7x their investment, then only to re-deposit 2,000 GUSD later (I can only imagine hoping to get a similar bonus? Maybe as a "thank you"?). The only other user is 0x7b004ea66389ca8263632719fc2ded63af288912, who deposited once at a share price of ~1.76, but then deposited again a few days ago, leaving their average share price at 2.85. In the ethos of vaults never leaving users with less than they deposited, I propose we send them an extra 50 GUSD, since they will be able to redeem 77 at a share price of 1.77. ## Problem #2: yvCurve-GUSD share price is below 1 **Cause:** Whenever the last user drained the old GUSD vault [here](https://etherscan.io/tx/0x307f83320e88d369d41799cbb64d05b36edd14ee927a3ffb7927e64f656d596a), their `withdrawAll` transaction also removed 0.00000000000158595 GUSD/3Crv from the Curve gauge—this is the difference between the `balance` and `totalSupply` values for the new GUSD/3Crv vault. `getPricePerFullShare` is equal to `balance / totalSupply`, so this explains why the value is below 1. This occurred because when a user withdraws, the vault checks to see if there are enough free funds to withdraw directly from the vault, or if it needs to pull from the strategy (in this cause withdrawing from the GUSD Curve gauge). Since the `balance` value was incorrectly skewed by the yvCurve-GUSD vault, this led to the following: - [yGUSD Vault](https://etherscan.io/token/0xec0d8d3ed5477106c6d4ea27d90a60e594693c90) calculates `r = shares * balance / totalSupply = 2422549` - Compares against `b = token.balanceOf(address(this)) = 836599` <- this is the GUSD sitting free in the vault - In this case, `b < r`, which told the vault to pull funds from the strategy, equal to `r - b = 1585950`, so the strategy pulled 0.00000000000158595 gusd3CRV from the gauge and burned it. In conclusion, we appeared to get **super fucking lucky** that there was both a bug in calculating `balance` **and** an issue with decimals—if the decimals weren't bugged as well, then this transaction would've withdrawn and burned (or maybe given the user?) 15,859.50 gusd3CRV. Why did this burn happen though? Appears to be something that has been around since the vault launched, and was the same issue that broke it in the first place [here](https://etherscan.io/tx/0x645186de671252408401fb2255606d5d0803ef62a40b0c6e4112dcb1adc6c00c). My best guess is that the amount that's burned is too small to generate and tokens in return from Curve, but idk about that. ## Problem #3: yGUSD Vault and Strategy balances are incorrect on yearn.finance/stats This should be fixed once the yGUSD vault and strategy are no longer pointing to the GUSD gauge. ## Problem #4: Setting GUSD strategy to zero address broke registry Batch functions like `getVaultsInfo` in the vault registry (`registry.ychad.eth`) have stopped working. **Cause:** Registry calls `strategy.want()` which reverts since 0x0 has no code.

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully