erc_4626.vault_protocol.lagoon.deployment

Documentation for eth_defi.erc_4626.vault_protocol.lagoon.deployment Python module.

Deploy new Lagoon vaults.

Lagoon automatised vault consists of

  • Safe multisig - we use 1.4.1 here

  • Vault module

  • Lagoon protocol smart contracts

  • TradingStrategyModuleV0 module enabling guarded automated trade executor for the Safe

  • Support deployments with Forge and Etherscan verification

Any Safe must be deployed as 1-of-1 deployer address multisig and multisig holders changed after the deployment.

Module Attributes

Functions

deploy_automated_lagoon_vault(*, web3, ...)

Deploy a full Lagoon setup with a guard.

deploy_fresh_lagoon_protocol(web3, deployer, ...)

Deploy a fresh Lagoon implementation from the scratch.

deploy_lagoon(web3, deployer, safe, ...[, ...])

Deploy a new Lagoon vault.

deploy_lagoon_protocol_registry(web3, ...[, ...])

Deploy a fee registry contract.

deploy_safe_trading_strategy_module(web3, ...)

Deploy TradingStrategyModuleV0 for Safe and Lagoon.

setup_guard(*, web3, safe, deployer, owner, ...)

Setups up TradingStrategyModuleV0 guard on the Lagoon vault.

Classes

LagoonAutomatedDeployment

Capture information of the lagoon automated deployment.

LagoonDeploymentParameters

Capture core parameters needed to deploy a Lagoon vault

class LagoonDeploymentParameters

Bases: object

Capture core parameters needed to deploy a Lagoon vault

managementRate: int

Management fee in BPS

performanceRate: int

Performance fee in BPS

rateUpdateCooldown: int

Max rate update frequency, seconds

wrappedNativeToken: Optional[eth_typing.evm.HexAddress]

If set None, then autoresolve

as_abi_encoded_bytes()

Return Lagoon vault initialization struct ABI encoded.

  • Before was passed as is, was changed to ABI encoded bytes in Lagoon v0.5.0.

  • Does not include wrappedNativeToken

  • Does not include feeRegistry, as it is passed separately.

Return type

hexbytes.main.HexBytes

get_create_vault_proxy_arguments()

For createVaultProxy()

Return type

list[Any]

__init__(underlying, name, symbol, safe=None, whitelistManager=None, valuationManager=None, admin=None, feeReceiver=None, feeRegistry=None, managementRate=200, performanceRate=2000, enableWhitelist=False, rateUpdateCooldown=86400, wrappedNativeToken=None)
Parameters
Return type

None

class LagoonAutomatedDeployment

Bases: object

Capture information of the lagoon automated deployment.

  • Have the deployment report for the users for diagnostics

vault_abi: str

Vault ABI file we use

old_trading_strategy_module: web3.contract.contract.Contract | None

In redeploy guard, the old module

beacon_proxy_factory: Optional[eth_typing.evm.HexAddress]

Address of beacon proxy factory

gas_used: decimal.Decimal | None

How much ETH deployment used

get_deployment_data()

Get JSON data describing the deployment.

Store all addresses etc.

Return type

dict

pformat()

Return pretty print of deployment info.

Return type

str

__init__(chain_id, vault, trading_strategy_module, asset_manager, multisig_owners, deployer, block_number, parameters, vault_abi, old_trading_strategy_module=None, beacon_proxy_factory=None, gas_used=None)
Parameters
Return type

None

deploy_lagoon_protocol_registry(web3, deployer, safe, broadcast_func, etherscan_api_key=None, verifier=None, verifier_url=None)

Deploy a fee registry contract.

  • This is referred by all Lagoon deployments

Parameters
Return type

web3.contract.contract.Contract

deploy_fresh_lagoon_protocol(web3, deployer, safe, broadcast_func, etherscan_api_key=None, verifier=None, verifier_url=None, forge_sync_delay=4.0)

Deploy a fresh Lagoon implementation from the scratch.

  • Fee registry contract

  • Vault implementation

  • Beacon proxy factory contract

Parameters
Return type

web3.contract.contract.Contract

deploy_lagoon(web3, deployer, safe, asset_manager, parameters, owner, gas=2000000, etherscan_api_key=None, use_forge=False, beacon_proxy=False, factory_contract=True, beacon_address='0x652716FaD571f04D26a3c8fFd9E593F17123Ab20', beacon_proxy_factory_address=None, beacon_proxy_factory_abi='lagoon/BeaconProxyFactory.json', vault_abi='lagoon/v0.5.0/Vault.json', deploy_fee_registry=True, fee_registry_address=None, legacy=False, salt=b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01', optin_proxy_delay=259200)

Deploy a new Lagoon vault.

  • Create a new Safe

  • Create a new Lagoon vault

  • Set guard policies

  • Set owership

For Foundry recipe see https://github.com/hopperlabsxyz/lagoon-v0/blob/main/script/deploy_vault.s.sol

Parameters
Returns

Vault contract.

Is a proxy contract.

Return type

web3.contract.contract.Contract

deploy_safe_trading_strategy_module(web3, deployer, safe, use_forge=False, etherscan_api_key=None, verifier=None, verifier_url=None, enable_on_safe=True)

Deploy TradingStrategyModuleV0 for Safe and Lagoon.

Parameters
Parma enable_on_safe

Automatically enable this module on the Safe multisig. Must be 1-of-1 deployer address multisig.

Returns

TradingStrategyModuleV0 instance

Return type

web3.contract.contract.Contract

setup_guard(*, web3, safe, deployer, owner, asset_manager, vault, module, broadcast_func, any_asset=False, uniswap_v2=None, uniswap_v3=None, orderly_vault=None, aave_v3=None, erc_4626_vaults=None, cowswap=False, hack_sleep=20.0, assets=None, multicall_chunk_size=40)

Setups up TradingStrategyModuleV0 guard on the Lagoon vault.

  • Creates the guard smart contract (TradingStrategyModuleV0) and enables it on the Safe multisig as a module.

  • Runs through various whitelisting rules as transactions against this contract

Parameters
deploy_automated_lagoon_vault(*, web3, deployer, asset_manager, parameters, safe_owners, safe_threshold, uniswap_v2, uniswap_v3, orderly_vault=None, aave_v3=None, cowswap=False, any_asset=False, etherscan_api_key=None, verifier=None, verifier_url=None, use_forge=False, between_contracts_delay_seconds=45.0, erc_4626_vaults=None, guard_only=False, existing_vault_address=None, existing_safe_address=None, vault_abi='lagoon/v0.5.0/Vault.json', factory_contract=True, from_the_scratch=False, assets=None)

Deploy a full Lagoon setup with a guard.

Lagoon automatised vault consists of

  • Safe multisig - we use 1.4.1 here

  • Vault module

  • Lagoon protocol smart contracts

  • TradingStrategyModuleV0 module enabling guarded automated trade executor for the Safe

For roles - Asset manager (Trading Straegy) and Valuation Manager (Lagoon) are the same role - Any Safe must be deployed as 1-of-1 deployer address multisig and multisig holders changed after the deployment.

Warning

Because we need to mix Forge, Safe lib and Web3.py transaction nonce management becomes a madness.

Note

Deployer account must be manually removed from the Safe by new owners.

Parameters
Return type

eth_defi.erc_4626.vault_protocol.lagoon.deployment.LagoonAutomatedDeployment

LAGOON_BEACON_PROXY_FACTORIES = {957: {'abi': 'lagoon/BeaconProxyFactory.json', 'address': '0x4058140097F313886536bd64a7C1D25FF7356931'}, 8453: {'abi': 'lagoon/BeaconProxyFactory.json', 'address': '0xC953Fd298FdfA8Ed0D38ee73772D3e21Bf19c61b'}, 42161: {'abi': 'lagoon/OptinProxyFactory.json', 'address': '0xb1ee4f77a1691696a737ab9852e389cf4cb1f1f5'}}

https://basescan.org/address/0xC953Fd298FdfA8Ed0D38ee73772D3e21Bf19c61b#writeContract https://docs.lagoon.finance/vault/create-your-vault