level
Mid Level Reading
24 May, 2024

Time-Weighted Automated Market Maker (TWAMM)

[ taim wey-tid au-to-mated mar-ket ma-ker ]

The Time-Weighted Automated Market Maker (TWAMM) allows DEXs to process large trades with minimal price impact and reduced gas fees.

Susan Oh
Written by
Susan Oh
Susan Oh Susan Oh Author
Susan Oh is a leading figure in the integration of AI and blockchain for social good, serving as the CMO for BeOmni by Beyond Imagination and a civic technologist dedicated to creating scalable solutions. She is a board member of the Blockchain Commission For Sustainable Development supported by the UN GA Office of Partnerships, and...
Sam Kazemian
Fact checked by
Sam Kazemian
Sam Kazemian Sam Kazemian Expert
Sam Hamidi-Kazemian is an accomplished American software engineer and entrepreneur. As the Co-Founder and President of Brainfund, he has demonstrated exceptional leadership in the tech industry. Sam pursued higher education at the University of California, Los Angeles, graduating with a double major in neuroscience and philosophy. During his time at UCLA in 2014, Sam co-founded...

The time-weighted automated market maker (TWAMM) is a decentralized finance component designed for dividing and executing large orders with minimal price impact or transaction fees (gas). 

The Overview of AMM

Crypto Automated market makers (AMM) ensure that a token pair is always tradeable at any value or time. AMMs manage two token pools with limited amounts and regulate their prices based on an algorithm to balance supply and demand.

The earliest version is called Constant Product Market Maker (CPAMM), as outlined by Vitalik Buterin in 2017. Uniswap v1 was the first Ethereum decentralized exchange (DEX) to implement it (TWAMM added to Uniswap v4).

Automated Market Makers

AMMs replace traditional order books, which centralized exchanges (CEXs) use to match prices for buyer and seller orders. 

For example, the constant product formula (xy=k) changes prices based on quantity proportions to guarantee token supplies for both pools.

The CPAMM algorithm prevents token supply shortages
The CPAMM algorithm prevents token supply shortages | Source: Dev.to

The AMM “ecosystem” involves liquidity providers, arbitrageurs, and traders. Providers deposit both tokens in exchange for incentives, traders swap them while unbalancing prices and arbitrageurs profit from the difference on other exchanges to rebalance them. 

In ideal conditions, traders get prices similar to those in large exchanges, and providers withdraw token pairs at original liquidity ratios (typically, 50/50).

If prices aren’t rebalanced quickly, traders swap with a price gap called spread.

For large buyers, not only may there be insufficient liquidity, but tokens become more and more expensive. Hypothetically, buying 100% of token A would cost an infinite amount of token B. TWAMM can prevent this.

The Time-Weighted Average Market Maker

TWAMMs aim to replicate the TWAP strategy used for traditional brokers (time weighting average prices). This strategy makes buyers split large orders into smaller ones executed evenly over minutes or days. It’s similar to dollar-cost averaging but with a higher frequency.

For example, TWAMMs may break down a $10M swap into $100,000 trades executed every 10 minutes (or every block), giving enough time to rebalance prices with arbitrageurs but short enough to avoid market volatility (in this case, ~16h).

As a result, the average execution price of $10M is much closer to the price where the order was first placed.

(Even if the pool only has $3M, arbitrageurs keep replacing them externally until they surpass the $10M trading volume.)

ETH supply change based on the number of order splits
ETH supply change based on the number of order splits | Source: Paradigm.xyz

Doing this isn’t efficient since every split adds up gas fees (in theory, infinite). TWAMMs prevent this with various built-in features (such as order pooling and lazy evaluation). Thus, accumulating small orders incurs similar costs to a single large swap—without the price impact.

On volatile markets, prices can sharply change before the swap completes, which is why traders are allowed to cancel it anytime.

What Are the Benefits of TWAMM

When using a time-weighted automated market maker in crypto:

  • Smoother price execution: Large orders have a minimal price impact on liquidity pools, achieving prices similar to those of large exchanges.
  • Simplified trading: Traders can execute large trades without having to switch to trading desks or CEXs, and without having to monitor orders manually.
  • Amplified liquidity: If orders are split and spaced out sufficiently, it’s possible to swap larger amounts than the maximum tokens held.
doc ico
Article Sources
arrow ico

Coinweb requires writers to use primary sources to support their work. These include white papers, government data, original reporting, and interviews with industry experts. We also reference original research from other reputable publishers. You can learn more about the standards we follow in producing accurate, unbiased content in our editorial process.

Susan Oh
Written by

Susan Oh is a leading figure in the integration of AI and blockchain for social good, serving as the CMO for BeOmni by Beyond Imagination and a civic technologist dedicated to creating scalable solutions. She is a board member of the Blockchain Commission For Sustainable Development supported by the UN GA Office of Partnerships, and a member of the Global Sustainability Network, a joint initiative by the Vatican and the Church of England to combat human trafficking. Recognized with the Quantum Impact Award #DecadeOfWomen by the UN GA as one of the top frontier women in digital, Susan speaks globally on leveraging AI and blockchain for the UN’s sustainable development goals.

In 2017, she co-founded Muckr.AI, a platform using machine learning to evaluate content trustworthiness. Additionally, Susan contributes her expertise to Coinweb as a journalist, covering advancements in blockchain and crypto technologies. Her work across these diverse roles underscores her commitment to using technology for transparency, trust, and positive societal impact.

More crypto lingo