Back to Blog


This post explains the working mechanism of swapping on Integral TWAP, and summarizes the main benefits you can draw from using this product over interacting with decentralized exchanges or aggregators for your large orders.

What is TWAP?

Time-Weighted Average Price (TWAP) is a trading algorithm based on weighted average price used to execution of bigger orders without excessive impact on the market price.

The most common use of TWAP is for distributing big orders throughout the trading day. Let’s say you want to buy 100,000 ETH. Putting one such a big order would vastly impact the market and the price most likely would start to raise. To prevent that, trader can define time period in TWAP Strategy over which they want to buy ETH. It will slice evenly big order into smaller sub-ones and execute them over defined period. The TWAP price of the large order will be the arithmetic mean (average) of the prices used to execute these sub-orders.

The Benefit of TWAP

TWAP is highly used to minimize a large order's price impact and result in price improvement, because:

  • It allows market liquidity to recover during the intervals between orders.
  • It lowers the possibility that other market participants notice your large order and interpret it as sell/buy signal.

How Integral Delivers TWAP

TWAP is extremely useful for large orders, as the strategy minimizes price impact. However, before Integral TWAP, it is not economic to perform the strategy on-chain because:

  • Transaction Costs: If the trader splits her order into too many pieces, she can end up spending more money on fees and gas than on actually buying ETH.
  • Constant Product AMM (CPAMM): In traditional finance, intervals between orders will give professional market makers to respond to instantaneous demand for liquidity, thus moving more capitals to the mid-price. However, this situation does not apply to CPAMM, whose liquidity is managed by mostly individual LPs, and they are not quick enough to respond to this surge in demand for liquidity promptly. If the liquidity cannot recover on time, it is meaningless to extend the time window of execution.

Therefore, Integral TWAP introduces a new design that delivers the same price-impact-mitigating effect just like traditional TWAP, without the need to split your orders and pay for extra fees.

One Order, 0 Price Imapct

Once the order is submitted, it will wait in the smart contract contract for 30 minutes before interacting with the pool. During this time, the protocol will pick up price information from the Uniswap V2 oracle, and calculate TWAP. After 30 minutes elapses, the protocol will execute the whole order at TWAP.

TWAP is mathematically defined as the arithmetic mean of the prices in a period. Suppose 1 ETH = 4,100 USDC on block #1, 4,110 USDC on block #2, and 4,105 USDC on block #3, TWAP for these 3 blocks is (4,100 + 4,110 + 4,105) / 3 = 4,105 USDC.

Oracle-based Pricing

DEXs like Uniswap relies on curves to deduce price between two assets based on their amounts in the pool. A large swap will both increase and decrease the amount of assets, thus changing the ratio/price substantially and resulting price impact.

This does not apply to Integral TWAP, whose prices is solely determined by the oracle. Even if a large order does change the ratio between two assets, it will not affect the TWAP used to execute the order.

The curve of Integral TWAP is actually a flat line. It creates the effect that the WHOLE liquidity of the pool is concentrated on the price point of TWAP. In theory, you can even swap all the liquidity out of the pool with 1 single TWAP.

Who Needs Integral TWAP

Integral TWAP is for everyone who would like to get a trade executed at the next 30-min TWAP. Whether you are a long-term investor, a HODLer, a day trader, or a farmer, with Integral TWAP:

  • You no longer need to write a customised SC to split large orders into small ones;
  • You no longer have to manually execute smaller orders across multiple venues;
  • You should be less concerned with sandwich attacks as your orders will be executed at 30-min TWAP.
  • With one click, you get 30-min TWAP for your orders. There is no additional slippage versus the 30-min TWAP.

However, saving with Integral TWAP would be the most when you have a large order to execute.

  • This is because when you have a large order to do, the price quote you get is almost never your executed price due to price impact (and even sandwich attack).
  • The larger the order, the larger the price impact, and hence the larger the saving would be with Integral TWAP.

How Much Will I Get from TWAP?

TWAP can help you minimize price impact, but it also exposes you under the risk of price volatility. Therefore, it is very important to get a proper estimation of how much you'll get from the trade, and tells the protocol when to stop if the execution price really diverges from your expectation.


When you input an amount into Integral TWAP, the system will display an estimated amount that you may receive through 30 min TWAP. The estimation is calculated based on the current Uniswap v2 spot price, and does not take price impact into consideration.

The Estimated Amount = Amount of Input Token * (1-0.1%) * Uniswap Spot Price

Minimum Received and Slippage Tolerance

Due to market movement, there will always be some difference between the TWAP and the spot price when you submit the order, and sometimes you may get fewer tokens from TWAP.

Located at the bottom of the swap interface, the Minimum Received corresponds to the worst-case scenario for your trade. After 30-min wait time elapses, if the actual amount of tokens you'll receive is less than Minimum Received, your order will be reverted to protect your funds.

Minimum Received = Estimated Amount * (1 - Slippage Tolerance)

The default slippage tolerance is 0.5%, and you can change it in the Advanced Settings (gear icon). However, we suggest you to only change it when the market is highly volatile and your order keeps being reverted.

Cost Benefit Analysis

*Manually splitting orders could possibly reduce the price impact, but it's hard to perform due to the fact that trader lacks the knowledge of when and how liquidity in the pool will be improved by LPs. Also, it's prone to sandwich attack.

** The current gas estimation of a swap on Integral TWAP is 50,000 GWEI.

*** Integral TWAP has low/no risk for getting sandwich attack because it is very difficult for non-atomic trade to get affected by sandwich attacker and flashloans, and oracle for a large pair is very hard to manipulate.