---
# System prepended metadata

title: HydraDX OmniPool Course Research Topic Template
tags: [Hydra]

---

# HydraDX OmniPool Course Research Topic Template

###### tags: `Hydra`

:::info
The concepts presented are open for discussion and change.
:::

---
### Research Topic/Question:

Are there signals that allow to gain information on market extern price changes without the need to rely on extern oracles?

ALTERNATIVELY

How can the wider market an AMM is immersed into be simulated in cadCAD by usage of trading agents?


---
### Brief Description:

Impermanent Loss can be caused by arbitrage trades: if a token rises in prise, the arbitrage-trades effectly cause a reduction of the supply of this token. This causes the pool to loose value until the prices are aligned. The intend of arbitraging might betray itself - for example: in trade size and succesive trades with same direction. The research task aims at identifying such hints at ongoing arbitrage and gain knownledge about the direction of the change in market extern prices.

ALTERNATIVELY

Simulating an AMM wihtout taking into account the wider market may oversee important dynamics. The interaction between the AMM and the wider market is carried by traders. By implementing more complex trader behaviour on cadCAD it is possible to simulate the AMMs interaction and action in more detail.

---
### _Relevance to Hydra AMM_ (e.g. component, subsystem, mechanism, implementation, cadCAD model,...)

Identifying arbitrage signals would allow to design dynamic reactions to those signals. This could in turn allow to optimize the AMM in such way that non-arbitrage trades are encouraged by reduced fees while arbitrage trades come with higher fees. If the arbitrage signals allow to gain knowledge on the direction of the extern price change, HYDRA could use the fees to reach faster price-alignement with less Impermanent Loss. An possible idea for implementation could be: low slippage for non-arbitrage, but high slippage for arbitrage.

ALTERNATIVELY

The trial of building a digital twin of HYDRA on cadCAD is only meaningful if this twin can be tested under different trading scenarios: it has to be possible to simulate the reaction of HYDRA to market extern price changes and how it can cope with possibly aggresive interests of traders. By iplementing more coplex trading behaviour in cadCAD the foundation for such wider simulation shall be laid down. 

---
### Expected Approach (e.g. analytical, numerical, experimental...)

The approach would be mainly based on data-analysis: determine relevant probability densities functions by usage of accessible market data. We need to find APIs that are freely accesible to gain (spot)price and trade-volume information for different market scenarios: 
* relatively stable prices that fluctuate arround a constant market extern price
* relatively stable prices that follow a clear trend of market extern prices
* volatile prices without clear trend

Based on this data it may be possible to determine correlators of market intern processes to market extern price changes.

A part of the analysis will be performed with the Wolfram Mathematica language. Interacting with the relevant APIs can be done within Mathematica or delegated to a Webserver (root server could be used) with PhP or performed in a C++ programm.

#### Project phases
* **Phase 1 - Data acquisition:** statistics on trade-directions and trade volume for different asset pairs on different markets needs to be made available. The quality of this data decides which methods of analysis are promising. (bad data already available through a small hack) 
**Expected duration: up to 3 weeks**

* **Phase 2 - Statistic acquisition:** using the infrastructure created in phase 1, data needs to be collected over a longer period so that we have enough statistics for different scenarios. 
**Expected duration: 2 weeks** (very dependent on market evolution, does not need phase 1 to be finished in total -> paralellization possible)

* **Phase 3 -  organize data:** organize the data into a time-series over prices and split the dataset in 3: price rise, price fall, sideway movement. Requires the calculation of different correlators.
**Expected duration: 1 week**  (does neither need phase 1 nor phase 2 to be finished -> paralellization possible)

* **Phase 4 - data analysis I:** taking a first look at the data, we identify possible parametrizations for probability densitie functions (PDFs)
**Expected duration: 1 week** 

* **Phase 5 - data analysis II:** identify the parametrization with least number of variables that can be fit to the data and use it to further identify specific signals that can be extracted from market intern data.
**Expected duration: 1 weeks** 

ALTERNATIVELY

The python notebook of cadCAD will be supplement by a new variable: the market-extern price for different assets. Then, trading bots with incentives based on this extern market prices will be implemented. The most simple trading bot is already given and can be easily complemented:
* Random swaps with trade-size distribution according to a given probability function,
* Arbitrageur bots that act upon differences of market-intern and -extern prices,
* Liquidity-providers that can be further splitted into: long-term ("fearless"), speculative ("flee-from-loss"), ... 

#### Project phases

* **Phase 1 -  extern price:** implementing the extern-price variable should be a simpe task during which one can get to know the architecture of cadCAD more closely.
**Expected duration: 1 week**

* **Phase 2 -  understand given implementations:** The existing modules and functionalities need to be understood to such degree, that the changes to be made do not endanger the correct functionality of the system.
**Expected duration: 1 week**

* **Phase 3 -  random swap bot:** complement the random swap actions with the possibility to define a probability function. This will be done either in a general way by creating a functional interface or in a less general way by fixing a parametrized probability function and allowing change of parameters. This will give the foundation on which more complex trading bots can be implemented and the following phases can be worked on in parallel. 
**Expected duration: 3 weeks**

* **Phase 4a -  arbitrage bots:** can be implemented by introducing the price-difference as a parameter that governs the tilt of the probability function for trades.
**Expected duration: 3 weeks**

* **Phase 4b -  Liquditiy bots:** the bots tendency towards removing liquidity should be governed by the price-volatility. 
**Expected duration: 3 weeks**

---
### Team Members (initial)

* Rudolf Golubich
* ... [comment or contact if interested]


---
### Team Skills

Used to a high abstraction on a strict mathematical foundation, knowledge of the programming and scripting languages Mathematica, Fortran77, C++, Javascript, PhP, MySQL, Haskell. Expertce within the formalism of (particle) physics also in the scope of Thermodynamics. Experience on "Logic and Computation".


---
### Any Additional Desired Skills

* trading is human behaviour: a behavioural scientist could be useful
* due to the lack of experience with python and the potential need to implement things in cadCAD, someone with more experience in this script language could be useful.
* (the data aquisition of financial data is new terrain for me: I do not know, which data sources are on the markt. An economist may bring in useful knowledge here.)

---
### Desired Goal/Overarching Objective (may not be/unlikely to be achieved during the course)

Identified arbitrage signals that do not rely on extern oracles and can be implemented onchain for HYDRA.

ALTERNATIVELY

Implementation of simple trading bots in cadCAD


---
### Attainable Goal/Specific Objective (may be/likely to be achieved during the course)

Knowledge of relevant probability density functions (PDFs)concerning price differences for different scenarios. These PDFs could be implemented in cadCAD so that the wider market into which the AMM is immersed can be respected during simulations.

ALTERNATIVELY

The capability to simulate the interaction of an AMM with the wider market it is immersed into.

