๐Ÿ”ง API Reference

Developer Reference

Complete API reference for the vaea-flash-ctx crate โ€” function signatures, error types, constants, and protocol use cases.

verify()

rust
pub fn verify(
    flash_state: &AccountInfo,
    sysvar_instructions: &AccountInfo,
) -> Result<FlashContext, ProgramError>

Validates the flash loan context. Returns FlashContext on success, or a ProgramError if any check fails.

ParameterTypeDescription
flash_state&AccountInfoThe VAEA FlashState PDA โ€” must be owned by the VAEA program
sysvar_instructions&AccountInfoThe instructions sysvar (Sysvar1nstructions...)

FlashContext

rust
pub struct FlashContext {
    pub amount: u64,           // Borrowed amount (native units)
    pub token_mint: Pubkey,    // Token mint address
    pub fee: u64,              // VAEA fee (native units)
    pub payer: Pubkey,         // Borrower's public key
    pub source_tier: u8,       // 0=SDK, 1=UI, 2=Protocol
    pub slot_created: u64,     // Slot when loan began
}
FieldTypeNotes
amountu64In native token units (e.g. lamports for SOL, 1e6 for USDC)
token_mintPubkeyUse this to confirm which token was borrowed
feeu64The VAEA fee, already calculated. 2 bps of borrowed amount
payerPubkeyThe user who initiated the flash loan
source_tieru80 = SDK bot, 1 = web UI, 2 = protocol-level CPI
slot_createdu64Should match the current slot โ€” used for freshness check

Error Types

ErrorCodeCauseFix
InvalidOwner6000flash_state.owner is not the VAEA programPass the correct FlashState PDA
InvalidPDA6001PDA seeds don't match the expected derivationDerive PDA correctly from payer + token_mint
NoBeginFlash6002begin_flash instruction not found before current IXEnsure VAEA.begin_flash is in the TX before your IX
NoEndFlash6003end_flash instruction not found after current IXEnsure VAEA.end_flash is in the TX after your IX
InvalidSysvar6004sysvar_instructions account is wrongPass Sysvar1nstructions... as the sysvar account
StaleSlot6005slot_created doesn't match current slotThe PDA is from a different transaction โ€” invalid

Constants

rust
// VAEA Program ID
pub const VAEA_PROGRAM_ID: Pubkey = pubkey!("HoYiwkNB7a3gmZXEkTqLkborNDc976vKEUAzBm8YpK5E");

// FlashState PDA seeds prefix
pub const FLASH_SEED: &[u8] = b"flash";

// Account size
pub const FLASH_STATE_SIZE: usize = 99;

// Source tiers
pub const SOURCE_SDK: u8 = 0;
pub const SOURCE_UI: u8 = 1;
pub const SOURCE_PROTOCOL: u8 = 2;

Cost Breakdown

MetricValueNotes
CPI consumed0PDA read โ€” not a cross-program call
Compute Units~2,000 CUOwner check + deserialization + sysvar scan
Account rent~0.001 SOLReclaimed at end_flash
VAEA fee2 bps (0.02%)Flat rate for all tiers

Protocol Use Cases

Use CaseHow Your Program Uses CTX
Self-liquidationVerify flash loan before releasing collateral โ€” prevent unauthorized withdrawals
Leverage vaultsConfirm initial deposit is flash-loaned โ€” enforce atomic rollback on failure
Risk gatingRead flash.amount to apply different risk parameters during flash loans
Atomic rebalancingCompose with Jupiter + AMMs at full CPI depth โ€” impossible with CPI verification
Flash mintVerify collateral backing before minting synthetic tokens

FAQ

Does this work without Anchor?

Yes. The crate depends only on solana-program. Pass two AccountInfo references and call verify().

What happens if the user doesn't use VAEA?

If the user borrows directly from Kamino or Marginfi without VAEA, no FlashState PDA is created. verify() will fail with InvalidOwner or NoBeginFlash. Your program decides how to handle that โ€” reject the TX, or proceed without flash loan verification.

Can I make verification optional?

Yes. You can make the flash_state account optional in your Accounts struct and only call verify() if it's present. This lets your instruction work both inside and outside flash loans.

What if VAEA goes offline?

The VAEA on-chain program is immutable (no upgrade authority post-mainnet). verify() only reads on-chain data. It has zero dependency on VAEA's backend servers, API, or Smart Router. The verification is fully decentralized.

๐Ÿ’ก Tip
Need help integrating? Join the Discord and ask in #protocol-integrations.
โš ๏ธ Devnet Only
Mainnet โ€” April 2026
๐Ÿ”