Skip to content

Commit

Permalink
refactor: only assess performance fees on non-delegated gains
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Mar 22, 2021
1 parent e8f7208 commit 4a6e498
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions contracts/Vault.vy
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,20 @@ def report(gain: uint256, loss: uint256, _debtPayment: uint256) -> uint256:
self._reportLoss(msg.sender, loss)

# Assess both management fee and performance fee, and issue both as shares of the vault
self._assessFees(msg.sender, gain)
total_strategy_debt: uint256 = self.strategies[msg.sender].totalDebt
cached_strategy_delegatedAssets: uint256 = self._strategy_delegatedAssets[msg.sender]
if cached_strategy_delegatedAssets == 0:
self._assessFees(msg.sender, gain)

elif total_strategy_debt > cached_strategy_delegatedAssets:
# NOTE: Only assess fees on the non-delegated part of the invested assests
adjusted_gain: uint256 = (
gain * total_strategy_debt / (total_strategy_debt - cached_strategy_delegatedAssets)
)
self._assessFees(msg.sender, adjusted_gain)

else:
self._assessFees(msg.sender, 0)

# Returns are always "realized gains"
self.strategies[msg.sender].totalGain += gain
Expand Down Expand Up @@ -1647,7 +1660,7 @@ def report(gain: uint256, loss: uint256, _debtPayment: uint256) -> uint256:

# Update cached value of delegated assets
# (used to properly account for mgmt fee in `_assessFees`)
self.delegatedAssets -= self._strategy_delegatedAssets[msg.sender]
self.delegatedAssets -= cached_strategy_delegatedAssets
delegatedAssets: uint256 = Strategy(msg.sender).delegatedAssets()
self.delegatedAssets += delegatedAssets
self._strategy_delegatedAssets[msg.sender] = delegatedAssets
Expand Down

0 comments on commit 4a6e498

Please sign in to comment.