-
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(reallocate): prevent withdrawing from market not enabled #358
Conversation
2 is what worries me the most: at worst, a vault manager cannot reallocate liquidity during the duration of their timelock |
I don't think taxing donations is a big deal. It's bonus for everyone anyway.
I don't think it's fine. Like if one market is frozen it could be for any reason including reason that could affect similar assets. The allocator would not be able to rebalance the portfolio to reduce risk exposure. The increase of the gas cost is worrying. IMO reallocation should be as cheap as possible. |
Not in all cases, see point 1 + in case of a forced market removal that no longer reverts for some reason |
But this is fixed by #338 right? |
Romain is right. #338 allows to recover (without being "taxed" by the feeRecipient) previously lost supply on reverting markets only when these markets are enabled again. But without enabling these markets it's possible (if they stop reverting) to withdraw from these market (to recover the supply) with |
Ok right I get it now, sorry |
what's the cost of reallocate @Rubilmax ? |
according to hardhat tests, 360k gas before this change, 560k gas now (on avg) |
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.
This must be tested I think
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.
a (simpler?) solution would be to prevent withdrawing from a market that is not listed? It removes the possibility to withdraw donations but maybe the spec is clearer?
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 not sure to agree with this fix.
- if the manager enables the market, the donation/previously loosed funds will be slashed right ?
- why shouldn't a donation profit to the fee too ?
(in english loosed -> lost, and also loose -> lose) If by "slashed" you mean that it will be subject to the MM fee, then yes.
I don't think it's a problem that a donation can be subject to the MM fee. In effect, donations to enabled markets are subject to the fee, even with the changes of this PR. We can imagine vaults making profit in other ways, and this can be cleanly accounted for with a donation. |
44fe10d
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.
LGTM!
@Rubilmax would you mind explaining this? I don't see how the PR has changed this behavior, compared to before |
This is indeed no longer true (it has been removed in the second commit of this PR). The point 3 is no longer true as well I think. |
If you can update the description of the PR with the logic that you want to achieve with the changes, it would allow me to verify that the code is correct and has no side effects. In general:
|
I updated the description |
Fixes https://cantina.xyz/code/8409a0ce-6c21-4cc9-8ef2-bd77ce7425af/findings/131b79f3-83fc-4674-a222-c5c4dc7d0539
This PR makes reverting when withdrawing from a market that is not enabled. This prevents users to benefit from a donation but it's considered quite unlikely. It also prevents the vault managers to tax the principal of funds deposited on a removed market.
We also acknowledge that the fee recipient will lose entitled fees in case of bad debt events. This is considered fairer since the loss result from the bad management from vault curators.