Contracts
The external interface of the vault, the router and the harvester.
Solidity, compiled with solc 0.8.39 and built with Foundry. Sources are in contracts/src. The vault, the router
and the harvester each run behind an ERC-1967 proxy: call the proxy's address.
QuantumVault
Entering
function shield(bytes32 account, uint256 amount) external returns (uint256 shares);
function donate(uint256 amount) external;
function absorb() external returns (uint256 amount);shield requires an approval for amount. account must be a key somebody holds: tokens shielded to an arbitrary
value have no signer.
Operating
function transact(Op calldata op, bytes calldata signature) external;
// ERC-4337 (EntryPoint only)
function validateUserOp(PackedUserOperation calldata userOp, bytes32, uint256 missingAccountFunds) external returns (uint256);
function execute4337(uint256 id) external;
function claimExit(uint256 id) external;Reading
function accounts(bytes32 account) external view returns (bytes32 key, uint64 nextLeaf, uint64 epoch);
function keyOf(bytes32 account) external view returns (bytes32);
function sharesOf(bytes32 account) external view returns (uint256);
function assetsOf(bytes32 account) external view returns (uint256);
function convertToShares(uint256 assets) external view returns (uint256);
function convertToAssets(uint256 shares) external view returns (uint256);
function opDigest(Op memory op) external view returns (bytes32);
function opId(bytes32 account, uint64 epoch, uint256 leaf) external pure returns (uint256);
function totalBacking() external view returns (uint256);
function totalShares() external view returns (uint256);
function pendingExitTotal() external view returns (uint256);
function tokensPerEthEma() external view returns (uint256); // tokens per HYPE, 1e18 scale
function networkFee() external view returns (uint128);
function previousNetworkFee() external view returns (uint128);
function maxOpCostWei() external view returns (uint256);
function entriesPaused() external view returns (bool);Price
function poke() external;Events
| Event | Emitted when |
|---|---|
Shielded(account, from, amount, shares) | Tokens enter an account |
Operated(account, opId, epoch, leaf) | A signed operation is applied |
Transferred(from, to, shares) | Shares move between accounts |
Exited(account, opId, recipient, amount, shares) | Tokens leave the backing |
ExitSettled(opId, byTarget) | An exit has been paid out |
KeyChanged(account, newKey, epoch) | An account replaces its key |
Donation(from, amount) | Tokens are added for every account |
VaultUpdated(totalBacking, totalShares) | The exchange rate changes |
PriceUpdated(tokensPerEthEma) | The price average moves |
NetworkFeeUpdated(networkFee) | The network fee is recomputed |
An account's full history is the set of logs indexed by its name: no indexer is needed beyond eth_getLogs.
Errors
InvalidSignature, LeafAlreadyUsed, KeyUnchanged, InsufficientShares, Expired, WrongCaller,
InsufficientGasFee, GasCostAboveLimit, InvalidUserOp, NotEntryPoint, NoPrice, NoSuchExit,
EntriesArePaused, NotGuardian, ZeroAddress, ZeroAccount, ZeroShares.
QuantumRouter
function buy(bytes32 account, uint256 minTokensOut) external payable returns (uint256 tokensOut);
function quote(bool isBuy, uint256 amountIn) external returns (uint256 amountOut);
function onShieldExit(uint256 amount, address ethRecipient, bytes calldata data) external; // vault only, data = abi.encode(minHypeOut)
// Shared with the harvester (VoltaSwapper)
function swapFeeBps(bool isBuy) external view returns (uint256); // Volta's current fee, in bps
function spotPrice() external view returns (uint256); // tokens per HYPE, 1e18 scale
function poolKey() external view returns (PoolKey memory);
function poolId() external view returns (PoolId);Events: Bought(account, ethIn, tokensOut), Sold(ethRecipient, tokensIn, ethOut); the eth amounts are in HYPE.
FeeHarvester
function harvest() external returns (uint256 tokensDonated);
function payTeam() external;
function claimable() external view returns (uint256);
function creatorNftId() external view returns (uint256);
function setTeamRecipient(address newRecipient) external; // owner
function proposeSuccessor(address successor) external; // owner
function cancelSuccessor() external; // owner
function executeSuccessor() external; // anyone, after SUCCESSOR_DELAY
function transferOwnership(address newOwner) external; // ownerexecuteSuccessor sends the creator NFT to the successor. The harvester accepts, through onERC721Received, only
the token's own creator NFT.
Events: Harvested(ethAvailable, ethToDeposit, ethSpent, tokensDonated) (amounts in HYPE), TeamShareAccrued,
TeamPaid, CallerTipped, SuccessorProposed, SuccessorCancelled, FeeRecipientHandedOver, CollectFailed.
Upgradeable
Shared by the vault, the router and the harvester (UUPS, OpenZeppelin 5.7.0):
function upgrader() external view returns (address);
function pendingUpgrader() external view returns (address);
function proposeUpgrader(address newUpgrader) external; // upgrader
function acceptUpgrader() external; // the proposed upgrader
function renounceUpgrades() external; // upgrader: no upgrade ever again
function upgradeToAndCall(address newImplementation, bytes memory data) external payable; // upgraderThe role lives in its own ERC-7201 slot. See contracts/UPGRADEABILITY.md.
Xmss
library Xmss {
function recover(bytes32 digest, bytes memory sig) internal pure returns (bytes32 key, uint256 leaf);
}A self-contained library with no dependencies. See the signature scheme.
Tests
The Foundry suite covers the signature library against vectors from the TypeScript implementation, the vault's
accounting, the ERC-4337 path against the real EntryPoint, stateful invariants on the vault's books, and the Volta
integration, proxies and upgrades included, on a fork of Elysium (VoltaFork.t.sol, at a fixed block: ELYSIUM_RPC
sets the endpoint, ELYSIUM_FORK_BLOCK another block, SKIP_FORK=true skips it).
pnpm contracts:test