SWAP WITH TWAP
This page explains the working mechanism of swapping on Integral SIZE, and summarizes the main benefits you can draw from using this product over interacting with decentralized exchanges or aggregators for your large orders.
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.
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.
TWAP is extremely useful for large orders, as the strategy minimizes price impact. However, before Integral SIZE, 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 SIZE 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.
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.
More importantly, both practices do not experience price impact.
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 SIZE, 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 SIZE 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.
Please visit the dedicate section to learn more about how Integral SIZE interacts with oracle.
Integral SIZE is for everyone. Whether you are a long-term investor, a HODLer, a day trader, or a farmer, with Integral SIZE:
- 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 SIZE 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 SIZE.
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 SIZE, 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.
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.
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.
*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 SIZE is 50,000 GWEI.
Note that Integral SIZE has low/no risk for getting sandwich attack because it is very difficult for non-atomic trade to get affected by sandwich attackers and flashloans. Further, the 30-min TWAP price oracle for a token with decent liquidity is very hard to manipulate.
According to our empirical studies, a 0.5% slippage tolerance will deliver 90% success rate for 30-min TWAP orders.