#arena #pool #strategy #uniswap #hook #framework #strategies

arena-core

Framework for holistic economic modelling and simulation of Uniswap v4 strategies, hooks and pools

5 releases

0.1.4 Aug 29, 2024
0.1.3 Aug 28, 2024
0.1.2 Aug 21, 2024
0.1.1 Aug 15, 2024
0.1.0 Jul 7, 2024

#83 in Simulation

Download history 65/week @ 2024-07-01 55/week @ 2024-07-08 113/week @ 2024-08-12 132/week @ 2024-08-19 252/week @ 2024-08-26

497 downloads per month

Custom license and LGPL-3.0+

115KB
735 lines

arena 🏟️

visitors Twitter Badge image

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.

Overview

Arena introduces a novel approach to LP simululation 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.

Technical details

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.

Additionally, each LP strategy accepts an Inspector. An Inspector allows custom behavior to be defined for performance analysis of strategy and continuous telemetry. Arena will provide default Inspector implementations for CSV output, graph plotting and JSON output.

The runtime can hold multiple strategies in paralell.

The price of the simulation's underlying pool is set via a price process that implements the Feed trait. Currently, Arena implements an Ornstein-Uhlenbeck price process using a Euler-Maryama discretization scheme for stable pool simulation. The price is set on an infinitely liquid exchange (sometimes referred to as a "lex"), and tied to the v4 pool using an Arbitrageur.

Usage

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

Dependencies

~41–56MB
~1M SLoC