This is the primary subgraph used by the Zup Protocol to calculate yields. It aggregates data from all protocols supported by Zup across different networks. For each network, it includes all Zup-supported DEXs in a single subgraph.
-
Node.js
- To know if Node.js is installed, run
node --version
you should see a response likevX.X.X
. - If Node.js is not installed, head over to How to install Node.js
- To know if Node.js is installed, run
-
Docker (optional)
- To know if Docker is installed, run
docker --version
you should see a response likeDocker version X.X.X
. - If Docker is not installed, head over to How to install Docker
- To know if Docker is installed, run
-
Yarn
- To know if Yarn is installed, run
yarn --version
you should see a response likeyarn x.x.x
. - If Yarn is not installed, head over to Yarn installation
- To know if Yarn is installed, run
- Clone the repository
- run
yarn install
To run all the tests, just open your terminal and type:
yarn test
To add a new network to the subgraph, you need to do a few things:
- Add a new subgraph manifest in subgraph-manifests for the intended network with the DEXs supported in that network.
- Add a new constant with the network name (following the Network CLI Name from the Graph) in current-network.ts for the new network.
- Add a new entry for each function defined in current-network.ts that needs to be overriden for the new network.
- Modify the functions in utils/position-manager-address.ts to return the position manager address of each DEX supported in the new network.
- Add new scripts in package.json for the new network (following the pattern
[script]:networkname
), to make it easier to deploy, generate code and build the subgraph.
To add a new DEX to the subgraph, you need to do a few things:
- Modify the manifest of the networks that should support the new DEX in subgraph-manifests:
- The Factory contract of the DEX must be included in the manifest, at the
dataSources
section, following the same pattern as the other DEXs. - In case that the new DEX events or code is a little different from the UniswapV3 original one, some additional things are required:
- You should add its ABI in the abis folder. For the Pool and the Factory.
- A new template for this DEX must be added in the subgraph manifest, with the correct events and handlers.
- You should create personalized handlers for this new DEX, to handle events emitted by this personalized template, following the pattern of the other ones at v3-pools/mappings/factory/dexs (WARNING: DON'T FORGET TO IMPORT THE EVENT FROM THE SAME DEX AS THE HANDLER, IMPORTING OTHER DEX EVENT CAN CAUSE BUGS).
-
Create a factory handler specific for the new DEX in v3-pools/mappings/factory/dexs, following the pattern of the other ones (WARNING: Be sure to import the correct event from the same DEX, importing other DEX event can cause bugs)
-
Create a new function in utils/position-manager-address.ts to return the address of the position manager for this new DEX for each network and attach it to its handler
-
Modify the root subgraph manifest subgraph.yaml to include the new DEX in the subgraph, so tests can be ran without any compilation error, this is simply copying and pasting the newly added config from the others manifests, but changing the network to
mainnet
and changing the path of the handlers and files -
Code tests for this nex DEX handlers if possible :)