diff --git a/Community_Verification_Event(First)/UniswapV2_Migration_verification/contracts.md b/Community_Verification_Event(First)/UniswapV2_Migration_verification/contracts.md new file mode 100644 index 0000000..3fbd57e --- /dev/null +++ b/Community_Verification_Event(First)/UniswapV2_Migration_verification/contracts.md @@ -0,0 +1,55 @@ +## 合约 + +环境 +ubuntu 1804 + + +## 准备条件 + +需要创建一个钱包,导出私钥,在每个合约仓库根目录有一个.env配置文件。修改私钥环境变量。去水龙头领测试的LAT + +### 部署uniswap核心合约 + +``` +$ git clone https://github.com/platon-uniswap/uniswap-v2-core.git +$ cd uniswap-v2-core +$ npm i +$ npx hardhat --network alaya_dev run scripts/01-deploy-factory.js // 部署工厂合约并得到地址 +$ npx hardhat --network alaya_dev run scripts/02-init-code-hash.js // 得到initcodehash,用户计算pair的地址 +$ npx hardhat --network alaya_dev run scripts/03-deploy-test-coin.js // 部署USDT测试合约地址 +``` + +### 部署uniswap周边合约 + +``` +$ git clone https://github.com/platon-uniswap/uniswap-v2-periphery.git +$ cd uniswap-v2-periphery +$ npm i +$ npx hardhat --network alaya_dev run scripts/01-deploy-weth.js // 部署WETH合约 +$ npx hardhat --network alaya_dev run scripts/02-deploy-router.js // 修改factory和weth合约地址,部署router02合约 +``` + +### 部署UNI和治理合约 + +``` +$ git clone https://github.com/platon-uniswap/governance.git +$ cd governance +$ npm i +$ npx hardhat --network alaya_dev run scripts/01-deploy-uni.js +$ npx hardhat --network alaya_dev run scripts/02-deploy-timelock.js // 部署时间锁合约,预计算治理合约地址 +$ npx hardhat --network alaya_dev run scripts/03-deploy-gov.js // 修改文件,替换前一步timelock合约地址,部署治理合约地址,若部署失败,需要从上一步重新开始 +$ npx hardhat --network alaya_dev run scripts/06-propose.js // 修改发起提案,如增发UNI,需要将uni的owner设置为timelock先 +``` + +### 部署流动性挖矿合约 + +``` +$ git clone https://github.com/platon-uniswap/liquidity-staker.git +$ cd liquidity-staker +$ npm i +$ npx hardhat --network alaya_dev run scripts/01-deploy-factory.js // 编辑文件,修改奖励地址为上述UNI的地址 +$ npx hardhat --network alaya_dev run scripts/02-deploy-staking.js // 编辑文件,替换factory合约地址为前一步生成的合约地址,替换stakingToken为WETHUSDT的pair地址。 +$ npx hardhat --network alaya_dev run scripts/03-notify-reward.js // 给池子转UNI奖励代币。开始流动性挖矿 + + +``` \ No newline at end of file diff --git a/Community_Verification_Event(First)/UniswapV2_Migration_verification/info.md b/Community_Verification_Event(First)/UniswapV2_Migration_verification/info.md new file mode 100644 index 0000000..a317755 --- /dev/null +++ b/Community_Verification_Event(First)/UniswapV2_Migration_verification/info.md @@ -0,0 +1,127 @@ +# PlatOn Uniswap Info (V2) + +website:https://devnet-info.ddex.cc/ + +code: https://github.com/platon-uniswap/info + + + +### To Start Development + +#### Git clone + +~~~bash +$ git clone https://github.com/platon-uniswap/info.git +~~~ + +#### Installing dependencies + +```bash +$ yarn +``` + +#### Running locally + +```bash +$ yarn start +``` + + + +### 部署 + +#### 修改自己部署的请求链接 + +**src/apollo/client.js 第7、15、39行** + +```javascript +export const client = new ApolloClient({ + link: new HttpLink({ + uri: '自我部署链接', + }), + cache: new InMemoryCache(), + shouldBatch: true, +}) + +export const healthClient = new ApolloClient({ + link: new HttpLink({ + uri: '自我部署链接', + }), + cache: new InMemoryCache(), + shouldBatch: true, +}) + +export const blockClient = new ApolloClient({ + link: new HttpLink({ + uri: '自我部署链接', + }), + cache: new InMemoryCache(), +}) +``` + +**src/apollo/queres.js 第6行** + +~~~javascript +export const SUBGRAPH_HEALTH = gql` + query health { + indexingStatusForCurrentVersion(subgraphName: "自我部署名称") { + synced + health + chains { + chainHeadBlock { + number + } + latestBlock { + number + } + } + } + } +` +~~~ + +#### 修改FACTORY_ADDRESS + +~~~javascript +// src/constants/index.js 第一行 +export const FACTORY_ADDRESS = '0x154b2f6202a5033Cb150931177B86a2B03E485dF' +~~~ + +#### Installing dependencies + +```bash +$ yarn +``` + +#### Build + +```bash +$ yarn build +``` + +#### Nginx 部署 + +~~~ +server { + listen 8080; + server_name localhost; + + location / { + // 编译文件路径地址 + root .../info/build; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } +} +~~~ + +nginx重新reload: + +```bash +$ nginx -s reload +``` diff --git a/Community_Verification_Event(First)/UniswapV2_Migration_verification/interface.md b/Community_Verification_Event(First)/UniswapV2_Migration_verification/interface.md new file mode 100644 index 0000000..98df523 --- /dev/null +++ b/Community_Verification_Event(First)/UniswapV2_Migration_verification/interface.md @@ -0,0 +1,289 @@ +# Swap Interface + +website:https://devnet-swap.ddex.cc/ + +code: https://github.com/platon-uniswap/interface + + + +## To Start Development + +#### Git clone + +~~~bash +$ git clone https://github.com/platon-uniswap/info.git +~~~ + +#### Installing dependencies + +```bash +$ yarn +``` + +#### Running locally + +```bash +$ yarn start +``` + + + +## 前端代码修改与打包 + +### 安装nodejs + +通过[node官网](https://nodejs.org/)下载安装最新的node稳定版本 + +### 修改代码 + +#### 依赖包修改并发布 + +* 包名:uniswap-sdk + +* 源码地址: https://github.com/platon-uniswap/uniswap-sdk + +* 修改位置: + + - src/constants.ts (28行处) + + ```javascript + export const FACTORY_ADDRESS = '0x154b2f6202a5033Cb150931177B86a2B03E485dF' + export const INIT_CODE_HASH = '0x1892ee6b3b8f653471529d0b06a772bdc5588bb0b15607cb427c8148f70004a9' + ``` + + 将上面的FACTORY_ADDRESS和INIT_CODE_HASH替换成新部署生成的对应的数据 + + - src/entities/token.ts(95行) + + ```javascript + [ChainId.PLATON_TESTNET]: new Token( + ChainId.PLATON_TESTNET, + '0xA838575b75a8b7C4A086a656F2d589eFb03109D6', + 18, + 'WLAT', + 'Wrapped LAT' + ), + ``` + + +将上面的lat地址替换成新部署生成的WLAT代币地址 + +* 直接替换包 + + 运行npm i 安装sdk依赖,再运行npm run build编译包,编译成功后将生成的diast文件替换 PlatON-Swap 项目 node_nodules/@platon-swap/uniswap-sdk 下的 dist 文件 + +* 重新发布该包 + + 修改package.json中的版本号, 然后运行npm i 安装sdk依赖,再运行npm run build编译包,编译成功后运行npm publish --access public发布 + + + +#### 前端代码修改 + +##### 针对流动性挖矿,如果已经部署了staking合约,则代码需要添加对应流动性相关的代码,这里以ETH-PUSDT交易对为例 + ++ src/constants/index.ts(24行) + +```javascript +export const PUSDT = new Token(ChainId.PLATON_TESTNET, '0x6A04AcbD67f6878A1Cc3DdDf7ACc45afA97057b1', 6, 'USDT', 'Tether USD') +``` + + 修改或增加对应代币的相关信息 + ++ src/state/stake/hooks.ts + +```javascript +export const STAKING_GENESIS = 1600744959(11行) + +export const REWARDS_DURATION_DAYS = 60(13行) +``` + +增加对应的交易对信息以及交易对流动性挖矿对应的staking合约地址 + +同时需要给Staking合约转对应的激励代币到合约账户,然后运行notifyRewardAmount接口将合约账户的激励代币生效 + + + +##### 其他和流动性挖矿无关的必要修改点 + +- src/constants/index.ts(第7/44/51/58行) + +```javascript +export const ROUTER_ADDRESS = '0x2d51fd37f175984603A7d6C4758b27D09A1B2227' + +export function getUniAddress(chainId: ChainId): string { + if (isPlatOnChains(chainId)) { + return '0xDFA36286675c8a03050b63F23D79786A067E0d24' + } + return '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984' +} + +export function getGovernAddress(chainId: ChainId): string { + if (isPlatOnChains(chainId)) { + return '0x7157e63BcAcfDa09Eb1C33Da88A0D0Bdc2880823' + } + return '0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F' +} + +export function getTimelock(chainId: ChainId): string { + if (isPlatOnChains(chainId)) { + return '0xb90a71E184454F0eb544BD5e135cD093037649b4' + } + return '0x1a9C8182C09F50C8318d769245beA52c32BE35BC' +} +``` + +将上面的ROUTER_ADDRESS替换成新部署生成的router, 治理, timelock, 治理代币UNI合约地址 + +- src/constants/multicall/index.ts(第10行) + +```javascript +[ChainId.PLATON_TESTNET]: '0xb80D5C1DE16301e57a13F19e2545E9813A4C2681', +``` + +将上面的lat地址替换成新部署生成的multicall合约地址 + +- src/state/stake/hooks.ts(第40行) + +```javascript +[ChainId.PLATON_TESTNET]: [ + { + tokens: [WETH[ChainId.PLATON_TESTNET], PUSDT], + stakingRewardAddress: '0x4d7ec635A8047A2B90206264220DB2a655BDCEd8' + } +] +``` + +将上面的stakingRewardAddress地址替换成新部署生成的stakingReward合约地址 + +- src/constants/list.ts(第15行) + +```javascript +const GEMINI_LIST = 'https://raw.githubusercontent.com/fujianlian/interface/main/public/main.json' +``` + +这个默认的json列表所在的URL地址需要替换成可以访问到token-list.json文件的URL地址 + +- public/token-list.json + +``` +{ + ... + "tokens":[ + { + "name": "Platon Wrapped ETH", + "chainId": 210309, + "symbol": "WETH", + "decimals": 18, + "address": "0xA838575b75a8b7C4A086a656F2d589eFb03109D6", + "logoURI": "https://raw.githubusercontent.com/Uniswap/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png" + }, + { + "name": "USDT", + "chainId": 210309, + "symbol": "USDT", + "decimals": 6, + "address": "0x6A04AcbD67f6878A1Cc3DdDf7ACc45afA97057b1", + "logoURI": "https://ethereum-optimism.github.io/logos/USDT.png" + }, + { + "name": "UNI-V2", + "chainId": 210309, + "symbol": "UNI-V2", + "decimals": 18, + "address": "0xE5177055644DF9e2FA47246EA0973dE2c11AE730", + "logoURI": "https://gemini.com/images/currencies/icons/default/uni.svg" + }, + { + "name": "UNI", + "chainId": 210309, + "symbol": "UNI", + "decimals": 18, + "address": "0xDFA36286675c8a03050b63F23D79786A067E0d24", + "logoURI": "https://gemini.com/images/currencies/icons/default/uni.svg" + } + ], + ... +} +``` + +将token-list.json文件修改,__WETH地址替换成新部署的代币合约地址,其他代币地址可以自己增加或者删除即可__,logoURI替换成可以访问的代币符号图片链接 + +### 编译打包 + +1. 运行`npm i`安装依赖包,请检查@platon-swap/uniswap-sdk的依赖包版本是否正确。 + +2. 运行`npm run build`命令编译项目。 + +3. 使用下面的命令把build目录下面的文件打包: + +```shell +$ cd build +$ tar -zcvf dist.tar.gz * +``` + + + +## 前端包部署 + +### Github.io部署 + +~~~bash +$ yarn depoly +~~~ + +成功后访问 https://username.github.io/interface 即可,username为GitHub的用户名 + +### Nginx部署 + +* 在nginx目标机器,新建web目录,假设全路径为/home/web,通过下面的命令解压dist.tar.gz 到web目录: + + ``` + tar -zxvf dist.tar.gz -C ./web + ``` + +* 前端包需要部署到nginx,nginx参考如下配置: + + ``` + server { + listen 8080; ##监听端口 + server_name 10.1.1.50; ##服务器ip 根据实际情况替换 + client_max_body_size 20m; + charset utf-8; + + #access_log logs/host.access.log main; + + location / { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + root /home/web; ##假设目标机器存放项目文件位置 根据实际情况替换 + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + location /api { ##/api是项目文件中.env.production文件下的REACT_APP_NETWORK_URL 作为请求转发的标记,根据实际情况替换,请确保与项目中一致 + proxy_pass http://10.1.1.50:6789; ##“节点搭建”步骤目标节点的地址 + #proxy_set_^_header Host $host:$server_port; + #proxy_set_header Host $host; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_send_timeout 12s; + proxy_read_timeout 60s; + proxy_connect_timeout 10s; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + ``` + +* nginx重新reload: + + ```shell + $ nginx -s reload + ``` + diff --git a/Community_Verification_Event(First)/UniswapV2_Migration_verification/subgraph.md b/Community_Verification_Event(First)/UniswapV2_Migration_verification/subgraph.md new file mode 100644 index 0000000..ea6f4df --- /dev/null +++ b/Community_Verification_Event(First)/UniswapV2_Migration_verification/subgraph.md @@ -0,0 +1,78 @@ +## subgraph + +环境 +ubuntu 1804 + +仓库 + +https://github.com/graphprotocol/graph-node.git + +安装依赖 + 1. 安装rust + 2. 安装ipfs + 3. 安装postgresql + +### 部署 + +运行ipfs + +``` +$ ipfs init + +$ nohup ipfs daemon& +``` + +运行postgresql + +``` +$ sudo systemctl start postgresql +``` + +创建数据库 + +``` +$ sudo su postgres +$ psql +$ create database graphnode; +``` + +运行rpc代理 + +``` +$ git clone https://github.com/a2a6c172b3f1b60a8ce26f/rpc-adaptor.git +$ npm i +$ node index.js +``` + +运行graph节点 + +``` +$ cargo run -p graph-node --release -- \ + --postgres-url postgresql://postgres:postgres@localhost:5432/graphnode \ + --ethereum-rpc lat:http://127.0.0.1:3000 \ + --ipfs 127.0.0.1:5001 +``` + + +部署ethereum-blocks + +``` +$ git clone https://github.com/blocklytics/ethereum-blocks.git +$ cd ethereum-blocks +$ npm i +$ npm run build +$ npm run create-local +$ npm run deploy-local +``` + +部署v2-subgraph + +``` +$ git clone https://github.com/Uniswap/v2-subgraph.git +$ cd v2-subgraph +$ npm i +$ npm run build +$ npm run create-local +$ npm run deploy-local +``` +