This repository contains Hardhat Ignition modules for deploying and managing smart contracts.
- Manager: Basic manager contract deployment
- ManagerWithProxy: Manager contract deployment with transparent proxy pattern and UserVaultFactory
- MockToken: Test token deployment for development and testing
- UniswapV3Strategies: Collection of UniswapV3 strategy contracts with transparent proxy pattern
- ManagerUpgrade: Upgrade existing Manager contract implementations
- UpgradeUserVault: Upgrade UserVault beacon implementation for all user vaults
- UpgradeStrategies: Upgrade existing strategy contract implementations
The project includes pre-configured deployment scripts in package.json for major networks:
# Deploy Manager with Proxy
pnpm run deploy:eth:manager
# Deploy UniswapV3 Strategies
pnpm run deploy:eth:strategies:uniswapv3# Deploy Manager with Proxy
pnpm run deploy:base:manager
# Deploy UniswapV3 Strategies
pnpm run deploy:base:strategies:uniswapv3Deploy modules using Hardhat Ignition with the following command pattern:
pnpm exec hardhat ignition deploy ./ignition/modules/<ModuleName>.ts \
--network <network> \
--parameters ignition/parameters.<network>.json \
--verify \
--deployment-id <deployment-id>The --deployment-id flag is used to create unique deployments and track different versions of your contracts. This is particularly useful when:
- Deploying multiple instances of the same contract
- Managing different deployment environments
Example:
# Deploy Manager module
pnpm exec hardhat ignition deploy ./ignition/modules/ManagerWithProxy.ts \
--network base \
--parameters ignition/parameters.base.json \
--verify \
--deployment-id manager-01All deployments require network-specific parameter files:
ignition/parameters.eth.json- Ethereum mainnet parametersignition/parameters.base.json- Base network parameters
Parameters should include:
positionManager: Address of the UniswapV3 position manager contractfactory: Address of the UniswapV3 factory contract (for strategy deployments)router: Address of the UniswapV3 router contract (for strategy deployments)ManagerProxy: Address of deployed manager proxy (for upgrade modules)ManagerProxyAdmin: Address of manager proxy admin (for upgrade modules)UserVaultFactory: Address of UserVaultFactory beacon (for vault upgrades)
This project implements the Beacon Proxy pattern for upgradeable user vaults, consisting of three main components:
- Manager Contract: The entry point for users to create and interact with their vaults
- UserVaultFactory: An UpgradeableBeacon contract that holds the implementation address
- UserVault: The implementation contract for user-specific vaults
The UniswapV3Strategies module deploys six different strategy contracts, each with transparent proxy pattern:
- UniswapV3Mint: Strategy for minting new positions without any calculation or token swap
- UniswapV3StrategyAddBaseTokenOnly: Strategy for minting new positions using a single type of token
- UniswapV3DecreaseLiquidity: Strategy for decreasing position liquidity
- UniswapV3ZapMint: Strategy for zap minting using any amount of two tokens
- UniswapV3AddLiquidity: Strategy for adding liquidity to existing positions
- UniswapV3Collect: Strategy for collecting fees from positions
- Deploy the initial
UserVaultimplementation contract - Deploy
UserVaultFactorywith:- The
UserVaultimplementation address - The owner address who can upgrade the implementation
- The
- Deploy
Managercontract with:- Owner address
- The deployed
UserVaultFactoryaddress
- Deploy UniswapV3 strategy contracts with transparent proxies
- Approve strategies in the Manager contract
- User calls
createUserVault()on the Manager contract - Manager calls
UserVaultFactory.createUserVault() - UserVaultFactory deploys a new BeaconProxy that:
- Points to the UserVaultFactory (Beacon) for its implementation
- Initializes with the user's address and manager's address
The Beacon Proxy pattern allows for upgrading all user vaults simultaneously:
- Deploy new
UserVaultimplementation - Use
UpgradeUserVaultmodule to upgrade the beacon - All existing and future user vaults will use the new implementation
Individual contracts can be upgraded using their respective upgrade modules:
- Deploy new implementation contract
- Use appropriate upgrade module (
ManagerUpgrade,UpgradeStrategies) - The proxy will point to the new implementation
# 1. Deploy Manager with UserVaultFactory and UserVault implementation
pnpm exec hardhat ignition deploy ./ignition/modules/ManagerWithProxy.ts \
--network base \
--parameters ignition/parameters.base.json \
--verify \
--deployment-id manager-01
# 2. Deploy UniswapV3 Strategies
pnpm exec hardhat ignition deploy ./ignition/modules/UniswapV3Strategies.ts \
--network base \
--parameters ignition/parameters.base.json \
--verify \
--deployment-id strategies-01
# 3. Upgrade Manager (if needed)
pnpm exec hardhat ignition deploy ./ignition/modules/ManagerUpgrade.ts \
--network base \
--parameters ignition/parameters.base.json \
--verify \
--deployment-id manager-upgrade-01