forked from cerc-io/stack-orchestrator
		
	Update sushiswap-subgraph stack to point to filecoin endpoint (#509)
* Update sushiswap-subgraph stack to point to filecoin endpoint * Deploy blocks subgraph in sushiswap-subgraph stack * Update subgraph config * Remove duplicate nativePricePool * Enable debug logs in graph-node and update instructions * Two additional miner nodes in fixturenet-lotus * Revert experimental change for additional miner nodes * Set ETHEREUM_REORG_THRESHOLD env for graph-node to catch up to head * Take ETH RPC endpoint for graph-node from env * Set default values for RPC endpoint in graph-node * Rename fixturenet-graph-node pod to graph-node * Clean up sushiswap-subgraph stack * Use deployment command in sushiswap-subgraph stack * Add a separate fixturenet-sushiswap-subgraph stack * Fix pods in fixturenet-sushiswap-subgraph * Fix fixturenet subgraph deployment commands and instructions --------- Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
		
							parent
							
								
									d3c26948fc
								
							
						
					
					
						commit
						53ed18b3dc
					
				| @ -0,0 +1,27 @@ | ||||
| version: '3.2' | ||||
| 
 | ||||
| services: | ||||
|   # Deploys the sushiswap v3 subgraph | ||||
|   sushiswap-subgraph-v3: | ||||
|     image: cerc/sushiswap-subgraphs:local | ||||
|     restart: on-failure | ||||
|     depends_on: | ||||
|       graph-node: | ||||
|         condition: service_healthy | ||||
|     environment: | ||||
|       - APP=v3 | ||||
|       - NETWORK=lotus-fixturenet | ||||
|     command: ["bash", "-c", "./v3/run-v3.sh && ./blocks/run-blocks.sh"] | ||||
|     working_dir: /app/subgraphs | ||||
|     volumes: | ||||
|       - ../config/fixturenet-sushiswap-subgraph-v3/lotus-fixturenet.js.template:/app/config/lotus-fixturenet.js.template | ||||
|       - ../config/fixturenet-sushiswap-subgraph-v3/run-blocks.sh:/app/subgraphs/blocks/run-blocks.sh | ||||
|       - ../config/fixturenet-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/periphery-deployments/docker | ||||
|     extra_hosts: | ||||
|       - "host.docker.internal:host-gateway" | ||||
| 
 | ||||
| volumes: | ||||
|   sushiswap_core_deployment: | ||||
|   sushiswap_periphery_deployment: | ||||
| @ -6,8 +6,9 @@ services: | ||||
|         condition: service_healthy | ||||
|       ipfs: | ||||
|         condition: service_healthy | ||||
|       lotus-node-1: | ||||
|         condition: service_healthy | ||||
|       # Uncomment when running against fixturenet-lotus to wait for the Lotus node to come up | ||||
|       # lotus-node-1: | ||||
|       #   condition: service_healthy | ||||
|     extra_hosts: | ||||
|       - host.docker.internal:host-gateway | ||||
|     environment: | ||||
| @ -17,9 +18,9 @@ services: | ||||
|       postgres_user: graph-node | ||||
|       postgres_pass: password | ||||
|       postgres_db: graph-node | ||||
|       # TODO: Get endpoint from env | ||||
|       ethereum: 'lotus-fixturenet:http://lotus-node-1:1234/rpc/v1' | ||||
|       GRAPH_LOG: info | ||||
|       ethereum: ${NETWORK:-filecoin}:${ETH_RPC_ENDPOINT:-https://archive.lotus.vdb.to/rpc/v1} | ||||
|       GRAPH_LOG: debug | ||||
|       ETHEREUM_REORG_THRESHOLD: 3 | ||||
|     ports: | ||||
|       - "8000" | ||||
|       - "8001" | ||||
| @ -10,17 +10,12 @@ services: | ||||
|         condition: service_healthy | ||||
|     environment: | ||||
|       - APP=v3 | ||||
|       - NETWORK=lotus-fixturenet | ||||
|     command: ["bash", "-c", "./run-v3.sh"] | ||||
|     working_dir: /app/subgraphs/v3 | ||||
|       - NETWORK=filecoin | ||||
|     command: ["bash", "-c", "./blocks/run-blocks.sh && ./v3/run-v3.sh"] | ||||
|     working_dir: /app/subgraphs | ||||
|     volumes: | ||||
|       - ../config/sushiswap-subgraph-v3/lotus-fixturenet.js.template:/app/config/lotus-fixturenet.js.template | ||||
|       - ../config/sushiswap-subgraph-v3/filecoin.js:/app/config/filecoin.js | ||||
|       - ../config/sushiswap-subgraph-v3/run-blocks.sh:/app/subgraphs/blocks/run-blocks.sh | ||||
|       - ../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: | ||||
|  | ||||
| @ -23,7 +23,6 @@ if [ ! -f /root/data/localnet.json ]; then | ||||
| fi | ||||
| 
 | ||||
| # start daemon | ||||
| # /root/.lotus-shared/devgen.car path | ||||
| nohup lotus daemon --lotus-make-genesis=/root/.lotus-shared/devgen.car --profile=bootstrapper --genesis-template=/root/data/localnet.json --bootstrap=false > /var/log/lotus.log 2>&1 & | ||||
| 
 | ||||
| # Loop until the daemon is started | ||||
| @ -33,9 +32,6 @@ while ! grep -q "started ChainNotify channel" /var/log/lotus.log ; do | ||||
| done | ||||
| echo "Daemon started." | ||||
| 
 | ||||
| # copy genesis file to shared volume | ||||
| cp /devgen.car /root/.lotus-shared | ||||
| 
 | ||||
| # if miner not already initialized | ||||
| if [ ! -d $LOTUS_MINER_PATH ]; then | ||||
|   # initialize miner | ||||
| @ -44,6 +40,7 @@ if [ ! -d $LOTUS_MINER_PATH ]; then | ||||
|   # fund a known account for usage | ||||
|   /fund-account.sh | ||||
| 
 | ||||
|   echo "Initializing miner..." | ||||
|   lotus-miner init --genesis-miner --actor=t01000 --sector-size=2KiB --pre-sealed-sectors=/root/data/.genesis-sectors --pre-sealed-metadata=/root/data/.genesis-sectors/pre-seal-t01000.json --nosync | ||||
| fi | ||||
| 
 | ||||
|  | ||||
| @ -1,5 +1,9 @@ | ||||
| module.exports = { | ||||
|   network: 'lotus-fixturenet', | ||||
|   blocks: { | ||||
|     address: '0x0000000000000000000000000000000000000000', | ||||
|     startBlock: 0, | ||||
|   }, | ||||
|   v3: { | ||||
|     factory: { | ||||
|       address: 'FACTORY_ADDRESS', | ||||
							
								
								
									
										15
									
								
								app/data/config/fixturenet-sushiswap-subgraph-v3/run-blocks.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								app/data/config/fixturenet-sushiswap-subgraph-v3/run-blocks.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,15 @@ | ||||
| #!/bin/bash | ||||
| 
 | ||||
| set -e | ||||
| 
 | ||||
| echo "Building blocks subgraph and deploying to graph-node..." | ||||
| 
 | ||||
| cd blocks | ||||
| 
 | ||||
| pnpm run generate | ||||
| pnpm run build | ||||
| 
 | ||||
| pnpm exec graph create --node http://graph-node:8020/ sushiswap/blocks | ||||
| pnpm exec graph deploy --node http://graph-node:8020/ --ipfs http://ipfs:5001 --version-label 0.1.0 sushiswap/blocks | ||||
| 
 | ||||
| echo "Done" | ||||
							
								
								
									
										42
									
								
								app/data/config/fixturenet-sushiswap-subgraph-v3/run-v3.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										42
									
								
								app/data/config/fixturenet-sushiswap-subgraph-v3/run-v3.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,42 @@ | ||||
| #!/bin/bash | ||||
| 
 | ||||
| set -e | ||||
| 
 | ||||
| cd v3 | ||||
| 
 | ||||
| # Loop until the NFPM deployment is detected | ||||
| echo "Waiting for sushiswap-periphery deployments to occur" | ||||
| while [ ! -f ./periphery-deployments/docker/NonfungiblePositionManager.json ]; do | ||||
|   sleep 5 | ||||
| done | ||||
| 
 | ||||
| echo "Reading contract addresses and block numbers from deployments" | ||||
| FACTORY_ADDRESS=$(jq -r '.address' ./core-deployments/docker/UniswapV3Factory.json) | ||||
| FACTORY_BLOCK=$(jq -r '.receipt.blockNumber' ./core-deployments/docker/UniswapV3Factory.json) | ||||
| NATIVE_ADDRESS=$(jq -r '.address' ./periphery-deployments/docker/WFIL.json) | ||||
| NFPM_ADDRESS=$(jq -r '.address' ./periphery-deployments/docker/NonfungiblePositionManager.json) | ||||
| NFPM_BLOCK=$(jq -r '.receipt.blockNumber' ./periphery-deployments/docker/NonfungiblePositionManager.json) | ||||
| 
 | ||||
| # Read the JavaScript file content | ||||
| file_content=$(</app/config/lotus-fixturenet.js.template) | ||||
| 
 | ||||
| # 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 v3 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" | ||||
							
								
								
									
										30
									
								
								app/data/config/sushiswap-subgraph-v3/filecoin.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								app/data/config/sushiswap-subgraph-v3/filecoin.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| const NATIVE_ADDRESS = '0x60e1773636cf5e4a227d9ac24f20feca034ee25a' | ||||
| const USDC_ADDRESS = '0xeb466342c4d449bc9f53a865d5cb90586f405215' | ||||
| const DAI_ADDRESS = '0x5c7e299cf531eb66f2a1df637d37abb78e6200c7' | ||||
| 
 | ||||
| module.exports = { | ||||
|   network: 'filecoin', | ||||
|   blocks: { | ||||
|     address: '0x719e14fcb364bb05649bd525eb6c4a2d0d4ea2b7', | ||||
|     startBlock: 2867000, | ||||
|   }, | ||||
|   v3: { | ||||
|     factory: { // 0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6
 | ||||
|       address: '0xc35dadb65012ec5796536bd9864ed8773abc74c4', | ||||
|       startBlock: 2867560, | ||||
|     }, | ||||
|     positionManager: { | ||||
|       address: '0xf4d73326c13a4fc5fd7a064217e12780e9bd62c3', | ||||
|       startBlock: 2868037, | ||||
|     }, | ||||
|     native: { address: NATIVE_ADDRESS }, | ||||
|     whitelistedTokenAddresses: [ | ||||
|       NATIVE_ADDRESS, | ||||
|       USDC_ADDRESS, | ||||
|       DAI_ADDRESS, | ||||
|     ], | ||||
|     stableTokenAddresses: [USDC_ADDRESS, DAI_ADDRESS], | ||||
|     nativePricePool: '0x1d1375281265e4dd496d90455f7c82f4fbd85cc2', | ||||
|     minimumEthLocked: 250 | ||||
|   }, | ||||
| } | ||||
							
								
								
									
										15
									
								
								app/data/config/sushiswap-subgraph-v3/run-blocks.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								app/data/config/sushiswap-subgraph-v3/run-blocks.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,15 @@ | ||||
| #!/bin/bash | ||||
| 
 | ||||
| set -e | ||||
| 
 | ||||
| echo "Building blocks subgraph and deploying to graph-node..." | ||||
| 
 | ||||
| cd blocks | ||||
| 
 | ||||
| pnpm run generate | ||||
| pnpm run build | ||||
| 
 | ||||
| pnpm exec graph create --node http://graph-node:8020/ sushiswap/blocks | ||||
| pnpm exec graph deploy --node http://graph-node:8020/ --ipfs http://ipfs:5001 --version-label 0.1.0 sushiswap/blocks | ||||
| 
 | ||||
| echo "Done" | ||||
| @ -2,38 +2,14 @@ | ||||
| 
 | ||||
| set -e | ||||
| 
 | ||||
| # Loop until the NFPM deployment is detected | ||||
| echo "Waiting for sushiswap-periphery deployments to occur" | ||||
| while [ ! -f ./deployments/docker/NonfungiblePositionManager.json ]; do | ||||
|   sleep 5 | ||||
| done | ||||
| echo "Building v3 subgraph and deploying to graph-node..." | ||||
| 
 | ||||
| echo "Reading contract addresses and block numbers from deployments" | ||||
| FACTORY_ADDRESS=$(jq -r '.address' ./core-deployments/docker/UniswapV3Factory.json) | ||||
| FACTORY_BLOCK=$(jq -r '.receipt.blockNumber' ./core-deployments/docker/UniswapV3Factory.json) | ||||
| NATIVE_ADDRESS=$(jq -r '.address' ./deployments/docker/WFIL.json) | ||||
| NFPM_ADDRESS=$(jq -r '.address' ./deployments/docker/NonfungiblePositionManager.json) | ||||
| NFPM_BLOCK=$(jq -r '.receipt.blockNumber' ./deployments/docker/NonfungiblePositionManager.json) | ||||
| cd v3 | ||||
| 
 | ||||
| # Read the JavaScript file content | ||||
| file_content=$(</app/config/lotus-fixturenet.js.template) | ||||
| 
 | ||||
| # 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 | ||||
| 
 | ||||
| pnpm exec graph create --node http://graph-node:8020/ sushiswap/v3-filecoin | ||||
| pnpm exec graph deploy --node http://graph-node:8020/ --ipfs http://ipfs:5001 --version-label 0.1.0 sushiswap/v3-filecoin | ||||
| 
 | ||||
| echo "Done" | ||||
|  | ||||
| @ -32,3 +32,6 @@ lasso | ||||
| reth | ||||
| watcher-sushiswap | ||||
| contract-sushiswap | ||||
| graph-node | ||||
| sushiswap-subgraph-v3 | ||||
| fixturenet-sushiswap-subgraph-v3 | ||||
|  | ||||
| @ -9,4 +9,4 @@ containers: | ||||
|   - cerc/graph-node | ||||
| pods: | ||||
|   - fixturenet-lotus | ||||
|   - fixturenet-graph-node | ||||
|   - graph-node | ||||
|  | ||||
							
								
								
									
										179
									
								
								app/data/stacks/fixturenet-sushiswap-subgraph/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										179
									
								
								app/data/stacks/fixturenet-sushiswap-subgraph/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,179 @@ | ||||
| # Fixturenet SushiSwap Subgraph | ||||
| 
 | ||||
| ## Setup | ||||
| 
 | ||||
| Clone required repositories: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so --stack fixturenet-sushiswap-subgraph setup-repositories --pull | ||||
| ``` | ||||
| 
 | ||||
| Checkout to a non-default branch in the cloned repos if required: | ||||
| 
 | ||||
| ```bash | ||||
| # Default repo base dir | ||||
| cd ~/cerc | ||||
| 
 | ||||
| # Example | ||||
| cd graph-node | ||||
| git checkout <your-branch> && git pull | ||||
| 
 | ||||
| # Remove the corresponding docker image if it already exists | ||||
| docker image rm cerc/graph-node:local | ||||
| # Remove any dangling images | ||||
| docker image prune | ||||
| ``` | ||||
| 
 | ||||
| Build the container images: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so --stack fixturenet-sushiswap-subgraph build-containers | ||||
| ``` | ||||
| 
 | ||||
| ## Deploy | ||||
| 
 | ||||
| 
 | ||||
| Create an env file with the following contents to be used in the next step: | ||||
| 
 | ||||
| ```bash | ||||
| # Network and ETH RPC endpoint to run graph-node against | ||||
| NETWORK=lotus-fixturenet | ||||
| ETH_RPC_ENDPOINT=http://lotus-node-1:1234/rpc/v1 | ||||
| ``` | ||||
| 
 | ||||
| Uncomment the dependency on `lotus-node-1` in the [graph-node compose file](../../compose/docker-compose-graph-node.yml) | ||||
| 
 | ||||
| Deploy the stack: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so --stack fixturenet-sushiswap-subgraph deploy --cluster sushigraph --env-file <PATH_TO_ENV_FILE> up | ||||
| 
 | ||||
| # Note: Remove any existing volumes for the cluster for a fresh start | ||||
| ``` | ||||
| 
 | ||||
| After all services have started: | ||||
| 
 | ||||
| * Follow `graph-node` logs: | ||||
| 
 | ||||
|   ```bash | ||||
|   laconic-so --stack fixturenet-sushiswap-subgraph deploy --cluster sushigraph logs -f graph-node | ||||
|   ``` | ||||
| 
 | ||||
| * Check that the subgraphs have been deployed: | ||||
| 
 | ||||
|   ```bash | ||||
|   laconic-so --stack fixturenet-sushiswap-subgraph deploy --cluster sushigraph logs -f sushiswap-subgraph-v3 | ||||
| 
 | ||||
|   # Expected output: | ||||
|   # . | ||||
|   # . | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | - Deploying to Graph node http://graph-node:8020/ | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Deployed to http://graph-node:8000/subgraphs/name/sushiswap/v3-lotus/graphql | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Subgraph endpoints: | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Queries (HTTP):     http://graph-node:8000/subgraphs/name/sushiswap/v3-lotus | ||||
|   # . | ||||
|   # . | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | - Deploying to Graph node http://graph-node:8020/ | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Deployed to http://graph-node:8000/subgraphs/name/sushiswap/blocks/graphql | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Subgraph endpoints: | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Queries (HTTP):     http://graph-node:8000/subgraphs/name/sushiswap/blocks | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Done | ||||
|   ``` | ||||
| 
 | ||||
| After `graph-node` has fetched the latest blocks from upstream, use the subgraph (GQL) endpoints for querying: | ||||
| 
 | ||||
| ```bash | ||||
| # Find out the mapped host port for the subgraph endpoint | ||||
| laconic-so --stack fixturenet-sushiswap-subgraph deploy --cluster sushigraph port graph-node 8000 | ||||
| # 0.0.0.0:HOST_PORT | ||||
| 
 | ||||
| # Blocks subgraph endpoint: | ||||
| http://127.0.0.1:<HOST_PORT>/subgraphs/name/sushiswap/blocks/graphql | ||||
| 
 | ||||
| # v3 subgraph endpoint: | ||||
| http://127.0.0.1:<HOST_PORT>/subgraphs/name/sushiswap/v3-lotus/graphql | ||||
| ``` | ||||
| 
 | ||||
| ## Run | ||||
| 
 | ||||
| * Deploy an ERC20 token: | ||||
| 
 | ||||
|   ```bash | ||||
|   docker exec -it sushigraph-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 | ||||
| 
 | ||||
|   # Deploy two tokens and set the addresses to variables TOKEN1_ADDRESS and TOKEN2_ADDRESS | ||||
|   export TOKEN1_ADDRESS=<TOKEN1_ADDRESS> | ||||
|   export TOKEN2_ADDRESS=<TOKEN2_ADDRESS> | ||||
|   ``` | ||||
| 
 | ||||
| * Get contract address of factory deployed: | ||||
| 
 | ||||
|   ```bash | ||||
|   docker exec -it sushigraph-sushiswap-v3-core-1 jq -r '.address' /app/deployments/docker/UniswapV3Factory.json | ||||
| 
 | ||||
|   # Set the address to variable FACTORY_ADDRESS | ||||
|   export FACTORY_ADDRESS=<FACTORY_ADDRESS> | ||||
|   ``` | ||||
| 
 | ||||
| * 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 variable POOL_ADDRESS | ||||
|   export POOL_ADDRESS=<POOL_ADDRESS> | ||||
|   ``` | ||||
| 
 | ||||
| * Initialize the 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 | ||||
|   ``` | ||||
| 
 | ||||
| ## Clean up | ||||
| 
 | ||||
| Stop all the services running in background run: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so --stack fixturenet-sushiswap-subgraph deploy --cluster sushigraph down | ||||
| ``` | ||||
| 
 | ||||
| Clear volumes created by this stack: | ||||
| 
 | ||||
| ```bash | ||||
| # List all relevant volumes | ||||
| docker volume ls -q --filter "name=sushigraph" | ||||
| 
 | ||||
| # Remove all the listed volumes | ||||
| docker volume rm $(docker volume ls -q --filter "name=sushigraph") | ||||
| 
 | ||||
| # WARNING: To avoid refetching the Lotus proof params on the next run, | ||||
| # avoid removing the corresponding volumes | ||||
| 
 | ||||
| # To remove volumes that do not contain Lotus params | ||||
| docker volume rm $(docker volume ls -q --filter "name=sushigraph" | grep -v "params$") | ||||
| ``` | ||||
							
								
								
									
										28
									
								
								app/data/stacks/fixturenet-sushiswap-subgraph/stack.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								app/data/stacks/fixturenet-sushiswap-subgraph/stack.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| version: "1.0" | ||||
| name: fixturenet-sushiswap-subgraph | ||||
| 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 | ||||
|   # sushiswap subgraph repo | ||||
|   - github.com/sushiswap/subgraphs | ||||
| containers: | ||||
|   # fixturenet-lotus image | ||||
|   - cerc/lotus | ||||
|   # graph-node image | ||||
|   - cerc/graph-node | ||||
|   # sushiswap contract deployment images | ||||
|   - cerc/sushiswap-v3-core | ||||
|   - cerc/sushiswap-v3-periphery | ||||
|   # sushiswap subgraphs image | ||||
|   - cerc/sushiswap-subgraphs | ||||
| pods: | ||||
|   - fixturenet-lotus | ||||
|   - graph-node | ||||
|   - contract-sushiswap | ||||
|   - fixturenet-sushiswap-subgraph-v3 | ||||
| @ -1,11 +1,27 @@ | ||||
| # SushiSwap Graph | ||||
| # SushiSwap Subgraph | ||||
| 
 | ||||
| ## Setup | ||||
| 
 | ||||
| Clone required repositories: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so --stack sushiswap-subgraph setup-repositories | ||||
| laconic-so --stack sushiswap-subgraph setup-repositories --pull | ||||
| ``` | ||||
| 
 | ||||
| Checkout to a non-default branch in the cloned repos if required: | ||||
| 
 | ||||
| ```bash | ||||
| # Default repo base dir | ||||
| cd ~/cerc | ||||
| 
 | ||||
| # Example | ||||
| cd graph-node | ||||
| git checkout <your-branch> && git pull | ||||
| 
 | ||||
| # Remove the corresponding docker image if it already exists | ||||
| docker image rm cerc/graph-node:local | ||||
| # Remove any dangling images | ||||
| docker image prune | ||||
| ``` | ||||
| 
 | ||||
| Build the container images: | ||||
| @ -14,76 +30,87 @@ Build the container images: | ||||
| laconic-so --stack sushiswap-subgraph build-containers | ||||
| ``` | ||||
| 
 | ||||
| ## Deploy | ||||
| ## Create a deployment | ||||
| 
 | ||||
| Initialize deployment and create "spec" file: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so --stack sushiswap-subgraph deploy init --output sushiswap-subgraph-spec.yml | ||||
| ``` | ||||
| 
 | ||||
| We need to assign a fixed port `8000` for graph-node subgraph GQL endpoint. The values can be | ||||
| customized by editing the "spec" file generated by `laconic-so deploy init`. | ||||
| ``` | ||||
| $ cat sushiswap-subgraph-spec.yml | ||||
| stack: sushiswap-subgraph | ||||
| ports: | ||||
|   graph-node: | ||||
|    - '8000:8000' | ||||
|    - '8001' | ||||
|    - '8020' | ||||
|    - '8030' | ||||
| ... | ||||
| ``` | ||||
| 
 | ||||
| Create deployment: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so deploy create --spec-file sushiswap-subgraph-spec.yml --deployment-dir sushiswap-subgraph-deployment | ||||
| ``` | ||||
| 
 | ||||
| ## Start the stack | ||||
| 
 | ||||
| Deploy the stack: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so --stack sushiswap-subgraph deploy --cluster sushigraph up | ||||
| laconic-so deployment --dir sushiswap-subgraph-deployment start | ||||
| 
 | ||||
| # Note: Remove any existing volumes for the cluster for a fresh start | ||||
| ``` | ||||
| 
 | ||||
| After all services have started, wait and check that the subgraph has been deployed to graph-node | ||||
| After all services have started: | ||||
| 
 | ||||
| * Follow `graph-node` logs: | ||||
| 
 | ||||
|   ```bash | ||||
|   laconic-so deployment --dir sushiswap-subgraph-deployment logs -f graph-node | ||||
|   ``` | ||||
| 
 | ||||
| * Check that the subgraphs have been deployed: | ||||
| 
 | ||||
|   ```bash | ||||
|   laconic-so deployment --dir sushiswap-subgraph-deployment logs -f sushiswap-subgraph-v3 | ||||
| 
 | ||||
|   # Expected output: | ||||
|   # . | ||||
|   # . | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | - Deploying to Graph node http://graph-node:8020/ | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Deployed to http://graph-node:8000/subgraphs/name/sushiswap/blocks/graphql | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Subgraph endpoints: | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Queries (HTTP):     http://graph-node:8000/subgraphs/name/sushiswap/blocks | ||||
|   # . | ||||
|   # . | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | - Deploying to Graph node http://graph-node:8020/ | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Deployed to http://graph-node:8000/subgraphs/name/sushiswap/v3-filecoin/graphql | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Subgraph endpoints: | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Queries (HTTP):     http://graph-node:8000/subgraphs/name/sushiswap/v3-filecoin | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | | ||||
|   # sushigraph-sushiswap-subgraph-v3-1  | Done | ||||
|   ``` | ||||
| 
 | ||||
| After `graph-node` has fetched the latest blocks from upstream, use the subgraph (GQL) endpoints for querying: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so --stack sushiswap-subgraph deploy --cluster sushigraph logs -f sushiswap-subgraph-v3 | ||||
| # Blocks subgraph endpoint: | ||||
| http://127.0.0.1:8000/subgraphs/name/sushiswap/blocks/graphql | ||||
| 
 | ||||
| # Expected end output | ||||
| # ... | ||||
| # sushigraph-sushiswap-subgraph-v3-1  | - Deploying to Graph node http://graph-node:8020/ | ||||
| # sushigraph-sushiswap-subgraph-v3-1  | Deployed to http://graph-node:8000/subgraphs/name/sushiswap/v3-lotus/graphql | ||||
| # sushigraph-sushiswap-subgraph-v3-1  | | ||||
| # sushigraph-sushiswap-subgraph-v3-1  | Subgraph endpoints: | ||||
| # sushigraph-sushiswap-subgraph-v3-1  | Queries (HTTP):     http://graph-node:8000/subgraphs/name/sushiswap/v3-lotus | ||||
| # sushigraph-sushiswap-subgraph-v3-1  | | ||||
| # 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 | ||||
| # v3 subgraph endpoint: | ||||
| http://127.0.0.1:8000/subgraphs/name/sushiswap/v3-filecoin/graphql | ||||
| ``` | ||||
| 
 | ||||
| ## Clean up | ||||
| @ -91,21 +118,11 @@ docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:burn:docker --pool | ||||
| Stop all the services running in background run: | ||||
| 
 | ||||
| ```bash | ||||
| laconic-so --stack sushiswap-subgraph deploy --cluster sushigraph down | ||||
| laconic-so deployment --dir sushiswap-subgraph-deployment stop | ||||
| ``` | ||||
| 
 | ||||
| Clear volumes created by this stack: | ||||
| 
 | ||||
| ```bash | ||||
| # List all relevant volumes | ||||
| docker volume ls -q --filter "name=sushigraph" | ||||
| 
 | ||||
| # Remove all the listed volumes | ||||
| docker volume rm $(docker volume ls -q --filter "name=sushigraph") | ||||
| 
 | ||||
| # WARNING: After removing volumes with Lotus params | ||||
| # They will be downloaded again on restart | ||||
| 
 | ||||
| # To remove volumes that do not contain Lotus params | ||||
| docker volume rm $(docker volume ls -q --filter "name=sushigraph" | grep -v "params$") | ||||
| laconic-so deployment --dir sushiswap-subgraph-deployment stop --delete-volumes | ||||
| ``` | ||||
|  | ||||
| @ -1,28 +1,16 @@ | ||||
| version: "1.0" | ||||
| name: sushiswap-subgraph | ||||
| description: "An end-to-end SushiSwap Subgraph stack" | ||||
| description: "SushiSwap Subgraph stack" | ||||
| repos: | ||||
|   ## fixturenet-lotus repo | ||||
|   - github.com/filecoin-project/lotus | ||||
|   ## graph-node repo | ||||
|   # 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 | ||||
|   # sushiswap subgraph repo | ||||
|   - github.com/sushiswap/subgraphs | ||||
| containers: | ||||
|   ## fixturenet-lotus image | ||||
|   - cerc/lotus | ||||
|   ## fixturenet-graph-node image | ||||
|   # graph-node image | ||||
|   - cerc/graph-node | ||||
|   ## sushiswap contract deployment images | ||||
|   - cerc/sushiswap-v3-core | ||||
|   - cerc/sushiswap-v3-periphery | ||||
|   ## sushiswap subgraphs image | ||||
|   # sushiswap subgraphs image | ||||
|   - cerc/sushiswap-subgraphs | ||||
| pods: | ||||
|   - fixturenet-lotus | ||||
|   - fixturenet-graph-node | ||||
|   - contract-sushiswap | ||||
|   - graph-node | ||||
|   - sushiswap-subgraph-v3 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user