-
Notifications
You must be signed in to change notification settings - Fork 8
berndartmueller - Protocol fees are not collected for a while after the LMPVault
got emptied
#787
Comments
1 comment(s) were left on this issue during the judging contest. Trumpero commented:
|
LMPVault
got emptiedLMPVault
got emptied
Escalate I agree with the judge's comment that fees should be collected when the NAV increases, compared to the previous NAV high mark threshold. My point is that a vault can be considered "reset" (i.e., the vault should behave as if it is newly deployed) if the total supply is zero after users have withdrawn their funds. Any realized profits from the newly deposited funds should be considered for the protocol fee calculation. Currently, if all funds are withdrawn, i.e., total supply is zero, and the debt and idle funds are zero, it will not reset the previous (potentially high) NAV high mark threshold (NAV is effectively the ratio between the debt + idle funds and Consequently, if users start depositing funds again into the vault, the protocol will miss out on fees on realized profits as long as the previous NAV high mark threshold is not surpassed again. |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
This issue is valid and similar to the one I have reported at Issue #661. Refer to my escalation (#661 (comment)) for more details. |
Planning to accept escalation and duplicate with #661. Same root cause. |
Result: |
Escalations have been resolved successfully! Escalation status:
|
berndartmueller
medium
Protocol fees are not collected for a while after the
LMPVault
got emptiedSummary
If an existing
LMPVault
with deposits gets emptied, the protocol fees are not collected until the NAV per share surpasses the previous high mark or the high mark is manually reset.Vulnerability Detail
Protocol fees are collected on the
LMPVault
's profits in the following three occasions:LMPVault.rebalance
in line 703LMPVault.flashRebalance
in line 727LMPVault._updateDebtReporting
in line 797The current NAV (i.e., net asset value) per share (
currentNavPerShare
) is calculated and used to determine if theLMPVault
made a profit and compared to the previously cached value (navPerShareHighMark
). If the current NAV per share is higher than the cached value, the difference is considered as profit, and the protocol fee is calculated based on the profit. Thereafter, the current NAV value is cached as the new high mark.However, if the destination vaults experience losses and the NAV per share decreases, the high mark will remain unchanged. If the
LMPVault
gets fully withdrawn and later gets deposits from users again, no protocol fees are collected asnavPerShareHighMark
is still the highest NAV value previously recorded. Even though theLMPVault
can be considered reset (meaning that any price increases of the underlying tokens of destination vaults are considered a profit) after all funds are withdrawn, and profits are realized again, fees are not collected until the current NAV per share surpasses the previous high mark.The following test case demonstrates the inability to collect protocol fees after the
LMPVault
got emptied:Test case (click to reveal)
How to run this test case:
Save git diff to a file named
test.patch
and run withResult:
Impact
The protocol misses out on collecting fees.
Code Snippet
src/vault/LMPVault.sol#L815
Tool used
Manual Review
Recommendation
Consider resetting the high mark
navPerShareHighMark
toMAX_FEE_BPS
during withdrawals if the total supply is zero.duplicate of #661
The text was updated successfully, but these errors were encountered: