FlashState PDA
The FlashState PDA is the core data structure that makes Zero-CPI verification possible. It's created by begin_flash, read by your program, and closed by end_flash โ all within a single transaction.
Account Layout (99 bytes)
| Offset | Size | Field | Type | Description |
|---|---|---|---|---|
| 0 | 8 | discriminator | u8[8] | Anchor account discriminator |
| 8 | 32 | payer | Pubkey | Borrower public key |
| 40 | 32 | token_mint | Pubkey | Borrowed token mint address |
| 72 | 8 | amount | u64 | Amount borrowed (native units) |
| 80 | 8 | fee_lamports | u64 | VAEA fee (native units) |
| 88 | 1 | source_tier | u8 | 0 = SDK, 1 = UI, 2 = Protocol |
| 89 | 8 | slot_created | u64 | Slot when begin_flash executed |
| 97 | 1 | bump | u8 | PDA bump seed |
| 98 | 1 | version | u8 | Schema version (currently 1) |
PDA Derivation
The FlashState PDA is derived from three seeds:
This means each (payer, token_mint) pair produces a unique PDA. A borrower cannot have two simultaneous flash loans for the same token.
Lifecycle
| Step | Instruction | FlashState PDA |
|---|---|---|
| 1 | begin_flash | Created โ rent paid by payer, 99 bytes allocated |
| 2 | Your instruction(s) | Exists โ your program reads it via verify() |
| 3 | end_flash | Closed โ rent refunded to payer, account deleted |
The PDA is ephemeral โ it exists only for the duration of the transaction. After end_flash, the account no longer exists on-chain. It cannot be replayed or reused.
Why 99 Bytes?
99 bytes is the minimum viable state for flash loan verification. For comparison:
| Protocol | State Size | Accounts/IX |
|---|---|---|
| VAEA FlashState | 99 B | 5 |
| Marginfi flash loan state | ~4,000 B | 11 |
| Kamino flash loan state | ~2,000 B | 11 |
| Jupiter Lend state | ~1,200 B | 9 |
Smaller state = less rent = lower transaction cost. The rent for 99 bytes (~0.001 SOL) is reclaimed when the PDA is closed at end_flash.
Deriving from Client (TypeScript)
If you need to derive the FlashState PDA address from your frontend or bot (e.g., to pass it to your program):
Reading from Client (TypeScript)
You can read an active FlashState PDA from TypeScript using the SDK: