Add sushiswap v3 subgraph stack

This commit is contained in:
Nabarun 2023-08-14 11:03:47 +05:30
parent fda74e5c33
commit 4f6c3529aa
10 changed files with 121 additions and 1 deletions

View File

@ -5,8 +5,10 @@ services:
sushiswap-v3-core:
image: cerc/sushiswap-v3-core:local
env_file:
# Defaults
- ../config/contract-sushiswap/deployment-params.env
environment:
# Overrides
ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT}
CHAIN_ID: ${CHAIN_ID}
ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY}
@ -23,8 +25,10 @@ services:
sushiswap-v3-periphery:
image: cerc/sushiswap-v3-periphery:local
env_file:
# Defaults
- ../config/contract-sushiswap/deployment-params.env
environment:
# Overrides
ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT}
CHAIN_ID: ${CHAIN_ID}
ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY}

View File

@ -25,6 +25,12 @@ services:
- "8001"
- "8020"
- "8030"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "8020"]
interval: 30s
timeout: 10s
retries: 10
start_period: 3s
ipfs:
image: ipfs/kubo:master-2023-02-20-714a968
volumes:

View File

@ -0,0 +1,25 @@
version: '3.2'
services:
# Deploys the sushiswap v3 subgraph
sushiswap-subgraph-v3:
image: cerc/sushiswap-subgraphs:local
restart: on-failure
depends_on:
graph-node
environment:
- APP=v3
- NETWORK=lotus-fixturenet
command: ["./run-v3.sh"]
working_dir: /app/subgraphs/v3
volumes:
- ../config/sushiswap-subgraph-v3/lotus-fixturenet.js:/app/config/lotus-fixturenet.js
- ../config/sushiswap-subgraph-v3/run-v3.sh:/app/subgraphs/v3/run-v3.sh
- sushiswap_core_deployment:/app/subgraphs/v3/core-deployments/docker
- sushiswap_periphery_deployment:/app/subgraphs/v3/deployments/docker
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
sushiswap_core_deployment:
sushiswap_periphery_deployment:

View File

@ -0,0 +1,20 @@
module.exports = {
network: 'lotus-fixturenet',
v3: {
factory: {
address: 'FACTORY_ADDRESS',
startBlock: FACTORY_BLOCK
},
positionManager: {
address: 'NFPM_ADDRESS',
startBlock: NFPM_BLOCK
},
native: { address: 'NATIVE_ADDRESS' },
whitelistedTokenAddresses: [
'NATIVE_ADDRESS',
],
stableTokenAddresses: [
],
minimumEthLocked: 1.5
}
}

View File

@ -0,0 +1,39 @@
#!/bin/bash
set -e
# Loop until the NFPM deployment is detected
echo "Waiting for sushiswap-periphery deployments to occur"
while [ ! -f /app/deployments/docker/NonfungiblePositionManager.json ]; do
sleep 5
done
echo "Reading contract addresses and block numbers from deployments"
FACTORY_ADDRESS=$(jq -r '.address' /app/core-deployments/docker/UniswapV3Factory.json)
FACTORY_BLOCK=$(jq -r '.receipt.blockNumber' /app/core-deployments/docker/UniswapV3Factory.json)
NATIVE_ADDRESS=$(jq -r '.address' /app/deployments/docker/WFIL.json)
NFPM_ADDRESS=$(jq -r '.address' /app/deployments/docker/NonfungiblePositionManager.json)
NFPM_BLOCK=$(jq -r '.receipt.blockNumber' /app/deployments/docker/NonfungiblePositionManager.json)
# Read the JavaScript file content
file_content=$(</app/config/lotus-fixturenet.js)
# Replace uppercase words with environment variables
echo "Reading values in lotus-fixturenet config"
replaced_content=$(echo "$file_content" | sed -e "s/FACTORY_ADDRESS/$FACTORY_ADDRESS/g" \
-e "s/FACTORY_BLOCK/$FACTORY_BLOCK/g" \
-e "s/NFPM_ADDRESS/$NFPM_ADDRESS/g" \
-e "s/NFPM_BLOCK/$NFPM_BLOCK/g" \
-e "s/NATIVE_ADDRESS/$NATIVE_ADDRESS/g")
# Write the replaced content back to the JavaScript file
echo "$replaced_content" > /app/config/lotus-fixturenet.js
echo "Building subgraph and deploying to graph-node..."
pnpm run generate
pnpm run build
pnpm exec graph create --node http://graph-node:8020/ sushiswap/v3-lotus
pnpm exec graph deploy --node http://graph-node:8020/ --ipfs http://ipfs:5001 --version-label 0.1.0 sushiswap/v3-lotus
echo "Done"

View File

@ -0,0 +1,11 @@
FROM node:18.15.0-alpine3.16
RUN apk --update --no-cache add git alpine-sdk bash jq
RUN curl -L https://unpkg.com/@pnpm/self-installer | node
WORKDIR /app
COPY . .
RUN echo "Installing dependencies..." && \
pnpm install

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Build cerc/sushiswap-subgraphs
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/sushiswap-subgraphs:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/subgraphs

View File

@ -48,3 +48,4 @@ cerc/sushiswap-v3-core
cerc/sushiswap-v3-periphery
cerc/watcher-sushiswap
cerc/graph-node
cerc/sushiswap-subgraphs

View File

@ -42,3 +42,4 @@ git.vdb.to/cerc-io/plugeth-statediff
github.com/cerc-io/sushiswap-v3-core
github.com/cerc-io/sushiswap-v3-periphery
github.com/graphprotocol/graph-node
github.com/sushiswap/subgraphs

View File

@ -1,12 +1,16 @@
version: "1.0"
name: sushiswap-subgraph
description: "An end-to-end SushiSwap Graph stack"
description: "An end-to-end SushiSwap Subgraph stack"
repos:
## fixturenet-lotus repo
- github.com/filecoin-project/lotus
## graph-node repo
- github.com/graphprotocol/graph-node
## sushiswap repos
- github.com/cerc-io/sushiswap-v3-core@watcher-ts
- github.com/cerc-io/sushiswap-v3-periphery@watcher-ts
## subgraph repo
- github.com/sushiswap/subgraphs
containers:
## fixturenet-lotus image
- cerc/lotus
@ -15,4 +19,6 @@ containers:
- cerc/sushiswap-v3-periphery
pods:
- fixturenet-lotus
- fixturenet-graph-node
- contract-sushiswap
- sushiswap-subgraph-v3