Welcome to Lagoon-v0 vault repository. In this repo, you will find the code source of Lagoon erc7540 vault. If you want to know more about the core concepts or how deploy your vaults, please read the documentation. The following README is a guide to deploy the all infrastructure. If you are a curator or integrator you can ignore it.
You need
- macOS / Linux
- Foundry
- Docker (Recommended for production)
The repository is split in two parts, protocol and vault. You will mainly be interested in Vault.sol and ERC7540.sol files.
src
├── BeaconProxyFactory.sol
├── Vault.sol
├── protocol
│ ├── Events.sol
│ └── FeeRegistry.sol
└── v0.5.0
├── ERC7540.sol
├── FeeManager.sol
├── Roles.sol
├── Silo.sol
├── Vault.sol
├── Whitelistable.sol
├── interfaces
│ ├── IERC7540.sol
│ ├── IERC7540Deposit.sol
│ ├── IERC7540Redeem.sol
│ ├── IERC7575.sol
│ └── IWETH9.sol
└── primitives
├── Enums.sol
├── Errors.sol
├── Events.sol
└── Struct.solFirst, create a .env file.
cp .env.example .envThis .env is meant to be used for local test development, not for packaging (docker image builds) nor deployments.
Also, if you run scripts from your local setup make sure to correctly override FOUNDRY_ETH_RPC_URL else you could end up with bad surprises.
forge buildforge test --match-path "./test/v0.5.0/**/*.sol"First, create a .env.deploy file.
cp .env.deploy.example .env.deployStart a local fork environment
anvil --host 0.0.0.0 --fork-url $FORK_RPC_URLAn other alternative is to use the Makefile, it requires FORK_RPC_URL to be defined.
make start-forkIt will spawn anvil inside a container instead of running it into your host.
Then, loads the .env.deploy variables into your environment
set -a && source .env.deploy && set +aAnd set FOUNDRY_ETH_RPC_URL to the network where you want to deploy
FOUNDRY_ETH_RPC_URL="http://localhost:8545"Now you can run scripts to deploy a new beacon and vault proxy on your local anvil node
forge script --chain-id 1 --private-key $PRIVATE_KEY --rpc-url "http://localhost:8545" "script/deploy_beacon.s.sol"
BEACON="0x..." # define BEACON address when you have it
forge script --chain-id 1 --private-key $PRIVATE_KEY --rpc-url "http://localhost:8545" "script/deploy_vault.s.sol"First make sure you have a newly created Safe address available.
You can create one using the safe-cli or through the Safe UI
Pull the image from Github packages.
docker pull --platform linux/x86_64 ghcr.io/hopperlabsxyz/lagoon-v0:v0.5.0
Make sure to be logged in with your docker cli
echo $GH_ACCESS_TOKEN | docker login ghcr.io -u $USER --password-stdinYour access token needs read:packages access.
Alternatively, create a .env.build file.
cp .env.build.example .env.buildAnd run
make build-imageFirst, create a .env.deploy file.
cp .env.deploy.example .env.deploy.mainnetLet's start a local fork where we are going to deploy
ENV_DEPLOY=.env.deploy.mainnet make start-forkOpen a new shell window where you will deploy the vault.
First, you are able to simulate the vault deployment running the following command:
ENV_DEPLOY=.env.deploy.mainnet make beaconInside .env.deploy.mainnet define the BEACON address.
If the deployment simulation fails, make sure all the addresses you put in your .env.deploy file are correct.
Then, you can use the following command to broadcast the deployment to the local network we started before.
ENV_DEPLOY=.env.deploy.mainnet make deploy-beacon-pkThe same apply to deploy a vault proxy using the vault script.
ENV_DEPLOY=.env.deploy.mainnet make vault # simulation
ENV_DEPLOY=.env.deploy.mainnet make deploy-vault-pk # broadcast to networkMake sure the RPC_URL variable points to the correct domain, when deploying from another container the domain should map to the container's local fork name. (example: RPC_URL="http://local-fork:8545")
If you want to deploy the vault on mainnet you can change RPC_URL to point to a mainnet rpc url.
The audit is stored in the audits' folder.
The primary license for Lagoon Protocol is the Business Source License 1.1 (BUSL-1.1), see LICENSE.