PARSIQ
Published in

PARSIQ

Data in Action: DEX Optimization using PARSIQ Historical Data Sets

PARSIQ x Hypersea Case Study

Hypersea is a brand new DEX launching on Arbitrum, being built to facilitate optimal trading between liquidity providers and traders. Below, learn about how PARSIQ (who also just launched on Arbitrum) provided valuable blockchain data crucial to the development of the precise mathematical models used to establish the basis for the Hypersea DEX.

Ready? Let’s GO! 🙌

It is very important to be able to backtest mechanics when creating a brand new DeFi mechanism, especially for DEX-es… and Hypersea is definitely a new type of DEX (we will cover a lot of its mechanics in an upcoming whitepaper)!

Sometimes it is sufficient to obtain historical data and see how your DeFi mechanism (scheme) will work in terms of reaction to past macroeconomic situations (global cryptocurrency rates and volumes) and microeconomic ones — past user transactions.

However, historical data might not cover all the needed scenarios, or it might even be impossible to apply historical data because the scheme could be interactive and change its state in response to user transactions. The main challenge is that the outer reality is adaptive too!

For example, if your trading pool produces a NEW price (because of different logic in the scheme), you can’t expect traders to interact with your pool in the same manner as with the existing ones (e.g. Uniswap) from which historical data have been collected. So not only do you need to build a mechanism (a model, in this case) of the DEX, but you also need to create a model of the TRADER, in order to predict new conditions outside of your historical data pool. And the more patterns (features) you can spot across different DEX-es that are common and visible between all trading pools, the more realistic your trader model will be.

So you would backtest your scheme on an old macroeconomic situation, yet not on old user transactions because user transactions need to be modelled. The most interesting and, unfortunately, less precise experiments are when you are modelling both the new macro situation and trader behavior within it. These experiments allow researchers to stress test DEX models and understand what will happen in extreme scenarios (e.g. price crashes, pumps). An additional benefit is that it allows understanding properties of the model in average, calm or stationary scenarios.

To approach the trader model, we, at Hypersea, decided to start with several observable measurements of trading pools where PARSIQ, the real-time and historical blockchain data provider, helped us a lot with the huge amount of data. It is also worth noting that for PARSIQ, DEX data aren’t a black box, for on-chain DEXes they are transparent. We can see not only the transactions but also the pool’s historical reserves, their trading curves and, surprisingly — arbitrage opportunities that arise from this knowledge (if compared to the outside macro-financial state). This allows Hypersea to develop our models not only on the basis of what has happened in the past but also on what was visible to users and COULD have happened (e.g. non-realised slippages, arbitrage opportunities and so on). Our trader model would be based on machine learning (ML), where observable measurements would define ML features.

Here is an example:

To explain what we can do with the PARSIQ data, we will cover a simple example with Uniswap V2 Data. We are using the UniV2 version because it is governed by the simplest possible curve: Hyperbola, yet it can be generalized to Uniswap V3 (piecewise hyperbolic pool), Curve (StableSwap curve) and so on.

We know that the moving along the hyperbola (in constant-product AMMs, like Uniswap V2, PancakeSwap etc.) is governed by the law:

In the next section, we will try to interpret these feature results.

By applying PARSIQ data about pool resources and trades we are able to reconstruct the following amazing pictures:

Each individual dot here is one of the several million trades performed in the Uniswap V2 ETHUSDT Pool. Here, we analyze the dependency between the size of the trade and the unrealized arbitrage opportunity. Minus means to sell, and plus means to buy. And the sign of arbitrage opportunity is synthetic — it is assigned on the basis of ETH. If it is oversold — it is positive, if overbought — it is negative. In both cases actual arbitrage profit is positive. The sign was assigned only to be able to build a scatter plot that visualizes an “Arbitrage Wind” — when it is profitable to sell, traders prefer to sell, and when it is profitable to buy — they buy. Rather logical, yet non-empty diagonal quadrants show that sometimes users make their trades “against the wind”. This scatter plot allows us to reconstruct a probability density (Using Kernel Density Estimation method) and more accurately model user behavior.

The color was added as an age component to be able to visualize an evolution of the user behavior over time.

Price difference showed intriguing patterns in user behavior that is yet to be explained. Anyway, our Machine Learning model happily used this input and produced similar distributions.

The same picture rotated and without a color component:

These are just a few of the hundreds of interesting results that the Hypersea team achieved with the help of PARSIQ. We hope to publish them gradually, with explanations. Stay tuned!

Want to the learn more about Hypersea? Check out this informative lecture by founder Anatoly Ressin.

About Hypersea

Hypersea — the new generation DEX with smart liquidity management. The goal is to facilitate optimal trading between liquidity providers and traders, by maximizing LPs yields, minimizing slippage for traders, and protecting the liquidity by applying automatic adaptive risk management procedures.

Website | Twitter | Discord | Telegram Community | Telegram Announcement Channel | Medium | Reddit

About PARSIQ

PARSIQ is a full-suite data network for building the backend of all Web3 dApps & protocols. The Tsunami API provides blockchain protocols and their clients (e.g. protocol-oriented dApps) with real-time and historical data querying abilities. ‘Data Lake’ APIs allow complex data querying & filtering for any project; specifically designed and tailored for our customers blockchain data needs. Supported chains: Ethereum, Polygon, BNB Chain, Avalanche, Arbitrum

Website | Blog | Twitter | Telegram | Discord | Reddit | YouTube | Link3.to

--

--

Full-suite data network used to build the backend for all web3 dApps & protocols.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store