Skip to content

beefyfinance/cowcentrated-subgraph

Repository files navigation

Beefy CLM Subgraph

This Subgraph sources events from the Beefy CLM contracts in different networks.

Deployments

Goldsky.com

Latest endpoints

Historical endpoints

Contributing

Prerequisites

Setup the project

yarn install

Running a local instance of graph-node locally

yarn infra:strat

Deploying the subgraph locally

yarn remove-local # if you have already deployed the subgraph
yarn create-local # create the subgraph locally
yarn prepare:<network> # 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

yarn test # run all tests
yarn test:graph # run only matchstick-as graph tests
yarn test:lint # run prettier linter

HOWTOs

How to add a new network

  1. Add the network configuration config/.json.
    • network must match one of the networks in Goldsky's supported networks list.
    • clockTickBlocks is the number of blocks between each clock tick, aim for a clock tick every 5 minutes.
    • Price feed:
      • Use chainlink
        • "priceOracleType" : "chainlink"
        • Find the <native>/USD price feed contract address on chainlink's documentation. Verify that it's a ChainLink AggregatorV3Interface with the latestRoundData() method. Put the address in chainlinkNativePriceFeedAddress.
        • Get the decimals of the price feed using the decimals field of the contract. Put the decimals in chainlinkNativePriceFeedDecimals.
      • Use pyth
  2. Add dev RPCs in graph-node config docker/graph-node/config.toml.
  3. Add a new prepare:<network> script in package.json.
  4. Add the chain name in the Release script in .github/workflows/Release.yml.
  5. Release the first version of the subgraph for the new network using the ./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 in alphabetical order.

Release a new version of the subgraph

  1. On github, create a new release with the new version number.
  • The tag should be the version number, e.g. 1.0.0.
  • This will trigger the Release workflow to deploy the subgraph to all networks.
  1. Wait for the workflow to finish, then check the Goldsky dashboard, the new subgraph version should be indexing on all chains.
  2. Run some manual tests on the subgraph endpoints using the next version tag to verify that the new version is working as expected.
  3. If everything is working as expected, we need to move the goldsky tags to the new version. This process is manual as of now
  4. For each subgraph on Goldsky's UI
    • Go to the new version and create the "latest" tag, this will in fact move the "latest" tag to the new version.
    • Go back to the old version and delete the subgraph

How to update the schema

  1. Create or update the schema.graphql file.
  1. Run yarn codegen to generate the typescript types.
  1. Update subgraph.template.yaml with the new entity bindings and/or data sources if needed.
  1. Update or create the mappings in the mappings folder to handle the new entity.
  1. Write tests for the new mappings in the tests folder.

Deploy the subgraph

./bin/deploy.sh <network> goldsky
./bin/deploy.sh <network> 0xgraph

# or both
./bin/deploy.sh <network> goldsky 0xgraph

Dependecies on the underlying contracts

Beefy Classic contracts

- classicVaultFactory: ProxyCreated(address)
- classicVault: strategy()
- classicVault: want()
- classicVault: balance()
- classicVault: totalSupply()
- classicVault: Transfer(indexed address,indexed address,uint256)
- classicVault: Initialized(uint8)
- classicVault: UpgradeStrat(address)
- classicVault: Transfer(indexed address,indexed address,uint256)

- classicStrategyFactory: ProxyCreated(address)
- classicStrategy.decimals()
- classicStrategy.name()
- classicStrategy.symbol()
- classicStrategy.vault()
- classicStrategy: Initialized(uint8)
- classicStrategy: Paused(address)
- classicStrategy: Unpaused(address)
- classicStrategy: StratHarvest(indexed address,uint256,uint256)

- classicBoostFactory: ProxyCreated(address)
- classicBoost: Initialized(uint8)
- classicBoost: Staked(indexed address,uint256)
- classicBoost: Withdrawn(indexed address,uint256)
- classicBoost: RewardPaid(indexed address,uint256)

Beefy CLM contracts

- clmManagerFactory: ProxyCreated(address)
- clmManager.decimals()
- clmManager.name()
- clmManager.symbol()
- clmManager.balances()
- clmManager.totalSupply()
- clmManager.balanceOf()
- clmManager.strategy()
- clmManager.wants()
- clmManager: Initialized(uint8)
- clmManager: Transfer(indexed address,indexed address,uint256)

- clmStrategyFactory: GlobalPause(bool)
- clmStrategy.pool()
- clmStrategy.vault()
- clmStrategy.price()
- clmStrategy.range()
- clmStrategy.output() // optional
- clmStrategy.balanceOfPool()
- clmStrategy.lpToken1ToNativePrice()
- clmStrategy.lpToken0ToNativePrice()
- clmStrategy: Initialized(uint8)
- clmStrategy: Paused(address)
- clmStrategy: Unpaused(address)
- clmStrategy: Harvest(uint256,uint256)
- clmStrategy: HarvestRewards(uint256)
- clmStrategy: ClaimedFees(uint256,uint256,uint256,uint256)
- clmStrategy: ClaimedRewards(uint256)

- rewardPoolFactory: ProxyCreated(address)
- rewardPool.decimals()
- rewardPool.name()
- rewardPool.symbol()
- rewardPool.stakedToken()
- rewardPool.totalSupply()
- rewardPool: Initialized(uint8)
- rewardPool: Transfer(indexed address,indexed address,uint256)
- rewardPool: RewardPaid(indexed address,indexed address,uint256)
- rewardPool: AddReward(address)
- rewardPool: RemoveReward(address,address)

Other contracts

beefySwapper: getAmountOut(address,address,uint256)
beefyOracle: getFreshPrice(address)