SubQuery is the Universal Web3 data indexing toolkit. SubQuery enables anyone to index, transform, and query blockchain data to power their applications. In this Customer Case Study series we'll hone in on how one team uses SubQuery to elevate and enhance their project via the seamless provision of mission critical data.

SUMMARY

Acala, a decentralised financial hub and stablecoin of Polkadot, uses SubQuery to show users transaction history, obtain internal data insights, and offer as a solution for builders developing on the new Acala EVM+. Ultimately Acala found building new SubQuery projects to be a breeze and with the right framework, a single SubQuery project can be leveraged for multiple use cases.

"Anyone who has tried querying the chain using Polkadot.js will understand how involved the process can be to achieve what you want, but with SubQuery you can just say "here's all the data I want and exactly how I want it" and then suddenly you have it." - Bette Chen, Co-founder of Acala
  • Acala can build, develop and test a new SubQuery project within 1--3 days
  • SubQuery has significantly improved Acala's developer productivity and happiness
  • Thanks to SubQuery's easy toolings like GraphQL and thorough documentation, an Acala developer can implement a feature end-to-end independently
  • SubQuery's Hosted Service means Acala saves 1--2 full time resources and spends virtually no time on maintaining data processing infrastructure

THE CHALLENGE FACING ACALA

Acala is a decentralised finance network powering the aUSD (AcalaUSD stablecoin) ecosystem. The team has built products including a multi-collateralized stablecoin (aUSD - The Acala Dollar), an automated market maker (AMM) DEX, a tokenised staked asset called Liquid DOT (LDOT), and implemented a bring-your-own-gas feature allowing gas fees to be payable in any supported assets such as stablecoins. Acala's parachain plans to play the role of DeFi hub for Polkadot and a landing pad that aggregates assets and liquidity from a variety of blockchains. With the recent launch of Acala EVM+, Acala lets developers leverage the aUSD ecosystem while enjoying the best of Ethereum and the full power of Substrate.

Acala described two key frustration moments that led them to SubQuery. The first challenge was the painful and iterative process of querying data on the chain using Polkadot.js. The second pain-point was with traditional block explorers which didn't provide comprehensive information and only showed data on the native token. This was particularly an issue on a chain like Karura where there are multiple tokens from several chains (e.g. KSM, LKSM, KAR). As a result, the Acala team sought a flexible solution which made querying easier and began by creating their own block explorer using SubQuery.

"Anyone who has tried querying the chain using Polkadot.js will understand how involved the process can be to achieve what you want, but with SubQuery you can just say "here's all the data I want and exactly how I want it" and then suddenly you have it." - Bette Chen, Co-founder of Acala

THE SOLUTION

Since discovering the flexible potential of SubQuery, the use cases for Acala have grown and evolved. The key use case that Acala's users will be most familiar with, is using SubQuery to retrieve on-chain historical data to feed into the Acala dApp and provide transaction history breakdown. This SubQuery project dynamically tracks all the extrinsic data created on Acala and can quickly show derived aggregated stats for the following:

  • Historical Data on liquidity changes (broken down by providers)
  • Historical Data on all cross chain asset swaps
  • Transfer history
"We find you can use one SubQuery Project for multiple different use cases because when you build out a SubQuery project and you structure your information in a manageable way, you can really leverage that to a very high extent. Keeping track of all the different transfers, different balances, and different uses of a certain extrinsic --- SubQuery gives you a level of flexibility when querying the data so we don't find we need to create a project for each different thing that we're doing. As long as the overall data is laid out in a reasonable way, you can get the most bang for your buck when it comes to using a single project."- Charlie, Software Engineer at Acala

On a more complex level, Acala leverages SubQuery internally to figure out the different financial parameters for their protocols to keep them safe. With SubQuery's help, they can keep an eye on all the different transactions that are happening on-chain to ensure everything is running smoothly and safely.

Finally, SubQuery extended to Acala's new EVM+ to offer universal EVM support within Polkadot. The SubQuery EVM+ implementation offers a simple way to filter and index both EVM+ and Substrate activity on Acala within a single SubQuery project. This means you can index EVM+ Calls or events, and filter these based on call function signatures, event log topics, and/or smart contract addresses.

"Acala EVM+ enables developers to develop and deploy dApps on Acala with great tooling support --- this indexing support from SubQuery is one of the last missing pieces to enable the developer experience that we strive for. We can't wait to see what dApps are built on Acala's DeFi hub using SubQuery" - Bryan Chen, Co-founder and CTO at Acala

THE RESULTS

Acala now have 11 SubQuery projects with two deployments for each project (Karura and Acala). Below is a simple example from one project of how a user can quickly and easily see the previous 5 transfer events using the ACA token over the Acala Mandala network. You can see here that we use simple GraphQL language to sort and retrieve this data to any client. DApps can use this to monitor loan positions, and jump on auctions etc to help liquidate collaterals.

A slightly more complex example follows, where we inspect a single account and retrieve all token swap events made by it. A portfolio DApp might use this data to create an overview of the holder's account and token performance, revenue from staking, liquidity provisioning, and expenses on borrowing.

"For any new data indexing needs we have it only takes 1--3 days for us to develop and test a SubQuery project before it's ready to implement. On top of this, without SubQuery's hosted service we would likely require 1--2 fulltime devops to manage data processing infrastructure --- instead we spend virtually no time maintaining this infrastructure." - Bryan Chen, Co-Founder at Acala

With the recent support of Acala's EVM+, SubQuery will be an excellent offering for Acala's growing ecosystem to accelerate their dApp development. One interesting aspect of the integration with Acala's EVM+ is that SubQuery itself will be migrating its own smart contract code across in preparation for the SubQuery Network launching on Acala. The SubQuery Network team will be one of the first users of the new EVM+ support and will benefit from the ease it brings, just like other teams building their own dApps on Acala.

"SubQuery has significantly improved our developer productivity and happiness. The toolings involved like GraphQL are super easy to work with, even for people who aren't familiar with them. With the help of the SubQuery documentation our developers can implement a feature end-to-end without dependence on anyone else which is so important as a small team." - Bryan Chen, Co-Founder at Acala

Key Resources

SubQuery Developer documentation: https://university.subquery.network

Acala SubQuery Project: https://explorer.subquery.network/subquery/AcalaNetwork/acala

Karura SubQuery Project: https://explorer.subquery.network/subquery/AcalaNetwork/karura

Acala Customer Interview: https://www.youtube.com/watch?v=Wbxwj8K67Lw&t=9s

EVM+ Starter Project: https://github.com/subquery/acala-evm-starter

Acala website: https://acala.network/

About SubQuery

SubQuery is a blockchain developer toolkit facilitating the construction of Web3 applications of the future. A SubQuery project is a complete API to organise and query data from Layer-1 chains. Currently servicing Polkadot, Substrate, Avalanche, Terra, and Cosmos (starting with Juno) projects, this data-as-a-service allows developers to focus on their core use case and front-end without wasting time building a custom backend for data processing activities. In the future, the SubQuery Network intends to replicate this scalable and reliable solution in a completely decentralised manner.

​​Linktree | Website | Discord | Telegram | Twitter | Matrix | LinkedIn | YouTube

Share this post