def test_profitable_harvest( gov, vault, strategy, strategist, token, amount, weth_amount, yveCrv, weth, usdc, crv3, chain, whale_3crv, user ): vault_before = token.balanceOf(vault) strat_before = token.balanceOf(strategy) token.approve(vault.address, amount, {"from": user}) vault.deposit(amount, {"from": user}) vault_after = token.balanceOf(vault) showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) strategy.harvest({"from": strategist}) assert token.balanceOf(strategy.address) == amount + vault_before + strat_before # showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) # Done to fix the UniswapV2: K issue pairs = [strategy.ethCrvPair(), strategy.ethYvBoostPair(), strategy.ethUsdcPair()] for pair in pairs: Contract.from_explorer(pair, owner=strategist).sync() # Simulate a claim by sending some 3Crv to the strategy before harvest crv3.transfer(strategy, 1e22, {"from": whale_3crv}) before = token.balanceOf(strategy.address) + token.balanceOf(vault.address) pps_before = vault.pricePerShare() strategy.harvest({"from": strategist}) chain.sleep(60*60*6) # sleep to increase pps chain.mine(1) print("pps before",pps_before) print("pps after",vault.pricePerShare()) assert vault.pricePerShare() > pps_before chain.mine(1) after = token.balanceOf(strategy.address) + token.balanceOf(vault.address) showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) print("before",before) print("after",after) assert after > before
def test_mint_over_swap(gov, vault, strategy, strategist, token, amount, weth_amount, yveCrv, weth, usdc, crv3, chain, whale_3crv, whale_eth, sushiswap, yveCrvContract, crv, user): chain.snapshot() pairs = [ strategy.ethCrvPair(), strategy.ethYvBoostPair(), strategy.ethUsdcPair() ] for pair in pairs: Contract.from_explorer(pair, owner=strategist).sync() # Deposit to the vault and harvest # print(yveCrv.strategies(strategy)) # Strategy params (perf fee, activation, debtraatio, mindebtperharvest, maxdebtperharvest, lastreport, totaldebt) token.approve(vault.address, amount, {"from": user}) vault.deposit(amount, {"from": user}) showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) # Move deposited funds to vault strategy.harvest() showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) # Simulate a claim by sending some 3Crv to the strategy before harvest crv3.transfer(strategy, 10e21, {"from": whale_3crv}) # Swap a load of ETH for yveCRV to make yveCRV more expensive than CRV sushiswap.swapExactETHForTokens( 0, [weth.address, token.address], whale_eth, time.time() + 10, { "from": whale_eth, "value": 1e22 }, ) before_shares = yveCrvContract.totalSupply() strategy.harvest() after_shares = yveCrvContract.totalSupply() # showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) assert after_shares > before_shares # Ensure that we didn't mint
def test_profitable_harvest(gov, vault, strategy, token, amount, weth_amount, yveCrv, weth, usdc, crv3, chain, whale_3crv, user): token.approve(vault.address, amount, {"from": user}) vault.deposit(amount, {"from": user}) assert token.balanceOf(vault.address) == amount showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) strategy.harvest() assert token.balanceOf(strategy.address) == amount # showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) # Simulate a claim by sending some 3Crv to the strategy before harvest crv3.transfer(strategy, 10e20, {"from": whale_3crv}) strategy.harvest() print("\n\n~~After Harvest #2~~") showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) assert token.balanceOf(strategy.address) > amount
def test_profitable_harvest(gov, vault, strategy, token, amount, weth_amount, yveCrv, weth, usdc, crv3, chain, whale_3crv, user): # Deposit to the vault and harvest # print(yveCrv.strategies(strategy)) # Strategy params (perf fee, activation, debtraatio, mindebtperharvest, maxdebtperharvest, lastreport, totaldebt) chain.snapshot() token.approve(vault.address, amount, {"from": user}) vault.deposit(amount, {"from": user}) assert token.balanceOf(vault.address) == amount showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) strategy.harvest() assert token.balanceOf(strategy.address) == amount # showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) # Simulate a claim by sending some 3Crv to the strategy before harvest crv3.transfer(strategy, 10e20, {"from": whale_3crv}) strategy.harvest() print("\n\n~~After Harvest #2~~") showBalances(token, vault, strategy, yveCrv, weth, usdc, crv3) assert token.balanceOf(strategy.address) > amount chain.revert()