Pool Architecture
All pools in quantamm inherit from the AbstractPool base class, which defines the core interface that any pool must implement.
This includes critical methods for:
Calculating reserves with and without fees
Handling dynamic inputs (like fees or arbitrage thresholds/gas costs)
Parameter initialization
JAX-optimized implementations for high performance
The following sections provide more detail on the different pool types implemented in the simulator.
All pool types in quantammsim inherit from the AbstractPool base class.
Out the box, the simulator implements four main types of pools:
Balancer Pools
Traditional constant-weight geometric mean AMM pools, following the Balancer protocol design.
CowAMM Pools
Implements the CoW Protocol AMM design where post-trade quoted prices must match execution prices. Available in two variants:
Gyroscope Pools
Pools that use elliptical curves as the trading function, able to provide concentrated liquidity within price bounds while still having a smooth trading function and fungible liquidity.
QuantAMM Pools
Dynamic pools that can adjust their weights based on market conditions.
All QuantAMM pools inherit from TFMMBasePool and implement different strategies.
Six strategies are currently supported, and more can be added by the user.
For more detail, see Temporal Function Market Makers: Introduction to Dynamic AMMs and QuantAMM: Pools as Portfolios.
Implementation Requirements
In order to implement a pool type, you need to implement the calculate_reserves_zero_fees and calculate_reserves_with_fees methods (as well as calculate_reserves_with_dynamic_inputs, and some helper functions around that method, if you want to support time-varying fees or provide a sequence of trades to apply).
These functions all require the calculation of how arbitrageurs will act given pool state and external market prices.
For the pool types provided in this simulator, we use externally-derived mathematical formulas for this process, which are then implemented in high-performance JAX code that can leverage GPU acceleration. This means that years of simulation, at 1-minute price resolution, can take only the order of a few seconds on a basic laptop and fractions of a second on a GPU. It is possible, however, to implement custom pool types using, for example, convex solvers, but this leads to a very noticeable slow-down in performance compared with the native JAX approach where the user implements hand-derived reserve update equations.
See Implementing a new AMM for more details on how to implement a new kind of AMM pool.
JAX Details
All pools and all strategies that come with this package use JAX for efficient computation:
Strategy and weight calculations are JIT-compiled
Reserve calculations are parallelised where possible (commonly in the zero-fees case) using JAX’s
vmapfunctionGPU acceleration support by construction
Batch processing of parameters supported for parallel simulations