Created
September 18, 2024 15:20
-
-
Save nCally/554b38457c188c0067a151360d9a11e2 to your computer and use it in GitHub Desktop.
The Foundry Script File to deploy Uniswap V3 Fork
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity >=0.4.0; | |
| import {Script, console} from "forge-std/Script.sol"; | |
| import {UniswapV3Factory} from "../lib/v3-core/contracts/UniswapV3Factory.sol"; | |
| import {UniswapV3Pool} from "../lib/v3-core/contracts/UniswapV3Pool.sol"; | |
| import {WRWA} from "../src/WRWA.sol"; | |
| import {NonfungiblePositionManager} from "../src/NonfungiblePositionManager.sol"; | |
| import {NonfungibleTokenPositionDescriptor} from "../src/NonfungibleTokenPositionDescriptor.sol"; | |
| import {SwapRouter} from "../lib/v3-periphery/contracts/SwapRouter.sol"; | |
| import {Quoter} from "../lib/v3-periphery/contracts/lens/Quoter.sol"; | |
| import {TickLens} from "../lib/v3-periphery/contracts/lens/TickLens.sol"; | |
| // Deploying fork | |
| // 1. Simulate so that pool hash is calculated. Run script without --broadcast | |
| // 2. Copy hash and replace POOL_INIT_CODE_HASH in PoolAddress contract | |
| // 3. Run script with --broadcast option | |
| contract Deployer is Script { | |
| function setUp() public {} | |
| function getInitCodeHash() public pure returns (bytes32) { | |
| return keccak256(abi.encodePacked(type(UniswapV3Pool).creationCode)); | |
| } | |
| function run() public { | |
| vm.startBroadcast(); | |
| WRWA wrwa = new WRWA(); | |
| UniswapV3Factory factory = new UniswapV3Factory(); | |
| bytes32 hash = getInitCodeHash(); | |
| console.logString("COPY HASH BELOW:"); | |
| console.logBytes32(hash); | |
| string memory nativeSymbol = "RWA"; | |
| bytes32 nativeCurrencyLabelBytes; | |
| assembly { | |
| nativeCurrencyLabelBytes := mload(add(nativeSymbol, 32)) | |
| } | |
| NonfungibleTokenPositionDescriptor tokenDescriptor = new NonfungibleTokenPositionDescriptor( | |
| address(wrwa), | |
| nativeCurrencyLabelBytes | |
| ); | |
| new NonfungiblePositionManager( | |
| address(factory), | |
| address(wrwa), | |
| address(tokenDescriptor) | |
| ); | |
| new SwapRouter(address(factory), address(wrwa)); | |
| new Quoter(address(factory), address(wrwa)); | |
| new TickLens(); | |
| vm.stopBroadcast(); | |
| } | |
| } | |
| // TODO: | |
| // forge install Brechtpd/base64@v1.1.0 --no-commit | |
| // forge install Uniswap/solidity-lib --no-commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [profile.default] | |
| src = "src" | |
| out = "out" | |
| libs = ["lib"] | |
| remappings = [ | |
| "@uniswap/v3-core=lib/v3-core", | |
| "@uniswap/v3-periphery=lib/v3-periphery", | |
| "@openzeppelin/contracts=lib/openzeppelin-contracts/contracts/", | |
| "@base64-sol=lib/base64/", | |
| "@uniswap/lib=lib/solidity-lib/", | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ANVIL_RPC_URL=http://127.0.0.1:8545 | |
| TESTNET_RPC_URL=https://enugu-rpc.assetchain.org | |
| MAINNET_RPC_URL=https://enugu-rpc.assetchain.org | |
| -include .env | |
| anvil: | |
| forge script script/Deployer.s.sol --rpc-url $(ANVIL_RPC_URL) --broadcast --private-key ${PK1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment