Unlocking DeFi with Decentralized Query

Data accessibility will drive the next generation of Web3 applications.

Conflux Network
Conflux Network

--

Blockchain technology has served as an incredible source of immutable information that powers applications from collectibles like CryptoKitties to decentralized finance (DeFi) like yield farming. The unique use cases and capabilities have driven rapid growth across many different blockchain ecosystems; however, decentralized technology has mostly been contained to its own space with a very slow general adoption rate.

This can be attributed to a host of reasons, but a key one of them is the difficulty to access large amounts of information from a blockchain. For example, it is easy to check the current token balance of an address. This can be accomplished by calling the equivalent smart contract function. However, checking the balance of every token holder is significantly more difficult. Within a standard ERC-20 token, there is not a running list of addresses that hold the token — this would be expensive to maintain from a storage perspective. In order to retrieve the list, each Transfer event would be examined to determine unique senders/receivers addresses. The list of addresses would then be individually checked against the smart contract for the balance. For a token with many transactions and holders, this can be very computationally expensive and slow.

Comparatively, a system implemented using databases would store the balances for each address which would be updated when transactions are submitted. The list of balances and addresses would only be as large as the number of addresses and does not require filtering out the ones with no balance. All of this information can be requested using a simple SQL command.

select * from balances;

Above: Sample PostgreSQL command to read the “balances” table that contains address and balance pairs.

The simplicity of a single command to retrieve all necessary information naturally attracts developers to create applications based around traditional databases rather than blockchains. In order to facilitate wider Web3 adoption in development, decentralized query protocols aim to simplify the process of accessing blockchain data. At Conflux Network, we see decentralized query as another key component of unlocking decentralized technology for developers to build solutions to advanced use-cases.

Decentralized Query Protocol Overview

Decentralized query protocols are a layer that interfaces between the underlying technology like blockchains and the front-facing application. A query protocol would monitor the blockchain for events and store information in a way that can be accessed by individuals using a common database language like SQL. This allows developers to create applications similar to a traditional web application stack where the backend reads information from a database.

One of the most popular query protocols is The Graph which allows developers to create connections to specific smart contracts on Ethereum, collect the data, and interact with it using GraphQL. The Graph uses nodes where a subgraph is defined that contains the smart contract of interest, corresponding events, and how information is stored. The node monitors the blockchain and stores indexed information via IPFS, where users can then request information from the node using GraphQL. Ultimately, the goal is to provide easily accessible blockchain data in a developer-friendly and decentralized manner.

Information flow from a blockchain network using The Graph as a query protocol.

Currently, The Graph only supports Ethereum JSON-RPC calls which allows connections to the vast majority of DeFi protocols. Applications like Uniswap, Balancer, and Compound all have subgraphs that can be used to power other decentralized applications.

Conceptual Application of ML-Powered AMM

By connecting The Graph to other blockchains like Conflux Network, new potential like multi-chain dashboards can be created. These dashboards can synthesise information from DeFi ecosystems across many different blockchains especially as the DeFi ecosystem on Ethereum continues to push its technical limits. As cross-chain protocols and wrapped assets become more prevalent, a multi-chain dashboard can monitor assets across the entire DeFi ecosystem — not just a single network — to better understand how tokens are being used across chains and ecosystems.

An exciting aspect of decentralized technology is the modularity where pieces can be assembled to create even more powerful applications. With that in mind, information about assets on multiple networks from The Graph can be used to train machine learning (ML) algorithms on a decentralized AI provider like SingularityNET to create AI-powered modeling for a token across multiple networks.

The predictive modeling results could then be reconnected back to an automated market maker (AMM) on Conflux Network using an oracle network like Chainlink. Typical AMMs use simple mathematical curves to manage on-chain liquidity, and more advanced cases like Hummingbot and MakerDAO Keepers can use programmable strategies for market making. The advanced cases can be paired with off-chain ML modeling to tune on-chain hyperparameters; however, this pairing requires knowledge and resources to build and train a ML model. By connecting AI-modeling from a decentralized network, any individual can build a ML-powered AMM to more intelligently manage assets distributed across various blockchains. Additionally, by connecting the AI-powered AMM to various networks, the DeFi ecosystem on multiple networks can be leveraged to provide more liquidity.

Conceptual implementation of connecting The Graph to multiple networks and using the data to power a predictive ML algorithm on SingularityNET. Chainlink then connects the predictions back to the automated market maker on Conflux Network with various liquidity pools.

Decentralized query protocols unlock a whole new level of information access that will power the coming generation of complex decentralized applications. At Conflux Network, we are looking at new and interesting ways to grow our ecosystem, community, and the decentralized technology sector as a whole. By making the developer experience smoother, individuals can be better equipped to solve complex problems with decentralized technology. Decentralized query protocols hold an important key in bridging the ease-of-use gap between today’s backend of databases and tomorrow’s backend of blockchains.

Written by Conflux Network’s Research Engineer Aaron Lu

To discuss Conflux Network and join our community, visit our official channels:

Twitter | Discord | Telegram | GitHub

--

--

Conflux Network
Conflux Network

Conflux is a PoW + PoS hybrid first layer consensus blockchain for dApps that require speed at scale, without sacrificing decentralization.