Concepts
Flash exercise
Flash exercise lets your desk exercise a position without holding the strike in its vault. In one transaction the program lends you the position's JitoSOL, your swap sells it for USDC, and the program pays the customer the strike out of that USDC. If any step fails, the whole transaction reverts and nothing moves.
It is optional. A desk without a flash policy exercises with exercise_v3, which pays the strike from its vault, exactly as before. See Capital and settlement.
The flash instructions are live on mainnet since the program upgrade of 22 October 2026. @covrfun/maker-sdk 0.1.1 has no flash builders yet; they are planned. Until then, build the instructions yourself from the account lists on this page.
How it works
One transaction holds three parts, in this order:
begin_flash_exercise_v3. Checks the position, the window and your flash policy. Moves the position's full JitoSOL quantity into a freshinputtoken account owned by the program. Approves a temporary delegate key to spend exactly that quantity from it. Creates a fresh, empty USDCoutputaccount.- Your swap. Any instructions you like. The delegate sells JitoSOL from
inputand the USDC lands inoutput. finish_flash_exercise_v3. Must be the last instruction. Measures the USDC that arrived inoutput(D) and refuses less than the floor you set at begin. Then it pays out and closes everything:
| Amount | Goes to |
|---|---|
| The strike T | The customer's USDC account (writer_payment) |
| D − T | Your USDC vault |
| Any JitoSOL the swap did not spend | Your authority's JitoSOL account (maker_collateral) |
| Any extra JitoSOL in the position vault, and its rent | The customer, as in a normal exercise |
Rent of context, input and output | Back to the key that signed begin |
The position ends exercised, and your exposure and mint usage are freed, exactly as with exercise_v3. The vault is never debited for the strike.
Pairing rules
The program reads the transaction's instruction list (the Instructions sysvar) in both begin and finish. It refuses the transaction unless:
- begin and finish are both top-level instructions, not called from another program (9100);
begin_index<finish_index, and finish is the last instruction in the transaction (9102);- begin and finish carry each other's exact data and accounts (9102);
- no other instruction in the transaction calls the covr program or lists its program ID as an account, before or after begin (9102);
- no instruction between begin and finish touches a protected account (9103).
Protected accounts: the begin signer, your Maker and its authority, your operator if set, the market, the position and its collateral vault, the customer (writer) and their two token accounts, your exposure, usage, USDC vault and maker_collateral, the flash policy, the context, covr's event authority and the covr program itself. The delegate, input and output are not protected: your swap uses them.
Instructions before begin are not checked for protected accounts. You may, for example, set a compute-unit limit there, or create fresh token accounts for the customer, as exerciseV3Instructions does for a normal exercise. They only need to stay clear of the covr program.
The swap cannot use any protected key, including the key that signed begin. Use the delegate as the swap's signer. It may be writable, for example to pay for accounts the swap creates.
The flash policy
Flash exercise needs a flash policy: one account per Maker and mint pair, written only by your authority. Begin refuses any position the policy does not allow.
| Seeds | "flash-policy-v1", Maker, collateral mint, payment mint |
| Size | 277 bytes. Discriminator 4b99abbfa05c8012. |
| Pair | JitoSOL / USDC only, both on the SPL Token program. Another pair needs a program upgrade. |
| Close | None. The policy is permanent; disable it instead. |
Settings
| Setting | Field | Unit | Meaning |
|---|---|---|---|
| Enabled | enabled | bool | Begin refuses a disabled policy (9106). |
| Q, max collateral | max_collateral_atoms | JitoSOL atoms | The largest position quantity you allow to flash. |
| T, max strike | max_strike_atoms | USDC atoms | The largest position strike payment you allow to flash. |
| A, min surplus | min_surplus_atoms | USDC atoms | The least USDC the swap must return above the strike. May be 0. |
| R, min price | min_price_atoms_per_collateral_token | USDC atoms per 1 JitoSOL | The least the swap must return per whole JitoSOL. |
Begin refuses a position whose quantity is above Q or whose strike payment is above T (9109). For each attempt it computes the policy floor, from the position's own quantity and strike:
F = max(strike + A, ceil(quantity × R / 10^9)) all in USDC atomsBegin takes your own floor for this attempt, min_payment_atoms, and refuses it if it is below F (9112). Finish refuses the transaction if the USDC that arrived in output is below min_payment_atoms (9113).
Example: a position of 1 JitoSOL with a $155 strike, A = 1 USDC and R = $150. Then F = max(155 + 1, 150) = 156 USDC. Your swap must deliver at least 156 USDC; the customer gets 155 and your vault gets the rest.
When enabled is true, Q, T and R must be above 0. Every write also checks that T + A and ceil(Q × R / 10^9) fit in a u64. Otherwise the write fails with 9108.
Generation
The policy has a generation counter. It starts at 1 and goes up by one on every update and every disable. It never goes down.
update_flash_exercise_policy_v1takes the generation you read and fails if it is not current (9107).begin_flash_exercise_v3takesexpected_policy_generationand fails if it is not current (9107). So a policy change made after you planned an attempt stops that attempt.
Layout
| Offset | Field | Type |
|---|---|---|
| 8 | version (1) | u8 |
| 9 | bump | u8 |
| 10 | collateral_decimals | u8 |
| 11 | payment_decimals | u8 |
| 12 | maker | Pubkey |
| 44 | owner: the Maker authority that last wrote it | Pubkey |
| 76 | collateral_mint | Pubkey |
| 108 | collateral_program | Pubkey |
| 140 | payment_mint | Pubkey |
| 172 | payment_program | Pubkey |
| 204 | terms_id (ordinary terms) | [u8; 32] |
| 236 | generation | u64 |
| 244 | enabled | bool |
| 245 | max_collateral_atoms (Q) | u64 |
| 253 | max_strike_atoms (T) | u64 |
| 261 | min_surplus_atoms (A) | u64 |
| 269 | min_price_atoms_per_collateral_token (R) | u64 |
Who can call what
| Instruction | Signer | Notes |
|---|---|---|
initialize_flash_exercise_policy_v1 | your authority | Creates the policy and pays its rent. Your operator cannot. |
update_flash_exercise_policy_v1 | your authority | Replaces every setting. Needs the current generation. |
disable_flash_exercise_policy_v1 | your authority | Sets enabled to false. Always available. |
begin_flash_exercise_v3 | your authority or your operator, plus the delegate | The begin signer pays the temporary rent and gets it back at finish. |
finish_flash_exercise_v3 | none of its own | Valid only in the same transaction as its begin. |
The policy's owner must equal your Maker's authority when begin runs (9105).
Instructions
Accounts are listed in the exact order the program expects. w = writable. s = signer. Arguments are Borsh-encoded after the 8-byte discriminator.
initialize_flash_exercise_policy_v1
Discriminator da39c082cee99aa7.
| # | Account | w | s | Notes |
|---|---|---|---|---|
| 0 | authority | w | s | Maker.authority. Pays the rent. |
| 1 | maker | Your Maker. | ||
| 2 | collateral_mint | JitoSOL. | ||
| 3 | payment_mint | USDC. | ||
| 4 | policy | w | The policy PDA. Created here. | |
| 5 | system_program |
Argument: settings, 33 bytes: enabled (bool), max_collateral_atoms, max_strike_atoms, min_surplus_atoms, min_price_atoms_per_collateral_token (each u64).
update_flash_exercise_policy_v1 and disable_flash_exercise_policy_v1
Discriminators 9d9e65e0df48bce5 (update) and b8d4f9405728b881 (disable).
| # | Account | w | s | Notes |
|---|---|---|---|---|
| 0 | authority | s | Maker.authority. | |
| 1 | maker | Your Maker. | ||
| 2 | policy | w | Your flash policy. |
Update takes expected_generation (u64), then settings as above. Disable takes no arguments.
begin_flash_exercise_v3
Discriminator 21607f587d0e3628. Data: 28 bytes.
| # | Account | w | s | Notes |
|---|---|---|---|---|
| 0 | authority | w | s | Maker.authority or Maker.operator. Pays the temporary rent. |
| 1 | delegate | s | A temporary key, approved to spend exactly the position's quantity from input. May be writable. Must not be any protected account, input or output. | |
| 2 | market | The position's MarketV3. | ||
| 3 | maker | Your Maker. | ||
| 4 | position | w | The PositionV3. Must be open and inside its exercise window. | |
| 5 | collateral_vault | w | The position's collateral vault. | |
| 6 | writer | Must equal position.writer. | ||
| 7 | collateral | JitoSOL mint. | ||
| 8 | writer_collateral | w | A clean JitoSOL account owned by the writer. | |
| 9 | collateral program | SPL Token. | ||
| 10 | exposure | w | Your Exposure for JitoSOL. | |
| 11 | usage | w | Your MintUsageV1 for JitoSOL. | |
| 12 | payment_mint | USDC. | ||
| 13 | maker_payment_vault | w | Your USDC vault. Receives D − T at finish. | |
| 14 | writer_payment | w | A clean USDC account owned by the writer. Receives T at finish. | |
| 15 | maker_collateral | w | A JitoSOL account owned by your authority. | |
| 16 | policy | Your flash policy. | ||
| 17 | context | w | PDA "flash-context-v1", position. 464 bytes. Created here, closed at finish. | |
| 18 | input | w | PDA "flash-input-v1", position. Created here as a JitoSOL account. | |
| 19 | output | w | PDA "flash-output-v1", position. Created here as a USDC account. | |
| 20 | payment program | SPL Token. | ||
| 21 | system_program | |||
| 22 | instructions | The Instructions sysvar, Sysvar1nstructions1111111111111111111111111. |
| Argument | Type | Meaning |
|---|---|---|
begin_index | u16 | This instruction's index in the transaction. |
finish_index | u16 | The finish instruction's index: the last one. |
expected_policy_generation | u64 | The policy generation you read. |
min_payment_atoms | u64 | Your floor for this attempt, in USDC atoms. At least F. |
finish_flash_exercise_v3
Discriminator 0f8709e6f3c10a17. Data: 12 bytes, begin_index (u16) and finish_index (u16), the same values as begin.
| # | Account | w | s | Notes |
|---|---|---|---|---|
| 0 | rent_payer | w | The key that signed begin. Gets all temporary rent back. | |
| 1–10 | market … usage | The same ten accounts as begin's positions 2 to 11, same order and flags. | ||
| 11 | payment_mint | USDC. | ||
| 12 | maker_payment_vault | w | Same as begin. | |
| 13 | writer_payment | w | Same as begin. | |
| 14 | maker_collateral | w | Same as begin. | |
| 15 | context | w | Same as begin. Closed here. | |
| 16 | input | w | Same as begin. Closed here. | |
| 17 | output | w | Same as begin. Closed here. | |
| 18 | payment program | SPL Token. | ||
| 19 | instructions | The Instructions sysvar. | ||
| 20 | event authority | PDA "__event_authority" under the covr program. | ||
| 21 | covr program | 8ZpbTPnDECPTDGN5VHHKH5gfer6EUTnRHcFwfUAbkJDg |
Finish emits the same PositionExercised event as exercise_v3, plus a FlashExerciseSettled receipt through Anchor's event CPI. Its payment_received_atoms is the new USDC in output. That is not your profit: anyone could add USDC to output between begin and finish.
Errors
Codes 9100 to 9118 come from the flash instructions. 9000 sits next to them in the error enum but is not a flash error.
| Code | Hex | Name | Meaning |
|---|---|---|---|
| 9000 | 0x2328 | LegacyCloseNeedsMigrationConsumption | A migrated maker tried to close an old settled position before its migration hold was consumed. Desks registered with register_maker_v3 never see it. |
| 9100 | 0x238c | FlashNotTopLevel | Begin or finish was called from another program. Both must be top-level instructions. |
| 9101 | 0x238d | FlashInstructionsSysvar | The instructions account is not the Instructions sysvar, or it could not be read. |
| 9102 | 0x238e | FlashPairing | The begin/finish pair is wrong: indices, data or accounts differ, finish is not last, or another covr instruction or the covr program ID appears elsewhere. |
| 9103 | 0x238f | FlashProtectedAccount | An instruction between begin and finish uses a protected account or the covr program. |
| 9104 | 0x2390 | FlashPolicySchema | The policy is not at its PDA, or its bump, length, version or owner program is wrong. |
| 9105 | 0x2391 | FlashPolicyOwner | The policy belongs to another Maker, its owner is not your current authority, or a policy write was not signed by your authority. |
| 9106 | 0x2392 | FlashPolicyDisabled | Begin with a disabled policy. |
| 9107 | 0x2393 | FlashPolicyGeneration | The generation you passed is not current, or the counter is used up. |
| 9108 | 0x2394 | FlashPolicySettings | Invalid settings: a zero Q, T or R while enabled, or a floor that does not fit in a u64. |
| 9109 | 0x2395 | FlashPolicyLimit | The position's quantity is above Q, or its strike payment above T. |
| 9110 | 0x2396 | FlashPairUnsupported | The pair is not JitoSOL/USDC on SPL Token, or the position's mints, programs, decimals or terms do not match the policy. |
| 9111 | 0x2397 | FlashFloorArithmetic | Computing the floor F overflowed. |
| 9112 | 0x2398 | FlashFloorBelowPolicy | Begin's min_payment_atoms is below the policy floor F. |
| 9113 | 0x2399 | FlashPaymentBelowFloor | The USDC that arrived in output is below min_payment_atoms. |
| 9114 | 0x239a | FlashDelegate | The delegate did not sign, or it is a protected account, input or output. |
| 9115 | 0x239b | FlashEndpoint | input or output no longer has the program's context as owner, has the wrong mint, a foreign delegate or a close authority, or its balance fell below where it started. |
| 9116 | 0x239c | FlashRecipient | writer_payment is not a clean USDC account of the current writer, or maker_collateral is not a JitoSOL account of your authority. |
| 9117 | 0x239d | FlashContext | The context account is wrong, or finish's accounts differ from those begin bound. |
| 9118 | 0x239e | FlashPositionState | The position is not in its flash state at finish, or its data changed since begin. |
Flash exercise can also fail with the codes a normal exercise can: InvalidOrder (6003) outside the window or when the position is not open, TokenLifecycleAuthority (8304) for a wrong begin signer, and CustodyUnsafeRecipient (7403) for an unclean writer_collateral. See Program errors.
Next
- Capital and settlement: what your vault must hold with and without flash.
- Fills and exercise: the normal exercise, with SDK code.
- Addresses: the program build that added these instructions.