Hyperliquid API in Node.js: a quick slippage check with impactPxs
December 4, 2026•1,101 words
Before a bot sends a market order on Hyperliquid, it helps to know roughly what the fill will cost. The Hyperliquid API already publishes a number for this on every perp, and most code ignores it: impactPxs.
This post reads it for every perp in one request, turns it into a spread in basis points, and checks it against a walk of the live order book. Everything uses public data, so no wallet or key is needed.
What impactPxs is
The asset contexts response (metaAndAssetCtxs in the Hyperliquid docs) returns one context per perp. Next to markPx, oraclePx and funding there is impactPxs, a pair of prices: the impact bid and the impact ask.
Hyperliquid's funding page describes them as the average execution prices to trade the impact notional on each side. The contract specifications page sets that notional at 20,000 USDC for BTC and ETH and 6,000 USDC for every other asset. The same page lists the maximum market order value, which depends on the asset's max leverage: 30,000,000 USD at 25x and above, 5,000,000 USD from 20x, 2,000,000 USD from 10x, and 500,000 USD below that.
So impactPxs answers a narrow question for free: if you hit the book for about that size right now, what average price would you get?
Setup
Node.js 24, an empty folder, and one package:
npm init -y
npm pkg set type=module
npm install @siebly/hyperliquid-api
The script
Save as impact-check.mjs:
// Quick slippage check on Hyperliquid perps from impactPxs, with an order book cross-check.
// Public data only: no wallet or key needed.
import { RestClient } from '@siebly/hyperliquid-api';
const client = new RestClient();
// From Hyperliquid's contract specifications page.
const impactNotional = (coin) => (coin === 'BTC' || coin === 'ETH' ? 20_000 : 6_000);
const maxMarketOrder = (lev) =>
lev >= 25 ? 30_000_000 : lev >= 20 ? 5_000_000 : lev >= 10 ? 2_000_000 : 500_000;
const [meta, ctxs] = await client.getPerpAssetContexts();
const rows = meta.universe
.map((asset, i) => ({ asset, ctx: ctxs[i] }))
.filter(({ asset, ctx }) => !asset.isDelisted && ctx.impactPxs)
.map(({ asset, ctx }) => {
const [bid, ask] = ctx.impactPxs.map(Number);
const mid = Number(ctx.midPx ?? ctx.markPx);
return {
coin: asset.name,
volume: Number(ctx.dayNtlVlm),
impactBid: bid,
impactAsk: ask,
spreadBps: ((ask - bid) / mid) * 10_000,
notional: impactNotional(asset.name),
maxMarket: maxMarketOrder(asset.maxLeverage),
};
})
.sort((a, b) => b.volume - a.volume);
const fmt = (n) => n.toLocaleString('en-GB', { maximumFractionDigits: 2 });
console.log(`Perps with impact prices: ${rows.length}\n`);
console.log('Top 10 by 24h volume:');
for (const r of rows.slice(0, 10)) {
console.log(
`${r.coin.padEnd(8)} impact ${r.impactBid} / ${r.impactAsk} ${fmt(r.spreadBps).padStart(6)} bps` +
` for ${fmt(r.notional)} USD each side, max market order ${fmt(r.maxMarket)} USD`,
);
}
const wide = rows.filter((r) => r.spreadBps > 20).length;
console.log(`\nPerps wider than 20 bps at their impact size: ${wide} of ${rows.length}`);
// Cross-check: walk the live book for the same notional, fetched together with fresh contexts.
function walk(levels, notional) {
let left = notional;
let qty = 0;
for (const { px, sz } of levels) {
const take = Math.min(left, Number(px) * Number(sz));
qty += take / Number(px);
left -= take;
if (left <= 0) break;
}
return left > 0 ? NaN : notional / qty;
}
for (const coin of ['BTC', 'ETH', 'HYPE']) {
const [[m, c], book] = await Promise.all([
client.getPerpAssetContexts(),
client.getOrderBook({ coin }),
]);
const ctx = c[m.universe.findIndex((a) => a.name === coin)];
const n = impactNotional(coin);
console.log(
`${coin} for ${fmt(n)} USD: impactPxs ${ctx.impactPxs.join(' / ')},` +
` book walk ${walk(book.levels[0], n).toPrecision(7)} / ${walk(book.levels[1], n).toPrecision(7)}`,
);
}
Run it with node impact-check.mjs.
Output (4 December 2026, 07:58 UK)
Perps with impact prices: 179
Top 10 by 24h volume:
BTC impact 50505 / 50510.7 1.13 bps for 20,000 USD each side, max market order 30,000,000 USD
ETH impact 1544.2 / 1544.3 0.65 bps for 20,000 USD each side, max market order 30,000,000 USD
ZEC impact 910.9735 / 911.1246 1.66 bps for 6,000 USD each side, max market order 2,000,000 USD
HYPE impact 64.3336 / 64.3539 3.15 bps for 6,000 USD each side, max market order 2,000,000 USD
SOL impact 67.056 / 67.057 0.15 bps for 6,000 USD each side, max market order 5,000,000 USD
NEAR impact 3.3132 / 3.31449 3.89 bps for 6,000 USD each side, max market order 2,000,000 USD
STRK impact 0.03122 / 0.03126 12.81 bps for 6,000 USD each side, max market order 500,000 USD
XRP impact 0.82981 / 0.829935 1.51 bps for 6,000 USD each side, max market order 5,000,000 USD
XMR impact 347.254 / 347.378 3.57 bps for 6,000 USD each side, max market order 500,000 USD
LIT impact 2.508991 / 2.512136 12.53 bps for 6,000 USD each side, max market order 500,000 USD
Perps wider than 20 bps at their impact size: 113 of 179
BTC for 20,000 USD: impactPxs 50517.2 / 50524.8, book walk 50510.00 / 50511.00
ETH for 20,000 USD: impactPxs 1544.0 / 1544.1, book walk 1544.000 / 1544.100
HYPE for 6,000 USD: impactPxs 64.3415 / 64.3624, book walk 64.38480 / 64.42744
What the numbers say
- One request covers the whole market.
getPerpAssetContexts()returns metadata and contexts as two arrays in the same order, so indexiinuniversematches indexiin the contexts. - The large books are tight at their impact size: BTC, ETH and SOL were around 1 basis point or less on this run.
- Most of the list is not. 113 of 179 listed perps showed more than 20 basis points between impact bid and impact ask at 6,000 USD. A scanner that treats every perp like BTC will underestimate costs on most of them.
- The value moves second by second. Three runs within about two minutes gave BTC 0.46, 3.57 and 1.13 basis points. The book walk lands close to
impactPxsbut not on it, in either direction, because the two are read a moment apart.
How to use it in a bot
Treat impactPxs as a cheap screen across all perps: skip markets whose impact spread is above your limit, or size down there. For the order you are actually about to send, walk the book for your real size, as the cross-check does, and keep the order under the maximum market order value for that asset.
For stock and index perps on HIP-3 DEXs, pass the DEX name (for example getPerpAssetContexts({ dex: 'xyz' })), since the default call only covers the main perp list.
More
The SDK used here is @siebly/hyperliquid-api, an open-source JavaScript and TypeScript SDK for the Hyperliquid API. Its documentation covers REST, WebSocket subscriptions and signed actions: https://siebly.io/sdk/hyperliquid/javascript
I help maintain this SDK at Siebly.