Crates.io | arena-core |
lib.rs | arena-core |
version | 0.1.7 |
source | src |
created_at | 2024-07-07 15:40:10.235914 |
updated_at | 2024-10-21 16:06:28.501362 |
description | Framework for holistic economic modelling and simulation of Uniswap v4 strategies, hooks and pools. |
homepage | |
repository | https://github.com/arena-rs/arena |
max_upload_size | |
id | 1294965 |
size | 412,518 |
Arena is a powerful and extensible framework for holistic economic modelling and simulation of Uniswap v4 strategies, hooks and pools.
Track how metrics evolve over time, and over various market conditions.
Arena has an examples folder on how to use the framework.
Arena introduces a novel approach to LP simulation through a highly-configurable event-driven runtime. Each event consists of integral market information for a strategy, from which the actor can derive insight from.
Arena is an alloy native project, utilizing many crate-native features such as the sol!
procedural macro, and the Anvil
testnet node implementation.
Every LP strategy must implement the Strategy
trait. This contains two key methods:
init()
is called upon initialization of the Arena runtime.process()
is called each discrete timestep of the simulation.These methods allow LP strategies to define specific behaviors and heuristics based on general market updates. Both functions are provided with:
Engine
for liquidity modificationSignal
containing comprehensive market informationAdditionally, each LP strategy accepts an Inspector
. An Inspector
allows custom behavior to be defined for performance analysis of strategy and continuous telemetry. Arena provides default Inspector
implementations for CSV output and JSON output.
The runtime can hold multiple strategies in paralell.
The price of the Uniswap pool being simulated is set via the Feed
trait. This allows for custom stochastic processes or backtesting feeds to be defined. The price of the pool is pegged to this price feed by utilizing an arbitrageur.
Arena also provides an infinitely liquid exchange, much like centralized exchanges in real markets, which the price is set on. The arbitrageur then swaps between this and the pool, thus tying the two prices.
The arbitrageur makes swaps every timestep to equalize the price between these two markets. Arena also provides an Arbitrageur
trait, allowing for custom behaviors to be defined and custom arbitrage strategies. We recommend most users use the FixedArbitrageur
implementation, which swaps a fixed amount each price equalization. This simulates an inefficient market whilst also tracking the price feed effectively.
Below is a graph showing the price of the liquid exchange with relation to the Uniswap pool, using a FixedArbitrageur
. The FixedArbitrageur
accepts a depth
parameter, which controls how much is swapped on each timestep. The below graph shows a run with a depth of 100000, which we find is a good balance between tracking granularity and minimizing tracking lag.
To use Arena, the Rust programming language alongside the Foundry framework must be installed on your machine. This is commonly achieved using rustup
, and foundryup
Arena can be added to your library or binary with
cargo add arena-core
If you wish to build from source, the project can be cloned with:
git clone https://github.com/arena-rs/arena.git
cd arena
git submodule update --init --recursive
examples/
directory.We welcome contributions!
See our Contributing Guidelines