covr.Docs

Guides

Withdraw USDC

withdraw moves USDC from your vault to your authority's USDC token account. The program does not check it against anything you owe. The package ships an example script, examples/keeper/withdraw.ts, that does those checks before it withdraws.

What the program requires

RuleValue
SignerOne Solana signature: your Maker authority's. Your operator cannot withdraw.
EIP-712 signatureNone. signWithdrawal and WITHDRAW_TYPES take a quote back from covr's gateway. They have nothing to do with the vault.
AmountAbove zero. A vault holding less fails the transfer.
DestinationA USDC token account your authority owns.

Nothing in the vault is reserved

Nothing in the vault is reserved on chain. A withdrawal can take USDC you still need. The program holds nothing back for:

  • the strikes of positions you may still exercise;
  • the premium of quotes you signed that can still fill;
  • your premium budget and your exposure limits. These only gate new fills.

Withdraw too much and those exercises and fills fail.

Before you withdraw

  1. Stop quoting. Stop your bot, or pause your mint policy if you cannot wait.
  2. Wait for outstanding quotes to expire. A quote you signed can still fill, and take its premium from the vault, until it expires: 60 s at most. The script cannot see your signed quotes.
  3. Withdraw. Leave at least the strikes of the positions you may still exercise.

What withdraw.ts does

  • Dry run by default. With DRY_RUN unset it checks everything, prints the exact instruction and sends nothing.
  • Checks who and where. It refuses another authority, a signer that is not the authority, a destination that is not your unfrozen USDC account, and more than the vault holds.
  • Keeps your strikes. It adds up the strikes of your open positions whose window has not closed. It refuses to leave less than that in the vault, unless ALLOW_SHORTFALL=1. The refusal names the most you can withdraw.
  • Fails closed. The position scan is never below its first read. Each position is re-read never below the highest slot seen so far. The vault balance is read last, never below any of them. A position the scan saw open that is then missing, owned by another program or undecodable stops the withdrawal. Only a position decoded as no longer open, or past its window, stops counting.

Settings

VariableRequiredMeaning
RPC_URL, MAKER_ETH_ADDRESS, MAKER_AUTHORITYyesAs for the expiry keeper
AMOUNT_USDCyesAmount in USDC, at most 6 decimals: 250, 250.5
DESTINATIONnoYour authority's USDC token account. Default: its associated token account, which must exist
AUTHORITY_KEYPAIRlive onlyPath to your authority's solana-keygen keypair file
ALLOW_SHORTFALLno1 lets the vault go below the strikes your open positions may still draw
DRY_RUNno0 sends for real

Run it

The script sits next to the keeper. Copy the keeper folder out of the installed package as in Expiry keeper, then:

sh
RPC_URL=https://<your own Solana RPC> \
MAKER_ETH_ADDRESS=0x<your quote key address> MAKER_AUTHORITY=<your Solana authority> \
AMOUNT_USDC=250 \
npx tsx keeper/withdraw.ts

This is a dry run. To send for real, set AUTHORITY_KEYPAIR and DRY_RUN=0.

Warning

A send that times out may still land until its blockhash expires. Read the vault balance before you try again.

Build it yourself

To build the instruction in your own pipeline, use withdraw from the SDK and sign with your authority. Do the same checks first.

Next