voidcashdocs

Deposit addresses

How the Bridge shields funds that arrive from another chain - an address computed from one note that can only become that note or go back to its refund address, the factory that completes it, its fee, its limits and its roles.

Bridges and services deliver funds to an address; they do not call a contract when they arrive. The vault refuses plain HYPE, so funds bridged to Elysium would first land on a public address of the user's and be shielded from there: the public step the vault exists to avoid.

A deposit address closes that gap. It is made for one note, anyone and anything can send HYPE to it, and what arrives can only become that note in the vault or go back to the user's refund address. The Bridge page uses it with Relay; any other way of sending HYPE on Elysium reaches it the same way.

The address

The app builds a note with the user's keys, as for any shield, and describes the deposit:

struct Deposit {
    uint256 stub;            // the note's stub, as in vault.shield
    bytes32 ciphertextHash;  // keccak256 of the note's ciphertext
    uint256 amount;          // exactly what the note holds
    uint256 fee;             // paid to whoever completes the deposit
    address refundAddress;   // where anything that is not shielded goes
    uint64 deadline;         // after it, an unshielded deposit may be refunded
}

The deposit address is a CREATE2 address:

  • Deployer: the DepositFactory proxy, 0x374DA27D9eC72F0812C633aEF9065207D27fA298, whose address never changes.
  • Salt: keccak256(abi.encode(deposit)), so every field is part of the address. Change any of them and the address changes.
  • Init code: DepositBox, one constant contract with no parameters. Its constructor sends its whole balance to the factory, and a sweep() that only the factory may call does the same later.

The factory's own code is not part of the address, so an upgrade of the factory does not move the addresses already given out. addressOf(deposit) returns it on-chain, and the SDK computes it locally (depositAddress).

Until it is completed, no code lives at the address and nobody holds a key for it: the funds wait there.

Completion

complete(deposit, ciphertext), callable by anyone, does everything in one transaction:

  1. checks that ciphertext hashes to ciphertextHash, and that amount is above zero and at most maxDeposit;
  2. deploys the box at the deposit address, which hands its balance to the factory;
  3. refuses, leaving the funds where they were, if less than amount + fee arrived;
  4. shields exactly amount in the vault with the note's stub and ciphertext;
  5. pays fee to the caller and sends anything above amount + fee to refundAddress.

The vault records the shield like any other: a NoteAdded with the note's ciphertext, sent by the factory. The note's ciphertext carries its amount, and the user's wallet recognises the note only if they match, which is why the factory shields exactly amount and never what happened to arrive.

A deposit is shielded once. After that, anything sent to the same address can only go back: a second identical note could not be spent.

Refund

refund(deposit), callable by anyone, sends everything at the deposit address to refundAddress:

  • after deadline, while the deposit is not shielded;
  • at any time once it is shielded.

A completion stays possible after the deadline, until a refund is made. The app sets the deadline 24 hours after the address is made.

Fee

A fixed fee in HYPE, chosen by the app when the address is made and fixed in it, paid to whoever completes the deposit. The deposit service quotes the minimum: 1,300,000 gas at Elysium's current gas price, with a 50% margin. A completion against the live vault used 1,045,216 gas. The user sees the fee before paying; voidcash pays nothing per deposit.

The deposit service

The factory needs a deposit's fields to complete it, and they are not on the chain before then. The app sends them to the deposit service (https://deposits.voidcash.io), which:

  • takes a deposit only from the app's origins, and checks it before storing it: the address, the ciphertext's hash, the amount within the cap, a fee at least the minimum and a deadline no further than 24 hours away;
  • reads the balances of the addresses it knows every few seconds, and calls complete once amount + fee has arrived and the fee covers the gas;
  • calls refund after the deadline, or when funds arrive at a deposit already shielded;
  • stops watching an empty address a week after its deadline;
  • alerts on a deposit above 5% of the HYPE in the vault.
EndpointWhat it does
GET /terms{ factory, boxCodeHash, minFee, maxDeposit, deadlineSeconds, paused }
POST /depositsRegisters { deposit, ciphertext }; answers { address }. From the app's origins only
GET /deposits/<address>{ address, state, balance, due, deadline, transactionHash? }, state being waiting, completed, refunded or expired

It learns the deposit address, the amount, the refund address and the network address of the request. It does not learn the note's owner: the stub reveals nothing, as for any shield. The app keeps the deposit's fields in the browser, so anyone can complete or refund it from another client if the service stops: both functions are open to all.

Limits and roles

The factory is an ERC-1967 proxy over a UUPS implementation, 0x34c331999efAb61D6Ec1a47577A6EC5F0187b260, chosen to be upgradeable so that a bug can be fixed in place without moving the addresses already given out.

Role or valueWhat it does
maxDeposit50 HYPE: the most one deposit may shield. Set by the admin (setMaxDeposit)
DEFAULT_ADMIN_ROLESets maxDeposit, grants and revokes the roles
GUARDIAN_ROLEpause and unpause: stops completions and refunds. Funds wait at their addresses meanwhile; nothing is lost
UPGRADER_ROLEReplaces the factory's implementation, with no delay

The three roles are held by 0xb06aBb2a232e6e7e91b37ADf79116c41AD4b879a, as the vault's. The vault's own entries pause also stops completions, since the factory shields through shield.

The factory holds HYPE only inside a transaction: a completion or a refund moves everything on before it ends. It accepts HYPE only from the box it is emptying in that transaction. What waits sits at the deposit addresses, each reachable only through the factory. Whoever holds UPGRADER_ROLE could change what the factory does with those funds; see Trust model.

Paying from another chain

The app calls Relay's public API directly, without its SDK: no third-party code runs in the page that holds the privacy keys. It asks for a quote that delivers exactly amount + fee HYPE to the deposit address on Elysium (EXACT_OUTPUT), with the user's wallet as Relay's refund address on the chain they pay from. It refuses a quote with a step that is not a transaction, or a transaction on another chain than the one chosen. The page's Content-Security-Policy adds https://api.relay.link and Relay's image host, and nothing else, for this.

On this page