Skip to content

saucepoint/v4-stoploss

Repository files navigation

v4-stoploss

test

Stop Loss Orders with Uniswap V4 Hooks 🦄

"if ETH drops below $1500, market sell my bags"

Integrated directly into the Uniswap V4 pools, stop loss orders are posted onchain and executed via the afterSwap() hook. No external bots or actors are required to guarantee execution.

image


Use Cases

  • Spot traders: protect overnight positions from downside risk

  • Leverage traders: use stop loss proceeds to repay loans. Please see examples/README.md for usage

  • Lending Protocols (advanced): use stop loss orders to liquidate collateral. Instead of liquidation bots and external participants, stop losses offer guaranteed execution

    • Note: additional safety is required to ensure that large market orders do not result in bad debt

Features

  • Guaranteed execution -- if the pool crosses the user-specified tick, the posted capital is guaranteed to market-sell

  • Asynchronous claims -- opening a stop loss order provides an ERC-1155 receipt token. Upon successful order execution, the receipt token is exchanged for the proceeds

  • Generic, reusable Hook -- the hook is deployed once, new pools can utilize the already-deployed hook


Additional resources:

v4-periphery and LimitOrder.sol

v4-core


requires foundry

# tests require a local mainnet fork
forge test --fork-url https://eth.llamarpc.com

About

Stop Loss Orders via Uniswap V4 Hooks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published