Read

Edit

History

Notify

Share

TWAMM (Time-Weighted Automated Market Maker)

Time-Weighted automated market maker (TWAMM) is an idea proposed by Paradigm that brings together the ideas in and TWAP (Time-Weighted Average Price).
The TWAMM protocol contains an embedded 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 TWAMM to track TWAP of an asset.[1]

Overview

AMM


An 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.[7]

  • 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.

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 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.[8]

TAWMM

Time-Weighted Automated Market Maker (TWAMM) aims is to help traders execute large orders with minimal slippage and low gas fees without negatively affecting the price.[5]

The Time-Weighted Average Market Maker (TWAMM) provides the on-chain equivalent of the TWAP order. The TWAMM has specialized logic for order splitting and a direct connection to an embedded exchange, providing smooth execution for low gas cost. Arbitrageurs keep prices on the TWAMM's embedded exchange in line with market prices, ensuring execution near the time-weighted average price of the asset.[2]

Conducting large trades on a traditional like 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. MEV (Maximal Extractable Value) refers to the maximum value that can be extracted permissionlessly through the inclusion, censoring or re-ordering of transactions within a single block.[4]

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.

The TWAMM breaks these long-term orders into infinitely many infinitely small virtual sub-orders, which trade against the embedded 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.[10]

For example, if long-term sells have made cheaper on the embedded 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.

The TWAMM treats virtual sub-orders as if they take place in the space between blocks, which is important to avoid sandwich attacks.
To achieve this in a gas-efficient manner, the TWAMM uses lazy evaluation, computing the effect of virtual trades only when it is necessary to determine the outcome of an interaction.

Every time a user interacts with the TWAMM (for example, by trading with the embedded AMM or by adding a new long-term order), the TWAMM retroactively calculates the effect of all the virtual trades that took place since the last interaction.
Because these virtual trades are interacting only with the TWAMM's embedded , the behavior of the TWAMM is completely deterministic between external interactions. Even if the TWAMM goes one million blocks between external interactions, the next time somebody interacts with it, it will be able to accurately calculate the results of all of the intervening virtual trades.[2]

Limitation of TWAMM

Information Leakage by Sandwich attack

A sandwich attack is an act of pocketing a profit by executing front- and back- running — a trader looks at a pending transaction on the network and places an order right before and after the trade. For instance, when a trader finds a transaction that purchases 10 at an pool on the network, an attacker spends a gas fee higher than the transaction itself, buys the ETH right before the trade takes place, sells the ETH right after the trade to gain profits from the price differences, and on the opposite, a transaction submitter suffers a property damage and loss.[1][9]

In the case of transactions using TWAMM, it seems that the transaction is also vulnerable to sandwich attacks because the contents of the transaction are open to the public. However, orders using TWAMM run on multiple blocks and increase in size sequentially over time, making it difficult for sandwich attackers to identify targets and make solid profits because multiple arbitrage traders participate. [6]

Therefore, there is little risk of sandwich attacks running on a single block, but TWAMM may no longer be safe from that risk if sandwich attack techniques targeting multiple blocks are developed.

Paradigm’s paper also recognizes the potential for these risks and states:

At present, there is no way for an attacker to guarantee that they will only trade at the end of a given block if they also get to trade at the beginning of the next block. When such multi-block MEV becomes more common, allowing traders to sandwich across multiple blocks, this may become more of an issue. — Paradigm, TWAMM

The biggest tradeoff long-term traders are likely to encounter with the TWAMM is the information leakage they are exposed to when placing publicly visible orders, which are necessary due to the nature of .
If a trader places a sufficiently large long-term order, other traders may be tempted to front-run it, buying up the asset on the TWAMM's embedded and elsewhere in order to sell it back to the trader later as the long-term order pushes prices up.
Because users can cancel their long-term orders at any time, we expect overly aggressive front-runners to be exploited by other traders, keeping the overall impact of information leakage in check.

Drawbacks of TWAMM for Large-Scale Transactions

The disadvantages of using TWAMM compared to other large-scale transactions include the details of transactions such as the size of the fund and the transaction period disclosed, and taking a relatively long time. These disadvantages make large traders shy away from using TWAMM, and make them prefer alternatives such as P2P transactions using the OTC market.

Use case

Fraxswap, the first TWAMM
wiki
In early April, 2022, , of , was launched as the first TWAMM exchange. Regarding the launch, , the founder of , said it had introduced TWAMM to provide services for fund rebalancing of ) DAO protocols (source: Do Dive, ‘, the last piece of the puzzle for ‘Next Curve’). DAOs have a continuous demand for funding rebalancing and have a strong anti-price incentive for their transactions, which meets the major user requirements of the TWAMM mentioned earlier, so they are presumed to have served the stated purpose.[6]

See something wrong? Report to us.

TWAMM (Time-Weighted Automated Market Maker)

Commit Info

Edited By

0x2E66379061a2A39ccf38cE73d6144665C7eDC3E1
Jaewon_Cho

Edited On

May 21, 2023

Feedback

Average Rating

No ratings yet, be the first to rate!

How was your experience?

Give this wiki a quick rating to let us know!

REFERENCES

Join the IQ Brainlist

Sign up for the IQ Brainlist to get early access to editing on the IQ.wiki site!

Join Now

Subscribe to our newsletter

The IQ Ecosystem Report will keep you updated on everything IQ.

Subscribe

IQ.wiki

IQ.wiki's vision is to bring blockchain knowledge to the world and knowledge onto the blockchain. A part of Brainfund group

https://twitter.com/IQWIKIhttps://www.reddit.com/r/Everipedia/https://t.me/everipediahttps://www.instagram.com/iqwiki_/https://github.com/EveripediaNetworkhttps://discord.gg/x9EWvTcPXthttps://web.facebook.com/everipedia?_rdc=1&_rdr

IQ

What's IQ?StakingBonds

Company

About usCareersBrandingIQ GPTIQ Dashboard

© 2024 IQ.wiki Powered By BrainDAO & IQ