Skip to content

Commit

Permalink
fix: shares to lock to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Feb 16, 2024
1 parent f869f7e commit 6a68dfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contracts/VaultV3.vy
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ def _process_report(strategy: address) -> (uint256, uint256):
# Don't lock fees or losses.
shares_to_lock = unsafe_sub(shares_to_lock, shares_to_burn)
else:
shares_to_burn = 0
shares_to_lock = 0

# Pull refunds
if total_refunds > 0:
Expand Down
13 changes: 9 additions & 4 deletions tests/unit/vault/test_profit_unlocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ def test_loss_no_fees_with_refunds_with_buffer(

management_fee = 0
performance_fee = 0
refund_ratio = 10_000
refund_ratio = 5_000

vault, strategy, accountant = initial_set_up_lossy(
asset,
Expand Down Expand Up @@ -1590,8 +1590,11 @@ def test_loss_no_fees_with_refunds_with_buffer(
- vault.convertToShares(first_loss),
)

increase_time_and_check_profit_buffer(chain, vault)
assert_price_per_share(vault, 3.0)
# The full profit from the first report should be fully unlocked in the same time
# period as initially set
increase_time_and_check_profit_buffer(chain, vault, secs=WEEK // 2)

assert_price_per_share(vault, 2.0)

check_vault_totals(
vault,
Expand All @@ -1610,7 +1613,7 @@ def test_loss_no_fees_with_refunds_with_buffer(
total_assets=amount + first_profit - first_loss + total_refunds * 2,
total_supply=amount,
)
assert_price_per_share(vault, 3.0)
assert_price_per_share(vault, 2.0)
assert vault.strategies(strategy).current_debt == 0

# Fish redeems shares
Expand All @@ -1627,8 +1630,10 @@ def test_loss_no_fees_with_refunds_with_buffer(
assert (
asset.balanceOf(fish)
== fish_amount
+ first_profit
+ first_profit * refund_ratio / MAX_BPS_ACCOUNTANT
+ first_loss * refund_ratio / MAX_BPS_ACCOUNTANT
- first_loss
)

# Accountant redeems shares
Expand Down

0 comments on commit 6a68dfd

Please sign in to comment.