Skip to content

Commit

Permalink
test: shares for amount (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
stcrab authored and fubuloubu committed Jul 9, 2021
1 parent 7fb294e commit 291840c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/functional/vault/test_withdrawal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import brownie

MAX_UINT256 = 2 ** 256 - 1


def test_multiple_withdrawals(token, gov, Vault, TestStrategy, chain):
# Need a fresh vault to do this math right
Expand Down Expand Up @@ -420,3 +422,29 @@ def test_token_amount_does_not_change_on_deposit_withdrawal(

assert deposit.block_number == withdraw.block_number
assert token.balanceOf(rando) == balanceBefore


def test_withdraw_not_enough_funds_with_gains(
chain, gov, token, vault, strategy, rando
):
vault.transfer(rando, vault.balanceOf(gov) / 2, {"from": gov})
vault.updateStrategyMaxDebtPerHarvest(strategy, MAX_UINT256, {"from": gov})
vault.updateStrategyDebtRatio(strategy, 10_000, {"from": gov})
vault.setManagementFee(0, {"from": gov})
vault.setPerformanceFee(0, {"from": gov})
vault.updateStrategyPerformanceFee(strategy, 0, {"from": gov})

strategy.harvest()

balance = token.balanceOf(strategy)
token.transfer(strategy, 150 * 10 ** token.decimals(), {"from": gov})
vault.removeStrategyFromQueue(strategy, {"from": gov})
chain.sleep(1)
strategy.harvest()
chain.sleep(1)
priceBefore = vault.pricePerShare()

vault.withdraw(balance / 10, {"from": rando})
priceAfter = vault.pricePerShare()

assert priceBefore <= priceAfter # with decimals=2 price remains the same.

0 comments on commit 291840c

Please sign in to comment.