Integral FIVE

5-min TWAP and Mean-zero IL

How does the trade delay mechanism work exactly?

Generate a new TWAP every 5 min

Every 5 minutes, Integral FIVE calculates a new time-weighted average price (TWAP) based on Uniswap V2's TWAP oracle.
For example, at T+5m, the TWAP is the average Uniswap price from T+0m to T+5m.
Then at T+10m, the TWAP is updated to the average Uniswap price from T+5m to T+10m.

5-min waiting period

When a new order comes in, say, at T+3m, it will not be eligible for execution until T+8m. This is the 5-min waiting period.
At T+8m, the order becomes eligible for execution. A keeper bot will send an "execute" tx every 5 seconds to clear up all orders that newly became eligible for execution.

Orders executed with latest price reference

If an "executable" tx is mined at T+9m, it will be executed with the TWAP generated at T+5m.
If an "executable" tx is mined at T+12m, it will be executed with the TWAP generated at T+10m.

Multiple orders

Price Impact: If there are multiple orders in this execution batch, their sequence in the queue will be kept. The total slippage of the entire batch is as if all the orders are combined into one big order. But because the sequence is kept, earlier orders to have less slippage.

Mean-0 IL

Although the trade delay is a slightly negative user experience for traders, it is implemented because it is a crucial way to protect LPs.
LPs incur sure losses when sure-profit traders (arbitrageurs, front-running, etc.) are able to trade on Integral.
But with our trade delay mechanism, they can't be certain that they will make sure profits anymore, so they will trade somewhere else.
They can't be sure of the profits because they have to wait 5 minutes, and their 5-min price prediction will carry substantial risk (as former top quants, we know for sure that nobody in the world can continually make 5-min predictions with more than 70% certainty). There is a huge risk to price prediction, so their rational choice is go to some other exchanges to execute their near 100% sure-profit trades, instead of taking their, at best, 70% chances with us.

Analogy Explainer

Our LP pool is a lot like a Chinese Hot Pot where you have two soup flavors, one soup flavor is called LINK, the other called ETH. Because this is a magical pot, LINK soup can be converted to ETH soup and vice versa. And as long as the conversion rate (price) is fair, the overall pot is still full of good soup.
This is what happens when we deal with most traders: a few come in for some LINK soup and take out some ETH soup; and the next few do the opposite. Yes, of course, sometimes you have more LINK soup and sometimes more ETH soup, but these are all fair conversions. This is called "Cyclical Imbalance". Oh don't forget, you get to charge a fee for providing this conversion service.
The problem here is with toxic traders: they steal soup from you, period. And as more and more of them come through, you have less and less soup. They do that by "front-running". The key pillar of "front-running" is that they know what you don't 100 milliseconds ahead of time. It's almost entirely about a time advantage. So our counter-move also has to do with time: anyone who wants to buy soup, place your order now, but you must WAIT 5 minutes before you get your soup. They lose their time advantage, they lose their edge, and our soup pot is safe again. This is why we have a 5-min TWAP.