Technical Specifications

A Unique Time Weighted Average Market Maker for Trustless Monetary Policy


Fraxswap is the first constant product automated market maker with an embedded time-weighted average market maker (TWAMM) for conducting large trades over long periods of time trustlessly. It is fully permissionless and the core AMM is based on Uniswap V2. This new AMM helps traders execute large orders efficiently and will be heavily used by the Frax Protocol to increase the stability of the pegs for the FRAX & FPI stablecoins as well as return protocol excess profits to FXS holders through TWAMM purchases. The motivation for building Fraxswap was to create a unique AMM with specialized features for algorithmic stablecoin monetary policy, forward guidance, and large sustained market orders to stabilize the price of one asset by contracting its supply or acquiring a specific collateral over a prolonged period. Specifically, Frax Protocol will use Fraxswap for: buying back and burning FXS with AMO profits, minting new FXS to buy back and burn FRAX stablecoins to stabilize the price peg, minting FRAX to purchase hard assets through seigniorage, and many more market operations in development.

Core AMM

The Core AMM for Fraxswap is Uniswap V2 and based on the full range xy=k constant product design. Fraxswap has adhered to many of the design decisions of Uniswap V2 as it extended the codebase to support TWAMMs. Fraxswap v2 plans to support concentrated liquidity & correlated asset liquidity in a unique & novel way to allow TWAMM functionality across such pairs as well.

Extensive documentation on Uniswap core functionality can be found here:

Time-weighted Average Market Maker (TWAMM)

Fraxswap is the first live TWAMM implementation. The embedded TWAMM adheres to Paradigm’s original whitepaper specifications. Features mentioned in the whitepaper are used to optimize the execution of long-term orders which include: order pooling and aligning order expiries (hourly). Long-term orders are executed prior to any interaction with Fraxswap, this means the long-term orders are executed first before the AMM interaction and once per block (see above schematic). Fraxswap implements an approximation formula of Paradigm’s original formula and allows for a simplified, more gas-efficient TWAMM. The TWAMM whitepaper describes the fundamental mechanics: "Each TWAMM instance facilitates trading between a particular pair of assets, such as ETH and [FRAX]. The TWAMM contains an embedded AMM, a standard constant-product market maker for [...] two assets. Anyone may trade with this embedded AMM at any time, just as if it were a normal AMM. Traders can submit long-term orders to the TWAMM, which are orders to sell a fixed amount of one of the assets over a fixed number of blocks — say, an order to sell 100 ETH over the next 2,000 blocks. The TWAMM breaks these long-term orders into infinitely many infinitely small virtual sub-orders, which trade against the embedded AMM at an even rate over time. Processing transactions for each of these virtual sub-orders individually would cost infinite gas, but a closed-form mathematical formula allows us to calculate their cumulative effect only when needed. The execution of long-term orders will push the embedded AMM's price away from prices on other markets over time. When this happens, arbitrageurs will trade against the embedded AMM's price to bring it back in line, ensuring good execution for long-term orders. For example, if long-term sells have made ETH cheaper on the embedded AMM than it is on a particular centralized exchange, arbitrageurs will buy ETH from the embedded AMM, bringing its price back up, and sell it on the centralized exchange for a profit."

Interactive comparison of Paradigm’s TWAMM formula and Fraxswap’s TWAMM formula can be found at:

Last updated