User Operation
Overview
The program provides three primary user operations:
User Account Creation: Initialize a user account linked to a specific bank
Minting Operations: Deposit yielding assets to mint USD* stablecoin tokens
Burning Operations: Burn USD* tokens to withdraw yielding assets
All user operations require interaction with multiple state accounts and include comprehensive validation, slippage protection, and accounting updates.
User Account Creation create_gen_user_account
create_gen_user_account
Before users can mint or burn tokens, they must create a user account associated with a specific bank. The create_gen_user_account
instruction initializes a UserGenState
account.
User Account Creation Flow
The instruction performs these key steps: validating the bank is active, initializing the user account, setting bank and authority references, and zeroing all balances.
The CreateGenUA
account context requires:
user
: The signing user who will own the accountbank_state
: Reference to the target bankuser_account
: The PDA-derived user account being created
Minting Operations mint_w_yielding_gen
mint_w_yielding_gen
The core minting operation allows users to deposit yielding tokens (like stSOL, mSOL) and receive USD* tokens in return. This operation involves complex pricing calculations and multiple token transfers.
The minting process involves several critical phases:
Pre-Validation Phase
Price Calculation Phase
Price Calculation Components
Token Transfer Phase
Slippage Protection
Accounting Updates
The MintWYieldingGen
struct defines all required accounts:
bank_state
Global bank state
vault_state
Vault-specific state
oracle_state
Price feed data
user_account
User accounting
team_state
Team fee accounting
Burning Operations burn_for_yielding_gen
burn_for_yielding_gen
The burning operation allows users to redeem USD* tokens for the underlying yielding assets. This is essentially the reverse of the minting operation.
Burning Process Flow
Pre-Validation Phase
Price Calculation Phase
Token Operations
Slippage Protection
Accounting Updates
User State Management
UserGenState Account Structure
The user account maintains:
Bank reference: Links user to specific bank instance
Authority: The user's public key for authorization
USD minted*: Net amount of USD* tokens minted (can be negative)
TVL deposited: Net TVL value deposited in yielding assets (can be negative)
PDA Derivation
User accounts use Program Derived Addresses (PDAs) with the seed structure: [BANK_USER_ACCOUNT_SEED, bank_pubkey, user_pubkey]
This ensures:
One user account per bank per user
Deterministic address generation
Prevention of account conflicts
Last updated