Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sim_execute_governor_five #1803

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 34 additions & 31 deletions brownie/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,37 +461,40 @@ def __exit__(self, *args, **kwargs):


def show_governor_four_proposal_actions(proposal_id):
actions = governor.getActions(proposal_id)
for i in range(0, len(actions[0])):
print("")
show_governance_action(i=i, to=actions[0][i], sig=actions[1][i], data=actions[2][i])
actions = governor.getActions(proposal_id)
for i in range(0, len(actions[0])):
print("")
show_governance_action(
i=i, to=actions[0][i], sig=actions[1][i], data=actions[2][i]
)


def show_governor_five_proposal_actions(proposal_id):
actions = governor_five.getActions(proposal_id)
for i in range(0, len(actions[0])):
print("")
show_governance_action(i=i, to=actions[0][i], sig=actions[2][i], data=actions[3][i])
if actions[1][i] != 0:
print(" TRANSFERS ETH!!! %d !!!", actions[1][i])

# set as an asset default strategy
def asset_default_strategy(strategy, asset):
tx = vault_admin.setAssetDefaultStrategy(asset.address, strategy.address, {'from': GOVERNOR})
tx.sig_string = 'setAssetDefaultStrategy(address,address)'
create_gov_proposal("Set comp strategy as default strategy for asset", [tx])
# execute latest proposal
sim_governor_execute(governor.proposalCount())

# harvest rewards from all the strategies
def harvest_all_strategies():
tx = harvester.harvestAndSwap({'from': GOVERNOR})
tx.sig_string = 'harvestAndSwap()'
create_gov_proposal("Harvest and swap all strategies", [tx])
# execute latest proposal
sim_governor_execute(governor.proposalCount())

# withdraw funds from Comp strategy
def withdrawFromComp(amount, asset):
comp_strat.withdraw(VAULT_PROXY_ADDRESS, asset.address, amount * math.pow(10, asset.decimals()), {'from': VAULT_PROXY_ADDRESS})
vault_core.rebase(OPTS)
actions = governor_five.getActions(proposal_id)
for i in range(0, len(actions[0])):
print("")
show_governance_action(
i=i, to=actions[0][i], sig=actions[2][i], data=actions[3][i]
)
if actions[1][i] != 0:
print(" TRANSFERS ETH!!! %d !!!", actions[1][i])


def sim_execute_governor_five(proposal_id):
"""
Bypasses the actual timelock/voting and just calls each governance action
as if the timelock sent the transaction individualy.

This skips the governance process time and block delays.
"""
actions = governor_five.getActions(proposal_id)
timelock = brownie.accounts.at(TIMELOCK, force=True)
for i in range(0, len(actions[0])):
show_governance_action(
i=i, to=actions[0][i], sig=actions[2][i], data=actions[3][i]
)
# Build actual data
sighash = brownie.web3.keccak(text=actions[2][i]).hex()[:10]
data = sighash + str(actions[3][i])[2:]
# Send it
timelock.transfer(to=actions[0][i], data=data, amount=actions[1][i])