Inspiration

We were inspired by research on simulating financial markets for reinforcement learning, specifically two papers on training RL agents inside simulated limit order books: Multi-Agent Reinforcement Learning in a Realistic Limit Order Book Market Simulation from UC Berkeley, and JAX-LOB, a GPU-accelerated order book simulator from Oxford. Both use simulated markets to study how RL agents behave, but they focus on order books. We wanted to apply that same idea to AMMs, the mechanism real DeFi protocols like Uniswap actually use, and use it to test whether an AI agent is safe to deploy and not just profitable.

What it does

PureSim simulates an AMM market with a noise trader, an arbitrageur, and AI agents under test. We inject shocks such as large trades and sudden price moves mid-run and observe how the AI agent reacts, and whether its presence makes the market more stable or more fragile. It's a sandbox for validating trading agents before they touch real capital.

How we built it

A Python implementation of a constant-product AMM (x \cdot y = k), where a swap updates reserves via:

$$\Delta y = \frac{y \cdot \Delta x}{x + \Delta x}$$

Rule-based agents generate order flow, a reference price feed drives the arbitrageur, and the AI agent decides its actions from the live pool state. A dashboard tracks price, depth, and PnL, and lets us trigger shocks live.

Challenges we ran into

Scaling down from the papers' GPU-parallelized, multi-day-trained order book simulations into something buildable in days. We pivoted from a full limit order book to an AMM to keep the mechanics simple while preserving the core question.

What we learned

A deeper hands-on grasp of AMM mechanics: slippage, impermanent loss, arbitrage, and that simulation design (agent behavior, shock timing) matters more than raw compute for a legible, demoable result.

Built With

Share this project:

Updates

Submission history