Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

部署 univ3 #118

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions T002_UniswapV3Deploy/Pool contract deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Uniswap V3 pool 合约部署

UniswapV3Factory 合约主要用来创建不同代币对的流动性池子合约,合约的 createPool 函数new UniswapV3Pool 部署新池子合约。所以通过部署UniswapV3Factory来创建Pool合约池子
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 去掉开头不必要的空格
  • createPool 这样的内容加上 `
  • 中英文直接放一个空格


一、使用Foundry部署合约

1、安装Foundry
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以简单介绍一下 Foundry


curl -L https://foundry.paradigm.xyz | bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码要用 ``` 框起来


foundryup // 安装foundry

foundry

二、克隆合约代码仓库 git clone https://github.com/Uniswap/v3-core.git

1、添加 .env 文件 // 用于存储 链的RPC节点、 部署钱包私钥、 浏览器API key

里面填入 ```SEPOLIA_RPC_URL=https://1rpc.io/sepolia
PRIVATE_KEY=0xadef625bf2530e93c80873d633fef9daa9adae04ca5f690663136c2c45033dd7
ETHERSCAN_API_KEY=6R9K4BAA2RHMRD5NXQB5YKKCNGQ8URW5Y8```

执行source .env 保存 // 更新环境变量,才能使用Foundry

2、添加foundry.toml 文件 // Foundry框架的配置文件

里面填入

```
[profile.default]
solc_version = "0.7.6"
src = "src"
out = "out"
libs = ["lib"]
extra_output = ["storageLayout"]
build_info = true
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
[rpc_endpoints]
sepolia = "${SEPOLIA_RPC_URL}"

[etherscan]
sepolia = { key = "${ETHERSCAN_API_KEY}" }
```

3、添加src 文件夹在里面添加 deploy.sol文件, // deploy.sol文件是Foundry 的部署脚本代码

填入

```solidity
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.6;

import {Script, console} from "forge-std/Script.sol";
import {UniswapV3Factory} from "./../contracts/UniswapV3Factory.sol";

contract Deploy is Script {
UniswapV3Factory public factory;

function setUp() public {}

function run() public {
vm.startBroadcast();

factory = new UniswapV3Factory(); // UniswapV3Factory是部署的合约名

vm.stopBroadcast();
}
}

```

4、安装库 : forge install foundry-rs/forge-std --no-commit // 安装Foundry 库

最后运行命令进行部署 :

forge script src/deploy.sol:Deploy --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verifier etherscan $ETHERSCAN_API_KEY -vvvv --verify // 部署Factory 上链交易
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整体内容还是太单薄了,要多一些解释