Basic

Basics of TWAMM

What is a TWAMM?

In simple words, a TWAMM is an AMM that allows one to place a long-term order. That is, a swap transaction that swaps given tokens to desired tokens, over a specified time duration.

Contrast this to a traditional DEX swap, that immediately swaps tokens in a single block. How does swapping over multiple blocks help?

Protection against MEV attacks

Most sandwich attacks use Flash loans. While TWAMM long term orders execute over multiple blocks, and virtual orders execute between blocks. Since Flash loans need to be repaid in the same block, flash loans can’t be effectively used to sandwich Long Term orders.

Also, for MEV attacks, the attacker needs to collude with the block creator. This becomes increasingly difficult as number of blocks increases.

Low slippage for large orders

In a traditional AMM, the larger the size of the order, the more slippage is to be expected. This slippage depends on size of the order and liquidity in the pool.

But in a TWAMM, the orders are executed in many small chunks (Virtual Orders), each incurring much less slippage. Meanwhile, the gas costs are a fraction of what it’d cost if you were to execute all these swaps yourself.

Time-Weighted Average Price

Many entities, such as DAOs or derivative protocols may need to restructure their treasuries/collateral from time to time. When they do it, they wouldn’t want a huge market impact and want to dollar cost average their token purchases over time.

With LongSwap, these entities can permissionlessly, transparently and gas-efficiently swap a huge amount of tokens and get a Time-weighted average price for their orders.

Applications of TWAMM

  1. Whales executing large orders without slippage

  2. Large liquidations with less market movements

  3. DAO treasuries managing token holdings

  4. Algorithmic currencies managing buy/sell pressures.

Last updated