Introduction

An on-chain Automatic Market Maker (AMM) requires several parameters to be set to create a healthy venue; in other words, these parameters can make or break a marketplace.

Any market designer needs to make several seemingly arbitrary decisions when putting together the rules for their market, for example:

A tool that IPOR Labs is building to help with this decision process is a simulation engine to understand the risks and outcomes for the AMM and other market participants in different market conditions and parameters.

Simulating market participants

In this note, we will focus on one piece of the whole picture: how to simulate trades to interact with the AMM?

In traditional markets with a long history and a myriad of data points, we could simply use past data to infer conclusions. However, the AMM we are considering is for interest rate swaps, a market that does not currently exist on-chain, so using past data is not an option.

Alternatively, we could design rule-based market participants to trade against the AMM under different market conditions. Still, this approach also comes with its limitations (hard to state complicated rules, which could quickly become unrealistic).

Given all of these options, the method we will adopt is to create a stochastic process to generate synthetic trade data. The process will be calibrated from real data, but the data will be a proxy for real trades (the second-best data we can find other than actual trade data).

Our goal, problem, and proposed solution described in this note are summarized below:

<aside> đź’ˇ Goal: Simulate market conditions to isolate the impact of market parameters on traders and AMM performance.

Problem: Market data for interest rate swaps does not exist in DeFi.

Solution: Create synthetic trades for AMM simulation. We will achieve this in three steps:

  1. Find data as a proxy to the “real” trades arrival rate
  2. Fit a self-exciting arrival model
  3. Generate data from the model

</aside>

The data

Currently, there are no markets for interest rate swaps on-chain; because of this, we will bootstrap our simulation framework from the positions (borrowing and lending) in Compound or AAVE, pretending that those positions would trigger equivalent trades on the IPOR AMM. The choice of data can seem arbitrary, but the results and tools in these notes are still useful if the reader has access to some better proxy for the trades they want to generate synthetically.

How we cleaned the data

  1. For each block in the Ethereum main net, we collected the amount of liquidity available for DAI on Compound and AAVE protocols.
  2. For each block in which the liquidity decreased with respect to the previous block, we marked that as a trade.

The following plots highlight the liquidity time series, followed by the negative movements of the time series.