voidcashdocs

Private swaps

How the vault trades out of notes in one atomic operation, through a router it does not trust, measuring its own balance.

A private swap is an exit and a shield in the same operation. The proof spends notes exactly as an exit does, with the vault itself as the recipient. The circuit does not change: the order rides in ext.data, which the proof already binds through extDataHash.

struct SwapOrder {
    address assetOut;   // 0 = HYPE; exactly one of assetIn, assetOut is HYPE
    uint256 minOut;     // in assetOut base units, after every fee
    uint48 deadline;    // unix seconds
    uint256 stub;       // H(opk, rho, r) of the note that comes back, output or refund
    bytes ciphertext;   // that note's ciphertext, amount 0, asset assetOut
}
// ext.recipient == address(vault)
// ext.data == abi.encode(minCallGasLimit, order)

The two phases

Validation (validateUserOp) runs the usual checks and the proof and spends the notes. Then SwapLib.record:

  • refuses a paused or routerless state, an order that is not one HYPE side, a stub outside the field, a minOut of 0 or at MAX_AMOUNT, and a deadline of 0;
  • for a buy, applies the HYPE limit per swap below, refusing anything above it;
  • moves the input from backing to pending, and stores the swap under the transaction's first nullifier;
  • emits SwapRecorded, which carries the ciphertext of the note to come.

The return value carries validUntil = deadline, so the EntryPoint refuses a late operation. Validation calls no contract that can change: SwapLib's code is fixed, and it reads only the vault's storage and the order.

Execution (execute4337) runs SwapLib.settle as a library call inside try, a frame of its own:

  1. Refuses if swaps are paused, the deadline has passed, the window is full, or the output may not enter: a closed entry, or a token no adapter recognises. A token not yet listed lists itself here, with its launchpad's limits.
  2. Counts a buy in the HYPE window, takes the exit fee and sends the rest through the router: HYPE as value, a token by transfer.
  3. Measures the vault's own balance of the asset out. It must have grown by at least minOut, and by less than MAX_AMOUNT.

On success the vault inserts the note commitment(stub, out, assetOut) and emits SwapSettled. On any failure the frame reverts, so nothing moved: it inserts commitment(stub, amountIn, assetIn), emits SwapRefunded, and takes no fee. If execution runs out of gas as a whole, the record stays, and after the deadline anyone can call refundSwap(id). That calls no token and no router, so neither can stop it.

The direct path, transact, runs both phases in one call.

Limits

Asset inPer swapPer 24 hours
HYPE (a buy)maxSwapIn: 100 HYPE, settable from 1 to 1,000swapWindowCap: 500 HYPE, settable from maxSwapIn to 10,000
A token (a sale)NoneNone

A buy above the limit per swap is refused in validation, not held: it cannot wait 24 hours. The window is counted in execution, so it holds only what settled: a buy that fails or never finishes cannot fill it for others, and a buy above it comes back as a note.

A sale has no limit of its own (decided on 2026-11-08), so a whole position sells in one swap. A token's largeExitThreshold and windowCap apply to its exits to an address only, and a sale takes nothing of that window. What a sale brings in is HYPE in a note, which leaves the vault only through an exit, with the HYPE exit's hold. The guardian's setSwapsPaused stops sales with every other swap.

Router and adapters

TerminalRouter sits behind an ERC-1967 proxy and is upgradeable. It holds a list of adapters, one per launchpad, and sends each token to the first that recognises it. Adapters are plain contracts, and adding one needs no vault upgrade.

VoltaAdapter accepts a token only if all of these hold:

  • Volta's creator NFT records it, in both directions: tokenId(token) and memecoin(id) agree;
  • its code equals the 44-byte clone of the token implementation pinned in the adapter, whole;
  • poolKey(token) hashes to native HYPE, the token, fee 0, tick spacing 60 and Volta's PositionManager as hook;
  • its trading has started.

It swaps through the PoolManager directly, and reverts rather than fill part of an input or pay below the minimum.

What a bad router can do

The vault sends the input and requires its own balance to grow by minOut in the same frame, or everything reverts. It grants no allowance, so a router can take nothing more, and it cannot pay with the vault's own funds, since every way out of the vault holds the reentrancy guard. So a broken or malicious router can pay as little as the order's minimum and no less, within the HYPE limits. The app reads its quote from the adapter, which cannot be upgraded, so the router has no say in that minimum. It never keeps an input without paying, and never touches notes. It can list a token that is no launch; books are per token, so that hurts only holders of such a token.

Finding the note

A wallet finds the note a swap ended in by its leaf: SwapSettled or SwapRefunded names the leaf, the amount and the asset, and by the swap's id leads to the ciphertext in SwapRecorded, which holds rho and r. The commitment is recomputed from them, so an event cannot claim another amount. A late refund lands in a later transaction than its record, and is found the same way.

Fees

No new fee. A buy pays the HYPE exit fee on its input, to the fee collector. A sale pays the token exit fee on its input, in the token, to the token fee recipient. The shield of the output is free, like every shield. A refund pays none.

On this page