All the Uniswap V3 contracts on various chains exist at identical address, hence we have defined these addresses as immutable constants.
- Ensure that UniswapV3Factory address mentioned in constants.sol is valid on the chain the deployment is being made.
- Deploy all the logic contracts: Account library, ClearingHouse, InsuranceFund, VPoolWrapper.
- Now deploy the RageTradeFactory contract. It will ask for the addresses of logic contracts deployed previously and USDC token address (settlement token / default collateral). Following things are performed by RageTradeFactory constructor.
- Deploys ProxyAdmin (Transparent Proxy).
- Deploys VQuote token at an address that starts from "f".
- Deploys proxy for InsuranceFund that points to InsuranceFund logic.
- Creates a settlement token oracle.
- Deploys proxy for ClearingHouse that points to ClearingHouse logic.
- Transfer ownership to deployer and initializes InsuranceFund.
Post deployment, a new pool can be initialized using initializePool function on RageTradeFactory.
- Deploys vToken at an address such that it will be token0 in UniswapV3Pool.
- Creates UniswapV3Pool with vToken as token0 and vQuote as token1 and fee as 500 (defined in constants.sol).
- Initializes UniswapV3Pool.
- Deploys proxy for VPoolWrapper that points to VPoolWrapper logic.
- Does necessary authorizations and registrations.
After pool is initialized, it is not usable (swaps won't work) unless liquidity is added to it.
- Create an account on ClearingHouse.
- Add margin to it (deposit settlement token or any supported collateral).
- Use the margin to add liquidity using
updateRangeOrder
.