Eta X NonML V2: Speed, Scale, and Efficiency

Jack Lodge
Deeplink Labs
Published in
5 min readFeb 10, 2023

· Eta X NonML V1 Recap
Why is Eta X Important?
What is Eta X?
· Eta X NonML V2 Updates
Data Collection and Caching
· DEX Filtering
· Try It Out Yourself

Eta X V1 Recap

The core concepts and motivation behind Eta X are explored in great detail in our previous article:

However, we will briefly summarize Eta X V1 for readers who are unfamiliar with our progress.

Why is Eta X Important?

The growth of decentralized finance has led to an increase in the number of DEXs, which provide a trustless solution for trading crypto assets. Eta X stands out by offering a platform that is resilient to manipulation and provides the best possible trade routes as calculated by reverse engineering publicly available smart contracts and their respective AMM conservation functions, without engaging in any biased practices.

What is Eta X?

Eta X is a decentralized exchange (DEX) aggregator and smart order routing (SOR) tool developed by Deeplink that can help traders find the most profitable trade routes by considering factors such as price impact, liquidity, and gas fees. Eta X V1 uses a modified Djisktra algorithm to traverse and validate paths from the token being sold to the token being purchased.

To evaluate the profitability of each route, Eta X V1 uses reverse-engineered conservation functions from each exchange to calculate a minimum return and price impact percentage. The algorithm returns a list of recommended routes for a user in descending order of highest returns. While early versions of Eta X are simply analytics tools to inform traders, the ultimate goal of Eta X is to facilitate the execution of profitable trade opportunities via wallet and smart contract integration.

Eta X V1.2 Updates

Eta X V1 proved to be an effective proof-of-concept, as such, we have since been expanding in several areas such as the inclusion of several new DEXs, optimizing data collection, order splitting, and mass query APIs.

Data Collection and Caching

One of the most noticeable improvements from Eta X V1.0 to V1.2 was the introduction of liquidity pool data caching. Early proof-of-concept iterations of Eta X were loaded down by ad-hoc GQL queries to subgraphs hosted by The Graph, this meant that a user’s query would trigger several queries on Eta X’s backend, essentially double-handling data retrieval. While this was fine for early testing purposes, Eta X is growing, and thus its data collection and caching functionality must mature along with it.

Previous Data Collection Method

Caching is a technique that involves storing frequently accessed data in a temporary storage location, such as in memory or on disk, to reduce the time and resources required to retrieve that data from its original source. In many cases, caching is significantly faster than ad hoc retrieval, which involves accessing data directly from its original source every time it is needed.

In the context of Eta X, caching can provide significant benefits by reducing the time and resources required to retrieve pool data from decentralized exchanges (DEXs). Since Eta X relies on up-to-date pool data to perform smart order routing, the speed at which this data can be accessed and processed is critical to both the application’s performance and user experience.

Eta X V2 and V3 now keep a running cache of all liquidity pools contained within each supported DEX in the backend. This way each time a user queries Eta X, the backend must only retrieve the relevant data via filtering it out of this pre-existing cache, rather than fetching it from third-party sources on the fly. This addition has removed Eta X’s greatest bottleneck, and has reduced data retrieval time down from a few seconds to less than one second, while still retaining comparable data granularity and currentness.

This is achieved by creating a hash map of all liquidity pools from supported DEXs to their respective relevant datapoints. Pool data is updated continuously and asynchronously by querying the relevant subgraphs for each DEX. The pools are refreshed periodically at a rate that is close to the limit of The Graph’s rate limiters, but still within the limits to ensure that the updates are successful. While this does mean that pools are no longer at the time of an end user’s request, the time difference between cache refreshes is negligible for the vast majority of use-cases. However, rest assured that we are working on even faster methods involving circumventing The Graph entirely, and leveraging direct on-chain queries and datasets provided by L3 Atom.

New Data Collection Method

DEX Filtering

In line with the aforementioned data filtering process that is triggered upon retrieving relevant liquidity pool data from the cache, we have also introduced the ability to filter the DEXs on which a user would like to identify trade routes across. The specific reasons why a user would like to limit their trades to a given exchange may vary from protocol loyalty to ease of integration, for instance, while one DEX may have fantastic liquidity, it may not be so easily integrated with your DApp as another. In the frontend GUI, a user can simply tick or untick the DEXs they wish to route through; when querying the API, a user can simply pass a list of strings including the DEXs they wish to include, an empty list indicates all DEXs shall be queried.

This filtering process is achieved by retrieving relevant liquidity pools by token ID from the greater hash map of liquidity pools. Pools are gathered in order of their most relevant metric for trade optimality, such as reserves or liquidity, and are merged into a smaller list of pools to be used in SOR for that particular user’s query. A DEX and its respective liquidity pools are included or excluded in this filtering process depending on whether or that DEX is selected in the user’s query.

Try It Out Yourself

You can try Eta X NonML V2 yourself at the following link:
https://etax.deeplink.network

The source code for Eta X can be found here:
https://github.com/Deeplink-Network/EtaX-V1

--

--