OTC desk
How an OTC deal settles as two private sends in one transaction, the keys each deal receives on, what the desk signs and checks, how it prices, and how its fees are refunded or burned.
An OTC deal is two ordinary private sends of the transact circuit, one by each side,
submitted together by the OtcDesk contract. The circuit and the vault do not change for the desk: each half names
the desk as its only submitter and carries the deal in its external data, which the proof already binds.
The parts
| Part | What it does |
|---|---|
OtcDesk (0xd3870A9bb581fb5dD6d3286bc9D77d7f73a75381) | Settles a deal: both halves in one transaction, only as the desk's signer signed it, once. Holds no funds and sees no amount or asset |
VoidBurner (0xc153026a5e907A249dc3B16d2A1C9e3B388207EE) | Receives the desk's fees in HYPE and buys VOID with all of it, then burns it |
The desk service (https://otc.voidcash.io, services/otc) | The board, blocks, offers, auctions, requests and answers, and the fees. Checks each pair of halves, signs the deal and submits it from its relayer. Holds no key that spends a note |
The fee keeper (services/otc, its own process) | Holds the only key that spends the desk's notes: refunds fees, repays the relayer's gas, sends what is burnable to VoidBurner |
The SDK (packages/sdk/src/otc.ts, otc-keys.ts, otc-wallet.ts) | Builds and checks the halves on the user's device: sellerHalf, buyerHalf, checkHalf, checkDeal, readStandingHalf, dealTypedData, dealFee; derives the keys of each deal (dealKeys) and brings their notes home (sweepKnownNotes, recoverDealKeys) |
A half
Each half is a private send that only the desk can submit:
ext.calleris theOtcDeskproxy. The vault accepts a transaction that names a caller only from that caller, so neither half can reach the vault on its own;- nothing leaves the vault:
exitAmount,feeAmountandext.gasFeeare 0,exitAssetandext.recipientare the zero address; ext.datais exactly one ABI-encodedLeg:
struct Leg {
bytes32 dealId; // one settlement per deal
uint64 deadline; // the last second this half may settle
uint256 counterCommitment; // the first note the other half creates (commitments[0]): what this owner receives
}The proof binds the half's root, commitments, caller, recipient and data, so a half cannot be changed after it is proven. Since the relayer submits both halves directly, they carry no gas fee and their fee pairs stay empty.
What each half pays
The desk's fee is always in HYPE, in the half that moves HYPE away from the seller:
| Deal | Seller's half | Buyer's half |
|---|---|---|
| A token for HYPE | out[0]: size of the token to the buyer; out[1]: change | out[0]: price − fee HYPE to the seller; out[1]: fee HYPE to the desk. Inputs hold exactly price |
| HYPE for USDC | out[0]: size HYPE to the buyer; out[1]: fee HYPE to the desk. Inputs hold exactly size + fee | out[0]: price USDC to the seller |
fee = hypeSide * 50 / 10_000 + gasFee // dealFee: OTC_FEE_BPS = 50, rounded down
// hypeSide: the price for a token sold for HYPE, the size for HYPE sold for USDC
// gasFee: the desk's quote, 12,000,000 gas (OTC_SETTLE_GAS) at the gas price when the standing half is madeA half that pays two notes has no room for change (the main pair has two outputs), so its inputs hold exactly what it
pays. The app first makes such a note by a private send to its owner (fundExact).
Each owner picks the secrets of the note it will receive (prepareIncoming), made for its own record's
deal keys, and hands over only its stub and ciphertext. Its own half names that note's commitment as counterCommitment, so it receives exactly that note or the
deal does not settle. The desk's fee note is made for the desk's private address, which the app takes from its own
configuration.
Standing and closing halves
- The standing half is made first, by whoever offers: a buyer's offer or sealed bid, or a holder's answer to a request. It spends one note of exactly what it pays, owned by its record's own keys (moved there first, see Funding a standing half). It is proven when it is made, and waits with the desk. Its note stays its owner's, set aside by the app; spending it voids the half.
- The closing half is made by whoever takes it: the seller accepting an offer, or the buyer taking an answer. The
taker's device reads the standing half first (
readStandingHalf): the note it pays the taker must be exactly the terms and readable by the keys of the taker's listing or request, and no other ciphertext in it may be readable by the taker. The closing half names that note, and the standing half already names the closing half's first note.
Both halves name the same deal id and deadline. The deadline is the standing half's, so a closing half takes the same bound; the app gives it a window of 10 minutes to settle after the hand-over, and offers to void it after that.
Keys of each deal
A deal names where each side is paid: the board shows each listing's sellerKeys and each request's buyerKeys, an
offer hands its buyerKeys to the seller, and an answer its sellerKeys to the buyer. None of them is the wallet's
main private address, which the vault's registry links to the wallet (KeysRegistered(owner, opk, viewKey)). Every
listing, offer, request and answer receives on keys derived for it alone (packages/sdk/src/otc-keys.ts):
nk' = H(DOMAIN_OTC_DEAL, sk, index) DOMAIN_OTC_DEAL = keccak256("voidcash/v1/otc-deal") mod p
opk' = H(nk', x_hi, x_lo, y_hi, y_lo) ownerKey(nk', wallet key): the main opk's formula
view secret' = HKDF-SHA256(ikm = sk as 32 bytes, no salt,
info = "voidcash/v1/otc-deal/view" || index as 4 bytes big-endian, 32 bytes)
view public' = X25519 public key of view secret'sk, H, p and the wallet key are those of Keys. index is a whole number from
0 to 2^32 − 1 that the wallet gives one record, once (OtcWallet.dealKeysFor).
- Apart from every other key. The main
nkisH(sk), a hash of one input. Poseidon2's sponge starts from the input length, so a three-input hash is separated from it on top of the domain constant, and two indexes are two inputs:nk'equals the mainnk, or another index's, only on a Poseidon2 collision (checked anyway). The view key comes from its own HKDF label, apart from the main view key (voidcash/v1/view) and the private address's (voidcash/v1/private-address/0). - Nothing public links them. They are never registered, so no
KeysRegisteredentry names them, and no two records share them. Only the wallet key is public, and it gives none of them: each needssk, which never leaves the device. - Deterministic. The same wallet derives the same keys for an index on any device, which is what lets a new device find its deals again (below).
Spending a deal-key note
The circuit already takes one nullifier key per input (in_nk: [Field; 3]) and one wallet
key, and checks every input's owner key as H(in_nk[i], x_hi, x_lo, y_hi, y_lo). So a note owned by opk' is spent
with nk' in its slot, next to main-key notes in the same transaction, under the same Spend signature. Nothing in
the circuit or the contracts changes for deal keys. The SDK refuses, before it proves, an input whose owner key is not
ownerKey(nk, wallet key) for the nk it carries.
A half pays its owner on the record's keys, and returns its change to the main keys. Its own outputs are therefore readable by its owner's main view key (the change) or the record's (the note it receives), never by another wallet.
Funding a standing half
A standing half spends only a note owned by its record's keys, and the app makes it in two signatures:
fundStandingmoves exactly what the half spends (the buyer's price; a token seller's size; a HYPE seller's size and the desk's fee) out of the main balance into one note owned by the record's keys, by a private send. The note's opening, with its index, is stored on the device before the send. The app waits until a refresh shows the note.otcStandingmakes and proves the half on that note alone.
So the nullifier the other side and the desk see belongs to a note that leaves only by a private send: the deal,
otcRelease (voiding, back to the main keys) or sweepKnownNotes. It can never meet a later spend of the main
balance, such as an unshield to a public address. A renewal tops up or reshapes on the record's keys the same way
(renewalNeed, fundRenewal), then proves the half again. A closing half settles at once, so it spends the main
balance (with fundExact first when it pays the desk).
Bringing notes home
The main scan reads only the main keys, so it never lists a deal-key note. The app keeps the opening of every note a
deal will pay it, with the index of its keys, and checks them after every refresh (syncOpenings). sweepKnownNotes
brings them into the main balance: private sends to the main keys, each spending the deal-key note with its nk'. A
token note's gas comes from a main-key HYPE note in the fee pair; a HYPE note pays its own. A group it cannot send (a
note too small for its gas, a token note with no HYPE note for its gas) is left and reported with the reason, and the
rest is sent. A note set aside for an open half is left alone. Each sweep is signed by the wallet, as every spend is.
A refunded fee is paid by ciphertext alone to the keys of the listing or offer it was paid for (the fee's refundTo).
findDealNotes finds such notes by trial decryption with the given indexes' view keys and stores their openings.
Recovery and index reconciliation
An index is never used twice. dealKeysFor takes the next index at once, so concurrent calls never share one, and
persists the allocation (saveDealKey) before it hands the keys out. An index whose allocation failed to persist is
never handed out, nor tried again. Two devices with disjoint records would derive the same keys for the same index,
so the app closes that gap two ways:
- Recovery from the chain. A device that keeps no allocation for the wallet runs
recoverDealKeysbefore any new one. It reads the vault's events once, checked against the chain's roots as every scan is, then tries the deal keys of the indexes from 0 up, with a gap limit of 20: it stops after 20 indexes in a row that were never paid (a note spent since counts as paid). It stores the openings of the unspent notes found, and an allocation (kindrecovered) for every index up to the last one used. It compares view tags with the platform's X25519 and decrypts in full only on a match: about 18 µs per note and index, so about 0.8 s for 2,000 notes of the vault and the default gap. - The desk's lists of the wallet's own records. The desk shows a signed-in wallet the keys of its own blocks,
offers, requests and answers, and each fee's
refundTo, to that wallet only. Before each allocation, the app maps every one of them to its index (among its allocations, or by deriving up to 256 past the highest known) and moves past the highest (reserveIndexesUpTo). A record made on another device, even one never paid, is then never given the same keys here. A desk that cannot be read allocates nothing.
An export of the device's records holds the openings and the allocations; importing it on another device skips the search, and is the only way to find a note whose ciphertext the other side made unreadable.
What stays visible
- The desk knows which signed-in wallet made each listing, offer, request and answer, as before: deal keys keep the wallet from the public and the counterparty, not from the desk.
- An invite-only block names its invited wallets' addresses; the seller typed them.
- A signer held by a service sees the
transactionhash of everySpendit signs, which anyone can compute from a transaction's public inputs on chain: such a service can tie the wallet's fundings, halves and sweeps to it.
The SDK's tests: otc-keys.test.ts (the derivation), otc-deal-keys.test.ts (real proofs spending a deal-key note
beside main-key notes; a whole deal on deal keys, swept), otc-wallet-deal-keys.test.ts (allocation, halves, funding,
sweeps, refunds), otc-deal-recovery.test.ts (the gap limit, indexes used elsewhere, sweeps that skip).
What the desk signs
The desk's signer signs an EIP-712 message under its own domain:
| Field | Value |
|---|---|
| Domain | name voidcash OTC desk, version 1, chain ID 99901, verifying contract the OtcDesk proxy |
| Type | Deal(bytes32 dealId,uint64 deadline,bytes32 sellerCommitments,bytes32 buyerCommitments,bytes32 sellerExt,bytes32 buyerExt) |
sellerCommitments, buyerCommitments | keccak256(abi.encode(commitments)): each half's four new commitments |
sellerExt, buyerExt | keccak256(abi.encode(ext)): each half's whole ExtData (caller, recipient, gas fee, data and the four ciphertexts). The plain hash, not the vault's field-reduced extDataHash |
The signature binds every commitment of both halves and each half's whole external data. A party that re-proves its
half with other external data, such as a ciphertext its counterparty cannot read, cannot settle it under a signature
copied from a pending settle: the new half needs a new signature, and the desk checks it again before signing.
OtcDesk.dealDigest(dealId, deadline, sellerCm, buyerCm, sellerExt, buyerExt) returns the digest, and the SDK's
dealTypedData builds the same message; both match the contract's test vector byte for byte.
What OtcDesk checks
settle(seller, sellerProof, buyer, buyerProof, deskSignature) checks, in order:
Paused).Each half is a private send only the desk can submit: ext.caller is the desk (WrongCaller), nothing leaves the
vault and there is no recipient (NotAPrivateSend).
DealMismatch), and the deadline has not passed (Expired).CounterpartMismatch).AlreadySettled).BadSignature).It then marks the deal settled, submits the seller's half and then the buyer's to the vault's transact, and emits
DealSettled(dealId). If either half fails in the vault (a spent note, an unknown root, a bad proof, the vault
paused), both revert. A half for the ERC-4337 path names the vault as its caller, not the desk, so it can never be
settled here.
What the desk service checks
The service runs every deal rule through the SDK (checkHalf, checkDeal, dealTypedData, dealFee,
checkGasFee, checkDeadline), and reads what costs nothing before it asks the chain anything.
A standing half, when it comes in. Without the chain: its deal id, its gas fee and the note it receives (a 306-byte ciphertext); a deadline at least 1 hour and at most 14 days from now, and no later than its block's end (an auction's 48 hours to choose included) or its request's; the desk's fee note if and only if the fee is on this side; a proof of exactly 9,152 bytes; a private send only the desk can submit, whose leg names this deal and deadline; the caps. Then on the chain:
- the gas fee against the desk's quote, 12,000,000 × the gas price from the service's own RPC: a buyer's within 20%
either way, a holder's from the quote up to twice it, and never above 3 × the quote (
checkGasFee); - its notes unspent and its root still known to the vault;
- its proof, by an
eth_callto the verifier the vault names, with the public inputs the vault would pass it. A revert is a refusal; an endpoint error is not, so "no" and "cannot ask" stay apart.
A closing half, under the block's lock: it names the standing half it read (by that half's first ciphertext); the
deadline is more than 60 seconds and at most 14 days away; a price paid in HYPE is more than the deal fee; the gas price
has not risen past 120% of what the standing half carries; the standing half is read on chain and verified again;
checkHalf on both halves, with the desk's own fee-note stub; the closing half's proof and its notes; and no deal with
this id, unless one failed and the contract says it never settled.
Before signing, everything is read again: checkDeal on the record; the deadline more than 60 seconds and at most
14 days away; both halves' notes unspent and roots known, at one block 2 confirmations deep; both proofs by the vault's
verifier, asked now; the gas price within 120% of what the halves carry. A deal that fails any check is never signed,
and its offer or answer opens again.
Settlement. The relayer simulates settle with 12,000,000 gas and sends the same call only if the simulation
succeeds. It records the transaction's hash as soon as the node takes it, then waits for the receipt 2 blocks deep. A
send that ends in an error is decided by OtcDesk.settled at a confirmed block. A deal sent and not seen on the chain
is sent again, while both halves are live and its deadline is more than 60 seconds away; the contract settles a deal,
and its notes, once.
A real deal's settle measured 9,838,953 gas (a token for HYPE) and 9,838,977 gas (HYPE for USDC) with two real proofs
in the contracts' end-to-end tests, under the 12,000,000 the desk quotes.
Prices
The desk reads prices straight from Elysium's Uniswap v4 PoolManager (0xE2e105d3F7209A9DA11f83cCf3E7398a753823F1). It finds each
token's pools against HYPE (native or WHYPE) from the PoolManager's Initialize events, and quotes from the deepest
pool that counts. A pool counts only if its hook is a launchpad's (Volta, Ascend, Montra) or it is a named reference
pool, since anyone can open a v4 pool at any price.
| Token | Pool | What |
|---|---|---|
| VOID | 0xe488e93cba1cbbb1493d898a4f352571d0d96ddc4902f5449d07ad33ee34ee08 | Volta's pool: native HYPE / VOID, fee 0 (Volta's hook charges its own), tick spacing 60 |
| KNTQ | 0xf9b8a9101438145d62c9f03156b203c6c573931167e2d36f9061a32575706c8a | Reference: native HYPE / KNTQ, 0.3%, tick spacing 60, no hook |
| USDC, for HYPE blocks | 0xb3032695ffb0a66e6342876dd2386835471466cb2bb70f341947d98a69e265cc | Reference: native HYPE / USDC, 0.3%, tick spacing 60, no hook |
The pools are read every 5 seconds. Each token keeps its good reads of the last 10 minutes; a failed round adds none, and no read is stored. A % to market price and the VOID holder's waiver use the median of that window, never the spot alone. The price is refused, with the reason, while:
- the latest read is more than 30 seconds old;
- the pool's HYPE side, on the latest read, is under the floor of 5.6 HYPE (such a token lists at a fixed price only);
- the window holds fewer than half the 120 reads it should;
- the window has a gap of more than a minute between reads, at its start or since its last read; after a restart it fills in about 9 minutes;
- the spot is more than 0.5% from the median (
MAX_SPOT_DEVIATION_BPS= 50).
HYPE's price in USDC inverts the USDC pool's price.
Fees, decided and moved
The desk service decides, once per payer, whether each listing, top-up and first-offer fee burns or is refunded
(the rules), and records the gas its relayer spent on each settlement. A fee
is a private send of a note of exactly the fee to the desk's private address. The payer hands in the note's opening
and its transaction. The desk computes the commitment with its own public key, and takes it only if that transaction
added that note, its block is 2 confirmations deep, the receipt comes within an hour of that block, the note is not a
deal's own fee note, and OtcDesk took no part in the transaction. Each note is taken once.
The fee keeper
The keeper is a separate process, and holds the only key that spends the desk's notes. The desk service holds only that address's public keys: it can decide, never move a note. Each round, 60 seconds after the last, the keeper:
- refunds every fee decided "refund", by a private send to the deal keys of the listing or offer it was paid for
(its
refundTo), exactly once; - repays the relayer the gas fee of each settled deal, at most once per deal;
- unshields to
VoidBurneronly amounts known to be burnable, each once, never "whatever is left"; - calls
VoidBurner.collect()when a simulation says it buys, andburnHeld()for VOID the burner holds.
It checks every record against the chain, since the desk's database can be written by the desk service's role:
- a fee's amount and refund address are copied into the keeper's own ledger the first time it sees the fee; a refund pays exactly those, and a record that says otherwise later is held for review, never paid;
- a fee's receipt must open, under the desk's keys, to the commitment that is the fee's id, and that note must be in the vault and not a deal's fee note;
- a deal is repaid or burned only once
OtcDesk.settled(dealId)says so on chain, its fee note opens under the desk's keys to the stub its record names and is in the vault, and its gas fee is within that note and 0.05 HYPE; - every send is written to the keeper's ledger before it is made, and one that may have landed is never sent again.
It caps what leaves. Refunds at most 30 HYPE a day, gas repayments at most 2 HYPE a day, and refunds and
repayments together at most 10 HYPE a round; past a cap they wait, and an alarm is raised. Burns go only to
VoidBurner, so a burn over the round's cap is split across rounds rather than stopped. Each unshield stays under the
vault's large-exit threshold. The desk's own gas (its private sends and each repayment's 1% exit fee) is held back
from the next burns, never taken from fees it still owes.
It raises alarms, as log lines and in the desk's /health: when the desk publishes another fee address (nothing
is sent), a cap was hit, the desk wallet holds more than 25 HYPE or less than the fees it owes plus its gas reserve, burnable fees wait more than 6
hours, the relayer is owed more than 0.5 HYPE, a refund has not landed within 24 hours, a send is unconfirmed for 15
minutes, an exit is stuck, VoidBurner sits on more than 5 HYPE or has not spent for 6 hours, or the keeper's own gas
runs low. The desk raises its own alarm when the keeper stops reporting for 30 minutes.
VoidBurner
VoidBurner receives the desk's fees in HYPE and burns VOID with all of it; there is no team share. It holds HYPE
until a call to collect() buys VOID on its Volta pool, and sends what it bought to
0x000000000000000000000000000000000000dEaD. VOID sent to it directly is burned by burnHeld(). Anyone can call
either.
It buys under the fee collector's rules, so that nothing read in the calling transaction decides how much is spent or at what price:
| Rule | Value |
|---|---|
| Price for the minimum out | Volta's TWAP over 600 seconds |
| Minimum VOID out | The TWAP price after the pool's swap fee, less MAX_SLIPPAGE_BPS = 1% |
| No buy while VOID is dearer than the TWAP by more than | MAX_DEVIATION_TICKS = 50 (about 0.5%) |
| Most HYPE per buy | MAX_BUY = 0.5 HYPE |
| Most HYPE per 24-hour window | WINDOW_CAP = 10 HYPE |
| Buys | At most one per BUY_INTERVAL = 12 seconds |
| A buy the pool does not fill within the minimum | Halved, up to 8 times; if none fits, nothing is bought |
| Pause | setBuyingPaused, by the guardian; the HYPE held waits |
What does not fit waits for the next call. A call that buys refunds its caller the call's gas plus 25,000, at the lower of the transaction's gas price and twice the base fee, and never more than 0.5% of what the call takes out in all. A call that buys nothing refunds nothing. The pool, hook, oracle and VOID are immutables of the implementation, checked in its constructor against Volta's hook and creator NFT.
Upgrades and roles
Both contracts are UUPS proxies. The vault's admin, 0xb06aBb2a232e6e7e91b37ADf79116c41AD4b879a, holds DEFAULT_ADMIN_ROLE (upgrades;
rotates the desk's signer) and GUARDIAN_ROLE (pauses settlement, or the burner's buying) on both. A pause of the desk
stops settlement only: every owner can still spend their notes in the vault. Rotating the signer voids every deal
signed by the old key. What this means for users is on Trust model; the
interfaces are on Contracts.
Private swaps
How the vault trades out of notes in one atomic operation, through a router it does not trust, measuring its own balance.
Private gas
How the vault acts as its own ERC-4337 account so that each private transaction pays its gas in HYPE from the notes it spends, what validation checks, where the gas fee goes, the bundler at bundler.voidcash.io, the SDK's submitters and gas prices on Elysium.