Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Flattened UniswapV3 Code

To deploy and use Uniswap V3, you'll need to follow the following steps:

  1. Deploy the Uniswap V3 Factory contract: The UniswapV3Factory contract is responsible for deploying new Uniswap V3 pools. You can deploy this contract using a tool like Remix or Hardhat. Once the contract is deployed, you'll need to take note of its contract address.

  2. Deploy a Uniswap V3 pool: To deploy a new Uniswap V3 pool, you'll need to call the createPool function on the UniswapV3Factory contract, passing in the desired token addresses and other parameters such as the initial tick spacing, the fee, and the price range. This will create a new pool, and you'll need to take note of its pool address.

  3. Add liquidity to the pool: To test swaps, you'll need to add liquidity to the pool by calling the addLiquidity function on the pool contract, passing in the desired amounts of the two tokens being traded. This will mint new liquidity tokens, which represent your share of the pool.

  4. Perform a swap: To perform a swap, you'll need to call the swap function on the pool contract, passing in the desired input token amount, output token amount, and the position on the price curve where you want the swap to occur. The position is specified as a tick, which represents the price range of the swap.

Here's an example of how Bob and Alice can test swaps on a Uniswap V3 pool:

  1. Bob deploys the Uniswap V3 Factory contract.

  2. Bob calls the createPool function on the UniswapV3Factory contract, passing in the addresses of the tokens being traded, the initial tick spacing, the fee, and the price range, and takes note of the pool address.

  3. Bob adds liquidity to the pool by calling the addLiquidity function on the pool contract, passing in the desired amounts of the two tokens being traded, and receives liquidity tokens in return.

  4. Alice wants to swap some of Token A for Token B, so she calls the swap function on the pool contract, passing in the amount of Token A she wants to swap, the amount of Token B she expects to receive, and the tick position where she wants the swap to occur.

  • The swap is executed, and Alice receives the desired amount of Token B in exchange for her Token A.

  • Bob and Alice can continue to perform swaps on the Uniswap V3 pool as desired.