Skip to content
Fossa

User accounts

User storage, vault authorities, deposits, and withdrawals.

Initialize and fund a user account

Precreate a zeroed, program-owned 120-byte user account and a token vault whose authority is the PDA [b"vault", user]. Send instruction 1 with [user(ws), owner(s), market, vault] and an empty payload. The contract pins the owner, market, vault, and authority bump. User storage is a supplied account address, not a provider-style PDA.

Deposit through instruction 3, accounts [market, user(w), owner(s), source(w), vault(w), mint, token_program], payload amount:u64. The owner signs a positive transfer from its token account into the vault. The contract verifies the mint and token authorities, performs TransferChecked, and increases the user account's free balance.

Read USER0V20 state as owner at 8, market at 40, free balance as u64 at 72, vault at 80, and vault-authority bump at 112. Booking reduces free balance while the tokens remain in this vault. Only free balance is available for another reservation or withdrawal.

Withdraw free balance

Send instruction 10 with [market, user(w), owner(s), vault(w), destination(w), mint, user_authority, token_program], payload amount:u64. The owner signs, amount must be positive, and free balance must cover it. The destination token account must belong to that owner and use the market mint.

The contract subtracts the amount from free balance and transfers it from the recorded vault using [b"vault", user] as authority. Reserved payment remains unavailable until a claim returns its unused portion, a release, or an expiry. Reading the vault's token balance alone does not identify the withdrawable amount.