Skip to content

Commit

Permalink
Beanstalk 3 Subgraphs (BIP-50) (#1084)
Browse files Browse the repository at this point in the history
soilking authored Oct 12, 2024
2 parents da9e639 + 76b4d02 commit c9f4745
Showing 190 changed files with 20,684 additions and 4,679 deletions.
18 changes: 10 additions & 8 deletions projects/subgraph-basin/README.md
Original file line number Diff line number Diff line change
@@ -9,19 +9,21 @@

### Subgraphs

All currently used subgraphs live on a centralized host controlled by beanstalk farms.

- [Testing Subgraph](https://graph.node.bean.money/subgraphs/name/basin-testing)
- Used during local development for debugging and rapid iteration.
- [Dev Subgraph](https://graph.node.bean.money/subgraphs/name/basin-dev)
- Used for testing fixes or improvements made in the testing subgraph.
- [Canonical Subgraph](https://graph.node.bean.money/subgraphs/name/basin)
- [Testing Subgraph](https://graph.bean.money/basin-testing)
- The bleeding edge. Used for debugging and rapid iteration.
- [Dev Subgraph](https://graph.bean.money/basin-dev)
- Used for testing fixes or improvements made in the testing subgraph before going live.
- [Canonical Subgraph](https://graph.bean.money/basin)
- Stable deployment and current source of truth for UI and other production processes.

All subgraphs are hosted on a mix of Alchemy and Graph Network, with responses served from a proxy api managed by Beanstalk Farms. Read more about the advantages of the proxy here: https://github.com/BeanstalkFarms/Subgraph-Proxy.

Looking to analyze data from Basin on Ethereum? Append "\_eth" to each of the above links.

### Testing

To test with Docker, the first time you will need to run `yarn run graph test -d`. This will build the `matchstick` Docker image. Then, you can use the `yarn testd` script to run all tests. Alternatively, use `yarn testd-named <TestName1> ...` to run specific tests. I have found running in Docker to be preferred since otherwise there can be issues with console output and some test cases fail silently.

### Deploying

When using graph cli commands, you will often need to specify which manifest file should be used. This is necessary to support multiple chains in the same codebase. The commands which need it will be evident - as they will fail when unable to find a `subgraph.yaml` file. In those commands, include `./manifest/${chain}.yaml` as the final argument to the command. See scripts inside `package.json` for examples.
When using graph cli commands, you will often need to specify which manifest file should be used. This is necessary to support multiple chains in the same codebase. The commands which need it will be evident - as they will fail when unable to find a `subgraph.yaml` file. In those commands, include `./manifest/${chain}.yaml` as the final argument to the command. See scripts inside `package.json` for examples.
113 changes: 113 additions & 0 deletions projects/subgraph-basin/manifests/arbitrum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
specVersion: 0.0.9
schema:
file: ../schema.graphql
dataSources:
###
# INITIALIZATION
###
- kind: ethereum/contract
name: InitVersion
network: arbitrum-one
source:
address: "0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521"
abi: Aquifer
# NOTE ON BLOCK NUMBERS: in practice no wells were deployed for months following Aquifer's
# initial deployment. Therefore there is no need to start indexing from the initial block
startBlock: 261000000
endBlock: 261000000
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Version
abis:
- name: Aquifer
file: ../../subgraph-core/abis/Aquifer.json
blockHandlers:
- handler: handleInitVersion
filter:
kind: once
file: ../src/utils/constants/Version.ts
- kind: ethereum/contract
name: Aquifer
network: arbitrum-one
source:
address: "0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521"
abi: Aquifer
startBlock: 261000000
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Aquifer
abis:
- name: Aquifer
file: ../../subgraph-core/abis/Aquifer.json
- name: ERC20
file: ../../subgraph-core/abis/ERC20.json
eventHandlers:
- event: BoreWell(address,address,address[],(address,bytes),(address,bytes)[],bytes)
handler: handleBoreWell
file: ../src/handlers/AquiferTemplateHandler.ts
- kind: ethereum/contract
name: Beanstalk
network: arbitrum-one
source:
address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70"
abi: Beanstalk
startBlock: 261772156 # Reseed
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Beanstalk
abis:
- name: Beanstalk
file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json
eventHandlers:
- event: Sunrise(indexed uint256)
handler: handleSunrise
file: ../src/handlers/BeanstalkHandler.ts
templates:
- kind: ethereum/contract
name: Well
network: arbitrum-one
source:
abi: Well
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Well
abis:
- name: Well
file: ../../subgraph-core/abis/Well.json
- name: WellFunction
file: ../../subgraph-core/abis/WellFunction.json
- name: BeanstalkPrice
file: ../../subgraph-core/abis/BeanstalkPrice.json
- name: ERC20
file: ../../subgraph-core/abis/ERC20.json
eventHandlers:
- event: AddLiquidity(uint256[],uint256,address)
handler: handleAddLiquidity
- event: RemoveLiquidity(uint256,uint256[],address)
handler: handleRemoveLiquidity
- event: RemoveLiquidityOneToken(uint256,address,uint256,address)
handler: handleRemoveLiquidityOneToken
- event: Swap(address,address,uint256,uint256,address)
handler: handleSwap
- event: Shift(uint256[],address,uint256,address)
handler: handleShift
- event: Sync(uint256[],uint256,address)
handler: handleSync
file: ../src/handlers/WellHandler.ts
# features:
# - grafting
# graft:
# base: QmWHi6hu2wXnyxBHHmQHwCQLoq5KkoTX2qLm8MdyVXTyTu
# block: 20216425
8 changes: 5 additions & 3 deletions projects/subgraph-basin/manifests/codegen-abis.yaml
Original file line number Diff line number Diff line change
@@ -26,9 +26,11 @@ dataSources:
- name: ERC20
file: ../../subgraph-core/abis/ERC20.json
- name: Beanstalk
file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json
file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json
- name: Well
file: ../../subgraph-core/abis/Well.json
- name: WellFunction
file: ../../subgraph-core/abis/WellFunction.json
- name: CurvePrice
file: ../../subgraph-core/abis/CurvePrice.json
- name: BeanstalkPrice
@@ -37,7 +39,7 @@ dataSources:
- handler: handleInitVersion
filter:
kind: once
file: ../src/utils/Init.ts
file: ../src/utils/constants/Version.ts
templates:
- kind: ethereum/contract
name: Well
@@ -57,4 +59,4 @@ templates:
- handler: handleInitVersion
filter:
kind: once
file: ../src/utils/Init.ts
file: ../src/utils/constants/Version.ts
14 changes: 8 additions & 6 deletions projects/subgraph-basin/manifests/ethereum.yaml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ dataSources:
# INITIALIZATION
###
- kind: ethereum/contract
name: Version
name: InitVersion
network: mainnet
source:
address: "0xBA51AAAA95aeEFc1292515b36D86C51dC7877773"
@@ -26,7 +26,7 @@ dataSources:
- handler: handleInitVersion
filter:
kind: once
file: ../src/utils/Init.ts
file: ../src/utils/constants/Version.ts
- kind: ethereum/contract
name: Aquifer
network: mainnet
@@ -48,7 +48,7 @@ dataSources:
eventHandlers:
- event: BoreWell(address,address,address[],(address,bytes),(address,bytes)[],bytes)
handler: handleBoreWell
file: ../src/templates/AquiferHandler.ts
file: ../src/handlers/AquiferTemplateHandler.ts
- kind: ethereum/contract
name: Beanstalk
network: mainnet
@@ -64,11 +64,11 @@ dataSources:
- Beanstalk
abis:
- name: Beanstalk
file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json
file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json
eventHandlers:
- event: Sunrise(indexed uint256)
handler: handleSunrise
file: ../src/BeanstalkHandler.ts
file: ../src/handlers/BeanstalkHandler.ts
templates:
- kind: ethereum/contract
name: Well
@@ -84,6 +84,8 @@ templates:
abis:
- name: Well
file: ../../subgraph-core/abis/Well.json
- name: WellFunction
file: ../../subgraph-core/abis/WellFunction.json
- name: CurvePrice
file: ../../subgraph-core/abis/CurvePrice.json
- name: BeanstalkPrice
@@ -103,7 +105,7 @@ templates:
handler: handleShift
- event: Sync(uint256[],uint256,address)
handler: handleSync
file: ../src/WellHandler.ts
file: ../src/handlers/WellHandler.ts
# features:
# - grafting
# graft:
Loading

0 comments on commit c9f4745

Please sign in to comment.