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
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.
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 scenarios
Aimed to abstract the gas accounting into its own contract
There is no front-end, please run the tests to the concept.