Program

Program

The hush_vault program: addresses, the config account, instructions and errors.

hush_vault is an Anchor program. It holds the deposited SOL and USDC, mints hSOL and hUSDC against them, and burns and releases on a withdraw. Every amount it moves is public. Encrypted balances, sends and proofs are Token-2022's own instructions, run on the two mints this program created.

Program id: Gc2VRibTyvsu83LuX8Yd6k9gyuLWKAwc2G1Eno49fMaD

The API's config returns the program id, both mints and both vaults for the network it serves. The SDK derives the same addresses with hushAddresses.

Addresses

Every account the program owns sits at a program-derived address with one fixed seed, so each exists once.

AddressSeedHolds
config"config"The Config account.
authority"authority"No data. It signs for the program: mint authority of hSOL and hUSDC, and owner of the USDC vault.
sol_vault"vault_sol"The deposited SOL, as the lamports of a data-less account the program owns.
usdc_vault"vault_usdc"The deposited USDC, in an SPL Token account owned by authority.
hsol_mint"hsol"The hSOL mint, a Token-2022 mint with the Confidential Transfer extension.
husdc_mint"husdc"The hUSDC mint, the same kind.

A wallet's Hush account is its associated token account for the hSOL or hUSDC mint under Token-2022. The program doesn't create it. Set up does, through the token program.

Config

initialize creates the Config account. It is 173 bytes and holds the program's settings.

FieldTypeOffsetDescription
adminPubkey8The wallet that may call set_fee.
fee_recipientPubkey40The wallet the withdraw fee is paid to.
fee_bpsu1672The withdraw fee in basis points.
usdc_mintPubkey74The USDC mint the vault accepts.
hsol_mintPubkey106The hSOL mint.
husdc_mintPubkey138The hUSDC mint.
bumpu8170Bump of the config address.
authority_bumpu8171Bump of the authority address.
sol_vault_bumpu8172Bump of the SOL vault address.

Bytes 0 to 7 are the account discriminator.

Constants

ConstantTypeValueDescription
MAX_FEE_BPSu16100The highest withdraw fee initialize and set_fee accept: 1%.
SOL_DECIMALSu89Decimals of hSOL.
USDC_DECIMALSu86Decimals of hUSDC.

Instructions

Accounts are listed in the order the instruction takes them.

initialize

Runs once. Creates the config, both vaults and both mints. Each mint gets the Confidential Transfer extension with no auditor key, automatic account approval and no authority that could change either, and the program's authority address as its mint authority, with no freeze authority.

ArgumentTypeDescription
fee_bpsu16The withdraw fee in basis points. At most MAX_FEE_BPS.
fee_recipientPubkeyThe wallet the fee is paid to.
AccountWritableSignerDescription
adminYesYesPays for the new accounts and becomes the admin.
configYesThe Config account.
authorityThe program's signing address.
sol_vaultYesCreated here.
usdc_vaultYesCreated here.
hsol_mintYesCreated here.
husdc_mintYesCreated here.
usdc_mintThe USDC mint to accept.
token_programThe SPL Token program, which owns USDC.
token_2022_programToken-2022.
system_programThe System program.

Errors: FeeTooHigh.

deposit_sol

Moves amount lamports from the owner into the SOL vault and mints the same amount of hSOL to the owner's Hush account.

ArgumentTypeDescription
amountu64The lamports to deposit, in base units. Above 0.
AccountWritableSignerDescription
ownerYesYesThe depositor.
configThe Config account.
authorityThe program's signing address.
sol_vaultYesReceives the lamports.
hsol_mintYesMust be the mint in config.
h_accountYesThe owner's hSOL account. Receives the hSOL.
token_2022_programToken-2022.
system_programThe System program.

Errors: ZeroAmount.

deposit_usdc

Moves amount USDC from the owner's USDC account into the USDC vault and mints the same amount of hUSDC to the owner's Hush account.

ArgumentTypeDescription
amountu64The USDC to deposit, in base units. Above 0.
AccountWritableSignerDescription
ownerYesThe depositor.
configThe Config account.
authorityThe program's signing address.
usdc_vaultYesReceives the USDC.
usdc_mintMust be the USDC mint in config.
owner_usdcYesThe owner's USDC account.
husdc_mintYesMust be the mint in config.
h_accountYesThe owner's hUSDC account. Receives the hUSDC.
token_programThe SPL Token program, which owns USDC.
token_2022_programToken-2022.

Errors: ZeroAmount.

withdraw_sol

Burns amount hSOL from the owner's Hush account, taken from its public balance. Releases amount minus the fee from the SOL vault to the owner, and the fee to the fee recipient.

ArgumentTypeDescription
amountu64The hSOL to burn, in base units. Above 0.
AccountWritableSignerDescription
ownerYesYesBurns, and receives the SOL.
configThe Config account.
sol_vaultYesPays out.
fee_recipientYesMust be the fee recipient in config. Receives the fee.
hsol_mintYesMust be the mint in config.
h_accountYesThe owner's hSOL account.
token_2022_programToken-2022.

Errors: ZeroAmount, InsufficientBalance, InsufficientVault.

withdraw_usdc

Burns amount hUSDC from the owner's Hush account, taken from its public balance. Releases amount minus the fee from the USDC vault to the owner's USDC account, and the fee to the fee recipient's.

ArgumentTypeDescription
amountu64The hUSDC to burn, in base units. Above 0.
AccountWritableSignerDescription
ownerYesBurns.
configThe Config account.
authorityThe program's signing address.
usdc_vaultYesPays out.
usdc_mintMust be the USDC mint in config.
owner_usdcYesThe owner's USDC account. Receives the USDC.
fee_recipient_usdcYesThe fee recipient's associated USDC account. Receives the fee.
husdc_mintYesMust be the mint in config.
h_accountYesThe owner's hUSDC account.
token_programThe SPL Token program, which owns USDC.
token_2022_programToken-2022.

Errors: ZeroAmount, InsufficientBalance, WrongFeeAccount.

set_fee

Sets the withdraw fee and its recipient. The admin signs.

ArgumentTypeDescription
fee_bpsu16The new fee in basis points. At most MAX_FEE_BPS.
fee_recipientPubkeyThe new recipient.
AccountWritableSignerDescription
adminYesMust be the admin in config.
configYesThe Config account.

Errors: FeeTooHigh.

How a withdraw uses them

withdraw_sol and withdraw_usdc burn from a Hush account's public balance. An amount gets there through Token-2022's confidential withdraw instruction, which carries the proofs. So a withdraw is two steps, the confidential withdraw and then withdraw_sol or withdraw_usdc, and a burn of more than the public balance holds fails with InsufficientBalance.

The fee is amount × fee_bps / 10,000, rounded down, at 0.10% today. Fees and the HUSH token covers where it goes.

Errors

CodeNameMessageRaised when
6000FeeTooHighThe fee is above the 1% cap.initialize or set_fee was given a fee above MAX_FEE_BPS.
6001ZeroAmountThe amount must be greater than zero.A deposit or a withdraw was given an amount of 0.
6002InsufficientVaultThe vault holds less than this withdraw.withdraw_sol would take the SOL vault below its rent-exempt minimum.
6003InsufficientBalanceThe public hToken balance is below this amount. Withdraw from the confidential balance first.A withdraw asks to burn more than the Hush account's public balance.
6004WrongFeeAccountThe fee account is not the fee recipient's USDC account.withdraw_usdc was given a fee account other than the fee recipient's associated USDC account.

An account that fails one of the checks in the tables above, such as a mint that isn't the one in config, is refused with Anchor's own constraint errors.

Events

The program emits no events. What happened is read from the transactions themselves: the instruction, its accounts and its amount.