A ZKDepth limit order sells one token for another once the price reaches a level you choose, and earns swap fees while it waits. It is a narrow Uniswap v3 position placed just beyond the current price, held by the RangeOrders contract.
Setting the price
You choose a side, a limit price and an amount in the Limit mode of the ticket on the Trade page. A sell puts the asset into a band above the market, and a buy puts the other token into a band below it.
The order converts as the price walks across the band, so your average price lies between its two edges: about 0.1 % apart on a 0.05 % pool, 0.6 % on a 0.30 % pool and 2 % on a 1 % pool. The button stays locked while the pool's own price and the API's differ by more than 100 bps. Only v3 pools are supported. DLMM pairs have a second kind of order that rests in a single bin, see ZKDepth pools.
place takes ETH when the sold token is WETH, or pulls the token after an exact-amount approval. The contract mints the position to itself, so a fill needs no approval from you. Your claim is the order's owner field, which cannot change.
When an order is done
A sell-token0 order is fully converted once the tick reaches tickUpper. A sell-token1 order is fully converted once the tick drops strictly below tickLower. fillable(orderId) answers this, and a partly crossed band is not fillable.
Until fill runs, the order is ordinary liquidity. If the price crosses the band and returns through it, the pool converts the order back into the token you were selling, and it waits for the next cross. One the price never reaches stays open, earning fees, until you cancel it.
Closing an order
fill | cancel | |
|---|---|---|
| Who | anyone, once fillable is true | the owner, any time while open |
| Caller's bounty | 1 % of the converted principal | none |
| Protocol | 10 % of the fees earned | 10 % of the fees earned |
| You receive | everything else | the position as it stands |
The protocol's share goes to the FeeRouter, booked to you so that your referrer earns 20 % of it. A closed order cannot reopen.
In practice ZKDepth's keeper bot closes orders. Every minute by default it reads fillable for every open order and sends fill only when the bounty is at least three times the estimated gas, so a small order may wait. You can close a crossed order yourself: fill brings the 1 % back to you.
A filler may push the price through the band and then close the order. That trade pays the position fees on the way and can only happen at or beyond your price. The proceeds always go to the owner.
contracts/src/RangeOrders.solplace, fillable, fill, cancel and the fee splitapps/web/lib/trade/limit.tslimitBand and earnsPerDayUsdapps/api/src/bots/keeper.tssweepRangeOrders: fillable in one batch and the bounty in wei