Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saucepoint/v4-stoploss
Stop Loss Orders via Uniswap V4 Hooks
https://github.com/saucepoint/v4-stoploss
Last synced: about 1 month ago
JSON representation
Stop Loss Orders via Uniswap V4 Hooks
- Host: GitHub
- URL: https://github.com/saucepoint/v4-stoploss
- Owner: saucepoint
- License: mit
- Created: 2023-06-23T22:07:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-27T21:03:45.000Z (about 1 year ago)
- Last Synced: 2024-10-23T05:36:33.082Z (about 2 months ago)
- Language: Solidity
- Size: 72.3 KB
- Stars: 77
- Watchers: 3
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-uniswap-v4-hooks - Stop Loss Order
- awesome-uniswap-hooks - Stop Loss Order
- awesome-uniswap-v4-resources - Stop Loss Order
- awesome-uniswap-v4-resources - Stop Loss Order
README
# v4-stoploss
[![test](https://github.com/saucepoint/v4-stoploss/actions/workflows/test.yml/badge.svg)](https://github.com/saucepoint/v4-stoploss/actions/workflows/test.yml)
### **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](https://github.com/saucepoint/v4-stoploss/assets/98790946/bf049297-2629-48bb-a0bd-8be22f6ace13)
---
## Use Cases
* Spot traders: protect overnight positions from downside risk
* Leverage traders: use stop loss proceeds to repay loans. Please see [examples/README.md](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](https://github.com/uniswap/v4-periphery) and [LimitOrder.sol](https://github.com/Uniswap/v4-periphery/blob/main/contracts/hooks/examples/LimitOrder.sol)
[v4-core](https://github.com/uniswap/v4-core)
---
*requires [foundry](https://book.getfoundry.sh)*
```shell
# tests require a local mainnet fork
forge test --fork-url https://eth.llamarpc.com
```