TWAMM Protocol is a new form of AMM that was designed by Paradigm and realized in Pulsar.
While current Automated market makers (AMM) like Uniswap allow traders to swap a pair of assets instantaneously, traders may experience loss of assets due to high price impact (i.e. high slippage) in large order trades, hence are more susceptible to being front-run.
In centralized finance, large trades are handed over to brokers who place algorithmic trades over a period of time. One such technique is using the TWAP Order.
TWAP order is a type of algorithmic trade that allows an order to be placed over a period of time, in order to mitigate assets loss by reducing price variations.
The Time-Weighted Average Market Maker (TWAMM) provides the on-chain AMM equivalent of the TWAP order.
Pulsar TWAMM also contains an embedded AMM, a standard constant-product market maker for those two assets, Instant Swap and Term Swap. Anyone may trade with this embedded AMM at any time, just as if it were a normal AMM.
TWAMM consists essentially of 4 parts.
Traders can submit long-term orders to the TWAMM through Term Swap. Long-term orders are sold through a fixed period of time (i.e. number of blocks), rather than the common AMM, which executes orders instantaneously.
The TWAMM breaks these long-term orders into infinitely many small virtual sub-orders, which trade against the embedded AMM at an even rate over time.
The execution of long-term orders in the form of small virtual sub-orders will push the price of the embedded AMM away from the price in other markets over time.
When embedded AMM’s price is different from prices in other markets, arbitrageurs will trade against the embedded AMM’s price to bring it back in line through instant swap or term swap, ensuring good execution for long-term orders, and earning profits.
With TWAMM, a DAO Treasury buyback can simply put in a buy-back order with the amount and number of blocks to execute the order in a given period of time.
For example, a DAO decides to buy back 10 million DAOToken worth of USDC over the next week (i.e. about 50,400 blocks). The DAO creates a long-term order in TWAMM to sell 10 million USDC over 50,400 blocks, or 19.84 USDC per block.
TWAMM will then split the long-term orders into trillions of tiny suborders known as virtual orders. The TWAMM then takes turns executing the virtual orders of buying DAOToken against its embedded AMM.
Because The DAO is buying much more DAOToken than the DAOToken-USDC pool is selling, the price of DAOToken on the embedded AMM will go up each block.
When this price is sufficiently high relative to the prices for DAOToken elsewhere, arbitrageurs will buy that cheaper DAOToken on other exchanges and sell it on the embedded AMM through Instant Swap or Term Swap, bringing its prices back in line with the market average and ensuring good execution for DAOToken buyback.
And after a week, DAO's long-term order will expire, and the buyback will be completed. And the execution price of this long-term order is roughly the average price over this week.