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
https://basescan.org/address/0xC953Fd298FdfA8Ed0D38ee73772D3e21Bf19c61b#writeContract https://docs.lagoon.finance/vault/create-your-vault |
Functions
|
Deploy a full Lagoon setup with a guard. |
|
Deploy a fresh Lagoon implementation from the scratch. |
|
Deploy a new Lagoon vault. |
|
Deploy a fee registry contract. |
|
Deploy TradingStrategyModuleV0 for Safe and Lagoon. |
|
Setups up TradingStrategyModuleV0 guard on the Lagoon vault. |
Classes
Capture information of the lagoon automated deployment. |
|
Capture core parameters needed to deploy a Lagoon vault |
- class LagoonDeploymentParameters
Bases:
objectCapture core parameters needed to deploy a Lagoon vault
- 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
- __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
underlying (eth_typing.evm.HexAddress) –
name (str) –
symbol (str) –
safe (str | None) –
whitelistManager (str | None) –
valuationManager (str | None) –
admin (str) –
feeReceiver (str) –
feeRegistry (str) –
managementRate (int) –
performanceRate (int) –
enableWhitelist (bool) –
rateUpdateCooldown (int) –
wrappedNativeToken (Optional[eth_typing.evm.HexAddress]) –
- Return type
None
- class LagoonAutomatedDeployment
Bases:
objectCapture information of the lagoon automated deployment.
Have the deployment report for the users for diagnostics
- 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
- __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
chain_id (int) –
vault (eth_defi.erc_4626.vault_protocol.lagoon.vault.LagoonVault) –
trading_strategy_module (web3.contract.contract.Contract) –
asset_manager (eth_typing.evm.HexAddress) –
multisig_owners (list[eth_typing.evm.HexAddress]) –
deployer (eth_typing.evm.HexAddress) –
block_number (eth_typing.evm.BlockNumber) –
parameters (eth_defi.erc_4626.vault_protocol.lagoon.deployment.LagoonDeploymentParameters) –
vault_abi (str) –
old_trading_strategy_module (web3.contract.contract.Contract | None) –
beacon_proxy_factory (Optional[eth_typing.evm.HexAddress]) –
gas_used (decimal.Decimal | None) –
- 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
deployer (eth_account.signers.local.LocalAccount | eth_defi.hotwallet.HotWallet) – The initial account used to deploy smart contracts
owner (Optional[eth_typing.evm.HexAddress]) –
All transfership is transferred to this user after.
Usually defaults to newly deployed Safe the vault is associated with.
asset_manager (eth_typing.evm.HexAddress) – Able to perform trades, valuations
beacon_address – Vault beacon on base.
use_forge – Deploy a new vault contract from source with Forge and Etherscan verification.
etherscan_api_key (str) – For Forge.
vault_abi –
Which Lagoon vault version we deploy.
Use “lagoon/Vault.json” for the legacy version. Warning: unsafe.
beacon_proxy – TODO
deploy_fee_registry (bool) –
Deploy a fee registry contract needed for deployment.
Set the fee receiver as the owner.
web3 (web3.main.Web3) –
safe (safe_eth.safe.safe.Safe) –
parameters (eth_defi.erc_4626.vault_protocol.lagoon.deployment.LagoonDeploymentParameters) –
fee_registry_address (Optional[eth_typing.evm.HexAddress]) –
legacy (bool) –
- 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
use_forge – Deploy Etherscan verified build with Forge
deployer (eth_account.signers.local.LocalAccount) –
safe (safe_eth.safe.safe.Safe) –
etherscan_api_key (str) –
verifier (Optional[Literal['etherscan', 'blockscout', 'sourcify', 'oklink']]) –
verifier_url (str | None) –
- 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
web3 (web3.main.Web3) –
safe (safe_eth.safe.safe.Safe) –
deployer (eth_defi.hotwallet.HotWallet) –
owner (eth_typing.evm.HexAddress) –
asset_manager (eth_typing.evm.HexAddress) –
vault (web3.contract.contract.Contract) –
module (web3.contract.contract.Contract) –
broadcast_func (Callable[[web3.contract.contract.ContractFunction], hexbytes.main.HexBytes]) –
any_asset (bool) –
uniswap_v2 (eth_defi.uniswap_v2.deployment.UniswapV2Deployment | None) –
uniswap_v3 (eth_defi.uniswap_v3.deployment.UniswapV3Deployment | None) –
orderly_vault (eth_defi.orderly.vault.OrderlyVault | None) –
aave_v3 (eth_defi.aave_v3.deployment.AaveV3Deployment | None) –
erc_4626_vaults (list[eth_defi.erc_4626.vault.ERC4626Vault] | None) –
cowswap (bool) –
assets (list[Union[eth_typing.evm.HexAddress, str]] | None) –
- 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
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.
web3 (web3.main.Web3) –
deployer (eth_account.signers.local.LocalAccount | eth_defi.hotwallet.HotWallet) –
asset_manager (eth_typing.evm.HexAddress) –
parameters (eth_defi.erc_4626.vault_protocol.lagoon.deployment.LagoonDeploymentParameters) –
safe_owners (list[Union[eth_typing.evm.HexAddress, str]]) –
safe_threshold (int) –
uniswap_v2 (eth_defi.uniswap_v2.deployment.UniswapV2Deployment | None) –
uniswap_v3 (eth_defi.uniswap_v3.deployment.UniswapV3Deployment | None) –
orderly_vault (eth_defi.orderly.vault.OrderlyVault | None) –
aave_v3 (eth_defi.aave_v3.deployment.AaveV3Deployment | None) –
cowswap (bool) –
any_asset (bool) –
etherscan_api_key (str) –
verifier (Optional[Literal['etherscan', 'blockscout', 'sourcify', 'oklink']]) –
verifier_url (str | None) –
erc_4626_vaults (list[eth_defi.erc_4626.vault.ERC4626Vault] | None) –
existing_vault_address (Optional[Union[eth_typing.evm.HexAddress, str]]) –
existing_safe_address (Optional[Union[eth_typing.evm.HexAddress, str]]) –
assets (list[Union[eth_typing.evm.HexAddress, str]] | None) –
- 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