๐Read Me
All information here is source from the official DFX Finance GitHub.
Last updated
All information here is source from the official DFX Finance GitHub.
Last updated
Any USD base pair created by the DFX factory is tracked by this subgraph. The subgraph tracks DFX for daily and hourly historical data on TVLs and volumes.
Currently there are 6 USD based stablecoin pairs on Ethereum (Mainnet) and 5 on Polygon.
DFX Subgraph Source:
https://github.com/dfx-finance/subgraph
Singapore - USDC/XSGD
Europe - USDC/EURS
Canada - USDC/CADC
New Zealand - USDC/NZDS
Turkey - USDC/TRYB
Indonesia - USDC/XIDR
Go to https://thegraph.com/studio/
Connect your MetaMask wallet and sign (This will not cost you any ETH)
Create a subgraph called 'dfx-test'
Install The Graph's CLI on your terminal npm install -g @graphprotocol/graph-cli
Clone this repo git clone https://github.com/dfx-finance/subgraph.git
Install dependencies yarn install
Go into the directory cd subgraph
Generate the code from the schema yarn codegen
(This should be done every time the schema is changed)
Copy the Deploy Key from https://thegraph.com/studio/
under 'dfx-test'
In your command line, graph auth --studio
Paste your Deploy Key when prompted
Deploy to your instance yarn deploy-test:mainnet
Set version to 'v0.0.1' and increment as you update the schema and source code.
Go back to https://thegraph.com/studio/dfx-test
and you can start querying in the Playground
even before the subgraph has synced to 100%
Run this query to get the latest trades ordered from newest to oldest
The legacy explorer is the free public subgraph service provided by the graph. It can be seen as the centralized production environment.
yarn prepare:mainnet
yarn codegen
yarn deploy-prod:mainnet
Full documentation on how to use GraphQL queries in The Graph playground can be found here.
One of the most common issues when changing the schema is all specified fields except for the id must be initialized or the subgraph will fail to index.
Switching from Ethereum to Polygon and vice versa requires a small change in subgraph\src\helpers.ts
.
In fetchRewardsForDuration()
there is a function that makes calls to the staking contracts contract.getRewardForDuration()
in Ethereum it is just 1 BigDecimal but Polygon the number is inside an array so upon switching between the two there needs to be a small change of contract.getRewardForDuration()[0]
.
To help with debugging the The Graph has provided a logging object within the graph-ts
module.
This can be used almost anywhere in your mapping code the provide insight on values that are being defined on your schema. There are four different types of logs that can be defined error, warn, info, debug
They all follow the format of string
message followed by and string
array filled with your variables. They will show up after the subgraph is deployed.
For example
Note:
Addresses and transaction hashes must be converted to Hexstrings in order to show up properly in the logging.