← Back to home

Uniswap V4 Hooks - Stop Loss Orders

Onchain stop loss orders courtesy of Uniswap V4 Hooks. Guaranteed execution offers great UX for spot traders, leveraged positions, and protocols

Screenshots

Uniswap V4 Hooks - Stop Loss Orders screenshot 1
Uniswap V4 Hooks - Stop Loss Orders screenshot 2
Uniswap V4 Hooks - Stop Loss Orders screenshot 3
Uniswap V4 Hooks - Stop Loss Orders screenshot 4

Problem Statement

Stop loss orders: "if the price falls below a trigger price, market sell the asset"With the Uniswap V4 preview, hooks introduced programmability to the swap lifecycle -- this feature creates new opportunities for trading UX. For the hackathon, I decided to implement onchain stop loss orders.While stop loss functionality can be built with external actors, there are trust assumptions around execution. Enabling onchain stop loss orders results in guaranteed execution -- to the benefit of all participants. For example, this order type can supercharge leverage users by trustlessly procuring funds for debt repayment. Protocols could also adopt stop loss orders to facilitate liquidations (assuming additional safety checks for market depth) -- instead of relying on external liquidators.

Solution

Just another classic foundry repo -- 100.0% solidity.The project defines a Hook contract which will enable new V4 pools to support stop loss orders. To showcase potential use-cases, the project includes example orders that are used to repay loans on Spark (MakerDAO) and Compound III.

Hackathon

ETHGlobal Waterloo

2024

Prizes

  • 🏆

    🥇 Compound Grants Program — Best Use

  • 🏆

    🥇 MakerDAO — Best Use

Contributors