Take-Profit / Stop-Loss (TP/SL)
Atlas supports automatic position closing based on price targets. Set a take-profit to lock in gains or a stop-loss to limit losses.
How It Works
- Set TP/SL prices when opening a position, or add them to an existing position
- The app creates or updates the on-chain trigger/order state for that position
- Atlas monitors oracle prices in real-time
- When the price crosses your target, a close transaction is triggered
- Your position is closed and PnL is settled
Setting TP/SL
When Opening a Position
Include take_profit_price and/or stop_loss_price in your order. Both are optional — you can set one, both, or neither.
On an Existing Position
Use the Set TP/SL button on your active position. You can set one, both, or clear them at any time.
Setting or clearing TP/SL may require a wallet signature because Atlas keeps position-related actions visible and cancellable through on-chain order/trigger state.
Trigger Conditions
| Direction | Take-Profit | Stop-Loss |
|---|---|---|
| Long | Price rises to ≥ TP price | Price drops to ≤ SL price |
| Short | Price drops to ≤ TP price | Price rises to ≥ SL price |
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /position/tpsl | Set or update TP/SL on an active position |
DELETE | /position/tpsl | Clear TP/SL from a position |
You can also set TP/SL when opening a position by including take_profit_price and/or stop_loss_price in the open order request.
How It's Executed
When your TP/SL condition is triggered:
- The Position Monitor Service detects the price crossing your target
- A
CloseTPSLtransaction is automatically built and submitted on-chain - The on-chain validator verifies the oracle price and calculates your final PnL
- Your payout (collateral + PnL - borrow fees) is sent to your wallet
Trigger execution itself does not need a fresh wallet signature — the protocol operator executes the close on your behalf, with on-chain guarantees that you receive the correct payout. Creating, changing, or clearing the TP/SL trigger can still require your signature.
Important Notes
- Execution price: Your position closes at the oracle price when processed, which may differ slightly from your target price
- Borrow fees: Normal borrow fees still apply to the position until it's actually closed
- Order visibility: TP/SL setup, clear, and triggered closes can appear in Orders or History while the related transaction is being indexed or processed