def test_live_migration(web3, chain, vault, strategy, token, whale, gov, strategist, rewards, amount): live_strat = Contract("0x37770F958447fFa1571fc9624BFB3d673161f37F", owner=gov) new_strat = Contract("0xCdC3d3A18c9d83Ee6E10E91B48b1fcb5268C97B5", owner=gov) vault = Contract(new_strat.vault(), owner=gov) print(f"\n >>> before migration") state_of_strategy(live_strat, token, vault) state_of_strategy(new_strat, token, vault) state_of_vault(vault, token) print() vault.migrateStrategy(live_strat, new_strat) print() print(f"\n >>> after migration") state_of_strategy(live_strat, token, vault) state_of_strategy(new_strat, token, vault) state_of_vault(vault, token) print(f"\n >>> harvest") new_strat.harvest() state_of_strategy(live_strat, token, vault) state_of_strategy(new_strat, token, vault) state_of_vault(vault, token) print(f"\n >>> wait 1 day to get the share price back") chain.sleep(86400) chain.mine(1) state_of_strategy(live_strat, token, vault) state_of_strategy(new_strat, token, vault) state_of_vault(vault, token)
def test_operation(web3, chain, vault, strategy, token, amount, dai, dai_vault, whale, gov, guardian, strategist): # whale approve weth vault to use weth token.approve(vault, 2**256 - 1, {"from": whale}) print('cdp id: {}'.format(strategy.cdpId())) print(f'type of strategy: {type(strategy)} @ {strategy}') print(f'type of weth vault: {type(vault)} @ {vault}') print() # start deposit vault.deposit(amount, {"from": whale}) print(f'whale deposit done with {amount/1e18} weth\n') print("\n****** Initial Status ******") print("\n****** yfi ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print("\n****** Dai ******") state_of_vault(dai_vault, dai) print("\n****** Harvest yfi ******") strategy.harvest({'from': strategist}) print("\n****** yfi ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print("\n****** Dai ******") state_of_vault(dai_vault, dai) # withdraw yfi print('\n****** withdraw yfi ******') print(f'whale\'s yfi vault share: {vault.balanceOf(whale)/1e18}') vault.withdraw(Wei('1 ether'), {"from": whale}) print(f'withdraw 1 yfi done') print(f'whale\'s yfi vault share: {vault.balanceOf(whale)/1e18}') # transfer dai to strategy due to rounding issue dai.transfer(strategy, Wei('1 wei'), {"from": gov}) # withdraw all yfi print('\n****** withdraw all yfi ******') print(f'whale\'s yfi vault share: {vault.balanceOf(whale)/1e18}') vault.withdraw({"from": whale}) print(f'withdraw all yfi') print(f'whale\'s yfi vault share: {vault.balanceOf(whale)/1e18}') # try call tend print('\ncall tend') strategy.tend() print('tend done')
def test_operation(web3, chain, vault, strategy, token, amount, usdp, usdp_vault, whale, gov, guardian, strategist): # whale approve weth vault to use weth token.approve(vault, 2**256 - 1, {"from": whale}) # start deposit vault.deposit(amount, {"from": whale}) print(f'whale deposit done with {amount/1e18} weth\n') print(f"\n****** Initial Status ******") print(f"\n****** {token.symbol()} ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n****** usdp ******") state_of_vault(usdp_vault, usdp) print(f"\n****** Harvest {token.symbol()} ******") strategy.harvest({'from': strategist}) print(f"\n****** {token.symbol()} ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n****** usdp ******") state_of_vault(usdp_vault, usdp) # withdraw {token.symbol()} print(f"\n****** withdraw {token.symbol()} ******") print( f"whale's {token.symbol()} vault share: {vault.balanceOf(whale)/1e18}") vault.withdraw(Wei('1 ether'), {"from": whale}) print(f"withdraw 1 {token.symbol()} done") print( f"whale's {token.symbol()} vault share: {vault.balanceOf(whale)/1e18}") # transfer usdp to strategy due to rounding issue usdp.transfer(strategy, Wei('1 wei'), {"from": gov}) # withdraw all {token.symbol()} print(f"\n****** withdraw all {token.symbol()} ******") print( f"whale's {token.symbol()} vault share: {vault.balanceOf(whale)/1e18}") vault.withdraw({"from": whale}) print(f"withdraw all {token.symbol()}") print( f"whale's {token.symbol()} vault share: {vault.balanceOf(whale)/1e18}") # try call tend print(f"\ncall tend") strategy.tend() print(f"tend done")
def test_operation(web3, chain, vault, strategy, token, whale, gov, strategist, rewards, amount): scale = 10 ** token.decimals() # Deposit to the vault token.approve(vault, 2 ** 256 - 1, {"from": whale}) print(f"shares amount: {vault.balanceOf(whale)/scale}") vault.deposit(amount, {"from": whale}) print(f"deposit amount: {amount/scale}") print(f"shares amount: {vault.balanceOf(whale)/scale}") # assert token.balanceOf(vault.address) == amount print(f"token on strategy: {token.balanceOf(strategy)/scale}") print(f"\n****** Initial Status ******") print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> call harvest") strategy.harvest() print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> wait 1 day") chain.sleep(86400) chain.mine(1) state_of_vault(vault, token) # print(f"\n >>> set path") # strategy.setPathTarget(1, 1, {"from": strategist}) print(f"\n >>> call approveAll") strategy.approveAll({"from": strategist}) print(f"\n >>> harvest to realized profit") strategy.harvest() print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> wait 1 day to get the share price back") chain.sleep(86400) chain.mine(1) state_of_vault(vault, token) # print(f"\n >>> set path") # strategy.setPathTarget(2, 0, {"from": strategist}) print(f"\n >>> call approveAll") strategy.approveAll({"from": strategist}) print(f"\n >>> harvest to realized profit") strategy.harvest() print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> wait 1 day to get the share price back") chain.sleep(86400) chain.mine(1) state_of_vault(vault, token) # withdraw print() print(f"shares amount: {vault.balanceOf(whale)/scale}") before = token.balanceOf(whale) vault.withdraw({"from": whale}) print(f"withdraw amount: {(token.balanceOf(whale)-before)/scale}") print(f"shares amount: {vault.balanceOf(whale)/scale}") assert token.balanceOf(whale) != 0 # all withdraw print() print(f"rewards+strategist withdraw") vault.withdraw({"from": rewards}) vault.transfer(strategist, vault.balanceOf(strategy), {"from": strategy}) vault.withdraw({"from": strategist}) print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> call tend") strategy.tend()
def test_operation(web3, chain, vault, strategy, token, amount, whale, gov, guardian, strategist, rewards, seth_vault): scale = 10**token.decimals() # Deposit to the vault token.approve(vault, 2**256 - 1, {"from": whale}) print(f"shares amount: {vault.balanceOf(whale)/scale}") vault.deposit(amount, {"from": whale}) print(f"deposit amount: {amount/scale}") print(f"shares amount: {vault.balanceOf(whale)/scale}") # assert token.balanceOf(vault.address) == amount print(f"token on strategy: {token.balanceOf(strategy)/scale}") print(f"\n****** Initial Status ******") print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> call harvest") strategy.harvest() print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> harvest underlying live vaults & wait 1 day") harvest_live_vault(seth_vault) chain.sleep(86400) chain.mine(1) state_of_vault(vault, token) print(f"\n >>> harvest to realized profit") strategy.harvest() print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> harvest underlying live vaults & wait 1 day") harvest_live_vault(seth_vault) chain.sleep(86400) chain.mine(1) state_of_vault(vault, token) print(f"\n >>> harvest to realized profit") strategy.harvest() print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> wait 1 day to get the share price back") chain.sleep(86400) chain.mine(1) state_of_vault(vault, token) # withdraw print(f"\n****** withdraw {token.name()} ******") print( f"whale's {token.name()} vault share: {vault.balanceOf(whale)/scale}") vault.withdraw(amount / 2, {"from": whale}) print(f"withdraw {amount/2/scale} {token.name()} done") print( f"whale's {token.name()} vault share: {vault.balanceOf(whale)/scale}") print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) # withdraw all print(f"\n****** withdraw all {token.name()} ******") print( f"whale's {token.name()} vault share: {vault.balanceOf(whale)/scale}") vault.withdraw(vault.balanceOf(whale), whale, 10_000, {"from": whale}) print(f"withdraw all {token.name()}") print( f"whale's {token.name()} vault share: {vault.balanceOf(whale)/scale}") print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) # # all withdraw # print() # print(f"rewards+strategist withdraw") # vault.withdraw(vault.balanceOf(rewards), rewards, 10_000, {"from": rewards}) # vault.transfer(strategist, vault.balanceOf(strategy), {"from": strategy}) # vault.withdraw(vault.balanceOf(strategist), strategist, 10_000, {"from": strategist}) print(f"\n****** State ******") state_of_strategy(strategy, token, vault) state_of_vault(vault, token) print(f"\n >>> call tend") strategy.tend()