Developers
Contracts
The external surface of OpaquePool.
Copy Markdown
Draft
This is the draft interface. It may change before launch.
Structs
struct ExtData {
address recipient;
address caller; // zero means anyone may submit
uint256 fee; // relayer fee, in shares
bytes data; // must be empty for now
bytes ciphertext0;
bytes ciphertext1;
}
struct Transaction {
uint256 root;
uint256[2] nullifiers;
uint256[2] commitments;
uint256 assetId;
uint256 exitAmount;
ExtData ext;
}Functions
function shroud(uint256 stub, uint256 amount, bytes calldata ciphertext) external returns (uint32 index);
function transact(Transaction calldata t, bytes calldata proof) external;
function donate(uint256 amount) external;
function setDepositsPaused(bool paused) external;| Function | Description |
|---|---|
shroud | Deposits amount $OPA into a note completed with stub. Reverts while deposits are paused or above the cap |
transact | Spends up to two notes, creates two notes and optionally exits part of the value, paying the flat fee. Checks the root, the nullifiers and the proof |
donate | Adds $OPA to the vault backing without minting shares. Anyone can call it, also while deposits are paused |
setDepositsPaused | Guardian only. Pauses or resumes new shrouds. Nothing else |
Views
function isKnownRoot(uint256 root) external view returns (bool);
function nullifierSpent(uint256 nullifier) external view returns (bool);
function depositCap() external view returns (uint256);
function sharesForTokens(uint256 amount) external view returns (uint256);
function tokensForShares(uint256 shares) external view returns (uint256);
function publicInputs(Transaction calldata t) external pure returns (bytes32[] memory);
function extDataHash(ExtData calldata e) external pure returns (uint256);publicInputs and extDataHash are exposed so clients and tests build the same values the contract checks.
Events
event NoteAdded(uint256 indexed index, uint256 commitment, bytes ciphertext);
event NullifierSpent(uint256 indexed nullifier);
event Shrouded(address indexed from, uint256 indexed index, address indexed asset, uint256 amount, uint256 units);
event Exited(uint256 indexed nullifier, address indexed recipient, address indexed asset, uint256 amount);
event Donation(address indexed from, address indexed asset, uint256 amount);
event AssetRegistered(uint256 indexed assetId, address indexed asset, bool shareBased);Wallets rebuild the tree and find their notes from NoteAdded.
Errors
| Error | Raised when |
|---|---|
DepositsPaused | A shroud while the guardian has paused deposits |
NotGuardian | Someone else calls setDepositsPaused |
UnknownAsset | An asset id other than 1 |
BadAmount | A zero or oversized amount |
NotInField | A value at or above the field size |
CapExceeded | A shroud above the current deposit cap |
ZeroShares | A $OPA shroud that would mint no shares |
UnknownRoot | A proof against a root that is not in the last 64 |
NullifierUsed | A nullifier already spent |
DuplicateNullifier | Both nullifiers in a transaction are the same |
WrongCaller | ext.caller is set and the sender is someone else |
FeeTooHigh | Relayer fee plus the flat fee exceeds the exit amount |
BadExit | An exit without a recipient, or a fee with no exit |
ExitTargetsNotSupported | ext.data is not empty |
InvalidProof | The verifier rejects the proof |
TransferFailed | A token transfer fails |
EthNotAccepted | ETH sent to the pool |
FeeOnTransferToken | The token delivered less than requested |
InsufficientBacking | An exit larger than the pool holds |
Reentrancy | A reentrant call |