From 1b65461f807f2fdd04f7e04680977327d90a4385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pr=C3=A9vost?= <998369+prevostc@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:45:29 +0100 Subject: [PATCH] Add sonic --- README.md | 37 ++++++++----------- bin/deploy.sh | 25 +++++++++---- bin/release.sh | 31 +++++++++------- config/sonic.json | 35 ++++++++++++++++++ docker-compose.yml | 69 ----------------------------------- docker/.gitignore | 1 - docker/graph-node/config.toml | 32 ---------------- package.json | 20 +--------- 8 files changed, 88 insertions(+), 162 deletions(-) create mode 100644 config/sonic.json delete mode 100644 docker-compose.yml delete mode 100644 docker/.gitignore delete mode 100644 docker/graph-node/config.toml diff --git a/README.md b/README.md index dff418c..956d90d 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,21 @@ This Subgraph sources events from the Beefy CLM contracts in different networks. ### Latest endpoints - [Arbitrum](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-arbitrum/latest/gn) +- [Avax](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-avax/latest/gn) - [Base](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-base/latest/gn) +- [Bsc](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-bsc/latest/gn) - [Linea](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-linea/latest/gn) +- [Lisk](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-lisk/latest/gn) - [Manta](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-manta/latest/gn) +- [Mantle](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-mantle/latest/gn) +- [Mode](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-mode/latest/gn) - [Moonbeam](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-moonbeam/latest/gn) - [Optimism](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-optimism/latest/gn) - [Polygon](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-polygon/latest/gn) -- [zkSync](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-zksync/latest/gn) -- [mantle](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-mantle/latest/gn) +- [Rootstock](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-rootstock/latest/gn) +- [sei](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-sei/latest/gn) +- [Sonic](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-sonic/latest/gn) +- [ZkSync](https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-clm-zksync/latest/gn) ### Historical endpoints @@ -29,8 +36,6 @@ This Subgraph sources events from the Beefy CLM contracts in different networks. - Git: [git-scm.com](https://git-scm.com) - Node.js: [nodejs.org](https://nodejs.org), see version in [.nvmrc](.nvmrc) - Yarn: [yarnpkg.com](https://yarnpkg.com) -- Docker: [docker.com](https://www.docker.com) -- Docker Compose: [docker.com](https://docs.docker.com/compose/install/) ## Setup the project @@ -38,21 +43,12 @@ This Subgraph sources events from the Beefy CLM contracts in different networks. yarn install ``` -## Running a local instance of graph-node locally +## Building the subgraph locally ```bash -yarn infra:start -``` - -## Deploying the subgraph locally - -```bash -yarn remove-local # if you have already deployed the subgraph -yarn create-local # create the subgraph locally -yarn prepare: # apply configuration for the network +yarn configure # apply configuration for the network yarn codegen # generate the typescript types yarn build # build the subgraph code -yarn deploy-local # deploy the subgraph locally ``` ## Run tests @@ -78,14 +74,13 @@ yarn test:lint # run prettier linter - `"priceOracleType" : "pyth"` - Find the pyth contract address [on pyth's documentation](https://docs.pyth.network/price-feeds/contract-addresses/evm). Put the address in `pythPriceFeedAddress`. - Grab the `Crypto./USD` price feed ID [on pyth's documentation](https://pyth.network/developers/price-feed-ids). Put the ID in `pythPriceFeedId`. -2. Add dev RPCs in graph-node config [docker/graph-node/config.toml](docker/graph-node/config.toml). -3. Add a new `prepare:` script in [package.json](package.json). -4. Add the chain name in the Release script in [.github/workflows/Release.yml](.github/workflows/Release.yml). -5. Release the first version of the subgraph for the new network using the [./bin/release.sh](./bin/release.sh) script. +2. Add the chain name in the Release script in [.github/workflows/Release.yml](.github/workflows/Release.yml). +3. Add the endpoint link to the [README](README.md) in alphabetical order. +4. Release the first version of the subgraph for the new network using the [./bin/release.sh](./bin/release.sh) script. - Must be logged in to goldsky with the provided cli. - Only used to deploy the first version, see below for updating a subgraph. -6. Tag the new version on Goldsky's UI as "latest" to create a stable endpoint. -7. Add the endpoint link to the [README](README.md) in alphabetical order. + +When ready: 4. Tag the new version on Goldsky's UI as "latest" to create a stable endpoint. ### Release a new version of the subgraph diff --git a/bin/deploy.sh b/bin/deploy.sh index 8734a24..0702ede 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -14,14 +14,17 @@ function exit_help { function prepare { CHAIN=$1 +} + +function publish_0xgraph { + CHAIN=$1 + SUBGRAPH=$2 + echo "preparing $CHAIN" - yarn prepare:$CHAIN + yarn configure $CHAIN yarn codegen yarn build -} -function publish_0xgraph { - SUBGRAPH=$1 echo "publishing $SUBGRAPH to 0xgraph" yarn run graph remove $SUBGRAPH --node https://api.0xgraph.xyz/deploy sleep 5 @@ -31,7 +34,14 @@ function publish_0xgraph { } function publish_goldsky { - SUBGRAPH=$1 + CHAIN=$1 + SUBGRAPH=$2 + + echo "preparing $CHAIN" + yarn configure $CHAIN + yarn codegen + yarn build + echo "publishing $SUBGRAPH to goldsky" goldsky subgraph delete $SUBGRAPH/0.0.1 sleep 10 @@ -43,10 +53,10 @@ function publish { PROVIDER=$2 case $PROVIDER in "0xgraph") - publish_0xgraph beefyfinance/clm-$CHAIN + publish_0xgraph $CHAIN beefyfinance/clm-$CHAIN ;; "goldsky") - publish_goldsky beefy-clm-$CHAIN-dev + publish_goldsky $CHAIN beefy-clm-$CHAIN-dev ;; esac } @@ -76,7 +86,6 @@ for provider in $providers; do done -prepare $chain for provider in $providers; do publish $chain $provider done diff --git a/bin/release.sh b/bin/release.sh index 491ddac..44a0b42 100755 --- a/bin/release.sh +++ b/bin/release.sh @@ -14,26 +14,32 @@ function exit_help { exit 1 } -function prepare { +function publish_0xgraph { CHAIN=$1 + SUBGRAPH=$2 + VERSION=$3 + DEPLOY_KEY=$4 + echo "preparing $CHAIN" - yarn prepare:$CHAIN + yarn configure $CHAIN yarn codegen yarn build -} -function publish_0xgraph { - SUBGRAPH=$1 - VERSION=$2 - DEPLOY_KEY=$3 echo "publishing $SUBGRAPH to 0xgraph" yarn run graph deploy $SUBGRAPH --node https://api.0xgraph.xyz/deploy --ipfs https://api.0xgraph.xyz/ipfs --version-label="v$VERSION" --deploy-key=$DEPLOY_KEY } function publish_goldsky { - SUBGRAPH=$1 - VERSION=$2 - DEPLOY_KEY=$3 + CHAIN=$1 + SUBGRAPH=$2 + VERSION=$3 + DEPLOY_KEY=$4 + + echo "preparing $CHAIN" + yarn configure $CHAIN + yarn codegen + yarn build + echo "publishing $SUBGRAPH to goldsky" goldsky subgraph deploy $SUBGRAPH/$VERSION --path . --token $DEPLOY_KEY sleep 5 # wait for the subgraph to propagate @@ -48,10 +54,10 @@ function publish { SUBGRAPH= case $PROVIDER in "0xgraph") - publish_0xgraph beefyfinance/clm-$CHAIN $VERSION $DEPLOY_KEY + publish_0xgraph $CHAIN beefyfinance/clm-$CHAIN $VERSION $DEPLOY_KEY ;; "goldsky") - publish_goldsky beefy-clm-$CHAIN $VERSION $DEPLOY_KEY + publish_goldsky $CHAIN beefy-clm-$CHAIN $VERSION $DEPLOY_KEY ;; esac } @@ -95,5 +101,4 @@ if [ -z "$deploy_key" ]; then exit_help fi -prepare $chain publish $version $chain $provider $deploy_key diff --git a/config/sonic.json b/config/sonic.json new file mode 100644 index 0000000..029ca31 --- /dev/null +++ b/config/sonic.json @@ -0,0 +1,35 @@ +{ + "network": "sonic", + + "multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11", + "shareTokenMintAddress": "0x0000000000000000000000000000000000000000", + "burnAddress": "0x000000000000000000000000000000000000dead", + + "clmManagerFactoryAddress": "0xD19ab62F83380908D65E344567378cF104cE46c2", + "clmManagerFactoryStartBlock": 491446, + "clmStrategyFactoryAddress": "0xC2cEE7cf27D2Eda09fEc1743f3953dA77Bf1DA61", + "clmStrategyFactoryStartBlock": 491464, + "rewardPoolFactoryAddress": "0x3C0b1765C379833b86A1704997019A7496Afdfae", + "rewardPoolFactoryStartBlock": 491452, + "beefyClassicVaultFactoryAddress": "0x8e0B63846ebEFf857EE35eF3BD3A2df9EF7D6456", + "beefyClassicVaultFactoryStartBlock": 490985, + "beefyClassicBoostFactoryAddress": "0x0000000000000000000000000000000000000000", + "beefyClassicBoostFactoryStartBlock": 490985, + "clockTickBlocks": 800, + + "wrappedNativeAddress": "0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38", + "wrappedNativeDecimals": 18, + + "priceOracleType": "pyth", + "chainlinkNativePriceFeedAddress": "0x0000000000000000000000000000000000000000", + "chainlinkNativePriceFeedDecimals": 8, + "pythPriceFeedAddress": "0x2880ab155794e7179c9ee2e38200202908c17b43", + "pythNativePriceId": "0xf490b178d0c85683b7a0f2388b40af2e6f7c90cbe0f96b31f315f08d0e5a2d6d", + "umbrellaRegistryAddress": "0x0000000000000000000000000000000000000000", + "umbrellaRegistryPriceFeedName": "WRBTC-rUSDT", + "umbrellaRegistryPriceFeedNameBytes32": "0xd2a0ad2667ba45a57ce6a98d6f51a4a4d256d704f578b3b90d7ee12e2f6af854", + "umbrellaRegistryPriceFeedDecimals": 8, + + "beefySwapperAddress": "0x9818dF1Bdce8D0E79B982e2C3a93ac821b3c17e0", + "beefyOracleAddress": "0xBC4a342B0c057501E081484A2d24e576E854F823" +} diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index e70d02b..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,69 +0,0 @@ -services: - postgres: - image: postgres:14 - ports: - - "5432:5432" - command: ["postgres", "-cshared_preload_libraries=pg_stat_statements", "-cmax_connections=200"] - environment: - POSTGRES_USER: graph-node - POSTGRES_PASSWORD: let-me-in - POSTGRES_DB: graph-node - POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C" - volumes: - - ./docker/data/postgres:/var/lib/postgresql/data - logging: - driver: "local" - options: - max-size: "5M" - max-file: "3" - healthcheck: - test: ["CMD-SHELL", "pg_isready -q -d graph-node -U graph-node"] - interval: 1s - timeout: 5s - retries: 10 - - ipfs: - image: ipfs/kubo:v0.14.0 - ports: - - "5001:5001" - volumes: - - ./docker/data/ipfs:/data/ipfs - logging: - driver: "local" - options: - max-size: "5M" - max-file: "3" - healthcheck: - test: ["CMD", "ipfs", "id"] - interval: 1s - timeout: 5s - retries: 5 - - graph-node: - image: graphprotocol/graph-node - # Note, this image is not supported by M1 machines, see here for a workaround: - # https://github.com/graphprotocol/graph-node/tree/master/docker#running-graph-node-on-an-macbook-m1 - ports: - - "8000:8000" - - "8001:8001" - - "8020:8020" - - "8030:8030" - - "8040:8040" - depends_on: - postgres: - condition: service_healthy - ipfs: - condition: service_healthy - extra_hosts: - - host.docker.internal:host-gateway - volumes: - - ./docker/graph-node:/etc/graph-node - logging: - driver: "local" - options: - max-size: "10M" - max-file: "3" - environment: - ipfs: "ipfs:5001" - GRAPH_LOG: debug - GRAPH_NODE_CONFIG: /etc/graph-node/config.toml diff --git a/docker/.gitignore b/docker/.gitignore deleted file mode 100644 index 6320cd2..0000000 --- a/docker/.gitignore +++ /dev/null @@ -1 +0,0 @@ -data \ No newline at end of file diff --git a/docker/graph-node/config.toml b/docker/graph-node/config.toml deleted file mode 100644 index 87b2557..0000000 --- a/docker/graph-node/config.toml +++ /dev/null @@ -1,32 +0,0 @@ -# A simple store configuration: we use one database for everything -# This is equivalent to the old way of configuring the store for tests -# by just setting the environment variable THEGRAPH_STORE_POSTGRES_DIESEL_URL - -[store] -[store.primary] -connection = "postgresql://graph-node:let-me-in@postgres:5432/graph-node" -pool_size = 10 - -[deployment] -[[deployment.rule]] -store = "primary" -indexers = ["default"] - -[chains] -ingestor = "default" - -[chains.matic] -shard = "primary" - -# archive node test: -# curl https://polygon.blockpi.network/v1/rpc/public -X POST -H "Content-Type: application/json" --data '{"method":"eth_getBalance","params":["0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", "0x55"],"id":1,"jsonrpc":"2.0"}' -provider = [ - { label = "ankr", url = "https://rpc.ankr.com/polygon", features = ["archive"] }, - { label = "finality", url = "https://polygon.api.onfinality.io/public", features = ["archive"] }, - { label = "tenderly", url = "https://gateway.tenderly.co/public/polygon", features = ["archive"] }, - { label = "meowrpc", url = "https://polygon.meowrpc.com", features = [] }, - { label = "dprc", url = "https://polygon.drpc.org", features = ["archive"] }, - { label = "pokt", url = "https://polygon-pokt.nodies.app", features = [] }, - { label = "polygon", url = "https://polygon-rpc.com", features = ["archive"] }, - { label = "blockpi", url = "https://polygon.blockpi.network/v1/rpc/public", features = [] } -] diff --git a/package.json b/package.json index 8ab7f78..10b7216 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "private": true, "scripts": { "prepare": "husky", - "postinstall": "yarn run --silent prepare:arbitrum && yarn run --silent codegen", + "postinstall": "yarn run --silent configure arbitrum && yarn run --silent codegen", "codegen": "rm -Rf generated && graph codegen", "build": "graph build", "format": "prettier . --write", @@ -15,23 +15,7 @@ "create-local": "graph create beefyfinance/beefy-cl --node http://127.0.0.1:8020", "deploy-local": "graph deploy beefyfinance/beefy-cl --node http://127.0.0.1:8020 --ipfs http://localhost:5001", "remove-local": "graph remove beefyfinance/beefy-cl --node http://127.0.0.1:8020", - "prepare:arbitrum-beta": "./bin/prepare.sh arbitrum-beta", - "prepare:arbitrum": "./bin/prepare.sh arbitrum", - "prepare:base": "./bin/prepare.sh base", - "prepare:bsc": "./bin/prepare.sh bsc", - "prepare:linea": "./bin/prepare.sh linea", - "prepare:manta": "./bin/prepare.sh manta", - "prepare:moonbeam": "./bin/prepare.sh moonbeam", - "prepare:optimism": "./bin/prepare.sh optimism", - "prepare:polygon": "./bin/prepare.sh polygon", - "prepare:zksync": "./bin/prepare.sh zksync", - "prepare:mantle": "./bin/prepare.sh mantle", - "prepare:sei": "./bin/prepare.sh sei", - "prepare:avax": "./bin/prepare.sh avax", - "prepare:rootstock": "./bin/prepare.sh rootstock", - "prepare:scroll": "./bin/prepare.sh scroll", - "prepare:mode": "./bin/prepare.sh mode", - "prepare:lisk": "./bin/prepare.sh lisk" + "configure": "./bin/prepare.sh " }, "main": "./bin/index.js", "bin": {