Sign, persist, send
openPosition and cashOut run in one call. To survive a reload mid-trade, split them into three steps:
sign, save the signed record, then send it.
Sign the funding first
The funding depends only on the stake, so it can be signed before a quote is chosen. Then onlyTakerAccept
is left to sign once you pick, and the accept goes out straight after. Makers replace their quotes as they renew
them, so the less time between the pick and the send, the less often a quote is gone when the accept arrives.
openPosition works this way.
QUOTE_REPLACED or QUOTE_EXPIRED, or the
maker answers DECLINED or TIMED_OUT, nothing traded and any bridge was discarded. Prepare again for the
next quote. Before you sign the next one, mark a refused record with refused: error.code and persist it, so
recoverAcceptance answers it NOT_ADMITTED from the record without cancelling the RFQ the next accept uses.
signEntry({ quote, core, cash })
Without prepared, asks the wallet for every signature the entry needs, at once. It plans the funding from cash (a
spendableCash() read) or, without it, from current balances: free vault cash first, then the wallet, then a
bridge of core to the wallet. 0.05 USDC (bridgeGasBuffer) stays behind.
coreis the HyperCore spot USDC you offer. Leave it out to fund from the wallet alone.core: nullmeans your HyperCore read failed.- Pass
cashto plan before the wallet prompt. Without it, the wallet is asked forTakerAcceptwhile the balances load, so a plan that fails throws after the prompt. - Throws
EntryErrorBALANCE_UNKNOWNwhen the vault balance is not current.
signCashout({ quote })
Has the owner, or its vault agent, sign a cash-out quote’s SellBack.
sendAcceptance(signed, { onRecord })
Sends either kind of record under its acceptance ID, and checks the answer echoes the record’s IDs. An entry’s
bridge is sent only after the accept answers ACCEPTED with its fund_by still ahead. Any other answer
discards it.
recoverAcceptance(signed, { wait, onRecord })
Reads and fences the acceptance. It signs nothing. It sends a never-sent bridge only if the acceptance is
ACCEPTED before its fund_by, and resends a sent one that got no answer, with the same bytes, in that same
window. It waits out PENDING_CONFIRM unless you pass wait: false.
Entry records and the bridge
An entry record carriesversion: 2 and a bridgeState: SENT, LANDED, PROCESSED, REFUSED or
DISCARDED. onRecord is awaited with the record before the bridge is first sent and again on each new state.
Persist it over the stored one. sendAcceptance refuses a record from SDK 0.63 or older; recoverAcceptance
only reads it.
The result never waits for Hyperliquid:
bridgingis set when this call sent the bridge. It resolves to Hyperliquid’s answer, orunknownwhen none came beforefund_by.bridgedis{ amount, landed }(amount in atomic USDC) once a bridge was sent, and never for one Hyperliquid refused.landed: "yes"means Hyperliquid answeredok: unless the operationCOMMITTED, that cash is now in the wallet on HyperEVM, not on HyperCore."unknown"means read the balances rather than assume where it is.
Retries
Each command is built once with itsIdempotency-Key. After a network failure or a BACKOFF error, the SDK
resends it byte for byte, up to five sends. Change that with retry: { attempts }, or turn it off with
retry: false.
Errors
unwrap and every flow throw ApiError for a venue error, with code, retry, status, requestId,
fieldViolations and retryAfterMs, plus resend on a flow command answered BACKOFF. Its retry says what to do next:
NetworkError means the outcome is unknown: the command may have reached the venue. When it carries resend, call it, never a
new command, so it cannot run twice.
normalizeError(error)
Turns any SDK failure into one shape for your UI: { code, message, retryable, retry, requestId, status, mayStillRun, resend, cause }. mayStillRun is true when the command may have reached the venue.

