deploy_automated_lagoon_vault
Documentation for eth_defi.erc_4626.vault_protocol.lagoon.deployment.deploy_automated_lagoon_vault function.
- deploy_automated_lagoon_vault(*, web3, deployer, config=None, asset_manager=None, asset_managers=None, parameters=None, safe_owners=None, safe_threshold=None, uniswap_v2=None, uniswap_v3=None, aave_v3=None, cowswap=False, velora=False, gmx_deployment=None, lighter_deployment=None, cctp_deployment=None, hypercore_vaults=None, any_asset=False, etherscan_api_key=None, verifier=None, verifier_url=None, use_forge=False, between_contracts_delay_seconds=5.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, safe_salt_nonce=None, safe_proxy_factory_address=None, max_settlement_amount=None, settlement_cooldown=86400)
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 - The primary asset manager and Valuation Manager (Lagoon) are the same role - Multiple asset-manager keys may share the same Guard rights; today this
mainly supports separate FreqTrade and GMX trading keys, but other workflows may use the same pattern in the future
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.
Set
max_settlement_amountto opt into the Lagoon v0.5 asset-manager settlement safety feature. The value is aDecimalin human-readable underlying-token units. Deployment discovers the stock v0.5 pending Silo, converts the value with the token’s actualdecimals(), configures the paired module, and reads the complete onchain configuration back before continuing.The cap is enforced atomically around an asset-manager call through
TradingStrategyModuleV0. It measures the gross sum of deposits and redemptions, so opposite flows cannot evade the limit by netting. A rejected settlement reverts the complete Lagoon transaction.Nonepreserves the historical unlimited settlement behaviour, whileDecimal(0)permits only zero measured movement. Every successful non-zero call startssettlement_cooldown, which defaults to 24 hours, so the asset manager cannot drain the vault through repeated below-cap settlements. Empty settlements do not start, extend or wait for cooldown.The amount check is per transaction and the cooldown rate-limits those transactions over time. It does not validate the NAV passed to Lagoon or restrict transactions signed directly by Safe governance. It requires the stock Lagoon v0.5 ABI and is unavailable on satellite chains, which have no Lagoon vault.
See the canonical Lagoon smart contract source for the underlying v0.5 settlement implementation.
- Parameters
config (Optional[eth_defi.erc_4626.vault_protocol.lagoon.deployment.LagoonConfig]) – Pass a
LagoonConfigobject instead of individual kwargs. When provided, all individual deployment kwargs, includingmax_settlement_amountandsettlement_cooldown, are ignored in favour of the values on the configuration object.max_settlement_amount (Optional[decimal.Decimal]) – Optional maximum gross Lagoon settlement for one asset-manager module transaction, expressed in human-readable underlying-token units as a
Decimal.Nonekeeps unlimited backwards-compatible behaviour. SeeLagoonConfig.max_settlement_amountfor security semantics and supported topology.settlement_cooldown (int) – Positive minimum delay in seconds between non-zero capped asset-manager settlements. Defaults to 24 hours. Empty settlements do not start or wait for it. Ignored when the maximum amount safety feature is disabled.
guard_only (bool) – Deploy a new version of the guard smart contract and skip deploying the actual vault.
from_the_scratch (bool) –
Need to deloy a fee registry contract as well.
A new chain deployment.
safe_salt_nonce (Optional[int]) – If set, deploy the Safe using CREATE2 via the canonical SafeProxyFactory for a deterministic address. Use the same value across chains to get the same Safe address everywhere.
safe_proxy_factory_address (Optional[Union[eth_typing.evm.HexAddress, str]]) – Override the Safe ProxyFactory address. Defaults to the canonical v1.4.1 factory (
0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67). See Safe canonical deployments and Safe contract deployment docs.web3 (web3.main.Web3) –
deployer (Union[eth_account.signers.local.LocalAccount, eth_defi.hotwallet.HotWallet]) –
asset_manager (Optional[eth_typing.evm.HexAddress]) –
asset_managers (Optional[list[eth_typing.evm.HexAddress | str]]) –
parameters (Optional[eth_defi.erc_4626.vault_protocol.lagoon.deployment.LagoonDeploymentParameters]) –
safe_owners (Optional[list[eth_typing.evm.HexAddress | str]]) –
uniswap_v2 (Optional[eth_defi.uniswap_v2.deployment.UniswapV2Deployment]) –
uniswap_v3 (Optional[eth_defi.uniswap_v3.deployment.UniswapV3Deployment]) –
aave_v3 (Optional[eth_defi.aave_v3.deployment.AaveV3Deployment]) –
cowswap (bool) –
velora (bool) –
gmx_deployment (Optional[eth_defi.gmx.whitelist.GMXDeployment]) –
lighter_deployment (Optional[eth_defi.lighter.deployment.LighterDeployment]) –
cctp_deployment (Optional[eth_defi.cctp.whitelist.CCTPDeployment]) –
hypercore_vaults (Optional[list[eth_typing.evm.HexAddress | str]]) –
any_asset (bool) –
etherscan_api_key (str) –
verifier (Optional[Literal['etherscan', 'blockscout', 'sourcify', 'oklink']]) –
erc_4626_vaults (Optional[list[eth_defi.erc_4626.vault.ERC4626Vault]]) –
existing_vault_address (Optional[Union[eth_typing.evm.HexAddress, str]]) –
existing_safe_address (Optional[Union[eth_typing.evm.HexAddress, str]]) –
assets (Optional[list[eth_typing.evm.HexAddress | str]]) –
- Return type
eth_defi.erc_4626.vault_protocol.lagoon.deployment.LagoonAutomatedDeployment