Hypercall
product update

Build an RFQ V2 Maker

RFQ V2 went live in October, and the launch post told it from the taker’s side: makers compete to price a package, every leg fills as one trade, and one signature can sweep quotes from several makers. This post is the other side of the table.

For a maker, RFQ V2 is a stream of options packages to price. You answer with firm quotes, signed once, that takers execute straight against your account. Every fill comes back as a single execution that ties the RFQ, your quote and every leg together, and you can hedge it with Hyperliquid perps from the same margin account. We built a small demo maker to show how those pieces fit together, and this post walks through it step by step.

By the end of this post you’ll have a working demo RFQ V2 market maker in under 300 lines of Python. It receives RFQs from Hypercall, prices every leg off Deribit, posts signed firm quotes, tracks each fill back to the quote that was hit, and hedges delta on Hyperliquid perps from the same Hypercall account, when that account can trade perps through Hypercall (step 7).

The point is to show how RFQ V2 works end to end: receiving RFQs, quoting, tracking fills and hedging. It is a demo, not a risk system. Its only limits are a cap on open quotes and on contracts per leg; bring your own risk limits before quoting real size. Pricing is stubbed out with Deribit’s mark price, so you don’t need a pricer or vol surface to follow along. You need Python 3.11 or newer and a funded Hypercall account. The hedge step also needs a portfolio margin Account contract with an on-chain API wallet; a plain wallet can quote but cannot hedge through Hypercall (see step 7).

The bot has six parts, one per step:

  1. Intake: a WebSocket subscription to rfq_v2, plus the change feed as a backstop.
  2. Pricing: Deribit’s mark price for each leg, plus your edge.
  3. Quoting: an EIP-712-signed firm quote, posted over REST.
  4. Fills: every fill tied back to its RFQ, quote and execution.
  5. Guardrails: a cap on open quotes and size, withdrawals and a dead-man switch.
  6. Hedging: delta hedged with Hyperliquid perps through Hypercall after each fill.

The RFQ V2 reference defines every message and code used here, and the maker FAQ answers the questions makers usually ask next.

Step 1: Setup and Identities

Three identities matter, and mixing them up is the most common integration bug:

IdentityWhat it isIn the API
AccountThe account that holds positions and margin. Quotes fill into itmaker_account
SignerThe key that signs quotes and grants: the account itself, its manager, an API wallet on the account, or an approved agentmaker_signer
ProviderYour enrollment as a quote provider, which decides which open RFQs reach youmaker_provider

Use an API wallet as the signer, so your account’s main key never sits on the quoting box.

Any funded account can quote an RFQ whose taker names it. RFQs sent to every eligible maker (all_eligible routing) reach enrolled quote providers only. Enrollment is done with Hypercall, and it can also restrict the underlyings you receive.

Plain wallet or Account contract?

maker_account is one of two things, and it decides whether step 7 works:

  • A plain wallet (EOA). A Standard margin account keyed by the wallet itself. It can quote and fill, and you can hedge it on another venue, but it cannot place perp orders through Hypercall.
  • An Account contract. A per-user Account.sol contract on HyperEVM, created by a manager wallet through the Factory (see Onboarding). Portfolio margin runs on these, and only these can hedge through Hypercall.

To check which you have, read maker_account from GET /private/rfq-provider (or use the address you enrolled), then ask HyperEVM whether it has code:

curl -s https://rpc.hyperliquid.xyz/evm -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getCode","params":["0xYourMakerAccount","latest"]}'
# "result":"0x"            a plain wallet
# "result":"0x<bytecode>"  an Account contract

On testnet use https://rpc.hyperliquid-testnet.xyz/evm.

To find the Account contract a manager wallet owns, call getAccounts(manager) on the Exchange contract; GET /exchange-info returns the Exchange address.

Size the account for firm quotes

Every executed quote needs margin. A short option needs initial margin well above its premium: a 0.001 BTC short out-of-the-money call took about $6.57 of initial margin on a $15 account. Hypercall checks margin at each execution, not when you quote, so an account that can cover one fill can still be refused on the next while other quotes are open. Size the account for what all your open quotes could fill at once.

Install the helper

pip install hypercall-rfq-example
export HC_ACCOUNT=0xYourAccount
export HC_SIGNER_KEY=0x...        # API wallet private key
import os
from hypercall_rfq_example import Hypercall   # small demo helper package

hc = Hypercall(
    host="https://api.hypercall.xyz",
    account=os.environ["HC_ACCOUNT"],
    signer_key=os.environ["HC_SIGNER_KEY"],
)
print(await hc.rfq_v2.provider())   # enrollment: status, tier, underlyings

The tutorial calls hypercall_rfq_example, a short demo package on PyPI as hypercall-rfq-example; it needs Python 3.11 or newer. The package and the complete demo maker (maker.py) are open source at hypercall-public/hypercall-rfq-example. It does the fiddly parts: EIP-712 signing, read grants, premium arithmetic and the change-feed cursor. It is teaching code, about 800 lines, short enough to read or copy if you’d rather not install it. Its signatures are tested byte for byte against Hypercall’s Rust SDK.

Try it on testnet first

Testnet runs RFQ V2 at https://api.testnet.hypercall.xyz with signing chain ID 998, on test funds. Before you point the bot at it, check that testnet is up and serving V2:

curl -s https://api.testnet.hypercall.xyz/version
# {"commit":"...","ref":"testnet-aws","signing_chain_id":998,...}

curl -s https://api.testnet.hypercall.xyz/private/rfqs
# {"code":"rfq_v2_session_required",...}  V2 is on; reads need a grant
# {"code":"rfq_v2_disabled",...}          V2 is off; wait or contact Hypercall

rfq_v2_session_required without a grant is the healthy answer. Then build the client with host="https://api.testnet.hypercall.xyz" and chain_id=998; a signature for one chain ID is rejected on the other environment.

Step 2: Receive RFQs

RFQs reach you over the rfq_v2 WebSocket channel. Subscribe with "view": "full" and each message carries your complete maker view of the RFQ (legs, target, fill policy, deadlines and the generations to sign against), so you can price straight off the socket. The default hint mode sends just {rfq_id, sequence} and leaves the read to you over REST.

Messages can be missed during a disconnect, so the change feed (GET /private/rfqs/changes) is the backstop: the helper saves a cursor and replays from it after a reconnect.

Access needs a read grant: a small EIP-712 message signed by your signer, valid for at most 5 minutes, sent as AuthenticateRfqV2 on the socket and as a bearer token on REST reads. The helper renews it before it lapses.

async for rfq in hc.rfq_v2.stream(cursor_file="rfq.cursor"):
    # rfq is the full maker view: legs, target, fill_policy,
    # quote_deadline_ms, expires_at_ms, and the generations to sign against.
    print(rfq.id, [(l.instrument, l.taker_side, l.contracts_per_package) for l in rfq.legs])
    await on_rfq(rfq)

What the stream does under the hood:

  1. Signs AuthorizeRfqReadV2 {account, issuedAtMs, expiresAtMs, nonce} and sends {"type":"AuthenticateRfqV2","token":...}. It re-signs about a minute before expiry; re-authenticating keeps the subscription.
  2. Sends {"type":"Subscribe","channel":"rfq_v2","view":"full"}.
  3. Replays the change feed from the saved cursor, reading GET /private/rfqs/{rfq_id} for each change it missed while disconnected, then yields each RfqV2Rfq message from the socket once per sequence.
  4. Saves the cursor only after your handler returns, so a crash never skips an RFQ. If you hand each RFQ to its own task instead, as step 8 does, pass manual_ack=True and call hc.rfq_v2.ack(rfq) when the task finishes; the cursor then never passes an RFQ that is still being handled.

If the grant ever lapses, the server sends an Error frame with code rfq_v2_grant_expired instead of going quiet, and the stream signs a new grant and re-authenticates.

Step 3: Price an RFQ Off Deribit

Pricing is the one part we keep trivial: take Deribit’s mark price for the same strike and expiry, convert it to USD, and add a spread. Swap in your own pricer here.

import httpx

DERIBIT = "https://www.deribit.com/api/v2"

async def price_leg(client: httpx.AsyncClient, leg, spread: float = 0.02) -> float:
    """USD price per contract for one leg: Deribit mark, plus or minus a 2% spread."""
    r = await client.get(f"{DERIBIT}/public/ticker", params={"instrument_name": to_deribit(leg.instrument)})
    t = r.json()["result"]
    mark_usd = t["mark_price"] * t["underlying_price"]   # Deribit quotes options in the coin
    return mark_usd * (1 + spread) if leg.taker_side == "buy" else mark_usd * (1 - spread)

to_deribit maps a Hypercall option symbol such as BTC-20261226-100000-C to Deribit’s BTC-26DEC26-100000-C.

Step 4: Sign and Post a Firm Quote

A firm quote is executable: once posted, the taker can fill it up to its capacity until it expires or you withdraw it. You price each leg, and the helper builds the signed terms.

answered = set()

async def on_rfq(rfq):
    # Your own quote produces another change for this RFQ, so the stream
    # yields it again. Answer each RFQ once, before the first await.
    if rfq.status != "open" or rfq.id in answered:
        return
    answered.add(rfq.id)
    if not limits.allows(rfq, rfq.target):                             # step 6
        return await hc.rfq_v2.decline(rfq)
    prices = [await price_leg(http, leg) for leg in rfq.legs]          # step 3, USD per contract
    quote = await hc.rfq_v2.quote(
        rfq,
        prices=prices,
        capacity=rfq.target,                  # quote the full size
        expires_in_s=20,
    )
    limits.track(quote.id, quote.expires_at_ms)

What quote() handles, which you’d otherwise get wrong:

  • Prices become price_micros (USD per contract times 1,000,000, unsigned, no tick). Direction comes from each leg’s taker_side; you take the opposite side.
  • Reference premium: the signed package premium is the sum over legs of price times contracts, plus for legs the taker buys and minus for legs it sells. It must come out exact in micros, so when your prices do not already make it exact the helper rounds each leg’s price to the step that keeps that leg’s premium whole, in your favour: 1 micro at whole contracts, 2 at half a contract, 100 at 0.01 contracts per package. It refuses a price the rounding would move by more than 1%.
  • Generations: copied from the RFQ you just read, never computed. A bulk withdrawal or a fired dead-man switch bumps them, which kills every quote signed against the old ones.
  • Fill policy, capacity and step must match the RFQ’s grid: full size once, one smaller package, or repeated partials.
  • Deadlines: the quote must arrive before quote_deadline_ms and expire no later than the RFQ.
  • Nonce: a millisecond timestamp, unique and increasing per signer. Hypercall refuses a nonce outside its time window when the quote is posted, with 400 rfq_v2_quote_nonce_rejected. The nonce itself is consumed at the quote’s first execution, so never reuse one across quotes.
  • Signature: EIP-712 AuthorizeRfqQuoteV2, domain Hypercall, version 1, chain 999.

The response says whether the quote is executable and gives the preflight result. Preflight is a best-effort margin check, not a reservation: a quote can still be refused at execution if your margin moved. Declining is optional, since silence just times out, but a decline tells the taker immediately. You cannot decline an RFQ while you have an executable firm quote on it (409 rfq_v2_decline_with_live_quote), and you cannot quote an RFQ you declined (409 rfq_v2_maker_declined). To back out of an RFQ you have quoted, withdraw the quote; decline afterwards if you want the taker to see it.

Step 5: Handle Fills

This is where most integrations break, so we do it properly. When a taker executes your quote, you get one execution: one record that ties the RFQ, your quote, the package size and the price of every leg together. Executions come from GET /private/rfqs/executions, read with the same grant and a cursor.

async for ex in hc.rfq_v2.executions(cursor_file="exec.cursor"):
    # ex.execution_id, ex.rfq_id, ex.quote_id, ex.package_units,
    # ex.legs = [ExecutionLeg(instrument, side, contracts, price_usd), ...]
    log.info("execution %s rfq %s quote %s", ex.execution_id, ex.rfq_id, ex.quote_id)
    await hedge(ex)                # step 7: hedge the package's net delta once

The rules this loop relies on:

  • One execution, many legs. A call spread fills as one execution with two legs. Hedge and book it as one unit, not as two unrelated trades.
  • Partial fills repeat. On a repeated_partial quote, the same quote can produce several executions until its capacity is used up. remaining_capacity on the quote always equals capacity minus the sum of execution sizes.
  • Keep the loop alive. Catch, log and retry a failed read or handler with backoff. In a TaskGroup, an unhandled error in this task also cancels RFQ intake and the dead-man switch renewal.
  • Exactly once. The cursor is saved only after your handler returns, so after a crash or reconnect the loop resumes after the last execution it handled and never hedges one twice. execution_id lets your own booking drop anything it already applied.
  • Fills still arrive on fills too. Each leg also appears on the fills channel and GET /fills, carrying rfq_id, quote_id and execution_id, so your existing position and PnL tooling reconciles against the same IDs.

Step 6: Guardrails

A firm quote is a live commitment until it fills, expires or you withdraw it. A real maker sizes what all its open quotes could fill at once against its book and margin. The demo bot does not. It has one guard: at most --max-open-quotes open quotes, and at most --max-contracts contracts per leg in any one quote. That keeps a stray RFQ from becoming a large position while you experiment, and nothing more. Order book MMP does not count RFQ fills, so the RFQ side needs limits of its own; bring yours before quoting real size.

class Limits:
    def __init__(self, max_open_quotes=20, max_contracts=5.0):
        self.open = {}                                     # quote id -> expires_at_ms
        ...
    def allows(self, rfq, units) -> bool:
        live = [q for q, expires in self.open.items() if expires > now_ms()]
        biggest_leg = max(float(leg.contracts_per_package) * units / 1_000_000 for leg in rfq.legs)
        return len(live) < self.max_open_quotes and biggest_leg <= self.max_contracts
    def track(self, quote_id, expires_at_ms): self.open[quote_id] = expires_at_ms

Two controls Hypercall gives you, and the bot uses both:

  • Withdraw. Pull one quote, every quote on an RFQ, or everything at once (hc.rfq_v2.withdraw_all()). Withdrawing everything bumps your maker generation, so even quotes signed but still in flight become dead on arrival.
  • Dead-man switch. A cancel schedule withdraws every quote if you stop renewing it. The bot renews a 30-second schedule every 10 seconds; if the process dies or loses the network, all quotes go within 30 seconds.
async def heartbeat():
    while True:
        await hc.rfq_v2.cancel_after(seconds=30)
        await asyncio.sleep(10)

Step 7: Hedge on Hyperliquid Perps, Through Hypercall

After each fill we flatten the new delta with the Hyperliquid perp for that underlying, placed through Hypercall from the same account. This is the point of quoting on Hypercall: your options and your hedge sit on one venue and one margin account. The perp counts toward the options margin, and nothing has to move between exchanges.

Which accounts can hedge here

Perp orders through Hypercall need all of the following. Each one is a one-time setup step:

RequirementHow to set it upRefusal without it
maker_account is an Account contract, not a plain walletThe manager wallet calls createAccount(salt) on the Factory (Onboarding)400 unknown_account
The Account is in portfolio margin modeOnboarding to Portfolio Marginthe order is rejected by the risk check
The Account is in HyperCore unified account modeThe manager signs hl_set_abstraction with abstraction: 2 (part of portfolio margin onboarding)rejected with code unified_account_required, for any order that adds risk
The signer is an active on-chain API wallet on the AccountThe manager signs hc_update_api_wallet (API wallet management) and waits for the directive to finalize400 invalid_signature
USDC on the Account’s HyperCore balanceFund the Account as the portfolio margin guide describesthe risk check or Hyperliquid refuses the order

The quote signer and the hedge signer can be the same API wallet. A key approved only through /approve-agent is an engine agent, not an on-chain API wallet: it can sign quotes and grants, but perp orders signed with it are refused with invalid_signature, and the message tells you to register it as an API wallet. The manager wallet cannot sign perp orders either.

The bot uses the smart contract route, POST /v1/actions/hl_limit_order, which goes on-chain through the Account contract. The TEE route (/v1/tee-perp/ endpoints, see Perps on Hypercall) needs two more one-time steps from the manager wallet: enrolling the account’s TEE API wallet on Hyperliquid (/v1/tee-api-wallet/approval-request, then /v1/tee-api-wallet/approval) and approving Hypercall’s builder through Account.approveZeroFeeBuilder. The Rust client walks through all of it in hypercall_client::tee_perp.

If your maker_account is a plain wallet, the hedge orders in this step fail with 400 unknown_account, and no setting on the wallet changes that. The example bot keeps quoting, logs each failed hedge and keeps the delta as unhedged. Either take out the hedge call and hedge on Hyperliquid (or anywhere else) from your own wallet, or create an Account contract, move it to portfolio margin, ask Hypercall to enroll that Account as your maker_account, and quote from it.

The hedge

The delta to hedge comes from step 5: for each leg in the execution, contracts times that leg’s delta, signed by our side. Hedge the net delta per underlying, not each leg; a call spread’s net delta is small. Deltas too small to trade carry over to the next execution, and a failed order stays unhedged so the next execution retries it.

“Too small to trade” has a hard floor: Hyperliquid refuses orders under about $10 of notional. A small RFQ fill often leaves less delta than that (0.001 contracts of a 0.10-delta BTC call is 0.0001 BTC of delta, under $10 at any BTC price below $100,000), so carry the residual delta until enough accumulates, and set each MIN_HEDGE above $10 at the current perp price.

unhedged = {}                                              # options delta not yet hedged

async def hedge(ex):
    for leg in ex.legs:
        # leg.contracts is a Decimal and Deribit's delta a float: convert first.
        d = leg_delta(leg) * float(leg.contracts) * (1 if leg.side == "buy" else -1)
        unhedged[underlying(leg)] = unhedged.get(underlying(leg), 0.0) + d
    for coin, delta in unhedged.items():
        if abs(delta) < MIN_HEDGE[coin]:
            continue                                       # carry it to the next fill
        await hc.perps.order(                              # Hyperliquid perp, same account
            coin=coin,
            is_buy=delta < 0,                              # long delta -> sell perp
            size=abs(delta),
            type="ioc",
            slippage_bps=20,
        )
        unhedged[coin] = 0.0

The demo assumes the IOC fills. It does not read the perp position back or rebuild its options delta after a restart; a real maker reconciles both.

leg_delta reuses the Deribit ticker from step 3, which also returns greeks.delta. The order is an HLOrder directive signed by your API wallet in the HypercallApiSign domain and sent to POST /v1/actions/hl_limit_order. It lands on Hyperliquid from your Account contract, so the perp shows up in the same margin calculation as the options it hedges.

Step 8: Run It

async def handle(rfq):
    await on_rfq(rfq)                                       # step 4
    hc.rfq_v2.ack(rfq)                                      # now the cursor may pass it

import signal

async def main():
    task = asyncio.current_task()
    for sig in (signal.SIGINT, signal.SIGTERM):            # Unix
        asyncio.get_running_loop().add_signal_handler(sig, task.cancel)
    try:
        async with asyncio.TaskGroup() as tg:
            tg.create_task(heartbeat())                     # dead-man switch
            tg.create_task(run_executions())                # step 5
            async for rfq in hc.rfq_v2.stream(cursor_file="rfq.cursor", manual_ack=True):
                tg.create_task(handle(rfq))                 # one task per RFQ
    finally:
        await hc.rfq_v2.withdraw_all()                      # never leave quotes behind

try:
    asyncio.run(main())
except (KeyboardInterrupt, asyncio.CancelledError):
    pass

The signal handlers matter. Without them SIGTERM, which kill, systemd, Docker and Kubernetes all send, ends the process on the spot, the finally never runs, and every open quote stays live until it expires or the dead-man switch fires. With them, SIGINT and SIGTERM cancel main(), and its finally withdraws everything first. kill -9 can never be caught, which is why the dead-man switch is still there.

The withdrawal runs inside main(), on the same event loop as the rest of the bot; a second asyncio.run() after the first has closed its loop can fail on the client’s pooled connections.

The full bot is maker.py, shipped with the hypercall-rfq-example package source. It needs Python 3.11 or newer, ignores a second signal while it withdraws, and has a --dry-run flag that prices and logs RFQs without posting quotes, declines, withdrawals or hedges.

What to watch once it’s live:

  • Hint-to-quote latency against quote_deadline_ms. Takers choose the deadline (our own clients use 20 seconds), so anything past a few seconds loses RFQs.
  • Quote rate and fill rate. Low fill rates usually mean your spread is wide, not that something’s broken.
  • Remaining capacity drift: for each quote, capacity minus the executed package_units minus remaining_capacity should always be zero. Anything else means you missed an execution; replay from the cursor.
  • Heartbeat failures. One missed renewal is fine. Two in a row means quotes are about to be cancelled.
  • Rate limits: 6,000 requests a minute per IP across all RFQ V2 routes. Reading every RFQ on every hint is well inside that.

Volatility, flow and market structure, in your inbox.

A weekly read on what moved, what it cost, and what it means. No shilling, no price targets.