
Rollback Hook
Rollback Hook lets prediction market LP's undo the past hour of trades to limit sudden price swings
Demo
About
Rollback Hook is an [Uniswap V4 hook](https://docs.uniswap.org/contracts/v4/quickstart/hooks/swap) hook built for prediction markets, giving liquidity providers a way to manage risk during rapid price movements. It introduces a mechanism where queued trades can be reversed for up to one hour before becoming permanent. This provides protection when markets experience sudden volatility, such as moments when an outcome becomes clear even though the market is still officially active. [The contract is deployed on Sepolia](https://sepolia.etherscan.io/address/0x69a4917737b578d5a917ee70118dc1c21c3d00c0) The pool deployer can choose when to trigger a rollback. Once this happens, the pool is no longer usable, and liquidity providers can withdraw their positions. The deployer holds only this single privilege: the ability to revert up to one hour of recent trades, without any additional control over the market.
How it's made
Rollback Hook is built using Solidity, Typescript and Viem. It then utilizes eth_ethSimulateV1 to run tests on top of ethereum mainnet directly. ethSimulate testing frame work had already been built and is not part of the project itself, but used as a tool to conduct testing. The contract is then deployed on sepolia. The tests utilize DAI and weth tokens currently and no real prediction market tokens are used, but could be easily added to the system.