From 0985c201c6c13600e0535979708c1f0de0a986c4 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Mon, 14 Aug 2023 18:25:34 +0530 Subject: [PATCH 1/3] Fix env variable overriding in sushiswap contract deployment containers --- .../docker-compose-contract-sushiswap.yml | 16 ++++++++-------- .../contract-sushiswap/deploy-core-contracts.sh | 8 ++++---- .../deploy-periphery-contracts.sh | 8 ++++---- .../contract-sushiswap/deployment-params.env | 8 ++++---- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/data/compose/docker-compose-contract-sushiswap.yml b/app/data/compose/docker-compose-contract-sushiswap.yml index 96ee1a3e..b157909e 100644 --- a/app/data/compose/docker-compose-contract-sushiswap.yml +++ b/app/data/compose/docker-compose-contract-sushiswap.yml @@ -10,10 +10,10 @@ services: - ../config/contract-sushiswap/deployment-params.env environment: # Overrides - ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT} - CHAIN_ID: ${CHAIN_ID} - ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY} - DEPLOY: ${DEPLOY} + CERC_ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT} + CERC_CHAIN_ID: ${CHAIN_ID} + CERC_ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY} + CERC_DEPLOY: ${DEPLOY} volumes: - ../config/network/wait-for-it.sh:/app/wait-for-it.sh - ../config/contract-sushiswap/deploy-core-contracts.sh:/app/deploy-core-contracts.sh @@ -31,10 +31,10 @@ services: - ../config/contract-sushiswap/deployment-params.env environment: # Overrides - ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT} - CHAIN_ID: ${CHAIN_ID} - ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY} - DEPLOY: ${DEPLOY} + CERC_ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT} + CERC_CHAIN_ID: ${CHAIN_ID} + CERC_ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY} + CERC_DEPLOY: ${DEPLOY} volumes: - ../config/network/wait-for-it.sh:/app/wait-for-it.sh - ../config/contract-sushiswap/deploy-periphery-contracts.sh:/app/deploy-periphery-contracts.sh diff --git a/app/data/config/contract-sushiswap/deploy-core-contracts.sh b/app/data/config/contract-sushiswap/deploy-core-contracts.sh index 0bf3b8fe..1f71713e 100755 --- a/app/data/config/contract-sushiswap/deploy-core-contracts.sh +++ b/app/data/config/contract-sushiswap/deploy-core-contracts.sh @@ -3,12 +3,12 @@ set -e # Chain config -ETH_RPC_ENDPOINT="${ETH_RPC_ENDPOINT:-${DEFAULT_ETH_RPC_ENDPOINT}}" -CHAIN_ID="${CHAIN_ID:-${DEFAULT_CHAIN_ID}}" -ACCOUNT_PRIVATE_KEY="${ACCOUNT_PRIVATE_KEY:-${DEFAULT_ACCOUNT_PRIVATE_KEY}}" +export ETH_RPC_ENDPOINT="${CERC_ETH_RPC_ENDPOINT:-${CERC_DEFAULT_ETH_RPC_ENDPOINT}}" +export CHAIN_ID="${CERC_CHAIN_ID:-${CERC_DEFAULT_CHAIN_ID}}" +export ACCOUNT_PRIVATE_KEY="${CERC_ACCOUNT_PRIVATE_KEY:-${CERC_DEFAULT_ACCOUNT_PRIVATE_KEY}}" # Option -DEPLOY="${DEPLOY:-${DEFAULT_DEPLOY}}" +DEPLOY="${CERC_DEPLOY:-${CERC_DEFAULT_DEPLOY}}" # Create a .env file echo "ETH_RPC_ENDPOINT=$ETH_RPC_ENDPOINT" > .env diff --git a/app/data/config/contract-sushiswap/deploy-periphery-contracts.sh b/app/data/config/contract-sushiswap/deploy-periphery-contracts.sh index 3586b867..92466bb9 100755 --- a/app/data/config/contract-sushiswap/deploy-periphery-contracts.sh +++ b/app/data/config/contract-sushiswap/deploy-periphery-contracts.sh @@ -3,12 +3,12 @@ set -e # Chain config -ETH_RPC_ENDPOINT="${ETH_RPC_ENDPOINT:-${DEFAULT_ETH_RPC_ENDPOINT}}" -CHAIN_ID="${CHAIN_ID:-${DEFAULT_CHAIN_ID}}" -ACCOUNT_PRIVATE_KEY="${ACCOUNT_PRIVATE_KEY:-${DEFAULT_ACCOUNT_PRIVATE_KEY}}" +ETH_RPC_ENDPOINT="${CERC_ETH_RPC_ENDPOINT:-${CERC_DEFAULT_ETH_RPC_ENDPOINT}}" +CHAIN_ID="${CERC_CHAIN_ID:-${CERC_DEFAULT_CHAIN_ID}}" +ACCOUNT_PRIVATE_KEY="${CERC_ACCOUNT_PRIVATE_KEY:-${CERC_DEFAULT_ACCOUNT_PRIVATE_KEY}}" # Option -DEPLOY="${DEPLOY:-${DEFAULT_DEPLOY}}" +DEPLOY="${CERC_DEPLOY:-${CERC_DEFAULT_DEPLOY}}" # Create a .env file echo "ETH_RPC_ENDPOINT=$ETH_RPC_ENDPOINT" > .env diff --git a/app/data/config/contract-sushiswap/deployment-params.env b/app/data/config/contract-sushiswap/deployment-params.env index f9854e88..53bf910f 100644 --- a/app/data/config/contract-sushiswap/deployment-params.env +++ b/app/data/config/contract-sushiswap/deployment-params.env @@ -1,11 +1,11 @@ # Chain config -DEFAULT_ETH_RPC_ENDPOINT="http://lotus-node-1:1234/rpc/v1" -DEFAULT_CHAIN_ID=31415926 +CERC_DEFAULT_ETH_RPC_ENDPOINT="http://lotus-node-1:1234/rpc/v1" +CERC_DEFAULT_CHAIN_ID=31415926 # From app/data/config/fixturenet-lotus/fund-account.sh -DEFAULT_ACCOUNT_PRIVATE_KEY="0xc05fd3613bcd62a4f25e5eba1f464d0b76d74c3f771a7c2f13e26ad6439444b3" +CERC_DEFAULT_ACCOUNT_PRIVATE_KEY="0xc05fd3613bcd62a4f25e5eba1f464d0b76d74c3f771a7c2f13e26ad6439444b3" # Options -DEFAULT_DEPLOY=true +CERC_DEFAULT_DEPLOY=true From 0c2b9425913c9b292e75e99b3ccf964fab95bd51 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Mon, 14 Aug 2023 18:27:50 +0530 Subject: [PATCH 2/3] Add steps for generating sushiswap events --- app/data/stacks/sushiswap-subgraph/README.md | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/app/data/stacks/sushiswap-subgraph/README.md b/app/data/stacks/sushiswap-subgraph/README.md index 4f82711b..d21b69a1 100644 --- a/app/data/stacks/sushiswap-subgraph/README.md +++ b/app/data/stacks/sushiswap-subgraph/README.md @@ -38,6 +38,59 @@ laconic-so --stack sushiswap-subgraph deploy --cluster sushigraph logs -f sushis # sushigraph-sushiswap-subgraph-v3-1 | Done ``` +## Run + +To check graph-node logs: +```bash +laconic-so --stack sushiswap-subgraph deploy --cluster sushigraph logs -f graph-node +``` + +To deploy tokens run: +```bash +docker exec -it sushigraph-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 +``` +This can be run multiple times to deploy ERC20 tokens + +Take note of the deployed token addresses to use later + +Get contract address of factory deployed: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 jq -r '.address' /app/deployments/docker/UniswapV3Factory.json +``` +Set it to environment variable `FACTORY_ADDRESS` to use later + +To create a pool: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:create:docker --factory $FACTORY_ADDRESS --token0 $TOKEN1_ADDRESS --token1 $TOKEN2_ADDRESS --fee 500 +``` + +Set the created pool address to environment variable `POOL_ADDRESS` to use later + +To initialize pool: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:initialize:docker --sqrt-price 4295128939 --pool $POOL_ADDRESS +``` + +Set the recipient address to the contract deployer: +```bash +export RECIPIENT=0xD375B03bd3A2434A9f675bEC4Ccd68aC5e67C743 +``` + +Trigger pool mint event: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:mint:docker --pool $POOL_ADDRESS --recipient $RECIPIENT --amount 10 +``` + +Trigger pool burn event: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:burn:docker --pool $POOL_ADDRESS --amount 10 +``` + +Trigger pool swap event: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:swap:docker --pool $POOL_ADDRESS --recipient $RECIPIENT --sqrt-price 4295128939 +``` + ## Clean up Stop all the services running in background run: From 01af18314ab3418a9fec5c991b85d2f4119e925d Mon Sep 17 00:00:00 2001 From: Nabarun Date: Mon, 14 Aug 2023 19:21:43 +0530 Subject: [PATCH 3/3] Remove pool swap event --- app/data/stacks/sushiswap-subgraph/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/data/stacks/sushiswap-subgraph/README.md b/app/data/stacks/sushiswap-subgraph/README.md index d21b69a1..b341a1a3 100644 --- a/app/data/stacks/sushiswap-subgraph/README.md +++ b/app/data/stacks/sushiswap-subgraph/README.md @@ -86,11 +86,6 @@ Trigger pool burn event: docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:burn:docker --pool $POOL_ADDRESS --amount 10 ``` -Trigger pool swap event: -```bash -docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:swap:docker --pool $POOL_ADDRESS --recipient $RECIPIENT --sqrt-price 4295128939 -``` - ## Clean up Stop all the services running in background run: