- Net: trdrs nets every account the policy covers, across every group that picks it, and holds a share of what is left in your one hedge account at the hedge market.
- Copy: each customer account has its own hedge account at the hedge market, and trdrs holds a share of the account’s position in it.
Hedging is a preview, served on the sandbox. A policy that copies picks up a group only where the
hedge market states its margin for each instrument it copies in its
symbol list.
See how a hedge works
- Your traders trade their accounts. Nothing about their orders changes, and the paper book fills them first.
- After each fill, trdrs reads a fresh price and sizes the hedge: the net of every account the policy covers, or the one account’s position for a copy, times the policy’s share, rounded toward zero to the instrument’s step, less what the hedge account holds and what is already on its way.
- If there’s a gap, trdrs saves a target and prepares one order, an intent, for the difference. A gap smaller than the policy’s smallest order waits, recorded on the target, unless the order takes the hedge to flat.
- trdrs sends the intent to your hedge account as a market order that fills at once or cancels, and records what the provider did with it.
Before you start
- Connect a provider. Plug in a public provider, create a connection and pass its validation. The provider must be able to hold accounts and take orders.
- Bind your hedge account. From the accounts the validation discovered, bind the one your venue
owns with
POST /api/venues/{venueId}/accounts/bindand"mode": "hedge". Bind it with a Venue key that carriesconnection:manage,hedge:manageandhedge:execute, or use the Back Office signed in with a role that grants those permissions. The account must use thenetposition model, and it can’t be shown or granted to a trader. A net hedges into one such account; a copy needs one for each customer account. - Or hedge into your company Hyperliquid account. On the sandbox, once your company Hyperliquid
account is connected, an owner sets it up as a hedge account in one step in the Back Office. trdrs
serves its connection itself, from the trading key it keeps for the account, so there’s no provider
to plug in: the connection, its validation and the bound hedge account appear with your venue’s
others, and a policy picks it by its
hedgeAccountId. On production this step isn’t open yet. - Activate the instruments you’ll hedge, each mapped at the hedge market.
- Give your Venue key the hedge scopes.
hedge:readreads the report,hedge:managemakes, changes and picks policies, andhedge:executeresumes them, sends, reconciles and flattens.
1
Make a hedging policy
Name it, and state what it does. Both ways’ settings are stated whatever its
mode.Required scope: hedge:manage.connectionIdis the hedge market.hedgeAccountIdis your hedge account there that the net goes into. Sendnulluntil you bind one: the net is then worked out and never sent.net.ratiois the share of the net hedged, from"0"to"1".net.minHedgeNotionalis the smallest order, in US dollars. Where the hedge market’s own minimum order value is larger (Hyperliquid’s is $10), that is the smallest order instead, so no order is ever sent that the hedge market refuses as too small.net.notionalCapis the largest hedge on one market, in US dollars, ornullfor none.- What is worth less than the smallest order is carried, not dropped: each target in
GET /api/venues/{venueId}/hedgesshows it asleftover, such as{ "quantity": "0.04", "notional": "6.12", "minimum": "10" }, and once the net adds up tominimumone order hedges it with the rest. net.leverageis optional: the leverage your hedge account holds each market’s hedge at, such as[{ "instrumentId": "BTC", "leverage": 20 }], by your id for the instrument. A market you leave out is held at 10x, or the highest its hedge market allows where that is lower. See Check the net.net.thresholdis optional: hold the net’s orders until the hedge drifts more than an amount. See Hedge the net in steps.net.crossis optional: hedge a market your hedge market doesn’t list in one it does. See Cross hedge a market.net.placementis optional: send a large order in slices over time, evenly or by volume. See Send large orders in slices.copyis the same for each trader, set out under Copy each trader.ruleshedge some trades another way: see Rules.
201 with the policy: its id, state (active), revision, its terms in
force and the groups that pick it.2
Pick it for a group
Each group picks one policy, or From here on each fill of an account in the group is hedged. A policy that copies checks the group
first: see Copy each trader. A group whose copies are still held at one hedge
market can’t pick a policy that copies at another until you close them.
null to keep its trades on your book.Required scope: hedge:manage, and hedge:execute as well while the policy is active.3
Read the hedge report
Read every policy, target, intent and open incident for your venue.Required scope:
hedge:read.hedgingPolicies lists your policies. A net’s targets name their hedgingPolicyId and no group,
since the net spans every group that picks it. The report also gives the number of executions,
adverse slippage in basis points, fees grouped by currency and a complete flag. Missing fee
data, unsettled orders and open incidents mark the report incomplete rather than reading as zero.4
Pause, resume or change it
Pause or resume a policy for every group that picks it, at the Change it with
revision you read. Pausing
cancels the orders it prepared and hadn’t sent. Resuming needs hedge:execute too.POST /api/venues/{venueId}/hedging-policies/{hedgingPolicyId}, sending the name, the
whole terms and expectedRevision. The new terms are in force at once for every group that picks
it. A change that moves a hedge still held is refused: a net hedge account that holds a position or
has an order on its way (hedge_account_holds_position), or copies held at a hedge market the new
terms leave (hedge_market_in_use). Flatten or reconcile first.Delete it with DELETE /api/venues/{venueId}/hedging-policies/{hedgingPolicyId}, sending
{"expectedRevision":3}, the revision you read, once no group picks it and its hedge account
holds no position and has no order on its way. Otherwise the refusal names hedging_policy_picked
or hedge_account_holds_position in blockers. A deleted policy stops at once and leaves the list,
its hedge account can carry another hedge, and the hedges it made stay in the report.hedge.failure, once while the incident stays
open. The incident’s details state tries, firstFailedAt and the reasons of the tries, and
hedge.failure carries tries. After that trdrs sizes it again once a minute while it is still
failing. A hedge is sent while the hedge account’s view catches up with a fill it just made, and is
read back filled the moment its own fill arrives. A hedge refused only because that view is catching
up, such as another market’s hedge a moment before, is not a failure: it waits for the view and is
sent again, and opens an incident only if the view stays stale for a minute.
A market the hedge can’t cover takes no new trades
While a group picks a hedging policy that is active or paused, its accounts open nothing the policy can’t hedge: a market its hedge market lists no symbol for, which its net hedges in no other market. A builder-deployed Hyperliquid market with no symbol at your hedge account is one.- An order that opens or adds to a position there is refused
422instrument_not_hedgeable, with theerror“new trades on XYZ:TSLA are closed because the venue’s hedge cannot cover it; closing and reducing still work”. Closing, reducing and cancelling still work. - The account’s instrument list (
GET /api/venues/{venueId}/accounts/{accountId}/instruments) lists the market withinstrument_not_hedgeableinblockedBy, so a picker can grey it out. - A paused policy refuses them too: once resumed it hedges every position its accounts hold, and it could never hedge these. A stopped policy, or a group that picks none, refuses nothing for this.
- A market a rule keeps on your book, though the hedge market lists it, is your choice and stays open.
A failed hedge pauses new trades
So your venue never carries a position the policy should have hedged for long, a net hedge that still fails after its tries also pauses new trades on its market, for every group that picks the policy, while the policy is active:- An order that opens or adds to a position on that market is refused
422hedge_failed, with theerror“new trades on BTC-PERP are paused because the venue’s hedge of it failed; closing and reducing still work”. An order that would take a position past flat to the other side counts as adding. - Closing, reducing and cancelling still work.
- A failure of the whole net, such as a hedge account that can’t trade (
instrumentId*), pauses every market the net hedges. A market a rule keeps on your book, or copies, isn’t paused. hedge.failurecarriesentriesPaused: true, and the incident in the hedge report (GET /api/venues/{venueId}/hedges) carriesentriesPaused: truewhile it pauses.
POST /api/venues/{venueId}/hedging-policies/{hedgingPolicyId}/resume-trading with
{"instrumentId":"BTC-PERP"} for one market, or {"instrumentId":null} for every market the policy
paused. It needs hedge:manage and hedge:execute. A hedge still failing pauses the market again
once its tries fail again.
The money check’s incident (*collateral) and the script’s (*script) pause nothing; its
near-liquidation incident (*liquidation, under Check the net) pauses every market. Pausing the
policy lifts the pause too, since a paused policy hedges nothing: that is how you choose to carry
the risk yourself.
Check the net
A policy that nets, by its mode or one of its rules, carriesnetChecks in the list of policies
(GET /api/venues/{venueId}/hedging-policies) and in the hedge report’s hedgingPolicies: the money
its hedge account needs beside what it holds, and what each group that picks it should know. A pick’s
answer carries the group’s own part as netWarnings. These are warnings: none stops hedging or
refuses a pick.
The money the hedge account needs
netChecks.money prices what the hedge account holds now, at the marks the net was last sized at:
initialMargin: what Hyperliquid asks to hold each market’s hedge at the leverage it is held at, added up.maintenanceMargin: the level Hyperliquid closes the hedge under.lossRoom: what the hedge account can lose as your traders lose down to their loss floors. In each market it holds, only the traders whose netted position points the same way as the hedge count, each at the share the policy nets. A trader on the other side gains as they lose, so it counts nothing, and the count is never more than the hedge itself loses before they reach their floors. Each trader counts once.needed: the larger ofinitialMargin, andmaintenanceMarginpluslossRoom. That is enough to hold every hedge and ride the traders’ losses down to their floors without Hyperliquid closing it.held: the hedge account’s equity as its provider last stated it.shortfallis how far it falls belowneeded, or"0".
markets shows each market’s position, mark, notional, leverage and both margins. A figure that
can’t be stated is null, and reason says why.
For example, you sell a $25,000 account for $1,000, and it fails $900 below where it started. Its
trader opens the largest BTC position the account allows, $36,000 at 40x, and the net hedges it whole
at 40x:
- Initial margin: $36,000 / 40 = $900.
- Maintenance margin: $450, half of that at 40x.
- Loss room: $900, all of it still to lose.
- Needed: the larger of $900, and $450 + $900, so $1,350.
held falls
below needed, it opens an incident on the policy (instrumentId *collateral, reason
hedge_collateral_short, the figures in its details) and sends hedge.failure with that reason,
once. The incident resolves when the account holds enough again. Hedging goes on either way: add money
to the hedge account, or hedge less.
Nearer the edge it stops new trades. Hyperliquid closes a hedge account whose value falls below its
maintenance margin, so when held falls under twice maintenanceMargin, the check opens a second
incident (instrumentId *liquidation, reason hedge_near_liquidation) that pauses new trades on
every market the net hedges, and sends hedge.failure with that reason, entriesPaused: true and
topUp: what moving in clears both the pause and needed. In the example, $36,000 of BTC at 40x
keeps $450 of maintenance margin, so a hedge account under $900 pauses. Hedges that reduce the net
still go out. A hedge that goes through and resume-trading leave it: only a money check that finds
the account clear lifts it.
What each group should know
netChecks.groups lists each group that picks the policy, over the markets it trades that the policy
nets:
notMapped: the markets the hedge market doesn’t list. Their trades stay on your book, unhedged, until you map them there. The report’sexchanges.hedgeMarketsnames them too, under the policy’s hedge market, andnotOnHedgeMarketturns true.leverage: the markets where the group lets a trader use more leverage than the hedge is held at, each with the trader’s most (traderLeverage, from the group’s risk policies) and the hedge’s (hedgeLeverage). The hedge account then needs more margin than the traders post, which the money check counts. Raise the hedge’s leverage, lower the group’s, or hold more money in the hedge account.
The leverage the hedge is held at
Your company Hyperliquid account holds each market’s hedge in cross margin, at the policy’snet.leverage for the market or, where it names none, at 10x, or the highest the hedge market
allows there where that is lower. Hyperliquid liquidates a cross account once its value falls under its
maintenance margin, whatever the leverage; the leverage caps how much the account can open on what it
holds. At BTC’s 40x, an account holding all it can is liquidated by a 1.25% move; at 10x by 8.75%.
trdrs sets it at Hyperliquid before the first hedge order in a market, and again before the next one
whenever the policy changes it. A leverage above the highest the hedge market allows is refused when
you make or change the policy (hedge_leverage_above_max).
A leverage that can’t be set sends no order: the hedge fails with reason hedge_leverage_not_set,
opens an incident and sends hedge.failure, and trdrs sizes it again as for any failed net hedge. A
policy that names a leverage for a hedge account at any other provider fails this way too, since trdrs
sets leverage only on your company Hyperliquid account. Without one, such an account trades at the
leverage it already holds.
Hedge the net in steps
By default the net is sized after every fill, so each fill that moves it by at leastminHedgeNotional sends an order. Threshold hedging sends fewer, larger orders instead: set
net.threshold to a start and a target, both in US dollars.
target of "0" hedges all of it. target must be below start, or the policy is refused
400 threshold_target_not_below_start at net.threshold.target.
When the net calls for no hedge on a market, because the traders closed, the hedge there closes
whatever the threshold. minHedgeNotional and notionalCap hold as before. Leave threshold out, or
send null, to size after every fill.
Cross hedge a market
A market your hedge market doesn’t list stays on your book. Cross hedging hedges it in another market instead, at a ratio of its value in US dollars:ratiois above zero and at most10; it can be above 1 for a market that moves more than the one you hedge it in.hedgeInstrumentIdmust be listed at the hedge market, or the policy is refused409 not_readywithcross_hedge_not_on_hedge_market. It can’t be the same market (cross_into_itself) or a market that is itself crossed (cross_chain), and each market is crossed once (duplicate).- A crossed market is never hedged in itself. If your hedge market does list it, the hedge held there closes and the cross takes over.
notionalCap,thresholdandminHedgeNotionalapply to the whole hedge inhedgeInstrumentId.- While the crossed market has no fresh mark, the hedge it is crossed into waits. One quoted in neither
USD nor USDC can’t be valued in dollars: its hedge fails with
reasoncross_value_unknown. - Only the net crosses. A rule that copies a market the hedge market doesn’t list still keeps it on your book.
- The money check prices what the hedge account holds, so it counts the ETH margin. Its loss room counts only the traders of the market the hedge is in, not those crossed into it.
Send large orders in slices
By default each order the net calls for goes to the hedge market at once. A time-weighted average price (TWAP) placement sends a large one in equal slices over time instead:GET /hedging-policies/{hedgingPolicyId}/parent-orders reads each one the
net placed, with how many of its slices came due, what they filled, at what average price, when the
next is due, and each slice. The net works at most one on each market.
-
Each slice is the order’s share, rounded up to the market’s step, so the order never takes more
than
slicesslices. -
Each slice is due at its time from the start: slice k is due k times
seconds / slicesafter the first, so the last is due insideseconds. A slot sized late is still due at its time, and a slot that passed with nothing sized is passed over. -
When a slice is due, trdrs sizes the net again. The next slice goes, or, once what is left is no more
than a slice, all of it. If the traders turned the net to the other side, the order ends and the
new order is sized afresh. What waits for its slice is on the target as
unsentQuantity. -
A net that grows while its order works doesn’t add slices: after its last slice the order ends, and
what the net still calls for is sized afresh, as a new order in slices where it is worth more than
over. -
Pausing, stopping or deleting the policy, an emergency stop, or publishing it with another
placement ends its order
cancelled; what its slices sent stands. A policy that runs again sizes its net afresh. -
With a
threshold, itsstartholds only the first slice; the rest go on to itstarget. -
slicesis from 2 to 100 andsecondsfrom 1 to 86,400 (a day).secondsmust be at leastslices, so slices are a second or more apart, or the policy is refused400 twap_interval_too_shortatnet.placement.seconds. -
A slice must be worth at least
minHedgeNotional:overmust be at leastminHedgeNotionaltimesslices, or the policy is refused400 twap_slice_below_min_notionalatnet.placement.over. - Only the net places in slices. A copied hedge goes at once.
-
An iceberg (an order that shows only part of its size) isn’t offered: no hedge market trdrs reaches
takes one. A
kindother thanmarketortwapis refused400 unsupported_valueatnet.placement.kind.
placement out, or send null or { "kind": "market" }, to send each order at once.
Rules
A rule hedges some trades another way than the policy’s mode. trdrs reads the rules top to bottom, and the first that matches decides; the policy’s mode covers the rest. A rule matches one instrument, by your id for it, every instrument of one risk class (futures, crypto_derivative or fx_cfd), the
orders over a size, or the accounts whose recent results are over a return. It keeps the trades on your
book, nets them, or copies them, at its own ratio.
{ "match": { "kind": "order_notional", "over": "1000000" }, "mode": "copy", "ratio": "1" }
copies whole the part of a position each order over 1,000,000 US dollars of filled notional opened,
while the rules below it and the mode decide the rest. trdrs splits each position by the orders that
opened it, from its fills, and a sale or a stop closes the oldest part first. An order’s notional is
its filled quantity times its price times the contract multiplier, for an instrument quoted in US
dollars or USDC. An instrument quoted in another currency has no size in dollars, so a rule that needs
one leaves that instrument’s hedge as it is and records the failure order_notional_unknown; place
an instrument or class rule above it to decide such an instrument first.
Match accounts by their results
A rule can pick accounts by how they’ve done:returnOver is a share, from -1 to 10: 0.05 is 5%, and below zero picks accounts down more
than that. days is from 1 to 365, and minTradingDays at most days.
- The window is the
dayswhole UTC days before today. Today’s trading counts from tomorrow. - The return is the trading profit and loss the account booked in the window, after commission, fees, financing and funding, over its balance when the window began, or what it opened with where it opened since. A position still open counts only what it has realized. An account that held no money matches nothing.
- A trading day is a UTC day in the window with a fill.
- Once a day. trdrs works out each account’s figures the first time they are read on a UTC day and keeps them for the rest of it, so every fill that day reads the same answer.
- What it holds moves with it. When the day turns, trdrs sizes every hedge again. An account that starts matching is hedged as the rule says, its open positions included; one that stops goes back to what the rules below and the mode say, and the hedge the rule held for it closes. A rule that copies needs each account it may match to have its own hedge account.
GET /api/venues/{venueId}/accounts/{accountId}/hedging-results
(scope hedge:read): for each results rule of its group’s policy, the figures and matches.
Write your hedging in code
When the settings above don’t say what you want, give a policy that hedges the net a script: a short TypeScript function that reads the net as it stands and answers the hedge it wants in each market. trdrs runs it on every sizing of the net and places its answer under every limit the policy states:notionalCap, the market’s step, minHedgeNotional, placement (each order at once or TWAP),
the money check and the emergency stop. The script never sends an order itself, and closing works as
always: a market it leaves out is hedged to none, which closes what the hedge account holds there.
A script that is on takes the place of the policy’s rules’ shares, its cross hedges and its
threshold; it can read what those would do, and do the same or something else.
What a script reads
Its default export is called with one argument,HedgeInput in @trdrs/script-sdk. Every quantity
is a number, signed in the market’s own quantity (long above zero), as the hedge account holds it.
instruments lists every market the covered accounts hold, the hedge account holds or has an order on
its way in, and those the policy crosses them into. accounts lists every covered account that holds a
position. An account’s results are the same figures a results rule reads, worked out once a UTC
day, over each window the script’s version names in resultsDays ([30] unless you say).
What a script answers
It answersHedgeAnswer: the position it wants the hedge account to hold in each market, as a
quantity, not a dollar value.
0.1 + 0.2 reads as 0.3; send decimal text, with at
most 18 places, for more. trdrs then caps the hedge at notionalCap, rounds it toward zero to the
market’s step, and sends the difference from what is held and on its way under minHedgeNotional and
placement, as it sends the policy’s own sizing. An answer that names a market not in instruments,
asks for a hedge other than 0 in one the hedge market doesn’t list, or isn’t this shape fails as
script_answer_invalid.
Where it runs
A script runs in the same sandbox as a strategy: no network, no files, and no module but@trdrs/script-sdk. It has no clock beyond now and no randomness: Date.now(), new Date() with no
argument and Math.random() throw. The same input always gives the same answer. Each run has 250 ms and
64 MB of memory. Import the types alone (import type), which costs nothing at run time.
When it breaks
A run that throws (script_error), runs past 250 ms (script_timeout) or 64 MB (script_memory), or
answers no hedge (script_answer_invalid) falls back to the policy’s own terms for that sizing, and is
recorded with its reason and message. The first failure in a row opens one incident on the policy,
instrumentId *script with reason hedge_script_failed, listed in GET /hedges, and sends
hedge.failure with that reason, scriptReason and mode. Each failure after it adds to
failuresInARow on the script and on the incident, which stays open: a hedge that goes through doesn’t
resolve it. The next run that answers resolves it and sets failuresInARow back to 0.
Modes, versions and runs
off(where a script starts): it doesn’t run.watch: it runs on every sizing and its runs record what it would have hedged, while the policy’s own terms trade. Nothing more is traded.on: its answer is what the net hedges. Turning it on, or saving a version while it is on, also needshedge:executewhile the policy is active.
400 script_compile_failed with each error’s line, col and message in diagnostics. A save is a
new version, with who saved it and when, and the policy runs it from then on in the mode it has. Set
the policy back to any earlier version with POST /script/version.
Each run lists, for every market the hedge market lists with a fresh mark,
wanted (what the script
asked for), target (within notionalCap and the step), held, pending, delta (the order it
calls for, before minHedgeNotional and placement) and policyTarget (what the policy’s own terms
call for). A run is recorded when its input, version, mode or outcome differs from the last, and the last
200 are kept. A try answers the same shape and records nothing.
Two examples
The threshold setting, as a script. On the same book it sends the orders"threshold": { "start": "1000000", "target": "400000" } sends:
results rule
{ "kind": "results", "returnOver": "0.05", "days": 30, "minTradingDays": 5 } that nets them, with the
policy’s ratio "0" for the rest, hedges:
Copy each trader
A policy with"mode": "copy" copies each fill of a customer account into that account’s own hedge
account at the hedge market. A customer account has at most one hedge account at each hedge market.
The copy is sized from the account’s position, so it is right after every fill, a restart or a missed
fill alike.
- Copy ratio: the share of the position the hedge account holds. With
copy.basis: "fixed"it iscopy.ratio. With"budget"it is what the trader paid for the account, the hedge budget you send when you issue it, over the account’s max loss, the drawdown its stage allows, and never more thancopy.ratio. A trader who paid $400 for an account that fails at a $400 loss is copied whole. - Size: the account’s position times its copy ratio, as above. A difference whose notional is
below
copy.minHedgeNotional, in US dollars, waits, unless it takes the copy to flat. - Failures: a copy the market refuses is sized again after a short wait that doubles each time,
opens an incident on the account and sends
hedge.failure. Failures count for each hedge account on its own. Atcopy.failureLimitfailures in a row, trdrs halts the account’s opening orders on the instruments that hedge market hedges, refused asentry_halted: reductions and cancels still work. Reconcile the account to lift it. - Close on fail: when the account fails, halts by a rule or is stopped out, trdrs flattens its
hedge account and closes its binding, and sends
hedge.closed. Bind a hedge account again for the account’s next attempt. - Checks: an active policy that copies is in force on a group only when the hedge market states
its margin for each instrument it copies, and no account of the group is held to looser margin terms
than the hedge market’s at the largest position it can hold. Under
"budget"every bound account must also state its hedge budget. A refusal names every blocker inblockers. - Hedge collateral: the report states, for each binding, what its hedge account must hold: the account’s copy ratio times the initial margin the hedge market asks for the largest positions the account can hold in the instruments it hedges, under your leverage and notional limits, plus its max loss. Where the account’s stage makes margin count only the money above the loss floor (sandbox only), the account opens positions on its max loss alone, so the hedge account holds the larger of the two, not their sum: about $900 for a $25,000 account bought for $1,000 with a $900 loss limit, rather than about $25,900. Fund each hedge account with at least that. It is null, with the reason, while a figure it needs is not stated.
1
Issue accounts with their hedge budget
Send
hedgeBudget, what the trader paid in US dollars and cents, when you
issue the account. It is part of the issue’s referenceId, and the account
list reads it back.2
Bind each customer account to its hedge account
Bind each hedge account at the hedge market in Each account in
hedge mode first, as above, then pair it with its
customer account. While bound, the customer account has only that hedge account at its hedge
market, and the hedge account only that customer account. The answer names its connectionId.Required scopes: hedge:manage and hedge:execute.GET /api/venues/{venueId}/accounts lists its bound hedge accounts in
hedgeAccounts, each with its hedgeAccountId and connectionId, one at each hedge market. A
closed binding leaves the list.3
Reconcile an account its failures halted
Once you have settled what failed, reconcile the account: the failures of each of its hedge
accounts start again from none, its incidents resolve, its halts lift and its copies are sized
again. The answer lists each binding in
hedgeAccounts and says in resumed whether a halt lifted.Required scope: hedge:execute.exchanges lists the exchanges your activated instruments list on. mixed warns that
they list on more than one, and notOnHedgeMarket that some are not mapped at a hedge market that
copies or nets them.
Earn a builder fee on Hyperliquid hedges
At Hyperliquid, a policy can carry your builder fee: a share of each hedge order’s notional that Hyperliquid moves from your hedge account to your builder address. Each hedge order also pays Hyperliquid its own trading fee. Your traders pay both on paper, so a hedge account never pays more than its trader’s paper account is charged.Sandbox only for now: the only Hyperliquid provider service trdrs runs is the testnet one.
builder to the policy’s terms:
addressis where the fee is paid. trdrs keeps it in lowercase. Hyperliquid requires it to hold at least 100 USDC of perpetuals account value, in the standard account abstraction mode, and you claim its fees as referral rewards.feeBpsis the fee per side in basis points:"5"is 0.05%, charged when a hedge opens and again when it closes. It is above zero, to a tenth of a basis point, and at most"10"(0.1%), Hyperliquid’s cap on perpetuals.
- Your traders pay both fees on paper. Each group that picks the policy charges a commission of
at least the policy’s
minimumCommissionBpson every fill: yourfeeBpsplus Hyperliquid’s base taker fee on a perpetual, 4.5 basis points (0.045%), the most a hedge order pays it. That is anotionalBpscommission at that rate or above, orliquidityBpswith both rates at it or above, withtimingfillanddirectionboth. AminAmountor anorderMinimumonly adds to it. Otherwise the refusal names each group undercommission_below_hedge_fees, and the least each must charge, in the same order, underminimum_commission_bps. Once the policy is in force, a change to a group’s override or to the venue’s conditions that would charge less is refused the same way. Type that one number as the group’s commission: trdrs never writes your commission for you. - Each hedge account approved the builder. Only the hedge account’s main wallet can approve a
builder, and trdrs trades your hedge accounts with an agent key, so you approve it yourself: sign
approveBuilderFeefor your builder address, atfeeBpsor more, with the main wallet of each hedge account, then retry. trdrs reads the approval back from Hyperliquid and names each hedge account still short underbuilder_fee_not_approved. Where the hedge account is your company Hyperliquid account or a trader wallet trdrs made in your Privy app, trdrs holds its main wallet, so the step that turns the builder on (making the policy active, publishing a new fee, picking it or binding a hedge account) signs the approval atfeeBpsfirst, as someone who can turn hedging on, then reads it back. Each policy you read statesbuilderApprovals: each hedge account the builder charges, the most it approved, in basis points per side, ornullwhere Hyperliquid’s answer couldn’t be read, andsignedByTrdrs: true where trdrs signs that approval for you. - Each market it hedges is one of Hyperliquid’s own perpetuals. A builder-deployed perpetual (a
HIP-3 market such as
xyz:TSLA) charges its deployer’s fee on top of Hyperliquid’s, set by each market’s own fee settings, so a hedge there costs more than your paper commission charges. trdrs reads each symbol your hedge market maps an instrument to against its registry of Hyperliquid’s builder-deployed perp dexes, and names each instrument the policy could hedge on one underhedge_market_builder_deployed. Map it to Hyperliquid’s own perpetual, or keep it on your book with a rule on the instrument or its class.
"feeBps": "5" the policy’s minimumCommissionBps is "9.5", and the group charges
{"kind": "notionalBps", "timing": "fill", "direction": "both", "bps": "9.5", ...}.
- Copy, at 100%. A trader who buys $40,000 of BTC and sells it again pays $38 of commission on each fill, $76 in all. The hedge account pays $20 to your builder address and $18 to Hyperliquid on each side, $76 in all: $40 to you and $36 to Hyperliquid.
- Net, two traders who cancel out. One buys $40,000 of BTC and another sells $40,000, and both close again. The net stays flat, so no hedge order goes out, and nothing goes to your builder address or to Hyperliquid. Both pay $76 on paper, $152 that stays in the hedge account.
- Net, part of it hedged. One buys $40,000 and another sells $10,000. The net, $30,000, is hedged in and out: $15 to your builder address and $13.50 to Hyperliquid on each side, $57. On paper they pay $95, and the $38 between them stays in the hedge account.
minimumCommissionBps doesn’t cover, so a policy with a
builder never hedges one (hedge_market_builder_deployed, above).
If an approval is taken away later, Hyperliquid refuses the hedge order. trdrs then reads the approval
again and records the hedge’s failure as builder_fee_not_approved, which opens its incident, counts
toward the account’s failureLimit and sends hedge.failure, as any failed hedge does. trdrs never
sends an opening or resizing hedge without the fee.
A flatten is different, because the position has to close: an emergency stop’s flatten, your own, or
the close of a failed customer account’s hedge. trdrs reads the hedge account’s approval first. Where it
is below the fee or can’t be read, and trdrs holds the hedge account’s main wallet (your company
Hyperliquid account or a trader wallet), it approves the builder again and reads it back. A flatten still
short closes without the builder, opens an incident on what the hedge account hedges, and sends
hedge.failure with reason flattened_without_builder_fee, naming the hedge account (hedgeAccountId),
your builder, its feeBps and the approvedFeeBps read, or null where it couldn’t be read. Those
closes pay Hyperliquid’s own fee and nothing to your builder address.
Hedge one group by hand
A group that picks no hedging policy can still be hedged by a policy of its own:POST /hedges/policies publishes one for one group, POST /hedges/activation turns it on, and
POST /hedges/calculate with POST /hedges/intents/{intentId}/dispatch work out and send its net
when you ask. These routes stay while venues move to hedging policies, and a group that picks a
hedging policy is hedged by it alone: its calculate answers hedging_policy_in_force.
Stop hedging in an emergency
An emergency stop stops every policy, hedging policies included, cancels the prepared orders that would add exposure, and opens incidents. Each hedging policy stays stopped until you resume it. Send areason of 1 to 300 characters. It needs hedge:manage and hedge:execute.
hedge:execute:
Trade desk orders
Your people can place orders by hand from the trade desk into a desk account: one of your own provider accounts bound for hedging that an owner marks for the desk. No hedge sends into a desk account, and an account a hedge sends into can’t be marked one, so hand orders never share an account with hedging.-
Mark the account. An owner marks it with
POST /desk/accountsand{ "accountId" }, underhedge:manage.POST /desk/accounts/{accountId}/releasegives it back to hedging. -
Set its limits. An owner sets them with
PUT /desk/accounts/{accountId}/limits, each a hard block on every desk order. trdrs sets none, and until both required ones are set every order is refuseddesk_limits_not_set.maxOrderNotional: the largest order, in US dollars. A market quoted in USDC or USDT counts one for one; one quoted in any other currency is refusednotional_not_usd. Required.priceBandPct: how far an order’s price may be from the market’s current price, the middle of its best bid and ask. A market buy is checked at the ask, a market sell at the bid, a limit at its limit price. A stale or missing quote refuses the order. Required.maxPositionNotional,maxDailyNotional(the UTC day) andduplicateWindowSeconds(the same side, quantity and market within the window): optional.
expectedRevision. -
Place an order.
POST /desk/accounts/{accountId}/ordersplaces a market or limit order underhedge:execute. Send"dryRun": trueto run every check and place nothing: the response states each check. An order that fails one is refuseddesk_order_refused, withfailednaming each. One that passes goes through the account’s lane with the gates a hedge order passes. The response reports the account’s free margin where the provider states it; the provider decides whether the account funds the order. -
Read and cancel.
GET /desk/accounts/{accountId}/ordersreads the account’s open and recent orders with their fills and average price.POST .../orders/{orderId}/cancelsends one cancel for what is left of a working order. Fills before it stand, and the order readscancelledonce the provider’s book shows it cancelled. -
Size and preview before you place. Each reads the account’s own provider, as a trader’s own
account answers, and places nothing, under
hedge:read:POST .../order-previewanswers what an order would take of the account’s margin,marginRequired, null where the provider figures none, andsufficient, whether the account can afford it by the provider’s own figures. It checks no desk limit: a dry run does.POST .../order-sizeanswers the order an amount of the account’s money opens. Every live provider sizes orders by quantity, so it’s refusedsize_unsupportedon every live desk account.GET .../symbol-settings?instrumentId=reads the account’s leverage and margin mode on the market, and whether the mode may be changed now.PUT .../symbol-settingschanges the leverage or the margin mode, one at a time, underhedge:execute, as a command on the account’s lane like a desk order. The provider decides each change, and a change is refused while your desk is stopped. An emergency stop never waits on a provider, so a change already being sent when the stop commits still lands, and its record says so. Send a change again under itsIdempotency-Keyand you get its first answer; it’s never sent twice. A refused change holds no key, so you can send it again under the same one. Each change is recorded with its market and the value before and after.
-
Settle an order whose outcome is unknown. An order reads
unknownwhile the engine can’t tell whether the provider took it. It finds out from the provider’s book and its answer for the order where it can. One stillunknownfive minutes after it was placed holds its account: every new order is refuseddesk_order_unresolved, and the incident shows in your hedges report. Check the account at its provider, and an owner states what it shows withPOST .../orders/{orderId}/settle:{ "outcome": "working", "providerOrderId" }where the provider took it under that id, or{ "outcome": "not_working" }where it never did. A statement the provider contradicts is refusedprovider_disagrees. Settling closes the incident with who stated what and when, and an order stated taken while a stop stands is cancelled at once.
POST /desk/resume, under hedge:manage and hedge:execute, opens the desk again.
Handle errors
Treat each of these as unfinished state. Don’t record one as zero exposure or as a hedge that
succeeded.
Get hedge events
Your venue’s webhooks can subscribe to the hedge events, with the same signature and retries as every other event. Receive events has the details.
A hedge event always describes your venue’s own hedge, in your hedge account. Your traders’ orders
stay on trdrs.
Test it end to end
In the sandbox, with a provider connection that has passed validation and a hedge account bound to it:- Publish and activate a policy for a test group.
- Open a position in a test account in the group, then calculate with
dryRun: trueand check the target matches the position times your ratio. - Calculate without
dryRun, dispatch the intent, reconcile it, and read the report to see the hedge account’s confirmed position. - Run an emergency stop, confirm a new calculation is refused, then flatten the hedge account.
Next steps
Provider conformance
Prove the provider your hedge account lives at.
Receive events
Get hedge targets, fills and failures pushed to your server.