← Back to home

Uniswap V4 Hook

A hook that executes stop loss orders when prices move down. Instead of a free ride on the swap that initiated the price decrease, there is gas accountability

Screenshots

Uniswap V4 Hook screenshot 1
Uniswap V4 Hook screenshot 2
Uniswap V4 Hook screenshot 3

Problem Statement

V4 hooks are executed in the context of the transaction initator. If a stop loss order is triggered, it will thus be paid for by the initiator of the swap which caused the tick range to change. This means that the stop loss order will effectively get a free ride, gas paid for by the original swap initiator. This hook aims to mitigate this by requiring an eth deposit when the stop loss order is placed. When the order is triggered, the deposit is transferred to the original swap initiator.

Solution

using a template for v4 hooks; converted an example TakeProfit hook to be a stop loss hook instead.All solidity code with some tests to cover basic scenariosAimed to abstract the gas accounting into its own contractThere is no front-end, please run the tests to the concept.

Hackathon

ETHOnline 2023

2023

Contributors