Hypervisor
A Uniswap V2-like interface with fungible liquidity to Uniswap V3
which allows for arbitrary liquidity provision: one-sided, lop-sided, and
balanced
Consult tests/deposit_withdraw.test.ts for deposit, withdrawal, rebalance examples
Tasks
Deploys hypervisor
npx hardhat deploy-hypervisor-orphan --pool UNIV3-POOL-ADDRESS --name ERC20-NAME --symbol ERC20-SYMBOL --network NETWORK
Initialize hypervisor
npx hardhat initialize-hypervisor --hypervisor HYPERVISOR-ADDRESS --amount0 TOKEN0-AMOUNT --amount1 TOKEN1-AMOUNT --uniProxy UNIPROXY-ADDRESS --adminAddress ADMIN-ADDRESS --network NETWORK
Testing
npx hardhat test
HypervisorFactory.sol Documentation
Overview
The HypervisorFactory.sol
contract is a component of the GammaStrategies' Hypervisor project, designed to facilitate the creation and management of Hypervisor contracts for Uniswap V3 liquidity provision. It enables the deployment of new Hypervisor instances, each corresponding to a specific Uniswap V3 pool defined by a pair of tokens and a fee tier. The contract maintains a registry of all created Hypervisors and ensures that each token pair and fee combination has a unique Hypervisor.
Key Components
State Variables
uniswapV3Factory
: An instance of the Uniswap V3 Factory contract, used to interact with Uniswap pools.
getHypervisor
: A nested mapping that stores the address of the Hypervisor for a given token pair and fee.
allHypervisors
: An array containing the addresses of all Hypervisors created by this factory.
Events
HypervisorCreated
: Emitted when a new Hypervisor is created, providing details about the tokens, fee, Hypervisor address, and the total number of Hypervisors.
Constructor
The constructor initializes the contract with the address of the Uniswap V3 Factory.
constructor(address _uniswapV3Factory) {
require(_uniswapV3Factory != address(0), "uniswapV3Factory should be non-zero");
uniswapV3Factory = IUniswapV3Factory(_uniswapV3Factory);
}
Functions
allHypervisorsLength
: Returns the total number of Hypervisors created.
createHypervisor
: Deploys a new Hypervisor contract for a specified token pair and fee. It ensures that the token addresses are valid and that a Hypervisor for the given parameters does not already exist. If the corresponding Uniswap V3 pool does not exist, it creates one.
Usage
To create a new Hypervisor:
- Call the
createHypervisor
function with the desired token addresses, fee, name, and symbol.
- The function will deploy a new Hypervisor contract and emit the
HypervisorCreated
event.
- The new Hypervisor can then be used to manage liquidity for the specified Uniswap V3 pool.
Security Considerations
- The
createHypervisor
function includes checks to prevent the creation of multiple Hypervisors for the same token pair and fee.
- The contract uses the
Ownable
modifier from OpenZeppelin, restricting certain functions to the contract owner.
Dependencies
This contract relies on:
IUniswapV3Factory
from the Uniswap V3 Core contracts.
Ownable
from OpenZeppelin's contracts.
Hypervisor
contract from the same project.
For the complete implementation, refer to the HypervisorFactory.sol file in the GammaStrategies GitHub repository.