Everything You Wanted to Know about TWAMM (Pt.1)

In the next two blog posts, we will walk you through one of the most innovative designs in DeFi, TWAMM, how Integral SIZE was inspired by this idea, and which DeFi protocols implement this design. This is part 1.

TL; DR: A time-weighted automated market maker is a new type of DEX that lets traders place long-term orders that execute at time-weighted average prices. It works through a combination of fancy math, arbitrage opportunities and shadowy super coding.

What is TWAP?

First it is going to be helpful to understand the basics that make up the TWAMM, first is TWAP.

Time-weighted average price (TWAP) is a strategy used by traders that aims to track the price of an asset over a set time. A TWAP can better reflect the true market price of an asset by averaging its price over time. It is a more sophisticated strategy often used in traditional financial markets to execute large orders.

When trading with size in traditional financial markets, brokers will often act as intermediaries to execute individual trades. For example, a broker looking to buy $10m of ETH over the course of a day might execute 1 trade of $35,000 every five minutes and complete buying in just under 24 hours. Trading this way with small orders can minimize the price impact of the overall trade and the final execution price will be a weighted average of the day’s price.

What is an AMM?

The next part of a TWAMM is the AMM.

An automated market maker (AMM) is a type of DeFi protocol that allows users to trade assets. This works by creating a pool of two or more assets and opening users to trade against these liquidity providers.

As we’ve looked at in previous posts, traditional AMMs run with different constraints. While they allow for permissionless trading and market making, there are a host of downsides for traders and LPs.

  • Traders encounter high price impact when trading in large amounts on chain.
  • Liquidity providers are subject to impermanent loss and adverse selection, often greater than what they gain in income from fees.

What is a TWAMM?

A time-weighted automated market maker (TWAMM) is an idea proposed by Paradigm that brings together the ideas in AMMs and TWAP.

The TWAMM protocol contains an embedded AMM and allows traders to place block orders that execute over a set time. As time passes and the trades in the embedded AMM cause its price to deviate from the market, arbitragers will trade against the pool to bring the price back in line with the market. This allows trades with the TWAMM to track TWAP of an asset.

Source: Paradigm TWAMM whitepaper

Say that 0xDorsal wants to sell 1,000 ETH and 0xLegoshi wants to buy 100 ETH.

  • 0xDorsal sends 1,000 ETH sell order to TWAMM with a duration of 1 day.
  • 0xLegoshi sends USDC to the TWAMM with an order to buy 100 ETH and a duration of a half day.
  • The TWAMM takes both orders and simulates their impact on the TWAMM price as infinite small orders over the selected periods.
  • As blocks tick by, 0xLegoshi’s order is quickly filled by the offsetting sell pressure from 0xDorsal.
  • If no other buyers step in, the sell will continue to push the internal TWAMM price down.
  • If the price gets low enough, outside arbitragers can step in buy from the TWAMM at a low price and sell to the market for a spread.

Conducting large trades on a traditional AMM like Uniswap can have a bad price impact and is vulnerable to MEV frontrunning or sandwich attacks. Splitting the trade into smaller orders means paying gas fees for each transaction. The TWAMM solves this problem by representing these orders in the smart contracts state.

The TWAMM opens itself up for arbitrage opportunities. Yet it ticks along, continuing to calculate the price impact of the infinitely-spaced long-term orders from the book. This makes the final execution price of the long-term orders traded in to a TWAMM roughly track the TWAP over the specified period.

Why use a TWAMM?

Traders that are not time-sensitive can use a TWAMM to execute large orders without adverse price impact. By splitting large orders up into infinite small orders, the TWAMM replicates a strategy similar to a TWAP broker order.

By executing the just a single transaction, the trader saves fees. Furthermore,TWAP transactions are more resistant to MEV sandwich and frontrunning attacks since they occur over multiple blocks.

LPs can also benefit from the model. Since trades against the TWAMM are not as rushed, they are less likely to suffer from adverse selection that hurt LP returns.

One use case that is still to be explored is how DAOs can benefit from trading with a TWAMM or a TWAP exchange like SIZE. Many DAOs already run into issues when trying to diversify their treasury or sell tokens to fund operations. It often has negative effects on the token price, made worse in cases where tokens have low liquidity on a distributed exchange. By using a TWAP model, DAOs can buy and sell tokens with a lower price impact.

Difference between TWAMM and SIZE?

As explained above, the TWAMM uses an embedded AMM that takes long term-orders in to account by evenly spacing their price impact.

While SIZE is also inspired by Paradigm’s TWAMM concept, our implementation is a bit different. Instead of representing trades in an embedded AMM, SIZE takes the 30-minute TWAP from an on-chain oracle like Uniswap v2. Then the trade is executed against the SIZE liquidity at the 30-minute TWAP with no price impact.

The protocols also have different defense mechanisms against MEV. Since the internal market of the TWAMM works similar to the familiar Uniswap v2 AMM, and it is open to outside arbitrage, the TWAMM could still be frontrun. In addition there is a larger attack surface for MEV arbitrage that results in toxic flows to the TWAMM.

Since Size doesn’t require large orders to touch the outside market at all, there is no arbitrage within the SIZE protocol, making it resistant to MEV.

SIZE’s TWAP is zero impact and offers magnitudes higher MEV resistance.

Trade on SIZE today at https://size.integral.link.

If you would like to reach out to us to discuss it more deeply, or want to suggest a topic for us, feel free to email us info@integral.link.


Integral Insights


April 1st, 2024

Integral Insights March ‘24

We achieved several important milestones, including a new all-time-high daily volume for Arbitrum and the addition of four new pools on the Ethereum mainnet.


March 4th, 2024

Integral Insights February ‘24

Another milestone was reached on February 21st when Integral processed over $2 billion in cumulative volume.


February 1st, 2024

Integral Insights: January ‘24

Our initial launch with the ETH-RPL pool was a success, quickly elevating us to the second most utilized liquidity pool for this pair’s trading.


January 17th, 2024

Is Liquidity Fragmentation Really That Bad?

When the token evolves into a store of value, it attracts outside traders, focusing on trading costs and slippage. This is when concentrated liquidity truly shines.


January 2nd, 2024

2023 Review

At Integral, our focus remains on developing a sustainable product for on-chain trading, serving both traders and liquidity providers.


December 12th, 2023

Integral Now Rewards Liquidity Providers with Trading Fees on Ethereum Mainnet

This enhancement enables liquidity providers (LPs) to directly receive a portion or all trading fees from Integral pools.


December 6th, 2023

Integral Insights: November ‘23

During November, Integral processed an average of approximately 6 million in volume with around 1.5 million in TVL. The system’s overall capital utilization sits at around 350%. It is the 10th most used DEX on Ethereum.


November 28th, 2023

Integral Now Rewards Liquidity Providers with Trading Fees

This enhancement enables liquidity providers (LPs) to directly receive a portion or all trading fees from Integral pools.


November 15th, 2023

How Do University Blockchain Societies Gain So Many Votes?

Explore how university blockchain societies like FranklinDAO and Michigan Blockchain have grown into influential players in DAO governance, utilizing delegated votes and strategic partnerships to shape the future of DeFi protocols like Uniswap, Compound, and Aave.


November 6th, 2023

Integral Insight: October ‘23

We give an update for our work in October and highlight a profitable LP position from a long-term user.


October 26th, 2023

Understanding the Stakes in Lido’s Growing Share of Staked ETH

The community is arguing whether a protocol may have too much control over the Ethereum network. Lido controls a large percentage of staked ETH, which could have consequences for the network’s future security and neutrality.


October 14th, 2023

Changes to Staking and Farming

Looking back at our progress so far and to the future with new updates to staking and farming.


October 11th, 2023

Integral Insight: September ‘23

We give an update for our work in September with utilization going up on higher volume for our new pools.


October 11th, 2023

The Hottest Narratives of the Summer

What were the hottest narratives of the summer? Our DeFi research team delves into the growth of trading bots, RFV traders and more in this overview.


October 2nd, 2023

Uniswap Governance: A Deep Dive

Governance is considered a critical component for the decentralization and community-driven development of DeFi protocols. We take a look at one of the largest goverance ecostystems in DeFi, Uniswap. In this blog post, we'll discuss the landscape of Uniswap's governance, pulling data from empirical research to dissect the system's delegates and proposals, revealing some interesting findings.


September 19th, 2023

What is the DAI Savings Rate (DSR)?

Our research team takes a look at the DAI Savings Rate and its influence on various yield dynamics in DeFi.


September 15th, 2023

Integral Insight: August ‘23

We give an update for our work in August with cheaper gas fees and the launch of the Integral Relayer on Arbitrum!


September 7th, 2023

Integral Relayer Launches on Arbitrum

We are excited to announce the launch of the Atomic Relayer on Arbitrum. This will bring the efficient and tested system for atomic trades to the Arbitrum Layer 2 network!


August 26th, 2023

How CRV Got Sold OTC

In this post we cover how the Curve founder sold large amounts of CRV in over-the-counter trades in order to prevent a potentially catastrophic liquidation event in DeFi.


August 18th, 2023

Integral Insight: July '23

Sharing our progress in July: preparations for atomic swaps on Arbitrum, trading SIZE with lower gas fees and more.