Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beanstalk 3 Subgraphs (BIP-50) #1084

Merged
merged 139 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
2edf9f3
Add cache builder js scripts for peg cross
soilking Sep 5, 2024
3c9361a
add package script for build-cache
soilking Sep 5, 2024
03381ca
updated readme with cache instructions
soilking Sep 5, 2024
138b266
bean entity init handler with sample input
soilking Sep 5, 2024
5bcfb35
bean subgraph l2 generator script
soilking Sep 5, 2024
8bb7f02
major refactor and file restructure
soilking Sep 6, 2024
8143641
chop converts and l2sr
soilking Sep 6, 2024
e8df1f9
entity bytes refactor and add protocol to version entity
soilking Sep 6, 2024
e9420ad
update bean manifest
soilking Sep 6, 2024
5893bb6
aggregate 3crv logic
soilking Sep 6, 2024
1df89b2
refactor constants usage
soilking Sep 6, 2024
83cc7ad
more constants refactor
soilking Sep 7, 2024
d4c791d
metapooloracle as legacy handler
soilking Sep 7, 2024
2464293
refactor constants
soilking Sep 7, 2024
7468335
add missing abis
soilking Sep 9, 2024
07fd6f7
refactor bean constants to core
soilking Sep 9, 2024
1ed4c38
add v function to all subgraphs
soilking Sep 9, 2024
c98b4b2
add shared constants to beanstalk subgraph
soilking Sep 9, 2024
40e21d7
remove unnecessary fields
soilking Sep 9, 2024
a47fa0b
string -> bytes for address refactor
soilking Sep 9, 2024
02ed6e3
misc refactor fixes
soilking Sep 9, 2024
46e1f40
finish constants refactor
soilking Sep 9, 2024
f69bf89
increment version to 3.0.0
soilking Sep 10, 2024
c9028c3
change string to bytes
soilking Sep 11, 2024
5380b78
extract stalk decimal constant
soilking Sep 11, 2024
3fd0222
carry over export for beanstalk subgraph
soilking Sep 11, 2024
60abb48
separate init and pre-unpause b3 init
soilking Sep 11, 2024
c62460a
clear deltas on pre-unpause
soilking Sep 11, 2024
24533c6
marketplace, silo legacy events
soilking Sep 12, 2024
32b75c0
reward event replacement
soilking Sep 12, 2024
4762926
legacy updategaugesettings
soilking Sep 12, 2024
325d262
fieldid to field events
soilking Sep 12, 2024
cb49737
Update ethereum manifests
soilking Sep 12, 2024
0e61694
update arbitrum manifest
soilking Sep 12, 2024
d8dabdd
update stalk decimal constants
soilking Sep 12, 2024
6b8f1d2
Update types in tests
soilking Sep 12, 2024
bf99584
latest events to use reseed abi
soilking Sep 12, 2024
2573dbd
set manifest abi to reseed
soilking Sep 12, 2024
2010d2e
move legacy gauge event handlers
soilking Sep 12, 2024
03db4f2
update farm event
soilking Sep 12, 2024
25a55fc
legacy season
soilking Sep 12, 2024
3b4707e
update type
soilking Sep 12, 2024
44bb42a
Add l2 constants
soilking Sep 12, 2024
ea2a306
arbitrum runtime constants
soilking Sep 12, 2024
9a6af5f
init arb version
soilking Sep 12, 2024
0a343c8
set fictitious deployment block
soilking Sep 12, 2024
d0efc38
fix replant milestone
soilking Sep 12, 2024
bb26fdb
basin arbitrum yaml
soilking Sep 13, 2024
01274b3
refactor basin subgraph for arb
soilking Sep 13, 2024
09e678b
refactor bean subgraph event abis
soilking Sep 13, 2024
fde954e
configure new pools
soilking Sep 13, 2024
a0d9788
clean up manifests
soilking Sep 13, 2024
e628689
Merge branch 'master' into b3-subgraph
soilking Sep 13, 2024
beea273
fix comparisons
soilking Sep 13, 2024
63dada4
add calculations curve abi
soilking Sep 13, 2024
7739532
fix variable shadowing
soilking Sep 13, 2024
4fb8736
migration event handlers
soilking Sep 14, 2024
773c351
fix plot index issue
soilking Sep 14, 2024
a7208b7
add abi
soilking Sep 14, 2024
bfee5e0
use correct handler name
soilking Sep 15, 2024
8249090
update endBlock for pre exploit
soilking Sep 15, 2024
3c9859e
update manifest
soilking Sep 16, 2024
99736a7
migration tests
soilking Sep 16, 2024
8e2855a
fix market tests
soilking Sep 16, 2024
b795509
refactor isgauge check on whitelisted tokens
soilking Sep 16, 2024
c58ea1c
handleUpdateWhitelistStatus
soilking Sep 16, 2024
80b8c2f
manifest for arb migration
soilking Sep 16, 2024
f4faf0f
fert token info cached
soilking Sep 16, 2024
2914bc0
Merge branch 'master' into b3-subgraph
soilking Sep 16, 2024
d33a6e3
fix bean manifest
soilking Sep 17, 2024
fbb86a7
Set basin deployment block
soilking Sep 18, 2024
0e2cd73
add init datasource to manifests
soilking Sep 18, 2024
dced90e
fix season beans init
soilking Sep 18, 2024
0e3115d
add RESEED_MIGRATED to plot source enum
soilking Sep 19, 2024
fe1b794
volatile price peg check every 10 seconds
soilking Sep 19, 2024
a3fc8a1
fix number of sows
soilking Sep 19, 2024
4b30336
fix harvestable pods count
soilking Sep 19, 2024
5a870e7
Update arb fert address
soilking Sep 19, 2024
8c3e498
set initial temperature
soilking Sep 19, 2024
10f590f
MigratedAccountStatus
soilking Sep 19, 2024
66ec3ae
fix ethereum manifest for silo
soilking Sep 19, 2024
a95aa2c
fix overcounting deposited beans
soilking Sep 19, 2024
834bfed
Update test
soilking Sep 19, 2024
dfa4ecd
set reseed pause block constants
soilking Sep 20, 2024
664d054
update b3 cached values
soilking Sep 23, 2024
29a3d57
update fert/bp address
soilking Sep 23, 2024
ed093f7
remove silo seeds
soilking Sep 24, 2024
fd03aa6
fix overall silo withdraw
soilking Sep 24, 2024
c023cb0
Fix deposited amount mismatch
soilking Sep 24, 2024
0477238
separate datasource
soilking Sep 24, 2024
e0b56ab
update MigratedAccountStatus signature
soilking Sep 25, 2024
11c156b
rename datasource
soilking Sep 25, 2024
e55e133
crosscheck after reseed complete
soilking Sep 25, 2024
480b594
restructur basin subgraph files
soilking Sep 25, 2024
80aaf70
Updated liquidity calculation
soilking Sep 25, 2024
50abeae
refactor ethereum.block
soilking Sep 25, 2024
dfd72d3
mock well function
soilking Sep 25, 2024
6cfd76a
fix test
soilking Sep 25, 2024
0b94f27
rework liquidity tests
soilking Sep 25, 2024
5d920d0
liquidity volume test
soilking Sep 26, 2024
57f719a
save token prices on each interaction
soilking Sep 26, 2024
234d46c
fix compilation
soilking Sep 26, 2024
18cf3cd
Fix inconsistent rate order
soilking Sep 26, 2024
68a845a
fix wellfunction duplication
soilking Sep 27, 2024
6954b3f
separate plot migration for contracts
soilking Sep 27, 2024
359c9cf
Update well constants
soilking Sep 30, 2024
00226a4
update bip50 abi
soilking Sep 30, 2024
0d69693
handle contract pod migration
soilking Sep 30, 2024
00dd88c
adjust for legacy withdrawal bug
soilking Oct 1, 2024
f7447a8
fix field totals bug
soilking Oct 1, 2024
bc93c72
comment
soilking Oct 1, 2024
9acad17
set placeholder beanstalk block for basin
soilking Oct 3, 2024
d01479e
set basin to index prior to arb well deployment
soilking Oct 3, 2024
1fa2fce
normalize snapshot timestamps
soilking Oct 8, 2024
b3f105b
reseed pause and initial r1-9
soilking Oct 8, 2024
ef80b27
update manifest for hotfix
soilking Oct 9, 2024
261eac3
handle proxy wells
soilking Oct 9, 2024
b0ecce5
set correct reseed8 complete block number
soilking Oct 9, 2024
97390d7
set unpause block
soilking Oct 10, 2024
3f02db8
misc fixes
soilking Oct 10, 2024
1f18059
add beanToMaxLpGpPerBdvRatio as carried over value
soilking Oct 10, 2024
8949328
add sunrise handler to manifest
soilking Oct 10, 2024
ded5479
Updated remove liquidity volume logic
soilking Oct 10, 2024
c06e401
fixes to bean/basin
soilking Oct 10, 2024
1dccce2
fix comparison
soilking Oct 10, 2024
b816555
workaround for unemitted whitelisttoken events
soilking Oct 10, 2024
5bb7d7c
add hardcoded initial whitelist
soilking Oct 10, 2024
6880600
identify whitelisted wells
soilking Oct 10, 2024
172838f
avoid apy calculation on tokens with no deposits
soilking Oct 10, 2024
616ae4d
Merge branch 'master' into b3-subgraph
soilking Oct 11, 2024
2d48d0c
revert submodule change
soilking Oct 11, 2024
8067d3a
track unmigrated asset amounts
soilking Oct 11, 2024
201a105
signatures in manifest
soilking Oct 11, 2024
8bbf37f
pod rate includes unmigrated l1 pods
soilking Oct 11, 2024
2194fc5
carry over unmigrated amount each season
soilking Oct 11, 2024
8ff29df
fix assignment
soilking Oct 11, 2024
8ee17d1
fix basin test mock
soilking Oct 11, 2024
cb57a6c
Update subgraph readmes
soilking Oct 11, 2024
76b4d02
Merge branch 'master' into b3-subgraph
soilking Oct 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions projects/subgraph-basin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Up @@ -6,7 +6,7 @@ dataSources:
# INITIALIZATION
###
- kind: ethereum/contract
name: Version
name: InitVersion
network: mainnet
source:
address: "0xBA51AAAA95aeEFc1292515b36D86C51dC7877773"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
Loading
Loading