TP/SL Orders
Automate exits with take-profit and stop-loss orders.
Take-Profit & Stop-Loss Orders
Lavarage supports server-side TP/SL orders that automatically close your position when a price target is hit.
How It Works
- You create an order specifying a trigger price
- The server monitors the asset price continuously
- When the trigger is hit, the server signs and submits a close transaction using your Privy wallet
- The position is closed at the best available market price
Creating a Take-Profit Order
curl -X POST https://api.lavarage.xyz/api/v1/orders \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"positionAddress": "YOUR_POSITION_ADDRESS",
"walletId": "privy-wallet-id",
"orderType": "TAKE_PROFIT",
"triggerPrice": "160.00",
"side": "LONG"
}'
Creating a Stop-Loss Order
curl -X POST https://api.lavarage.xyz/api/v1/orders \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"positionAddress": "YOUR_POSITION_ADDRESS",
"walletId": "privy-wallet-id",
"orderType": "STOP_LOSS",
"triggerPrice": "130.00",
"side": "LONG"
}'
Order Behavior by Side
| Side | Take Profit | Stop Loss |
|---|---|---|
| LONG | Triggers when price >= target | Triggers when price <= target |
| SHORT | Triggers when price <= target | Triggers when price >= target |
Managing Orders
List orders for a position:
curl "https://api.lavarage.xyz/api/v1/orders?positionAddress=YOUR_POSITION" \
-H "x-api-key: YOUR_KEY"
Cancel an order:
curl -X DELETE https://api.lavarage.xyz/api/v1/orders/ORDER_ID \
-H "x-api-key: YOUR_KEY"
Order Statuses
| Status | Meaning |
|---|---|
| ACTIVE | Monitoring price, not yet triggered |
| EXECUTED | Price target hit, position closed |
| CANCELLED | Cancelled by user |
| FAILED | Execution attempted but failed (e.g. insufficient liquidity) |
Important Notes
- You can have one TP and one SL per position simultaneously
- Orders require a Privy wallet ID for server-side transaction signing
- Execution is best-effort — in extreme volatility, the executed price may differ from the trigger
- Orders are automatically cancelled when a position is manually closed
Updated 4 days ago