This project contains Uniswap related smart contracts and deployment scripts
Make sure you have the following installed:
- npm
- Foundry + Forge
-
Clone the repository:
git clone https://github.com/astriaorg/uniswap.git cd uniswap
-
Initialize git submodules:
git submodule update --init --recursive
-
Install dependencies:
npm i
-
Set up environment variables: Copy the
.env.example
file to.env
in the root directory:cp .env.example .env
Then open the
.env
file and update the values according to your requirements.
-
Deploy WTIA9 (weth9 based contract):
just deploy-wtia9
Optionally, customize name and symbol:
just deploy-wtia9 "Custom Wrapped Token" "CWRIA"
-
Deploy Uniswap V3 Core:
just deploy-uniswapv3
To use a different native currency label (default is "RIA"):
just deploy-uniswapv3 "CUSTOM"
-
(Optional) Transfer Ownership:
just transfer-ownership <new_owner_address>
Deployment details are saved to the file specified in the DEPLOY_JSON
environment variable.
Note: Ensure proper configuration of PRIVATE_KEY
and JSON_RPC
in the .env
file before deployment.
To deploy a new ERC20 token:
-
Use the
deploy-erc20
command:just deploy-erc20 <name> <symbol> <total_supply> [decimals]
Parameters:
<name>
: Token's full name (e.g., "My Custom Token")<symbol>
: Token's symbol (e.g., "MCT")<total_supply>
: Total token supply in human-readable format[decimals]
: (Optional) Token decimal places (default: 18)
Example:
just deploy-erc20 "My Custom Token" MCT 1000000 6
This deploys a token with 1 million total supply and 6 decimal places.
-
Note the deployed token address for future interactions.
Note: The deploy-erc20
command automatically adjusts for decimals, so input the total supply as a human-readable number. For instance, to deploy 1 million tokens with 18 decimals, simply use 1000000 as the total supply.
To deposit native currency (e.g., RIA) into the WTIA9 contract and receive wrapped tokens:
-
Ensure you have deployed the WTIA9 contract using the
deploy-wtia9
command as described earlier. -
Use the
wtia9-deposit
command:just wtia9-deposit <amount>
Parameter:
<amount>
: The amount of native currency to deposit, in wei.
Example:
just wtia9-deposit 1000000000000000000
This deposits 1 native token (assuming 18 decimal places).
-
The command will execute a transaction to deposit the specified amount into the WTIA9 contract.
-
Upon successful execution, you will receive an equivalent amount of wrapped tokens (e.g., WRIA).
Note: Ensure you have sufficient native currency in your account to cover both the deposit amount and the transaction fee.
Run these commands using just <command>
:
deploy-uniswapv3 [nativeCurrencyLabel]
: Deploy UniswapV3 contracts (default nativeCurrencyLabel: "RIA")transfer-ownership <new_owner>
: Transfer ownership of contractsdeploy-wtia9 [name] [symbol]
: Deploy WTIA9 contract (default name: "Wrapped RIA", default symbol: "WRIA")wtia9-deposit <amount>
: Deposit into WTIA9 contractdeploy-erc20 <name> <symbol> <max_supply> [decimals]
: Deploy ERC20 token (default decimals: 18)deploy-pool <tokenA> <tokenB> <fee> <sqrtPriceX96>
: Deploy a new Uniswap V3 poolcreate-position <tokenA> <tokenB> <tokenAAmount> <tokenBAmount> <fee>
: Create a new position in a Uniswap V3 poolswap <tokenIn> <tokenOut> <fee> <amountIn>
: Execute a token swap on Uniswap V3
Run these commands using npm run <script>
:
prettier
: Format Solidity filesprettier:check
: Check Solidity file formattingsolhint
: Lint Solidity files and fix issuessolhint:check
: Check Solidity files for linting issueslint
: Run both prettier and solhint with fixeslint:check
: Check both formatting and linting without fixes