"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.
-
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
-
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
requires foundry
# tests require a local mainnet fork
forge test --fork-url https://eth.llamarpc.com