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.
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:
What verify() Returns
On success, verify() returns a FlashContext struct with all the loan details your program needs:
| Field | Type | Description |
|---|---|---|
| amount | u64 | Borrowed amount in native token units |
| token_mint | Pubkey | Mint address of the borrowed token |
| fee | u64 | VAEA fee in native units |
| payer | Pubkey | Public key of the borrower |
| source_tier | u8 | 0 = SDK, 1 = UI, 2 = Protocol CPI |
| slot_created | u64 | Slot when the flash loan began |
Package
| Crate | Registry | Install | Dependencies |
|---|---|---|---|
| vaea-flash-ctx | crates.io | vaea-flash-ctx = "0.1" | solana-program only โ no Anchor required |
Status
| Milestone | Status |
|---|---|
| Devnet deployment | โ Live |
| vaea-flash-ctx crate | โ Ready |
| Mainnet launch | April 2026 |
| crates.io publication | Post-mainnet |
HoYiwkNB7a3gmZXEkTqLkborNDc976vKEUAzBm8YpK5E. The crate source is available in the VAEA monorepo.