Skip to content

Commit

Permalink
chore: track current debt
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Jan 7, 2024
1 parent 13e628e commit ba2c961
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions contracts/VaultV3.vy
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,8 @@ def _process_report(strategy: address) -> (uint256, uint256):
# Record any reported gains.
if gain > 0:
# NOTE: this will increase total_assets
self.strategies[strategy].current_debt += gain
current_debt = unsafe_add(current_debt, gain)
self.strategies[strategy].current_debt = current_debt
self.total_debt += gain

profit_max_unlock_time: uint256 = self.profit_max_unlock_time
Expand All @@ -1251,7 +1252,8 @@ def _process_report(strategy: address) -> (uint256, uint256):

# Strategy is reporting a loss
if loss > 0:
self.strategies[strategy].current_debt -= loss
current_debt = unsafe_sub(current_debt, loss)
self.strategies[strategy].current_debt = current_debt
self.total_debt -= loss

# NOTE: should be precise (no new unlocked shares due to above's burn of shares)
Expand Down Expand Up @@ -1317,7 +1319,7 @@ def _process_report(strategy: address) -> (uint256, uint256):
strategy,
gain,
loss,
unsafe_sub(unsafe_add(current_debt, gain), loss),
current_debt,
total_fees * convert(protocol_fee_bps, uint256) / MAX_BPS,
total_fees,
total_refunds
Expand Down

0 comments on commit ba2c961

Please sign in to comment.