Get Mystery Box with random crypto!

The Uniswap Protocol is a vital piece of crypto infrastructure | 🦄Uniswap🦄DeFi🦄PreSale🦄News

The Uniswap Protocol is a vital piece of crypto infrastructure for millions of swappers, offering deep liquidity to support over $1.6 trillion in volume. Uniswap v4 is the latest evolution of the Protocol, which allows developers to build custom AMM features on top of Uniswap using hooks.

The truncated oracle is an onchain price oracle that records the price of an asset in a Uniswap liquidity pool using the geometric mean formula. This oracle is then truncated -- meaning the recorded price can only move up or down to a maximum amount in a single block.

Truncation helps smooth out the price impact of large swaps over time -- whether they are legitimate or malicious. If a bad actor tried to manipulate the price, they would have to sustain their manipulation over many blocks -- making the truncated oracle much costlier to manipulate.

How it works

The hook contract stores a copy of the pool's price. In Uniswap v3 and v4, these prices are represented as ticks. Before a swap or LP adjustment, the hook compares the pool's current tick to the tick stored in its contract. If the difference between these two numbers is less than some number (we use 9,116 based on our research), then the hook will update to this new tick. However, if the pool's current tick has moved more than 9,116 units, the oracle will cap its tick value to +- 9,116, limiting how much a pool's tick can move in a block.

After the hook has updated, swap or LP transactions will execute until the block is over. The cycle then repeats the next block that triggers the hook contract. By truncating how drastically price (tick) swings can be recorded, the oracle ignores outliers and smoothes out the price impact of large swaps. If a large price swing is sustained, then the oracle would quickly catch up to the pool’s tick.

To learn more - https://blog.uniswap.org/uniswap-v4-truncated-oracle-hook

Contact
To get in touch, please email [email protected] or telegram @uniswapkevin