Skip to content

Commit

Permalink
Progress on Enzyme arbitrum deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Sep 26, 2024
1 parent 10e1d2c commit 01e7892
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 229 deletions.
30 changes: 24 additions & 6 deletions eth_defi/enzyme/generic_adapter_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from web3 import Web3
from web3.contract import Contract

from eth_defi.aave_v3.constants import AAVE_V3_DEPLOYMENTS
from eth_defi.aave_v3.constants import AAVE_V3_DEPLOYMENTS, AAVE_V3_NETWORKS
from eth_defi.aave_v3.deployment import fetch_deployment as fetch_aave_deployment
from eth_defi.enzyme.deployment import EnzymeDeployment
from eth_defi.enzyme.policy import (
Expand Down Expand Up @@ -463,12 +463,30 @@ def deploy_guard(
tx_hash = guard.functions.whitelistAaveV3(aave_pool_address, note).transact({"from": deployer.address})
assert_transaction_success_with_explanation(web3, tx_hash)

assert web3.eth.chain_id == 1, "TODO: Add support for non-mainnet chains"
ausdc_address = "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c"
logger.info("Aave whitelisting for pool %s, aUSDC %s", aave_pool_address, ausdc_address)
match web3.eth.chain_id:
case 1:
assert web3.eth.chain_id == 1, "TODO: Add support for non-mainnet chains"
ausdc_address = "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c"
logger.info("Aave whitelisting for pool %s, aUSDC %s", aave_pool_address, ausdc_address)

note = f"Aave v3 pool whitelisting for USDC"
tx_hash = guard.functions.whitelistToken(ausdc_address, note).transact({"from": deployer.address})

case 42161:
# Arbitrum
aave_tokens = AAVE_V3_NETWORKS["arbitrum"].token_contracts
for symbol, token in aave_tokens.items():
logger.info(
"Aave whitelisting for pool %s, atoken:%s address: %s",
aave_pool_address,
token.token_address,
)
note = f"Whitelisting Aave {symbol}"
tx_hash = guard.functions.whitelistToken(token.token_address, note).transact({"from": deployer.address})
assert_transaction_success_with_explanation(web3, tx_hash)
case _:
raise NotImplementedError(f"TODO: Add support for non-mainnet chains, got {web3.eth.chain_id}")

note = f"Aave v3 pool whitelisting for USDC"
tx_hash = guard.functions.whitelistToken(ausdc_address, note).transact({"from": deployer.address})
assert_transaction_success_with_explanation(web3, tx_hash)

deployer.sync_nonce(web3)
Expand Down
8 changes: 7 additions & 1 deletion eth_defi/foundry/forge.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ def deploy_contract_with_forge(
assert type(contract_name) == str
assert isinstance(deployer, HotWallet), f"Got deployer: {type(deployer)}"

assert deployer.private_key is not None, f"Deployer missing private key: {deployer}"

if constructor_args is None:
constructor_args = []

Expand Down Expand Up @@ -236,7 +238,11 @@ def deploy_contract_with_forge(
for arg in constructor_args:
cmd_line.append(arg)

censored_command = " ".join(cmd_line)
try:
censored_command = " ".join(cmd_line)
except TypeError as e:
# Be helpful with None error
raise TypeError(f"Could not splice command line: {cmd_line}") from e

logger.info(
"Deploying a contract with forge. Working directory %s, forge command: %s",
Expand Down
Loading

0 comments on commit 01e7892

Please sign in to comment.