TWAP Execution on Hyperliquid: Filling Size Without Slippage
Learn how a hyperliquid twap bot slices large positions across Hyperliquid's CLOB to minimise slippage, manage funding exposure, and protect execution with live kill-switches.
Trying to fill a large notional position in a single market order is one of the fastest ways to hand money to whoever is sitting on the other side of the book. On a centralised-limit-order-book (CLOB) venue like Hyperliquid, every resting order you consume shifts the best bid or ask. Do that at scale and your average fill price diverges sharply from the mid at the moment you decided to trade. Time-Weighted Average Price (TWAP) execution exists to solve exactly this problem: instead of one aggressive sweep, the order is broken into smaller child orders that dribble into the market over a chosen window, harvesting liquidity as it refreshes rather than draining it all at once.
How Hyperliquid's Native TWAP Works — and Where It Falls Short
Hyperliquid ships a first-party TWAP instruction that splits a parent order into equal-sized slices dispatched on a fixed interval. The chain executes each child order at the prevailing market price, which is already a meaningful step up from naive market orders for most retail-sized trades. For institutional-sized positions, however, the native implementation leaves several levers untouched.
The fixed-interval design is agnostic to current book depth. A slice dispatched when spread widens after a funding settlement or a large liquidation cascade will cross a thin book at a worse price than the same slice sent sixty seconds later when liquidity has rebuilt. A custom hyperliquid twap bot can solve this by reading the L2 snapshot before each child order and gating dispatch behind a minimum depth threshold — only sending the child if enough passive liquidity exists within a configurable basis-point band around mid.
Custom Logic That Actually Moves the Needle
A production-grade implementation layers several mechanisms on top of the base interval logic:
- Adaptive slice sizing. Rather than equal nominal chunks, the bot scales each child order to a fraction of rolling 30-second volume. Thin periods get smaller slices; liquid periods absorb more — keeping market impact proportional to actual conditions.
- Passive-first posting. When the spread is wide enough to sit inside it profitably, the bot posts a limit order one tick inside the best ask (for a buy) rather than crossing. If the resting order doesn't fill within a timeout, it's cancelled and replaced with an IOC to guarantee progress. Over a long TWAP window, the saving from capturing the spread on even a minority of child orders compounds noticeably.
- Funding-rate awareness. Hyperliquid's perpetuals settle funding every hour. If the running position is long and funding is deeply negative — i.e., you are already paying to hold — the bot can temporarily widen intervals to reduce the rate at which the exposure accrues, or pause altogether during the settlement window and accelerate afterward.
- Inventory skew and kill-switches. The parent TWAP tracks cumulative filled quantity in real time. If a separate signal (price drop beyond a threshold, external WebSocket feed disconnect, or a breached position limit) fires, a kill-switch halts all pending child orders immediately. The same inventory tracking feeds a skew parameter: if the bot is running behind schedule it tightens intervals; if ahead, it widens them, keeping the execution timeline on target.
For a concrete look at how similar adaptive logic plays out at a market-making level on Hyperliquid, see the Hyperliquid market-maker case study, which covers inventory management and spread control in a live environment.
Connecting the Execution Layer to Your Strategy
A TWAP bot is rarely the whole system. In practice it is the execution layer that sits beneath a higher-level signal — a mean-reversion entry, a cross-venue arb trigger, or a delta-hedging flow. The interface between them needs to be clean: the strategy emits a target quantity and a maximum window; the TWAP engine handles everything below that, reporting fills back upward so the strategy can update its net position in real time.
Error handling deserves the same care as the happy path. Hyperliquid order submission can fail transiently — the bot should distinguish between a rejected order (wrong parameters, margin breach) and a timeout (retry eligible) without over-posting. A simulation layer that replays a recent session's L2 data against the proposed child-order schedule before live deployment is not optional; it is the difference between a credible execution algorithm and one that surprises you in production.
On the infrastructure side, co-locating the bot with low-latency connectivity to Hyperliquid's API endpoints materially affects how reliably passive child orders get posted and cancelled before adverse price moves consume them. Latency in the tens of milliseconds matters when you are racing the order book's refresh cycle.
Our trading-bot services cover the full stack from architecture design through to live deployment, including custom TWAP, VWAP, and iceberg execution strategies tailored to the specific venue and asset class you are trading.
If you are running positions large enough that slippage is showing up as a measurable cost in your P&L, a properly built execution algorithm is one of the highest-ROI engineering investments you can make. Start a project with us and we will scope out an execution layer matched to your order size, trading window, and venue constraints.
Need a bot like this built?
We design, build and run trading bots on Solana, Hyperliquid and Polymarket.
Start a projectMore from the blog
Public vs Paid RPC: How to Run a Fair Benchmark
A fair comparison of public and paid RPC endpoints must account for quotas, workload, freshness and support guarantees.
Read articleRPC Benchmark Percentiles Explained: p50, p95 and p99
Why averages hide the latency spikes that break trading bots, wallets and production blockchain applications.
Read articleHyperliquid REST vs WebSocket Benchmark: What to Measure
A benchmark plan for Hyperliquid market data that separates request latency from streaming freshness and recovery.
Read article