From 6a68dfd67db6a8d7f197860b70f27c1744b89eb9 Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Fri, 16 Feb 2024 09:33:42 -0700 Subject: [PATCH] fix: shares to lock to zero --- contracts/VaultV3.vy | 2 +- tests/unit/vault/test_profit_unlocking.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/contracts/VaultV3.vy b/contracts/VaultV3.vy index 88cec4d5..0a3816b2 100644 --- a/contracts/VaultV3.vy +++ b/contracts/VaultV3.vy @@ -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: diff --git a/tests/unit/vault/test_profit_unlocking.py b/tests/unit/vault/test_profit_unlocking.py index 6d382a07..d62f0762 100644 --- a/tests/unit/vault/test_profit_unlocking.py +++ b/tests/unit/vault/test_profit_unlocking.py @@ -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, @@ -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, @@ -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 @@ -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