Add deployment scripts for sushiswap contracts

This commit is contained in:
Prathamesh Musale 2023-08-11 12:21:10 +05:30 committed by Nabarun
parent 0e1e3d67e1
commit 3eaf20877b
6 changed files with 125 additions and 4 deletions

View File

@ -5,10 +5,39 @@ services:
sushiswap-v3-core:
image: cerc/sushiswap-v3-core:local
env_file:
- ../config/watcher-sushiswap/lotus-params.env
- ../config/contract-sushiswap/deployment-params.env
environment:
ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT}
CHAIN_ID: ${CHAIN_ID}
ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY}
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
- sushiswap_core_deployment:/app/deployments/docker
command: ["bash", "-c", "/app/deploy-core-contracts.sh && tail -f"]
extra_hosts:
- "host.docker.internal:host-gateway"
# Deploys the periphery (NFPM, token, etc.) contracts
sushiswap-v3-periphery:
image: cerc/sushiswap-v3-periphery:local
env_file:
- ../config/watcher-sushiswap/lotus-params.env
- ../config/contract-sushiswap/deployment-params.env
environment:
ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT}
CHAIN_ID: ${CHAIN_ID}
ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY}
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
- sushiswap_core_deployment:/app/core-deployments/docker
- sushiswap_periphery_deployment:/app/deployments/docker
command: ["bash", "-c", "/app/deploy-periphery-contracts.sh && tail -f"]
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
sushiswap_core_deployment:
sushiswap_periphery_deployment:

View File

@ -0,0 +1,34 @@
#!/bin/bash
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}}"
# Option
DEPLOY="${DEPLOY:-${DEFAULT_DEPLOY}}"
# Create a .env file
echo "ETH_RPC_ENDPOINT=$ETH_RPC_ENDPOINT" > .env
echo "CHAIN_ID=$CHAIN_ID" >> .env
echo "ACCOUNT_PRIVATE_KEY=$ACCOUNT_PRIVATE_KEY" >> .env
echo "Using RPC endpoint ${ETH_RPC_ENDPOINT}"
# Wait for the RPC endpoint to be up
endpoint=${ETH_RPC_ENDPOINT#http://}
endpoint=${endpoint#https://}
RPC_HOST=$(echo "$endpoint" | awk -F'[:/]' '{print $1}')
RPC_PORT=$(echo "$endpoint" | awk -F'[:/]' '{print $2}')
./wait-for-it.sh -h "${RPC_HOST}" -p "${RPC_PORT}" -s -t 0
if [ "$DEPLOY" ]; then
echo "Performing core contract deployments..."
pnpm hardhat --network docker deploy --tags UniswapV3Factory
else
echo "Skipping contract deployments"
fi
echo "Done"

View File

@ -0,0 +1,47 @@
#!/bin/bash
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}}"
# Option
DEPLOY="${DEPLOY:-${DEFAULT_DEPLOY}}"
# Create a .env file
echo "ETH_RPC_ENDPOINT=$ETH_RPC_ENDPOINT" > .env
echo "CHAIN_ID=$CHAIN_ID" >> .env
echo "ACCOUNT_PRIVATE_KEY=$ACCOUNT_PRIVATE_KEY" >> .env
echo "Using RPC endpoint $ETH_RPC_ENDPOINT"
# Wait for the RPC endpoint to be up
endpoint=${ETH_RPC_ENDPOINT#http://}
endpoint=${endpoint#https://}
RPC_HOST=$(echo "$endpoint" | awk -F'[:/]' '{print $1}')
RPC_PORT=$(echo "$endpoint" | awk -F'[:/]' '{print $2}')
./wait-for-it.sh -h "${RPC_HOST}" -p "${RPC_PORT}" -s -t 0
if [ "$DEPLOY" ]; then
# Loop until the factory deployment is detected
echo "Waiting for core deployments to occur"
while [ ! -f /app/core-deployments/docker/UniswapV3Factory.json ]; do
sleep 5
done
echo "Reading factory address from core deployments"
FACTORY_ADDRESS=$(jq -r '.address' /app/core-deployments/docker/UniswapV3Factory.json)
echo "Using UniswapV3Factory at $FACTORY_ADDRESS"
echo "FACTORY_ADDRESS=$FACTORY_ADDRESS" >> .env
echo "Performing periphery contract deployments..."
yarn hardhat --network docker deploy --tags NonfungiblePositionManager
else
echo "Skipping contract deployments"
fi
echo "Done"

View File

@ -0,0 +1,11 @@
# Chain config
DEFAULT_ETH_RPC_ENDPOINT="http://lotus-node-1:1234/rpc/v1"
DEFAULT_CHAIN_ID=31415926
# From app/data/config/fixturenet-lotus/fund-account.sh
DEFAULT_ACCOUNT_PRIVATE_KEY="0xc05fd3613bcd62a4f25e5eba1f464d0b76d74c3f771a7c2f13e26ad6439444b3"
# Options
DEFAULT_DEPLOY=true

View File

@ -1,6 +1,6 @@
FROM node:18.15.0-alpine3.16
RUN apk --update --no-cache add git python3 alpine-sdk bash
RUN apk --update --no-cache add git python3 alpine-sdk bash jq
RUN curl -L https://unpkg.com/@pnpm/self-installer | node
WORKDIR /app

View File

@ -1,6 +1,6 @@
FROM node:18.15.0-alpine3.16
RUN apk --update --no-cache add git python3 alpine-sdk bash
RUN apk --update --no-cache add git python3 alpine-sdk bash jq
WORKDIR /app