enzyme.generic_adapter_vault
Documentation for eth_defi.enzyme.generic_adapter_vault Python module.
Safe deployment of Enzyme vaults with generic adapter.
To patch the guard deployment in console:
import json
from eth_defi.abi import get_deployed_contract
deploy_data = json.load(open("deploy/STOCH-RSI-vault-info.json", "rt))
guard_address = deploy_data["guard"]
guard = get_deployed_contract(web3, "guard/GuardV0", guard_address)
Functions
|
Make GenericAdapter to work with a single vault only. |
|
Deploy a new generic adapter for a vault. |
|
Deploy a new GuardV0 smart contract. |
|
Deploy an Enzyme vault and make it secure. |
|
Configure guard to allow vault to trade with tokens. |
- deploy_vault_with_generic_adapter(deployment, deployer, asset_manager, owner, denomination_asset, terms_of_service, fund_name='Example Fund', fund_symbol='EXAMPLE', whitelisted_assets=None, etherscan_api_key=None, production=False, meta='', uniswap_v2=True, uniswap_v3=True, one_delta=False, aave=False, mock_guard=False)
Deploy an Enzyme vault and make it secure.
Deploys an Enzyme vault in a specific way we want to have it deployed.
Because we want multiple deployed smart contracts to be verified on Etherscan, this deployed uses a Forge-based toolchain and thus the script can be only run from the git checkout where submodules are included.
Set up default policies
Assign a generic adapter
Assign a USDC payment forwarder with terms of service sign up
Assign asset manager role and transfer ownership
Whitelist USDC and the other given assets
Whitelist Uniswap v2 and v3 spot routers
Note
The GuardV0 ownership is not transferred to the owner at the end of the deployment. You need to do it manually after configuring the guard.
- Parameters
deployment (eth_defi.enzyme.deployment.EnzymeDeployment) – Enzyme deployment we use.
deployer (eth_defi.hotwallet.HotWallet) – Web3.py deployer account we use.
asset_manager (Union[eth_typing.evm.HexAddress, str]) –
Give trading access to this hot wallet address.
Set to the deployer address to ignore.
terms_of_service (web3.contract.contract.Contract | None) – Terms of service contract we use.
owner (Union[eth_typing.evm.HexAddress, str]) –
Nominated new owner.
Immediately transfer vault ownership from a deployer to a multisig owner. Multisig needs to confirm this by calling claimOwnership.
Set to the deployer address to ignore.
whitelisted_assets (Optional[Collection[eth_defi.token.TokenDetails]]) –
Whitelist these assets on Uniswap v2 and v3 spot market.
USDC is always whitelisted.
denomination_asset (web3.contract.contract.Contract) – USDC token used as the vault denomination currency.
etherscan_api_key (str | None) – Needed to verify deployed contracts.
production – Production flag set on GuardedGenericAdapterDeployed event.
meta (str) – Metadata for GuardedGenericAdapterDeployed event.
uniswap_v2 – Whiteliste Uniswap v2 trading
uniswap_v3 – Whiteliste Uniswap v3 trading
mock_guard – Deploy unit test mock of the guard
- Returns
Freshly deployed vault
- Return type
- deploy_guard(web3, deployer, asset_manager, owner, denomination_asset, whitelisted_assets=None, etherscan_api_key=None, uniswap_v2=True, uniswap_v3=True, one_delta=False, aave=False, mock_guard=False)
Deploy a new GuardV0 smart contract.
To be associated with Enzyme vault or SimpleVault
Can be deployment standalone and the vault upgraded to use a newer version of the guard
See
deploy_vault_with_generic_adapter()for more details.- Parameters
mock_guard –
Set to true to disable actual deployment.
Used in legacy unit test setup.
web3 (web3.main.Web3) –
deployer (eth_defi.hotwallet.HotWallet) –
asset_manager (Union[eth_typing.evm.HexAddress, str]) –
owner (Union[eth_typing.evm.HexAddress, str]) –
denomination_asset (web3.contract.contract.Contract) –
whitelisted_assets (Optional[Collection[eth_defi.token.TokenDetails]]) –
etherscan_api_key (str | None) –
- Return type
web3.contract.contract.Contract
- deploy_generic_adapter_with_guard(deployment, deployer, guard, etherscan_api_key=None)
Deploy a new generic adapter for a vault.
TODO: If the vault has existing generic adapter, we do not currently revoke the old adapter.
- Parameters
deployment (eth_defi.enzyme.deployment.EnzymeDeployment) –
deployer (eth_defi.hotwallet.HotWallet) –
guard (web3.contract.contract.Contract) –
etherscan_api_key (str | None) –
- Return type
web3.contract.contract.Contract
- whitelist_sender_receiver(guard, deployer, allow_sender=None, allow_receiver=None)
Configure guard to allow vault to trade with tokens.
Configure where incoming/outgoing tokens
- Parameters
guard (web3.contract.contract.Contract) –
deployer (eth_defi.hotwallet.HotWallet) –
allow_sender (str | None) –
allow_receiver (str | None) –
- bind_vault(generic_adapter, vault, production, meta, deployer, gas=500000)
Make GenericAdapter to work with a single vault only.
- Parameters
gas (int) – estimateGas will crash when calling bindVault() because the tx to deploy the contract has not hit all RPCs yet.
generic_adapter (web3.contract.contract.Contract) –
vault (web3.contract.contract.Contract) –
production (bool) –
meta (str) –
deployer (eth_defi.hotwallet.HotWallet) –