EnzymeDeployment

Documentation for eth_defi.enzyme.deployment.EnzymeDeployment Python class.

class EnzymeDeployment[source]

Enzyme protocol deployment description.

  • Describe on-chain Enzyme deployment

  • Provide property access and documentation of different parts of Enzyme protocol

  • Allow vault deployments and such

Attributes summary

web3

Web3 connection this deployment is tied to

deployer

The deployer account used in tests

contracts

Mimic Enzyme's deployer.sol

mln

MELON ERC-20

weth

WETH ERC-20

usdc

USDC contract for the chain, or None

Methods summary

__init__(web3, deployer, contracts, mln, weth)

add_primitive(token, aggregator, rate_asset)

Add a primitive asset to a Enzyme protocol.

create_new_vault(owner, denomination_asset)

Creates a new fund (vault).

deploy_core(web3, deployer, mln, weth[, ...])

Make a test Enzyme deployment.

fetch_deployment(web3, contract_addresses[, ...])

Fetch enzyme deployment and some of its contract.

fetch_vault(vault_address)

Fetch existing Enzyme vault contracts.

remove_primitive(token)

Remove a primitive asset to a Enzyme protocol.

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

usdc: web3.contract.contract.Contract | None

USDC contract for the chain, or None

Optional

add_primitive(token, aggregator, rate_asset)[source]

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
Return type

str

remove_primitive(token)[source]

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

str

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)[source]

Creates a new fund (vault).

  • See CreateNewVault.sol.

  • See FundDeployer.sol.

Parameters
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')[source]

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

eth_defi.enzyme.deployment.EnzymeDeployment

fetch_vault(vault_address)[source]

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)[source]

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

eth_defi.enzyme.deployment.EnzymeDeployment

__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