yearn / yearn-vaults-v3

GNU Affero General Public License v3.0
103 stars 37 forks source link

fix: tweaks #142

Closed Schlagonia closed 1 year ago

Schlagonia commented 1 year ago

Remove 4626 interface

why: Its' unused

Move api_version variable

why: Move it with the other constant variables Should the api's be changed to use 3? i.e. 3.1.0

Remove unused return variable from burn_unlocked_shares

why: the function is only called during the report and does not need the return variable

Remove state update when the full unlock has passed in burn_unlocked_shares

why: This function is only ever called during a report which will update the needed profit unlock variables at the end of the report. If all shares are unlocked then they are all burned, balanceOf(self) == 0 and therefore will not effect any calculations between the burning of shares and the end of the report

Add a min check when lowering debt

why: Adding a min check after a withdraw will assure that we will never underflow on the subtraction from total_debt and the strategies debt even if the strategy incorrectly sends even 1 wei extra tokens when moving debt to 0. While the 4626 standard should prevent this from happening. This will make the function more robust to potential small rounding errors, especially given vaults can deposit directly into 3rd party vaults that may not properly implement the 4626 withdraw()

Allow accounting manager to change the profit_max_unlock_time

why: The profit_max_unlocking_time allows for yvTokens to continue to appreciate slowly between report periods. The optimal use of this is to match a reporting cycle as close as possible to the time it takes for profit to unlock. However, the optimally efficient time for a strategy to report is highly variable both across vaults and strategies but also for the same strategy depending on market conditions. For example a vault with one strategy will have different needs from multi strategy vaults, the same vault could have different needs at different times of its life based on TVL and expected returns. Justrecently Yearn has extended many vaults harvest cycles to reduce gas costs during times of lower TVL. Allowing the profit_max_unlocking_time to change means accounting managers can better match the vaults unlocking to the reporting cycles, ending in a better user experience.

Remove default array from the internal _redeem

why: there is already a default variable on the external redeem which is the only function that can ever call the internal one

Check token in sweep for activation

Added protection from being able to sweep any current strategies tokens that will be minted to the vault on deposits. Will be able to sweep the strategies token if it has been force revoked previously for the potential for management to possibly recover any lost funds.

Checklist