covr.Docs

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.

Note

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:

  1. begin_flash_exercise_v3. Checks the position, the window and your flash policy. Moves the position's full JitoSOL quantity into a fresh input token account owned by the program. Approves a temporary delegate key to spend exactly that quantity from it. Creates a fresh, empty USDC output account.
  2. Your swap. Any instructions you like. The delegate sells JitoSOL from input and the USDC lands in output.
  3. finish_flash_exercise_v3. Must be the last instruction. Measures the USDC that arrived in output (D) and refuses less than the floor you set at begin. Then it pays out and closes everything:
AmountGoes to
The strike TThe customer's USDC account (writer_payment)
D − TYour USDC vault
Any JitoSOL the swap did not spendYour authority's JitoSOL account (maker_collateral)
Any extra JitoSOL in the position vault, and its rentThe customer, as in a normal exercise
Rent of context, input and outputBack 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
Size277 bytes. Discriminator 4b99abbfa05c8012.
PairJitoSOL / USDC only, both on the SPL Token program. Another pair needs a program upgrade.
CloseNone. The policy is permanent; disable it instead.

Settings

SettingFieldUnitMeaning
EnabledenabledboolBegin refuses a disabled policy (9106).
Q, max collateralmax_collateral_atomsJitoSOL atomsThe largest position quantity you allow to flash.
T, max strikemax_strike_atomsUSDC atomsThe largest position strike payment you allow to flash.
A, min surplusmin_surplus_atomsUSDC atomsThe least USDC the swap must return above the strike. May be 0.
R, min pricemin_price_atoms_per_collateral_tokenUSDC atoms per 1 JitoSOLThe 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:

text
F = max(strike + A, ceil(quantity × R / 10^9))      all in USDC atoms

Begin 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_v1 takes the generation you read and fails if it is not current (9107).
  • begin_flash_exercise_v3 takes expected_policy_generation and fails if it is not current (9107). So a policy change made after you planned an attempt stops that attempt.

Layout

OffsetFieldType
8version (1)u8
9bumpu8
10collateral_decimalsu8
11payment_decimalsu8
12makerPubkey
44owner: the Maker authority that last wrote itPubkey
76collateral_mintPubkey
108collateral_programPubkey
140payment_mintPubkey
172payment_programPubkey
204terms_id (ordinary terms)[u8; 32]
236generationu64
244enabledbool
245max_collateral_atoms (Q)u64
253max_strike_atoms (T)u64
261min_surplus_atoms (A)u64
269min_price_atoms_per_collateral_token (R)u64

Who can call what

InstructionSignerNotes
initialize_flash_exercise_policy_v1your authorityCreates the policy and pays its rent. Your operator cannot.
update_flash_exercise_policy_v1your authorityReplaces every setting. Needs the current generation.
disable_flash_exercise_policy_v1your authoritySets enabled to false. Always available.
begin_flash_exercise_v3your authority or your operator, plus the delegateThe begin signer pays the temporary rent and gets it back at finish.
finish_flash_exercise_v3none of its ownValid 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.

#AccountwsNotes
0authoritywsMaker.authority. Pays the rent.
1makerYour Maker.
2collateral_mintJitoSOL.
3payment_mintUSDC.
4policywThe policy PDA. Created here.
5system_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).

#AccountwsNotes
0authoritysMaker.authority.
1makerYour Maker.
2policywYour flash policy.

Update takes expected_generation (u64), then settings as above. Disable takes no arguments.

begin_flash_exercise_v3

Discriminator 21607f587d0e3628. Data: 28 bytes.

#AccountwsNotes
0authoritywsMaker.authority or Maker.operator. Pays the temporary rent.
1delegatesA temporary key, approved to spend exactly the position's quantity from input. May be writable. Must not be any protected account, input or output.
2marketThe position's MarketV3.
3makerYour Maker.
4positionwThe PositionV3. Must be open and inside its exercise window.
5collateral_vaultwThe position's collateral vault.
6writerMust equal position.writer.
7collateralJitoSOL mint.
8writer_collateralwA clean JitoSOL account owned by the writer.
9collateral programSPL Token.
10exposurewYour Exposure for JitoSOL.
11usagewYour MintUsageV1 for JitoSOL.
12payment_mintUSDC.
13maker_payment_vaultwYour USDC vault. Receives D − T at finish.
14writer_paymentwA clean USDC account owned by the writer. Receives T at finish.
15maker_collateralwA JitoSOL account owned by your authority.
16policyYour flash policy.
17contextwPDA "flash-context-v1", position. 464 bytes. Created here, closed at finish.
18inputwPDA "flash-input-v1", position. Created here as a JitoSOL account.
19outputwPDA "flash-output-v1", position. Created here as a USDC account.
20payment programSPL Token.
21system_program
22instructionsThe Instructions sysvar, Sysvar1nstructions1111111111111111111111111.
ArgumentTypeMeaning
begin_indexu16This instruction's index in the transaction.
finish_indexu16The finish instruction's index: the last one.
expected_policy_generationu64The policy generation you read.
min_payment_atomsu64Your 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.

#AccountwsNotes
0rent_payerwThe key that signed begin. Gets all temporary rent back.
1–10market … usageThe same ten accounts as begin's positions 2 to 11, same order and flags.
11payment_mintUSDC.
12maker_payment_vaultwSame as begin.
13writer_paymentwSame as begin.
14maker_collateralwSame as begin.
15contextwSame as begin. Closed here.
16inputwSame as begin. Closed here.
17outputwSame as begin. Closed here.
18payment programSPL Token.
19instructionsThe Instructions sysvar.
20event authorityPDA "__event_authority" under the covr program.
21covr program8ZpbTPnDECPTDGN5VHHKH5gfer6EUTnRHcFwfUAbkJDg

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.

CodeHexNameMeaning
90000x2328LegacyCloseNeedsMigrationConsumptionA migrated maker tried to close an old settled position before its migration hold was consumed. Desks registered with register_maker_v3 never see it.
91000x238cFlashNotTopLevelBegin or finish was called from another program. Both must be top-level instructions.
91010x238dFlashInstructionsSysvarThe instructions account is not the Instructions sysvar, or it could not be read.
91020x238eFlashPairingThe 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.
91030x238fFlashProtectedAccountAn instruction between begin and finish uses a protected account or the covr program.
91040x2390FlashPolicySchemaThe policy is not at its PDA, or its bump, length, version or owner program is wrong.
91050x2391FlashPolicyOwnerThe policy belongs to another Maker, its owner is not your current authority, or a policy write was not signed by your authority.
91060x2392FlashPolicyDisabledBegin with a disabled policy.
91070x2393FlashPolicyGenerationThe generation you passed is not current, or the counter is used up.
91080x2394FlashPolicySettingsInvalid settings: a zero Q, T or R while enabled, or a floor that does not fit in a u64.
91090x2395FlashPolicyLimitThe position's quantity is above Q, or its strike payment above T.
91100x2396FlashPairUnsupportedThe pair is not JitoSOL/USDC on SPL Token, or the position's mints, programs, decimals or terms do not match the policy.
91110x2397FlashFloorArithmeticComputing the floor F overflowed.
91120x2398FlashFloorBelowPolicyBegin's min_payment_atoms is below the policy floor F.
91130x2399FlashPaymentBelowFloorThe USDC that arrived in output is below min_payment_atoms.
91140x239aFlashDelegateThe delegate did not sign, or it is a protected account, input or output.
91150x239bFlashEndpointinput 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.
91160x239cFlashRecipientwriter_payment is not a clean USDC account of the current writer, or maker_collateral is not a JitoSOL account of your authority.
91170x239dFlashContextThe context account is wrong, or finish's accounts differ from those begin bound.
91180x239eFlashPositionStateThe 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