Architecture
Deep dive into the on-chain programs, token model, account structure, and transaction flows.
On-Chain Programs
regvault
8nGe1FgxR8tDcvrnsaC7C3o9PjypG2br4xsXQYxsfGeLThe main protocol program handling vault operations, entity registry, and compliance controls. Built with Anchor 0.32.1.
- Vault initialization and role management
- Entity registry (create, status updates, limits)
- Wallet claiming and venue linking
- Issuer attestations with expiry
- Deposit and mint share tokens
- Withdraw queue (request, approve, execute, cancel)
- Immutable receipt generation
- Pause controls and emergency mechanisms
share_hook
EduibecVcDB9oMp1uUy1WLnYJMGCMHXHwRwi7eSdg9GKToken-2022 Transfer Hook program that validates every share transfer. This is where compliance enforcement happens at the token layer.
- Initialize ExtraAccountMetaList for share mint
- Execute hook validates source entity and attestation
- Validate destination (approved venue or active entity)
- Uses SPL TLV account resolution for deterministic PDAs
Token Model
Deposit Token (USDC)
Users deposit USDC into the vault. On localnet, this is a mock USDC mint created during initialization. On devnet/mainnet, this would be the official USDC mint.
Share Token (rvUSDC)
The share token is a Token-2022 mint with the Transfer Hook extension enabled. This extension calls the share_hook program on every transfer, enabling protocol-level enforcement of compliance rules.
Why Token-2022?
Vault Custody Accounts
Vault Deposit ATA: Holds deposited USDC, owned by the vault authority PDA.
Vault Share Escrow ATA: Holds shares during the withdraw request period, owned by the vault authority PDA.
Vault Authority PDA: Derived from ["vault_authority", vault_config]. Signs mints, burns, and transfers on behalf of the vault.
Account Structure
All protocol accounts are Program Derived Addresses (PDAs) for deterministic addressing and cross-program invocation safety.
VaultConfig
Seeds:["vault_config", vault_id]Central configuration: roles, policy, limits, mints, pause flags
Entity
Seeds:["entity", vault_config, entity_id]Institutional entity with status, tier, jurisdiction, and caps
EntityWallet
Seeds:["entity_wallet", vault_config, wallet]Wallet-to-entity binding with active flag
Attestation
Seeds:["attestation", vault_config, entity, issuer]Issuer-signed compliance attestation with expiry
WithdrawRequest
Seeds:["withdraw_request", vault_config, request_id]Withdrawal queue entry with approvals and timelock
Receipt
Seeds:["receipt", vault_config, request_id]Immutable audit evidence of execution
DailyWithdrawCounter
Seeds:["daily_counter", vault_config, entity, epoch_day]Per-entity daily withdrawal tracking
Transaction Flows
Deposit Flow
- User calls
deposit(amount)with valid entity wallet and attestation - Program validates: wallet active, entity active, attestation valid and not expired
- Program checks entity deposit cap
- USDC transferred from user ATA to vault deposit ATA
- Vault authority mints rvUSDC shares to user share ATA
- Entity total_deposited incremented
Withdraw Flow
- Request: User calls
request_withdraw(shares, amount_quote)- Shares transferred from user to escrow via Transfer Hook
- WithdrawRequest PDA created with timelock and approval requirements
- Approve: Operator and/or Compliance call
approve_withdraw- Approval flags tracked via bitmap
- Required approvals determined by amount threshold
- Execute: Operator/Compliance calls
execute_withdrawafter timelock expires- Shares burned from escrow
- USDC transferred from vault to destination
- Immutable Receipt PDA created
Share Transfer Flow (P2P)
- Any Token-2022 transfer invokes the Transfer Hook
- Hook resolves EntityWallet and Attestation PDAs for source
- Hook validates source: active entity, valid attestation
- Hook checks if destination is approved venue
- If not venue, resolves and validates destination entity/attestation
- Transfer succeeds only if all checks pass
Tip
Role-Based Access Control
Admin
- Initialize vault config
- Set roles (compliance, operator, emergency)
- Manage allowed issuers and primary issuer
- Set approved venues
- Pause/unpause operations
- Set policy thresholds
Compliance
- Create and manage entities
- Set entity status and limits
- Link/unlink venue wallets
- Approve withdrawals
- Sign attestations (if also issuer)
Operator
- Approve withdrawals
- Execute approved withdrawals after timelock
- Monitor queue and system health
Emergency Admin
- Pause operations in emergency
- Unpause only if explicitly allowed by admin
- Cannot perform other admin actions