DefiPlaza uses subgraphs to index and organize the data from the smart contracts. These subgraphs make the information on the Ethereum blockchain available via a GraphQL API on the web.
Endpoints and API explorer
Github Source: https://github.com/OmegaSyndicate/dex-subgraph
Explorer page: https://thegraph.com/hosted-service/subgraph/omegasyndicate/defiplaza
API Endpoint: https://api.thegraph.com/subgraphs/name/omegasyndicate/defiplaza
The Explorer page contains all example queries on this page for an easy way to explore and play with the subgraph API.
All USD values are derived from the average number of the three stable coins on DefiPlaza: USDC, USDT and DAI.
Subgraph Reference
Factory
The factory object contains consolidated information on the DefiPlaza dex, such as the total value locked in USD and the circulating supply of the DFP2 Governance token.
You can retrieve the data via the contract’s address:
{
factory(id:"0xe68c1d72340aeefe5be76eda63ae2f4bc7514110") {
swapCount
totalValueLockedUSD
dfp2TotalSupply
}
}
Token
The token object contains information on each of the 16 tokens trade-able on DefiPlaza.
You can query the tokens in different ways, for example by times swapped. The id of the Token is it’s address on the Ethereum blockchain.
{
tokens(orderBy:swapCount, orderDirection:desc) {
id
symbol
tokenAmount
swapCount
}
}
Pair
All 120 pairs present on DefiPlaza, created alphabetically. The id is the base and quote symbol, for example: DFP2_ETH.
{
pairs(orderBy:id, orderDirection:asc) {
id
baseToken {
symbol
}
quoteToken {
symbol
}
swapCount
}
}
Swap
Every swap on DefiPlaza is logged and available to query. It includes the pair, the input and output token, the amounts of both tokens, and the value in USD.
{
swaps(first:10, orderBy:timestamp, orderDirection:desc) {
id
pair {
id
}
inputToken {
symbol
}
inputAmount
outputToken {
symbol
}
outputAmount
swapUSD
}
}
Hourly and Daily stats
The subgraphs also feature hourly and daily stats for both the complete dex and per token. You can explore these here.