diff --git a/brownie/runlogs/2023_07_strategist.py b/brownie/runlogs/2023_07_strategist.py index 462afa9b5d..7fba56d036 100644 --- a/brownie/runlogs/2023_07_strategist.py +++ b/brownie/runlogs/2023_07_strategist.py @@ -443,3 +443,297 @@ def main(): print("Transaction ", idx) print("To: ", item.receiver) print("Data (Hex encoded): ", item.input, "\n") + + + + + + +# -------------------------------- +# July 30, 2023 - OETH Funds Pull +# -------------------------------- + +from world import * + +txs = [] +with TemporaryFork(): + # Before + txs.append(vault_oeth_core.rebase({'from':STRATEGIST})) + txs.append(oeth_vault_value_checker.takeSnapshot({'from':STRATEGIST})) + + # Strategist + txs.append(vault_oeth_admin.withdrawAllFromStrategy(OETH_CONVEX_OETH_ETH_STRAT, {'from': STRATEGIST})) + + #After + vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0] + supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1] + profit = vault_change - supply_change + txs.append(oeth_vault_value_checker.checkDelta(profit, (0.1 * 10**18), vault_change, (2000 * 10**18), {'from': STRATEGIST})) + print("-----") + print("Profit", "{:.6f}".format(profit / 10**18), profit) + print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change) + print("-----") + print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs]))) + +print("Schedule the following transactions on Gnosis Safe") +for idx, item in enumerate(txs): + print("Transaction ", idx) + print("To: ", item.receiver) + print("Data (Hex encoded): ", item.input, "\n") + + + +# -------------------------------- +# July 30, 2023 - OUSD Funds Pull +# -------------------------------- + +from world import * + +txs = [] +with TemporaryFork(): + # Before + txs.append(vault_core.rebase({'from':STRATEGIST})) + txs.append(vault_value_checker.takeSnapshot({'from':STRATEGIST})) + + # Withdraw 19.2M USDT from Morpho Aave + txs.append(vault_admin.withdrawAllFromStrategy(OUSD_METASTRAT, {'from': STRATEGIST})) + + # After + vault_change = vault_core.totalValue() - vault_value_checker.snapshots(STRATEGIST)[0] + supply_change = ousd.totalSupply() - vault_value_checker.snapshots(STRATEGIST)[1] + profit = vault_change - supply_change + + txs.append(vault_value_checker.checkDelta(profit, (500 * 10**18), vault_change, (500 * 10**18), {'from': STRATEGIST})) + print("-----") + print("Profit", "{:.6f}".format(profit / 10**18), profit) + print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change) + + print("Schedule the following transactions on Gnosis Safe") + for idx, item in enumerate(txs): + print("Transaction ", idx) + print("To: ", item.receiver) + print("Data (Hex encoded): ", item.input, "\n") + + + +# -------------------------------- +# July 30, 2023 - OUSD All Funds Pull +# -------------------------------- + +from world import * + +txs = [] +with TemporaryFork(): + # Before + txs.append(vault_core.rebase({'from':STRATEGIST})) + txs.append(vault_value_checker.takeSnapshot({'from':STRATEGIST})) + + # Withdraw 19.2M USDT from Morpho Aave + txs.append(vault_admin.withdrawAllFromStrategies({'from': STRATEGIST})) + + # After + vault_change = vault_core.totalValue() - vault_value_checker.snapshots(STRATEGIST)[0] + supply_change = ousd.totalSupply() - vault_value_checker.snapshots(STRATEGIST)[1] + profit = vault_change - supply_change + + txs.append(vault_value_checker.checkDelta(profit, (500 * 10**18), vault_change, (300000 * 10**18), {'from': STRATEGIST})) + print("-----") + print("Profit", "{:.6f}".format(profit / 10**18), profit) + print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change) + + print("Schedule the following transactions on Gnosis Safe") + for idx, item in enumerate(txs): + print("Transaction ", idx) + print("To: ", item.receiver) + print("Data (Hex encoded): ", item.input, "\n") + + +# -------------------------------- +# July 30, 2023 - OETH All Funds Pull +# -------------------------------- + +from world import * + +txs = [] +with TemporaryFork(): + # Before + txs.append(vault_oeth_core.rebase({'from':STRATEGIST})) + txs.append(oeth_vault_value_checker.takeSnapshot({'from':STRATEGIST})) + + # Strategist + txs.append(vault_oeth_admin.withdrawAllFromStrategies({'from': STRATEGIST})) + + #After + vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0] + supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1] + profit = vault_change - supply_change + txs.append(oeth_vault_value_checker.checkDelta(profit, (0.1 * 10**18), vault_change, (2000 * 10**18), {'from': STRATEGIST})) + print("-----") + print("Profit", "{:.6f}".format(profit / 10**18), profit) + print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change) + print("-----") + print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs]))) + +print("Schedule the following transactions on Gnosis Safe") +for idx, item in enumerate(txs): + print("Transaction ", idx) + print("To: ", item.receiver) + print("Data (Hex encoded): ", item.input, "\n") + + +# -------------------------------- +# July 30, 2023 - Vault Buffers +# -------------------------------- + +from world import * + +txs = [] +with TemporaryFork(): + + # Strategist + txs.append(vault_oeth_admin.setVaultBuffer(10**18, {'from':STRATEGIST})) + txs.append(vault_admin.setVaultBuffer(10**18, {'from':STRATEGIST})) + + print("-----") + print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs]))) + +print("Schedule the following transactions on Gnosis Safe") +for idx, item in enumerate(txs): + print("Transaction ", idx) + print("To: ", item.receiver) + print("Data (Hex encoded): ", item.input, "\n") + + +# --------------------------------------- +# July 31, 2023 - OUSD back into earning +# -------------------------------------- + +from world import * +from allocations import * +import json +import time + +def to_gnosis_json(txs): + main = { + "version": "1.0", + "chainId": "1", + "createdAt": int(time.time()), + "meta": { + "name": "Transactions Batch", + "description": "", + "txBuilderVersion": "1.16.1", + "createdFromSafeAddress": "0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC", + "createdFromOwnerAddress": "", + # "checksum": "0x" + }, + "transactions": [] + } + for tx in txs: + main['transactions'].append({ + "to": tx.receiver, + "value": "0", + "data": tx.input, + "contractMethod": None, + "contractInputsValues": None + }) + return json.dumps(main) + + +txs = [] +with TemporaryFork(): + # Before + txs.append(vault_core.rebase({'from':STRATEGIST})) + txs.append(vault_value_checker.takeSnapshot({'from':STRATEGIST})) + + txs.append(to_strat(OUSD_METASTRAT, [[4_688_314, usdt]])) + + txs.append(vault_admin.setVaultBuffer(0, {'from':STRATEGIST})) + txs.append(vault_admin.setAssetDefaultStrategy(dai, MORPHO_COMP_STRAT,{'from':STRATEGIST})) + txs.append(vault_admin.setAssetDefaultStrategy(usdc, MORPHO_COMP_STRAT,{'from':STRATEGIST})) + txs.append(vault_admin.setAssetDefaultStrategy(usdt, MORPHO_COMP_STRAT,{'from':STRATEGIST})) + txs.append(vault_core.allocate({'from': STRATEGIST})) + + # After + vault_change = vault_core.totalValue() - vault_value_checker.snapshots(STRATEGIST)[0] + supply_change = ousd.totalSupply() - vault_value_checker.snapshots(STRATEGIST)[1] + profit = vault_change - supply_change + + txs.append(vault_value_checker.checkDelta(profit, (500 * 10**18), vault_change, (300000 * 10**18), {'from': STRATEGIST})) + print("-----") + print("Profit", "{:.6f}".format(profit / 10**18), profit) + print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change) + print("-----") + print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs]))) + print("-----") + print(load_from_blockchain()) + + print("Schedule the following transactions on Gnosis Safe") + for idx, item in enumerate(txs): + print("Transaction ", idx) + print("To: ", item.receiver) + print("Data (Hex encoded): ", item.input, "\n") + print(to_gnosis_json(txs)) + +# --------------------------------------- +# July 31, 2023 - OETH back into earning +# -------------------------------------- + + +from world import * +import json +import time + +def to_gnosis_json(txs): + main = { + "version": "1.0", + "chainId": "1", + "createdAt": int(time.time()), + "meta": { + "name": "Transactions Batch", + "description": "", + "txBuilderVersion": "1.16.1", + "createdFromSafeAddress": "0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC", + "createdFromOwnerAddress": "", + # "checksum": "0x" + }, + "transactions": [] + } + for tx in txs: + main['transactions'].append({ + "to": tx.receiver, + "value": "0", + "data": tx.input, + "contractMethod": None, + "contractInputsValues": None + }) + return json.dumps(main) + +txs = [] +with TemporaryFork(): + # Before + txs.append(vault_oeth_core.rebase({'from':STRATEGIST})) + txs.append(oeth_vault_value_checker.takeSnapshot({'from':STRATEGIST})) + + # Strategist + txs.append(vault_oeth_admin.depositToStrategy(OETH_CONVEX_OETH_ETH_STRAT, [weth], [2_445*1e18], {'from': STRATEGIST})) + txs.append(vault_oeth_admin.setVaultBuffer(0, {'from':STRATEGIST})) + txs.append(vault_oeth_core.allocate({'from': STRATEGIST})) + + #After + vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0] + supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1] + profit = vault_change - supply_change + txs.append(oeth_vault_value_checker.checkDelta(profit, (0.1 * 10**18), vault_change, (2000 * 10**18), {'from': STRATEGIST})) + print("-----") + print("Profit", "{:.6f}".format(profit / 10**18), profit) + print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change) + print("-----") + print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs]))) + +print("Schedule the following transactions on Gnosis Safe") +for idx, item in enumerate(txs): + print("Transaction ", idx) + print("To: ", item.receiver) + print("Data (Hex encoded): ", item.input, "\n") +print("----") +print(to_gnosis_json(txs)) \ No newline at end of file diff --git a/brownie/runlogs/2023_08_strategist.py b/brownie/runlogs/2023_08_strategist.py new file mode 100644 index 0000000000..6acc3ad29f --- /dev/null +++ b/brownie/runlogs/2023_08_strategist.py @@ -0,0 +1,21 @@ +from world import * + + +with TemporaryForkForReallocations() as txs: + # Before + txs.append(vault_oeth_core.rebase({'from':STRATEGIST})) + txs.append(oeth_vault_value_checker.takeSnapshot({'from':STRATEGIST})) + + # Strategist + txs.append(vault_oeth_admin.withdrawAllFromStrategy(OETH_CONVEX_OETH_ETH_STRAT, {'from': STRATEGIST})) + txs.append(vault_oeth_admin.depositToStrategy(OETH_CONVEX_OETH_ETH_STRAT, [weth], [4_853*1e18], {'from': STRATEGIST})) + + #After + vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0] + supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1] + profit = vault_change - supply_change + txs.append(oeth_vault_value_checker.checkDelta(profit, (0.1 * 10**18), vault_change, (1000 * 10**18), {'from': STRATEGIST})) + print("-----") + print("Profit", "{:.6f}".format(profit / 10**18), profit) + print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change) + print("-----") diff --git a/brownie/world.py b/brownie/world.py index c5d34c0868..0a25c7df9b 100644 --- a/brownie/world.py +++ b/brownie/world.py @@ -405,7 +405,57 @@ def show_governance_action(i, to, sig, data): print(" >> ", nice_contract_address(v)) else: print(" >> ", ORANGE+str(v)+ENDC) - + +def to_gnosis_json(txs): + main = { + "version": "1.0", + "chainId": "1", + "createdAt": int(time.time()), + "meta": { + "name": "Transactions Batch", + "description": "", + "txBuilderVersion": "1.16.1", + "createdFromSafeAddress": "0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC", + "createdFromOwnerAddress": "", + # "checksum": "0x" + }, + "transactions": [], + } + for tx in txs: + main["transactions"].append( + { + "to": tx.receiver, + "value": "0", + "data": tx.input, + "contractMethod": None, + "contractInputsValues": None, + } + ) + return json.dumps(main) + + +def show_txs_data(txs): + print("Schedule the following transactions on Gnosis Safe") + for idx, item in enumerate(txs): + print("Transaction ", idx) + print("To: ", item.receiver) + print("Data (Hex encoded): ", item.input, "\n") + + +class TemporaryForkForReallocations: + def __enter__(self): + self.txs = [] + brownie.chain.snapshot() + return self.txs + + def __exit__(self, *args, **kwargs): + brownie.chain.revert() + print("----") + print("Gnosis json:") + print(to_gnosis_json(self.txs)) + print("----") + print("Est Gas Max: {:,}".format(1.10 * sum([x.gas_used for x in self.txs]))) + def show_governor_four_proposal_actions(proposal_id): actions = governor.getActions(proposal_id)