TVL–
Volume 24h–
Fees (all time)–
Paid to lockers–
Buybacks–
Epoch ends in–

Limit orders

A limit order is single-sided liquidity in one tick-spacing range on the far side of the price. While the price trades through the range the order fills and earns the market's LP fees; once the price is through the whole range, it is closed and locked in.

Life of an order

  1. place(key, tickLower, zeroForOne, amountIn): selling token0 sits entirely above the current tick, selling token1 entirely below; the range is one tick spacing wide (0.1% on stock markets with spacing 10).
  2. Orders at the same market, tick and side share one v4 position per epoch. Each order gets the LP fees the range earned while it was in it (booked per unit of liquidity), whether it is filled or cancelled.
  3. When the price is through the whole range, close (or closeMany) removes the position, takes the fill fee (0.05%, cap 0.5%) for the RevenueRouter and marks the epoch filled. Our keeper does it within seconds; anyone can.
  4. Owners call withdraw(epoch, to) for their share. Before the range is fully crossed, cancel returns the order (both tokens if the price is inside the range).

Important

Until a crossed range is closed, the order can turn back if the price returns. Order positions are not NFTs, so they earn no Points and no LP emissions. Native ETH orders send ETH as value; dust is refunded.

import { buildPlaceLimitOrder, limitOrderRange } from "@blackhookfinance/sdk";
const r = limitOrderRange(currentTick, key.tickSpacing, true, targetTick); // sell token0
const call = buildPlaceLimitOrder(d, { key, tickLower: r.tickLower, zeroForOne: true, amountIn });