๐Ÿ“– Introduction
For Protocol Developers

What is CTX No-CPI?

vaea-flash-ctx is an on-chain crate that lets any Solana program verify it's executing inside a flash loan โ€” without consuming any CPI depth. One function call. Zero cross-program invocation.

โ„น๏ธ Note
This documentation is for Solana program developers building protocols in Rust (Anchor or native). If you're building a bot, liquidator, or script that needs to borrow capital, see the SDK documentation instead.

Why CTX Exists

Many protocols need to know if their instruction is executing inside a flash loan. A lending protocol might want to restrict certain actions during flash loans. A vault protocol might need to confirm that borrowed funds will be repaid atomically.

The naive approach โ€” calling the flash loan program via CPI to ask "is there an active loan?" โ€” consumes one CPI level. On Solana, the limit is 4 levels. In complex call chains (Protocol โ†’ Jupiter โ†’ AMM โ†’ Token Program), one lost level can make the transaction impossible.

CTX solves this by reading a 99-byte PDA instead. Account read. Not a CPI. Zero depth consumed.

How It Works

When a user borrows via VAEA's begin_flash instruction, the on-chain program creates a FlashState PDA (99 bytes). This account exists only for the duration of the transaction. Your program receives this account as a read-only input and calls vaea_flash_ctx::verify(), which:

โœ… Checks owner
flash_state.owner must be the VAEA program ID
โœ… Validates PDA
Seeds match ["flash", payer, token_mint]
โœ… Scans sysvar
Confirms begin_flash before and end_flash after
โœ… Returns context
amount, token_mint, fee, payer, source_tier

What verify() Returns

On success, verify() returns a FlashContext struct with all the loan details your program needs:

FieldTypeDescription
amountu64Borrowed amount in native token units
token_mintPubkeyMint address of the borrowed token
feeu64VAEA fee in native units
payerPubkeyPublic key of the borrower
source_tieru80 = SDK, 1 = UI, 2 = Protocol CPI
slot_createdu64Slot when the flash loan began

Package

CrateRegistryInstallDependencies
vaea-flash-ctxcrates.iovaea-flash-ctx = "0.1"solana-program only โ€” no Anchor required

Status

MilestoneStatus
Devnet deploymentโœ… Live
vaea-flash-ctx crateโœ… Ready
Mainnet launchApril 2026
crates.io publicationPost-mainnet
๐Ÿ’ก Tip
Program ID (devnet): HoYiwkNB7a3gmZXEkTqLkborNDc976vKEUAzBm8YpK5E. The crate source is available in the VAEA monorepo.
โš ๏ธ Devnet Only
Mainnet โ€” April 2026
๐Ÿ”