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: —
Classes
Manage the registry of Enzyme contracts. |
|
Enzyme protocol deployment description. |
|
See IChainlinkPriceFeedMixin.sol |
|
Enzyme policy configuration. |
Exceptions
Something is not so right. |
- 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.
- __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
- deploy(contract_name, *args)
Deploys a contract and stores its reference.
Pick ABI JSON file from our precompiled package.
- Parameters
contract_name (str) –
- get_all_addresses()
Return all labeled addresses as a dict.
- 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
Optional[web3.contract.contract.Contract]
- 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
- __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 (Optional[web3.contract.contract.Contract]) –
- Return type
None
- 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
- 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 (Optional[eth_defi.enzyme.deployment.VaultPolicyConfiguration]) –
- 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
- 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 (Optional[web3.contract.contract.Contract]) – Set USDC contract address in unit testing.
web3 (web3.main.Web3) –
- Returns
Enzyme deployment details
- 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]
- exception EnzymeDeploymentError
Bases:
ExceptionSomething is not so right.
- __init__(*args, **kwargs)
- __new__(**kwargs)
- add_note(note, /)
Add a note to the exception
- with_traceback(tb, /)
Set self.__traceback__ to tb and return self.
- class VaultPolicyConfiguration
Bases:
objectEnzyme policy configuration.
Passed to the fund deployer when the vault is created.
- __init__(policies, shares_action_time_lock=0)
- Parameters
policies (Dict[eth_typing.evm.HexAddress, bytes]) –
shares_action_time_lock (int) –
- Return type
None
- encode()
Serialise for the fund deployer.
See https://github.com/enzymefinance/protocol/blob/v4/tests/utils/core/PolicyUtils.sol
- Return type