enzyme.deployment
Documentation for eth_defi.enzyme.deployment Python module.
Enzyme protocol deployment.
Functions to fetch live on-chain Enzyme deployment or deploy your own unit testing version.
Setting the Enzyme to debug mode:
window.enzymeDebug = true;
Enables
Testnet deployments
Impersonator wallet
See Enzyme Subgraphs: —
Module Attributes
Enzyme deployment details for Polygon |
|
Enzyme deployment details for Arbitrum |
|
Enzyme deployment details for Ethereum |
Classes
Manage the registry of Enzyme contracts. |
|
Enzyme protocol deployment description. |
|
See IChainlinkPriceFeedMixin.sol |
|
Enzyme policy configuration. |
Exceptions
Something is not so right. |
- POLYGON_DEPLOYMENT = {'allowed_adapters_policy': '0x4218783aE10BD1841E6664cF048ac295D8d27a4a', 'allowed_external_position_types_policy': '0x5A739da3099fd4fC954BD764099Fc000Da76D8e7', 'comptroller_lib': '0xf5fc0e36c85552E44354132D188C33D9361eB441', 'cumulative_slippage_tolerance_policy': '0x1332367C181F1157F751b160187DcAa219706bF2', 'deployed_at': 25825795, 'fund_value_calculator': '0xcdf038Dd3b66506d2e5378aee185b2f0084B7A33', 'only_remove_dust_external_position_policy': '0xC0f49507c125a000e02ab58C22bE9764e2ABAB99', 'only_untrack_dust_or_priceless_assets_policy': '0x9F856372F7Bd844dac0254c7859B117259b5c9D2', 'usdc': '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', 'weth': '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', 'wmatic': '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270'}
Enzyme deployment details for Polygon
See
EnzymeDeployment.fetch_deployment()See https://docs.enzyme.finance/developers/contracts/polygon
- ARBITRUM_DEPLOYMENT = {'allowed_adapters_policy': '0x1768b813d17f82a8d70bd8b80a8c8c1562878337', 'allowed_external_position_types_policy': '0x3c441b696bd451d0ba95ebb73cf1b23c20873e14', 'arb': '0x912ce59144191c1204e64559fe8253a0e49e6548', 'comptroller_lib': '0x3868c0fc34b6ece124c6ab122f6f29e978be6661', 'cumulative_slippage_tolerance_policy': '0x487f6a8a93c2be5a296ead2c3fbc3fceed4ac599', 'deployed_at': 230330758, 'fund_value_calculator': '0xea609eeb38d1ee8e8719597d47cc9276df9f8707', 'only_remove_dust_external_position_policy': '0xe4453105be9e579896a3ed73df9a1e285c8c95c2', 'only_untrack_dust_or_priceless_assets_policy': '0xa482f4ab637cd5ca00084d511b3ca9aa8d8f475e', 'usdc': '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8', 'usdt': '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9', 'weth': '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'}
Enzyme deployment details for Arbitrum
See
EnzymeDeployment.fetch_deployment()See https://docs.enzyme.finance/general-info/codebase/contracts/arbitrum
- ETHEREUM_DEPLOYMENT = {'comptroller_lib': '0x03F7f3B8Da875881206655D8099B9DACf721f1EF', 'deployed_at': 11632494, 'fund_value_calculator': '0x490e64E0690b4aa481Fb02255aED3d052Bad7BF1', 'usdc': '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 'weth': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'}
Enzyme deployment details for Ethereum
See
EnzymeDeployment.fetch_deployment()See https://docs.enzyme.finance/developers/contracts/polygon
- exception EnzymeDeploymentError
Bases:
ExceptionSomething is not so right.
- __init__(*args, **kwargs)
- __new__(**kwargs)
- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class EnzymeContracts
Bases:
objectManage the registry of Enzyme contracts.
See Enzyme specification documentation for overview of different contracts.
Mimics Deployer.sol from Enzyme unit tests.
- address_list_registry: web3.contract.contract.Contract
Enzyme Council maintained address list.
Audited adapters.
- deploy(contract_name, *args)
Deploys a contract and stores its reference.
Pick ABI JSON file from our precompiled package.
- Parameters
contract_name (str) –
- get_deployed_contract(contract_name, address)
Helper access for IVault and IComptroller
- Parameters
contract_name (str) –
address (eth_typing.evm.HexAddress) –
- Return type
web3.contract.contract.Contract
- get_optionally_deployed_contract(contract_name, address)
Helper access for IVault and IComptroller
- Parameters
contract_name (str) –
address (Optional[eth_typing.evm.HexAddress]) –
- Return type
web3.contract.contract.Contract | None
- get_all_addresses()
Return all labeled addresses as a dict.
- __init__(web3, deployer, dispatcher=None, external_position_factory=None, protocol_fee_reserve_lib=None, protocol_fee_reserve_proxy=None, address_list_registry=None, fund_deployer=None, value_interpreter=None, policy_manager=None, external_position_manager=None, fee_manager=None, integration_manager=None, comptroller_lib=None, protocol_fee_tracker=None, vault_lib=None, gas_relay_paymaster_lib=None, gas_relay_paymaster_factory=None, fund_value_calculator=None, cumulative_slippage_tolerance_policy=None, allowed_adapters_policy=None, only_remove_dust_external_position_policy=None, only_untrack_dust_or_priceless_assets_policy=None, allowed_external_position_types_policy=None)
- Parameters
web3 (web3.main.Web3) –
deployer (Optional[eth_typing.evm.HexAddress]) –
dispatcher (web3.contract.contract.Contract) –
external_position_factory (web3.contract.contract.Contract) –
protocol_fee_reserve_lib (web3.contract.contract.Contract) –
protocol_fee_reserve_proxy (web3.contract.contract.Contract) –
address_list_registry (web3.contract.contract.Contract) –
fund_deployer (web3.contract.contract.Contract) –
value_interpreter (web3.contract.contract.Contract) –
policy_manager (web3.contract.contract.Contract) –
external_position_manager (web3.contract.contract.Contract) –
fee_manager (web3.contract.contract.Contract) –
integration_manager (web3.contract.contract.Contract) –
comptroller_lib (web3.contract.contract.Contract) –
protocol_fee_tracker (web3.contract.contract.Contract) –
vault_lib (web3.contract.contract.Contract) –
gas_relay_paymaster_lib (web3.contract.contract.Contract) –
gas_relay_paymaster_factory (web3.contract.contract.Contract) –
fund_value_calculator (web3.contract.contract.Contract) –
cumulative_slippage_tolerance_policy (web3.contract.contract.Contract) –
allowed_adapters_policy (web3.contract.contract.Contract) –
only_remove_dust_external_position_policy (web3.contract.contract.Contract) –
only_untrack_dust_or_priceless_assets_policy (web3.contract.contract.Contract) –
allowed_external_position_types_policy (web3.contract.contract.Contract) –
- Return type
None
- class VaultPolicyConfiguration
Bases:
objectEnzyme policy configuration.
Passed to the fund deployer when the vault is created.
- policies: Dict[eth_typing.evm.HexAddress, bytes]
Dict of enabled policies and their configs
Policy contract address -> policy config bytes
What is the minimum time before user can redeem shares after deposit.
Prevent arbitrage attacks.
Set to zero by default, because there is a conflict with this setting and using a deposit contract (TermedVaultUSDCPaymentForwarder). Can be set to any value after Enzyme whitelists the deposit contract.
- encode()
Serialise for the fund deployer.
See https://github.com/enzymefinance/protocol/blob/v4/tests/utils/core/PolicyUtils.sol
- Return type
- __init__(policies, shares_action_time_lock=0)
- Parameters
policies (Dict[eth_typing.evm.HexAddress, bytes]) –
shares_action_time_lock (int) –
- Return type
None
- class EnzymeDeployment
Bases:
objectEnzyme protocol deployment description.
Describe on-chain Enzyme deployment
Provide property access and documentation of different parts of Enzyme protocol
Allow vault deployments and such
- web3: web3.main.Web3
Web3 connection this deployment is tied to
- deployer: eth_typing.evm.HexAddress
The deployer account used in tests
- contracts: eth_defi.enzyme.deployment.EnzymeContracts
Mimic Enzyme’s deployer.sol
- mln: web3.contract.contract.Contract
MELON ERC-20
- weth: web3.contract.contract.Contract
WETH ERC-20
- add_primitive(token, aggregator, rate_asset)
Add a primitive asset to a Enzyme protocol.
This will tell Enzyme how to value this asset.
See ValueInterpreter.sol
See ChainlinkPriceFeedMixin.sol
- Returns
Transaction hash for the addition
- Parameters
token (web3.contract.contract.Contract) –
aggregator (web3.contract.contract.Contract) –
rate_asset (eth_defi.enzyme.deployment.RateAsset) –
- Return type
- remove_primitive(token)
Remove a primitive asset to a Enzyme protocol.
This will tell Enzyme how to value this asset.
See ChainlinkPriceFeedMixin.sol
- Returns
Transaction hash for the addition
- Parameters
token (web3.contract.contract.Contract) –
- Return type
- create_new_vault(owner, denomination_asset, fund_name='Example Fund', fund_symbol='EXAMPLE', shares_action_time_lock=None, fee_manager_config_data=b'', policy_manager_config_data=b'', deployer=None, policy_configuration=None)
Creates a new fund (vault).
See CreateNewVault.sol.
See FundDeployer.sol.
- Parameters
shares_action_time_lock – Give part of the policy_configuration.
owner (eth_typing.evm.HexAddress) –
denomination_asset (web3.contract.contract.Contract) –
policy_configuration (eth_defi.enzyme.deployment.VaultPolicyConfiguration | None) –
- Returns
Tuple (Comptroller contract, vault contract)
- Return type
Tuple[web3.contract.contract.Contract, web3.contract.contract.Contract]
- static deploy_core(web3, deployer, mln, weth, chainlink_stale_rate_threshold=315360000, vault_position_limit=20, vault_mln_burner='0x0000000000000000000000000000000000000000')
Make a test Enzyme deployment.
Designed to be used in unit testing.
This is copied from the Forge test suite deployLiveRelease().
See
contracts/enzyme/tests/deployment
- Parameters
deployer (eth_typing.evm.HexAddress) – EVM account used for the deployment
web3 (web3.main.Web3) –
mln (web3.contract.contract.Contract) –
weth (web3.contract.contract.Contract) –
- Return type
- fetch_vault(vault_address)
Fetch existing Enzyme vault contracts.
- Returns
Tuple (Comptroller contract, vault contract)
- Parameters
vault_address (Union[eth_typing.evm.HexAddress, str]) –
- Return type
Tuple[web3.contract.contract.Contract, web3.contract.contract.Contract]
- static fetch_deployment(web3, contract_addresses, deployer=None, usdc=None)
Fetch enzyme deployment and some of its contract.
Read existing Enzyme deployment from on-chain.
Note
Does not do complete contract resolution yet.
Example:
from eth_defi.enzyme.deployment import EnzymeDeployment, POLYGON_DEPLOYMENT deployment = EnzymeDeployment.fetch_deployment(web3, POLYGON_DEPLOYMENT) assert deployment.mln.functions.symbol().call() == "MLN" assert deployment.weth.functions.symbol().call() == "WMATIC"
- Parameters
contract_addresses (dict) – Dictionary of contract addresses required to resolve Enzyme deployment
deployer (Optional[Union[eth_typing.evm.HexAddress, str]]) – Associate a deployer account with this Enzyme deployment to deploy new vaults.
usdc (web3.contract.contract.Contract | None) – Set USDC contract address in unit testing.
web3 (web3.main.Web3) –
- Returns
Enzyme deployment details
- Return type
- __init__(web3, deployer, contracts, mln, weth, usdc=None)
- Parameters
web3 (web3.main.Web3) –
deployer (eth_typing.evm.HexAddress) –
contracts (eth_defi.enzyme.deployment.EnzymeContracts) –
mln (web3.contract.contract.Contract) –
weth (web3.contract.contract.Contract) –
usdc (web3.contract.contract.Contract | None) –
- Return type
None