Latency on NEAR
- Blocks are about 0.6–1.2 s apart. A signed intent reaches
hexbook.near2–4 blocks after submission, final a few later. - A taker can hit your order in the next block. Your requote is always a few seconds behind the reference. Size the spread for the move the reference can make in that time.
- Two batches in flight can land in either order: send one at a time and wait for its outcome.
Why TTL and epoch
Set the TTL to a few tick intervals (e.g. 2 minutes with a 30 s loop, 3–5 minutes with a 1-minute cron): a missed tick
only lets orders expire.
Expiry is checked against the block timestamp (ns). Keep your clock synchronized (NTP): an
expires_at that is not in
the future when the batch executes makes it panic.
Kill switch
Sendcancel_all and stop quoting when:
- your reference price is stale (the source failed and the last good price is older than you accept);
- the reference price jumps more than you accept between two ticks;
- an inventory limit or your loss limit trips;
- your process is shutting down.
cancel_all costs the same with 3 or 200
orders.
Inventory limits
- Cap what you may hold per asset (internal balance + resting orders). Past a limit, stop quoting the side that grows it.
- Skew both sides against your inventory before the limit, so fills tend to bring it back.
- With payout mode
intents, fills land inintents.nearand must be deposited again;internalavoids that.
Hedging
hexbook does not hedge for you. If you hedge elsewhere, hedge when the net delta since the last hedge passes a threshold, not on every fill.- A hedge has its own latency and fees; include them in your spread.
- Do not stack hedges: wait for one to settle (or fail) before sending the next.
- If you cannot hedge, manage risk with skew, inventory limits and a wider spread.
Operational checklist
- Dry run against mainnet data; check prices, tick rounding and sizes.
- Start with small sizes and tight inventory limits; raise them after a day of clean fills.
- Watch
place_skipped(crossoften means the spread is too tight or the fair is stale). - Cancel your dead orders in your batches (see the lifecycle); otherwise they fill
your 200-order cap and placements are skipped with
owner_cap. - Keep keys out of config files and repositories; use a dedicated account.