How DeFi Applications can benefit using Subgraphs for data indexing?
On-chain data is what allows DeFi applications to operate their functionalities, maintain visibility, and remain competitive over time. But, obtaining specific data in a preferred format from the blockchain’s decentralized database is extremely complex. Subgraphs– powered by the Graph protocol, makes data indexing and querying easy with features such as high-speed data indexing, high volume queries handling, and fastest queries through GraphQL. Hence, if you are building a DeFi application that requires all these benefits and seamless access to varied data from blockchain’s huge and complex datasets, then deploying your own Subgraph/using a shared indexer could be an excellent choice.
This article delves deeper into the importance of Subgraph for data indexing in DeFi applications in addition to analyzing a concise list of DeFi Subgraphs that are deployed and running on the Graph ecosystem.
Briefing the Subgraph Services
Subgraphs– the data indexing tool, works as a bridge between DeFi (or every other) applications and the blockchain ecosystem. All kinds of DeFi applications— be it a decentralized exchange, crypto investment platform, liquidity platform, lending and borrowing platform, yield farming apps, or Automated Market Makers (AMMs); these projects can build their own Subgraph to extract real-time and historical data via GraphQL calls. The extracted data serves the backed of dApps, driving their dApp-specific functionalities while offering the intended value to the end users.
DeFi applications can use Subgraph’s hosted service or the Graph’s decentralized network. The decentralized Graph network offers unique benefits such as 60-98% lower monthly cost, Superior uptime, access to hundreds of independent Indexers, and 24/7 technical support by the global community. However, to reap all these benefits, it requires deployment of nodes, and specific infrastructure requirements.
Regarding Hosted Service, you do not need to stake $GRT tokens, run nodes, or manage Subgraph infrastructure on your own. Instead, you just need to deploy your Subgraph on a low-code interface and make it available for data querying, but on a Graph-managed centralized infrastructure. Hosted Service also supports deployment of custom subgraphs for query of very specific on-chain data. Want to learn about the end-to-end process of Subgraph deployment and management. Refer to our guide below:
How to deploy custom Subgraph with The Graph Protocol?
Challenges of data indexing in DeFi applications
1. Infrastructure setup: DeFi applications looking to index and query blockchain data, will need to invest significant time, effort, and resources in setting up complex infrastructure such as data servers, RPC nodes, clients, and delegate hardware infrastructure for handling SQL queries. This process is cost and resource-intensive, and meanwhile, it requires specialized skills to continuously maintain optimal performance of each component.
2. Slow response to queries: Most of the Layer-1 blockchains and even prominent DeFi applications distribute their historical data across the events that are stored separately outside of the blockchain and its decentralized ledger. Retrieving these data via the traditional method of RPC will slow down the query process and the response time considerably. This problem will even increase when data needs to be queried frequently.
3. Problem in customizing queries: Data indexing and querying via current RPCs and APIs are ideal for serving generic queries (for example, top-k queries). Therefore, DeFi applications may face a lot of challenges while customizing their queries for highly specific data retrieval.
4. Inefficient data retrival: One of the big headache for DeFi applications is parsing data from massive resources. Talking about Ethereum alone, it records more than 1 million daily transaction as of August 2023. This amount is twice that of Bitcoin, which processes 55,000 daily transactions. Retrieving data from such huge resources is usually unsuitable and difficult.
How Subgraphs can tackle the above data indexing challenges in DeFi apps
Subgraphs on the Graph protocol can be based on Graph’s decentralized network or hosted service. Both these Subgraph services can tackles the above data indexing challenges in DeFi applications:
1. Providing deployment-ready infrastructure: To deploy your Subgraph to Graph’s decentralized network, you need specific infrastructure to run nodes, or manage the graph-CLIs, and other components. By choosing the Graph’s hosted service, it will provide you with a simple UI for seamless creation and deployment of Subgraph. For this, you just need a Github account, with no need for infrastructure setup, RPC or Graph nodes, CLI, wallets, and more. However, the decentralized Graph network offers unique benefits that we will discuss later.
2. Blazingly fast response to queries: The Graph decentralized network is optimized to offer fastest queries through GraphQL API, allowing all types of DeFi applications to access on-chain data easily and instantly. Also, The Graph is optimized for best in-class performance and fast syncing speed, which further boosts the response time.
3. Customized queries with Custom Subgraphs: Knowing that DeFi applications need very specific blockchain data, such as the transaction history of a specific user, identity of investors, and precise smart contract events– The Graph facilitates the creation of custom subgraphs that run highly customized queries back and forth.
4. 24/7 data flow with uptime: With Subgraph deployed on the Graph protocol– whether hosted or decentralized network– , your DeFi applications will keep data flowing on its ecosystem 24/7. Regardless of the massive database or number of blockchains, Subgraphs will ensure efficient data retrieval for each query.
List of 10 DeFi Subgraphs and the data they query using Subgraph?
On the Graph protocol, numerous projects have deployed their Subgraph for data indexing in DeFi applications. Let’s talk about ten prominent DeFi Subgraphs and the type of data they extract using their DeFi Sugraphs:
1.Kunji Finance Subgraph
Kunji– the innovative, non-custodial investment and asset management has recently deployed its Subgraph on Zeeve’s hosted service to extract specific data Kunji’s smart contracts and a range of DeFi platforms. With the Subgraph, Kunji utilizes on-chain data related to investment and trading, such as portfolio value, invested amount, returns, deposits, withdrawals, strategy returns etc. The Subgraphs serves equally to the asset managers, allowing them to make investment decision making and report on money circulation across various DeFis.
2. SushiSwap Subgraph
Sushiswap has deployed a series of Subgraph on the Graph protocol, which includes SushiSwap Ethereum, Sushiswap Gnosis, SushiSwap, and simplefi-sushiswap. All these subgraphs extract different set of data from Sushiswap’s smart contracts deployed on different chains. Web3 enterprises and projects building their dApp on Sushiswap can access all kinds of on-chain data easily due to the Subgraphs. These data can range from account balances, token transfers, information related to pool, transaction details/history, and much more. Subgraph simply indexes the raw data, cache it, and provides data based on the GraphQL queries.
3. Curve Subgraph
Curve is the next to deploy various subgraphs, such as CurveFi, Curve Finance, and Curve Factory pools. All these Subgraphs offer a GraphQL endpoint for DeFi Dapps to query on-chain data like transaction history, liquidity pool balance, and TradeFi data. These extracted data are utilized to build high-quality DeFi applications with advanced user behavior analytics and interactive Curve protocol-based features.
4. Loopring Subgraph
Loopring currently has two open-source DeFi Subgraphs– Loopring zkRollup and Lexplorer. The first one is designed to index and on-chain data from all the Loopring’s zkRollups, providing real-time and historical data like accounts, balances, transactions, and more via GraphQL queries. Talking about the Lexplorer, it’s a block explorer that powers the Loopring protocol.
5. Hop Protocol Subgraph
Hop again, has deployed a range of DeFi Subgraphs on the Graph protocol, which includes HOPR on Gnosis, HOPR Channels, and HOPR Nodes Rotsee that enable DeFi projects and dApps to easily access and query data about smart contracts, nodes, and assets bridged across various Ethereum-based chains such as Ethereum, Arbitrum, Optimism, Polygon, and xDAI.
6. Uniswap Subgraph
Uniswap manages a suite of DeFi subgraphs for indexing and querying on-chain data from different Uniswap smart contracts. Some of its Subgraphs include Uniswap V3 Celo, Uniswap V3 Ethereum, and Uniswap V3 Arbitrum. Through Subgraphs, dApps can query data like TVL- Total value locked, current liquidity of the pool, swap data, aggregated fee collections, etc. DeFi projects building on the top of Uniswap can leverage all of these Subgraphs published in the Graph Explorer.
7. Aave Subgraph
Aave maintains 10+ Subgraphs on the Graph protocol that query the indexed data from various Aave smart contracts via the GraphQL endpoint. Leveraging the Aave Subgraphs, DeFi projects can track data related to deposits, borrows, collateral ratios, and a lot more. All these insights support the development of data-rich DeFi apps that analyze and use both individual and market-level activities.
8. Airswap Subgraph
Airswap Subgraphs allow DeFi projects to query and access valuable on-chain data out of AirSwap smart contracts, such as swap amount, tokens, transaction volume, user balances, and more. With access to these details, DeFi applications can include custom analytics and trading tools that enhance their overall experience with the AirSwap DEX ecosystem.
9. Synthetix Subgraph
Synthethix Subgraph includes a GraphQL API endpoint to query the indexed on-chain data from Synthetix smart contracts. The data can vary from exchange rates, price feeds, and volumes per Synths to TVL. DeFi applications can utilize all these data to build innovative applications on top of the Synthethix protocol.
10. Convex Subgraph
Convex hosts a suite of Subgraphs on the Graph protocol, allowing decentralized finance projects to index and access a complete range of historical and other relevant on-chain data, such as tracking total revenue and yield on the Convex Finance platform.
Deploy and manage your DeFi Subgraph easily with Zeeve’s Hosted Service
As discussed, there are tremendous benefits to using Subgraph for data indexing in Defi applications. However, you are using Hosted Service; note that it is gradually sunsetting, and projects are being encouraged to move to Graph’s decentralized network. For all the projects that still want to leverage hosted service– Zeeve can help.
Zeeve’s hosted service enables deployment for the protocols that are not yet available on the Graph. Basically, you have three options- to opt for shared indexers where a single Graph node will manage multiple Subgraphs for different projects. Secondly, you can have a dedicated indexer where a single node will be dedicated to a single Subgraph (this is suitable for projects with huge data indexing needs). Lastly, you build fully custom Subgraphs with Zeeve’s advanced stack and expert assistance. The indexers, nodes, and every other component will be deployed and maintained by Zeeve.
With Zeeve, you do not need to manage Graph nodes or stake GRT tokens. Everything will be managed on Zeeve’s end, and you can simply make pay the indexers in any fiat currency. This approach will decrease the cost of maintaining Subgraph significantly while you can get benefits like 99.9% API SLA, upto 5x speeder data indexing and 2x lower data lag. Plus, Zeeve will monitor all your Subgraphs constantly on critical parameters, eliminating further chance of downtime or performance-related issues.
For more information on how Zeeve’s hosted Subgraph brings value to your project, connect with our experts. We are happy to assist you. You can drop your queries via email on this page or you can also schedule one-to-one call with our web3 consultants.
Responses