Take Profit & Stop Loss
How to automate your exits on Project 0 with take profit and stop loss orders.
Take profit (TP) and stop loss (SL) orders close a position automatically once its value reaches a level you choose. You set the levels once, and keepers watch the position and execute the order for you, so you don't need to keep the app open.
How Orders Work
An order covers one pair: one collateral position and one debt position in the same Account. It watches the pair's net value, collateral minus debt, in USD.
- Take profit triggers when the net value reaches your level or higher.
- Stop loss triggers when the net value falls to your level or lower.
You can set either one, or both. When an order triggers, a keeper withdraws your collateral, swaps it into the debt asset, and repays the debt in full. You keep the remaining collateral.
Before: $5,000 SOL collateral, $4,000 USDC debt, net value $1,000
TP hit: SOL rises, net value reaches your $1,200 take profit
After: debt repaid, ~$1,200 of SOL left in your Account (minus the closing cost)Each pair can have one order. Setting a new order on the same pair replaces the old one.
The net value is measured the same way the order trigger measures it, using EMA prices with a confidence margin, so it can differ slightly from the value on your portfolio page.
Setting an Order
When Looping
- Set up your loop as usual (see Looping & Strategies).
- In the Take profit / Stop loss card, click Set.
- Enter your take profit and/or stop loss as a net value in USD. The app shows the gain or loss each level means.
- Check the Max closing cost (see below), then click Save and close.
- Click Loop. The order is placed together with the loop.
On an Existing Position
- Open the Orders tab on your portfolio and click New order, or choose Set TP/SL from a position's menu.
- Select the collateral and debt positions the order covers.
- Enter your levels and max closing cost, then click Place order.
Open orders show in the Orders tab, with where the net value sits between your levels. From there you can Adjust or close an order. Executed and closed orders move to History, and the notification bell lets you know when one executes. An open order can also end up unable to execute; see Orders That Can't Execute.
Max Closing Cost
Closing a position costs something: the swap from collateral into the debt asset, plus the keeper's fee. Max closing cost caps that total, as a percentage of your take profit or stop loss level. The keeper can claim any remaining amount within your limit after the swap.
- Too low, and the order may not execute when triggered, because the swap doesn't fit inside the limit.
- Too high, and you may pay more than you need to.
The swap covers your whole debt, so the cost grows with leverage. On a 5x position, the debt is four times the net value: a 1% swap cost on the debt is 4% of your net value.
The app shows a Suggested range under the max closing cost, based on a live swap quote for closing your position. Setting your max closing cost inside that range is the easiest way to get it right.
Limits
You set one max closing cost, and it applies to both levels.
If the position is worth more than your take profit level when the order executes, the keeper can also take the difference, up to a protocol cap. For example, with a $10,000 take profit and a 2% max closing cost, you keep at least $9,800, even if the order executes when the position is worth $10,500.
If a take profit needs more than the protocol cap to close, it can't execute. This mainly affects highly leveraged positions.
Costs
| Cost | Amount | When |
|---|---|---|
| Order fee | 0.002 SOL | Every time you place or update an order. Not refunded. |
| Order rent | ~0.002 SOL | Paid when you place an order. Refunded when you close it yourself; kept by the keeper when the order executes. |
| Closing cost | Up to your max closing cost | Only when the order executes. |
When an Order Closes Automatically
Orders are tied to the exact positions they cover, so the app closes an order, and refunds its rent, when you:
- Change one of its positions. Depositing, withdrawing, borrowing, repaying, swapping, or looping on either asset closes the order in the same transaction. The app warns you before you confirm. Set the order up again afterward if you still want it.
- Close or transfer the Account. Its orders are closed first.
Orders That Can't Execute
An order can stay open after it can no longer execute. For example:
- You withdrew or repaid one of its positions outside the app, so the order wasn't closed along with it.
- Two orders share the same collateral, and the other one executed first.
If one of an order's positions is gone, the Orders tab shows the order as Orphaned. Anyone can close an orphaned order and claim its rent, and keepers clean up some of them. Close it yourself to get the rent back.
Which Positions Qualify
Most collateral and debt pairs can have an order. These can't be used as the collateral side:
- Isolated assets, since they count as zero toward the order
- Native stake
- Fixed-price assets
Positions on a paused Bank can't have an order either.
Risks
- Execution price. A stop loss executes at the net value when the keeper reaches it, not exactly at your level. In a fast move, that can be below your stop loss.
- Liquidation. A stop loss can close your position before it's liquidated, but it isn't guaranteed to. In a fast move, liquidation can come first. Keep your stop loss well above your liquidation level; the app blocks stop losses at or below it.
- Orders that don't execute. If the max closing cost is too low for current market conditions, a triggered order waits until the close fits inside the limit.
Project 0 makes no guarantee that an order will trigger or execute, and takes no financial responsibility if it fails to.
FAQ
Do I need to keep the app open?
No. Orders live on-chain, and keepers execute them whenever they trigger.
Can I set different orders for different loops?
Yes. Each collateral and debt pair has its own order. Use separate Accounts for loops on the same assets; see Managing Your Account.
Why did my order disappear after I added to my position?
Any action on one of the order's positions closes the order, because the levels you set no longer match the new position. Set it up again with levels for the new size.