def test_revoke_live(token_ecrv, strategy_ecrv_live, vault_ecrv_live, whale, gov_live): token_ecrv.approve(vault_ecrv_live, 2**256 - 1, {"from": whale}) vault_ecrv_live.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv_live.harvest({"from": gov_live}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) vault_ecrv_live.revokeStrategy(strategy_ecrv_live, {"from": gov_live}) strategy_ecrv_live.harvest({"from": gov_live}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv)
def test_revoke(token_ecrv, strategy_ecrv, vault_ecrv, whale, gov, strategist): token_ecrv.approve(vault_ecrv, 2**256 - 1, {"from": whale}) vault_ecrv.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv.harvest({"from": strategist}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) vault_ecrv.revokeStrategy(strategy_ecrv, {"from": gov}) strategy_ecrv.harvest({"from": strategist}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv)
def test_ops_live(token_seth, token_ecrv, strategy_ecrv_live, chain, vault_ecrv_live, dev, whale): # token_ecrv.approve(vault_ecrv_live, 2 ** 256 - 1, {"from": whale}) # whalebefore = token_ecrv.balanceOf(whale) # vault_ecrv_live.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv_live.harvest({"from": dev}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) chain.sleep(2592000) chain.mine(1) strategy_ecrv_live.harvest({"from": dev}) print("sETH = ", token_seth.balanceOf(strategy_ecrv_live) / 1e18) print("eCRV = ", strategy_ecrv_live.balance() / 1e18) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) # print( # "\nEstimated APR: ", # "{:.2%}".format( # ((vault_ecrv_live.totalAssets() - 100 * 1e18) * 12) / (100 * 1e18) # ), # ) # vault_ecrv_live.withdraw({"from": whale}) print("\nWithdraw") genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv)
def test_ops(token_seth, token_ecrv, strategy_ecrv, chain, vault_ecrv, voter_proxy, whale, strategist): token_ecrv.approve(vault_ecrv, 2**256 - 1, {"from": whale}) whalebefore = token_ecrv.balanceOf(whale) vault_ecrv.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv.harvest({"from": strategist}) assets_before = vault_ecrv.totalAssets() genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) chain.sleep(2592000) chain.mine(1) strategy_ecrv.harvest({"from": strategist}) print("sETH = ", token_seth.balanceOf(strategy_ecrv) / 1e18) print("eCRV = ", voter_proxy.balance() / 1e18) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) print( "\nEstimated APR: ", "{:.2%}".format( (vault_ecrv.totalAssets() - assets_before) / assets_before * 12), ) vault_ecrv.withdraw({"from": whale}) print("\nWithdraw") genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) print("Whale profit: ", (token_ecrv.balanceOf(whale) - whalebefore) / 1e18)
def test_migrate(token_ecrv, StrategyCurveEcrv, strategy_ecrv, chain, vault_ecrv, whale, gov, strategist): token_ecrv.approve(vault_ecrv, 2**256 - 1, {"from": whale}) vault_ecrv.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv.harvest({"from": strategist}) assets_before = vault_ecrv.totalAssets() genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) chain.sleep(2592000) chain.mine(1) strategy_ecrv.harvest({"from": strategist}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) print( "\nEstimated APR: ", "{:.2%}".format( (vault_ecrv.totalAssets() - assets_before) / assets_before * 12), ) strategy_ecrv2 = strategist.deploy(StrategyCurveEcrv, vault_ecrv) vault_ecrv.migrateStrategy(strategy_ecrv, strategy_ecrv2, {"from": gov}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfStrat(strategy_ecrv2, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv)
def test_ops_live( token_seth, token_ecrv, strategy_ecrv_live_old, strategy_ecrv_live, chain, vault_ecrv_live_old, vault_ecrv_live, voter_proxy, dev, whale, gov_live, devychad, ): # vault_ecrv_live_old.updateStrategyDebtRatio(strategy_ecrv_live_old, 0, {"from": devychad}) # strategy_ecrv_live_old.harvest({"from": dev}) # gauge = "0x3C0FFFF15EA30C35d7A85B85c0782D6c94e1d238" # voter_proxy.approveStrategy(gauge, strategy_ecrv_live, {"from": gov_live}) # vault_ecrv_live.setDepositLimit(2 ** 256 - 1, {"from": dev}) # strategy_ecrv_live.harvest({"from": devychad}) # vault_ecrv_live.migrateStrategy(strategy_ecrv_live, strategy_ecrv_live, {"from": devychad}) # strategy_ecrv_live.harvest({"from": devychad}) whalebefore = token_ecrv.balanceOf(whale) token_ecrv.approve(vault_ecrv_live, 2**256 - 1, {"from": whale}) vault_ecrv_live.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv_live.harvest({"from": dev}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) chain.sleep(2592000) chain.mine(1) assets_before = vault_ecrv_live.totalAssets() strategy_ecrv_live.harvest({"from": dev}) print("eCRV = ", strategy_ecrv_live.balance() / 1e18) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) print( "\nEstimated APR: ", "{:.2%}".format((vault_ecrv_live.totalAssets() - assets_before) / assets_before * 12), ) chain.sleep(21600) # 6 hour sandwitch protection vault_ecrv_live.withdraw({"from": whale}) print("\nWithdraw") genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) print("Whale profit: ", (token_ecrv.balanceOf(whale) - whalebefore) / 1e18)
def test_migrate_live(token_ecrv, StrategyCurveEcrv, strategy_ecrv_live, chain, vault_ecrv_live, whale, dev, devychad, gov_live, voter_proxy): strategy_ecrv_live.harvest({"from": gov_live}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) vaultAssets = vault_ecrv_live.totalAssets() vaultDebt = vault_ecrv_live.totalDebt() vaultLoose = token_ecrv.balanceOf(vault_ecrv_live) assert vaultAssets == vaultDebt + vaultLoose strategy_ecrv2 = dev.deploy(StrategyCurveEcrv, vault_ecrv_live) vault_ecrv_live.migrateStrategy(strategy_ecrv_live, strategy_ecrv2, {"from": gov_live}) voter_proxy.approveStrategy(strategy_ecrv2.gauge(), strategy_ecrv2, {"from": gov_live}) strategy_ecrv2.harvest({"from": gov_live}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfStrat(strategy_ecrv2, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) assert vault_ecrv_live.totalAssets() == vaultAssets assert vault_ecrv_live.totalDebt() + token_ecrv.balanceOf( vault_ecrv_live) == vaultDebt + vaultLoose # teardown vault_ecrv_live.updateStrategyDebtRatio(strategy_ecrv2, 0, {"from": gov_live}) strategy_ecrv2.harvest({"from": gov_live}) voter_proxy.approveStrategy(strategy_ecrv_live.gauge(), strategy_ecrv_live, {"from": gov_live}) vault_ecrv_live.updateStrategyDebtRatio(strategy_ecrv_live, 1000, {"from": gov_live})
def test_ops( token_seth, token_ecrv, strategy_ecrv, chain, vault_ecrv, whale, gov, strategist, ): debt_ratio = 10_000 vault_ecrv.addStrategy(strategy_ecrv, debt_ratio, 0, 1000, {"from": gov}) token_ecrv.approve(vault_ecrv, 2**256 - 1, {"from": whale}) whalebefore = token_ecrv.balanceOf(whale) vault_ecrv.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv.harvest({"from": strategist}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) chain.sleep(2592000) chain.mine(1) strategy_ecrv.harvest({"from": strategist}) print("sETH = ", token_seth.balanceOf(strategy_ecrv) / 1e18) print("eCRV = ", strategy_ecrv.balance() / 1e18) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) print( "\nEstimated APR: ", "{:.2%}".format( ((vault_ecrv.totalAssets() - 100 * 1e18) * 12) / (100 * 1e18)), ) vault_ecrv.withdraw({"from": whale}) print("\nWithdraw") genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) print("Whale profit: ", (token_ecrv.balanceOf(whale) - whalebefore) / 1e18)
def test_migrate(token_ecrv, StrategyCurveEcrv, strategy_ecrv, chain, vault_ecrv, voter_proxy, whale, gov, gov_live, strategist): token_ecrv.approve(vault_ecrv, 2**256 - 1, {"from": whale}) vault_ecrv.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv.harvest({"from": strategist}) assets_before = vault_ecrv.totalAssets() assert token_ecrv.balanceOf(vault_ecrv) < dust genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) chain.sleep(2592000) chain.mine(1) strategy_ecrv.harvest({"from": strategist}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) print( "\nEstimated APR: ", "{:.2%}".format( (vault_ecrv.totalAssets() - assets_before) / assets_before * 12), ) vaultAssets = vault_ecrv.totalAssets() vaultDebt = vault_ecrv.totalDebt() vaultLoose = token_ecrv.balanceOf(vault_ecrv) assert vaultAssets == vaultDebt + vaultLoose strategy_ecrv2 = strategist.deploy(StrategyCurveEcrv, vault_ecrv) vault_ecrv.migrateStrategy(strategy_ecrv, strategy_ecrv2, {"from": gov}) voter_proxy.approveStrategy(strategy_ecrv2.gauge(), strategy_ecrv2, {"from": gov_live}) strategy_ecrv2.harvest({"from": gov}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfStrat(strategy_ecrv2, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) assert vault_ecrv.totalAssets() == vaultAssets assert vault_ecrv.totalDebt() + token_ecrv.balanceOf( vault_ecrv) == vaultDebt + vaultLoose
def test_ops_live(token_seth, token_ecrv, strategy_ecrv_live, chain, vault_ecrv_live, dev, whale, gov_live, devychad): # proxy = Contract("0x9a3a03c614dc467acc3e81275468e033c98d960e") # gauge = "0x3C0FFFF15EA30C35d7A85B85c0782D6c94e1d238" # proxy.approveStrategy(gauge, strategy_ecrv_live_new, {"from": gov_live}) # strategy_ecrv_live.harvest({"from": devychad}) # vault_ecrv_live.migrateStrategy(strategy_ecrv_live, strategy_ecrv_live, {"from": devychad}) # strategy_ecrv_live.harvest({"from": devychad}) # token_ecrv.approve(vault_ecrv_live, 2 ** 256 - 1, {"from": whale}) # whalebefore = token_ecrv.balanceOf(whale) # vault_ecrv_live.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv_live.harvest({"from": dev}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) chain.sleep(2592000) chain.mine(1) assets_before = vault_ecrv_live.totalAssets() strategy_ecrv_live.harvest({"from": dev}) print("sETH = ", token_seth.balanceOf(strategy_ecrv_live) / 1e18) print("eCRV = ", strategy_ecrv_live.balance() / 1e18) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) print( "\nEstimated APR: ", "{:.2%}".format((vault_ecrv_live.totalAssets() - assets_before) / assets_before * 12), ) vault_ecrv_live.withdraw({"from": dev}) print("\nWithdraw") genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv)
def test_migrate( token_ecrv, StrategyCurveEcrv, strategy_ecrv, chain, vault_ecrv, whale, gov, strategist, ): debt_ratio = 10_000 vault_ecrv.addStrategy(strategy_ecrv, debt_ratio, 0, 1000, {"from": gov}) token_ecrv.approve(vault_ecrv, 2**256 - 1, {"from": whale}) vault_ecrv.deposit(Wei("100 ether"), {"from": whale}) strategy_ecrv.harvest({"from": strategist}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) chain.sleep(2592000) chain.mine(1) strategy_ecrv.harvest({"from": strategist}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv) print( "\nEstimated APR: ", "{:.2%}".format( ((vault_ecrv.totalAssets() - 100 * 1e18) * 12) / (100 * 1e18)), ) strategy_ecrv2 = strategist.deploy(StrategyCurveEcrv, vault_ecrv) vault_ecrv.migrateStrategy(strategy_ecrv, strategy_ecrv2, {"from": gov}) genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv) genericStateOfStrat(strategy_ecrv2, token_ecrv, vault_ecrv) genericStateOfVault(vault_ecrv, token_ecrv)
def test_migrate_live( token_ecrv, StrategyCurveEcrv, strategy_ecrv_live, chain, vault_ecrv_live, whale, dev, devychad, ): # token_ecrv.approve(vault_ecrv_live, 2 ** 256 - 1, {"from": whale}) # vault_ecrv_live.deposit(Wei("100 ether"), {"from": whale}) # strategy_ecrv_live.harvest({"from": dev}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) chain.sleep(2592000) chain.mine(1) assets_before = vault_ecrv_live.totalAssets() strategy_ecrv_live.harvest({"from": dev}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) print( "\nEstimated APR: ", "{:.2%}".format((vault_ecrv_live.totalAssets() - assets_before) / assets_before * 12), ) strategy_ecrv2 = dev.deploy(StrategyCurveEcrv, vault_ecrv_live) vault_ecrv_live.migrateStrategy(strategy_ecrv_live, strategy_ecrv2, {"from": devychad}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfStrat(strategy_ecrv2, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv)
def test_migrate_live( token_ecrv, StrategyCurveEcrv, strategy_ecrv_live, chain, vault_ecrv_live, whale, dev, ): # token_ecrv.approve(vault_ecrv_live, 2 ** 256 - 1, {"from": whale}) # vault_ecrv_live.deposit(Wei("100 ether"), {"from": whale}) # strategy_ecrv_live.harvest({"from": dev}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) chain.sleep(2592000) chain.mine(1) strategy_ecrv_live.harvest({"from": dev}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv) # print( # "\nEstimated APR: ", # "{:.2%}".format( # ((vault_ecrv_live.totalAssets() - 100 * 1e18) * 12) / (100 * 1e18) # ), # ) strategy_ecrv2 = dev.deploy(StrategyCurveEcrv, vault_ecrv_live) vault_ecrv_live.migrateStrategy(strategy_ecrv_live, strategy_ecrv2, {"from": dev}) genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live) genericStateOfStrat(strategy_ecrv2, token_ecrv, vault_ecrv_live) genericStateOfVault(vault_ecrv_live, token_ecrv)