Integral Docs


This page explains the working mechanism of using Integral to execute TWAP 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 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.
Please visit the dedicated section to learn more about how TWAP helps minimize price impact.

How Does Integral Deliver TWAP?

TWAP is extremely useful for large orders, as the strategy minimizes price impact. However, before Integral, it is not economic to perform the strategy on-chain because:
  • Transaction Costs: If the trader splits his order into too many pieces, he 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 introduces a new design that delivers the same price-impact-mitigating effect just like physical TWAP, without the need to split your orders and pay for extra fees.

One Order, 0 Price Impact

Once the order is submitted, it will wait in the smart 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.
In terms of the amount of tokens received, this practice delivers the same result as physical TWAP without actually splitting the order, because they are both executed at TWAP.
TWAP is mathematically defined as the arithmetic mean of the prices in a period. Suppose the interval between blocks being mined is constant, and 1 ETH = 4,100 USDC on block #1, 4,110 USDC on block #2, and 4,105 USDC on block #3, then TWAP for these 3 blocks is (4,100 + 4,110 + 4,105) / 3 = 4,105 USDC.

Oracle-based Pricing

A DEX 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, whose price 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.
In other words, Integral does not have a curve. It always fills the order at the oracle twap price, regardless of order size.
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.
This is de facto “Concentrated Liquidity”. Thus, the difference between Integral Concentrated Liquidity and Uniqswap V3, is that V3 allows a trader to set the price range for their liquidity, but with Integral, this price range is controlled by the system (oracle).
Please visit the dedicated section to learn more about how Integral interacts with oracle.