-
Notifications
You must be signed in to change notification settings - Fork 321
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
DebtRatio problem #376
Comments
now use var self.debtRatio controller vault_debtLimit. It's hard to control and understand. |
What you are suggesting is the code we use to have prior to the changes. The original design was based on totalAssets() but this can be user manipulated. A potential fraudulent strategy that doesn't want to return back his assets after gains could fraud by depositing assets into the vault, call harvest it debtRatio compared to total assets would not change and then the strategist can withdraw the funds. We tried to prevent that with our latest changes but that introduced another issue: |
What you are suggesting is the code we use to have prior to the changes. |
I think. add var debtLimit controller available amout. vault 1 code: |
sorry, I do not understand your suggestion. |
Well, I'll change the code tomorrow, and we'll discuss it. You can better understand my idea from the code. |
Ok I will discuss with @fubuloubu |
a5c51b2#diff-b583ba5c4d7b67e56b9084eff9fe883e12a2cdd94a2ea25029322c6f3568d807L1140 |
Because a strategy owner can reduce or bypass debt reduction. The computation of the ratio change depends on total assets, which are computed using the balance of the vault. However, a strategy owner can temporarily increase this value with a flash loan, with the following sequences of calls in a single transaction:
Since the value of the _totalAssets() will be increased (up to the deposit limit), the amount of ratio_change can be reduced, even to zero, avoiding the debt change. The updates I made were incorrect and we have to find a way around that. |
thank you. |
To my understanding, your suggestion is also prone to the manipulation described above. |
To solve this problem, we estimate that we should lock deposit amount. |
for example: |
yearn-vaults/contracts/Vault.vy
Lines 1441 to 1445 in ec7d2e3
yearn-vaults/contracts/Vault.vy
Line 1478 in ec7d2e3
above. compute strategy_debtLimit is different
yearn-vaults/contracts/Vault.vy
Line 1476 in ec7d2e3
should add var debtLimit
vault_debtLimit: uint256 = self.debtLimit * vault_totalAssets / MAX_BPS
self.debtLimit <= MAX_BPS
No more judgment self.debtRatio<=MAX_BPS
compute strategy_debtLimit
self.strategies[strategy].debtRatio * self.totalDebt / self.debtRatio
add strategy
self.debtRatio += self.strategies[strategy].debtRatio
The text was updated successfully, but these errors were encountered: