-
Notifications
You must be signed in to change notification settings - Fork 26
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(erc4626): make decimals offset adapt #342
Conversation
Rubilmax
commented
Dec 11, 2023
- Fixes https://cantina.xyz/code/8409a0ce-6c21-4cc9-8ef2-bd77ce7425af/findings/414d3776-a3c9-450f-aca6-549a7cff2d41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting a failing testRedeemTooMuch(0)
.
Also, is the following (from the cantina issue) true?
Most protocols only support tokens with up to 18 decimals
Finally this can lower the virtual shares : virtual asset ratio down to 1, is this safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good
Well, we consider it being quite relevant because Blue itself was not designed specifically for tokens with over 18 decimals, even though it does support them to some extent
Indeed for tokens with 18 decimals However, a ratio of virtual assets over virtual shares of 1 means that 1 share is worth 1 asset and the conversion rate is expected to grow (unless a lot of bad debt is realized) so it is expected that roundings upon interactions with MetaMorpho grow in size It may be an issue for high value, low decimals tokens such as WBTC though. Hence why we don't simply choose a decimals offset of 0 : we instead choose a decimals offset of 18 - decimals so that for the case of high value, low decimals tokens such as WBTC, the ratio is so low (1e-12) that enough precision on shares is given to mitigate the worth of roundings |
What about decoupling
In discussions related to Blue I'm seeing references to trying to maintain the property #shares > #assets as long as possible, and those discussions led to References: |
That is correct: it is possible but you end up with a share token that has a
While it seems this was chosen because we had the freedom of having the precision we want on shares because they are not transferrable and are not expected to be handled anywhere outside Blue |
163fb0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kind of weird to have 1e6 virtual shares in Blue and here only have 1. If 1 isn't enough in Blue, why would it be enough in a user of Blue? This downside is clearer to me than the one we are trying to fix, of a protocol not handling tokens with 24 decimals. I also like the proposal of @adhusson of hardcoding the decimals. I can approve because it doesn't seem really dangerous just a bit weird.
Because Blue is a primitive, so we want it to be robust to different kind of attacks. In this case, it's good that the inflation attack is completely removed from it, they layers on top will not have to worry about it at all.
It has other issues, as pointed out here. Do you think they are negligible ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, it's good that the inflation attack is completely removed from it, they layers on top will not have to worry about it at all.
At first glance it seems like you could inflation-attack MM by donating to the vault, is it clear why not? (edit: nevermind I forgot that 4626 is safe with decimalOffset = 0)
I think yes |