# 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

| Rule | Value |
| --- | --- |
| Signer | One Solana signature: your Maker **authority's**. Your operator cannot withdraw. |
| EIP-712 signature | None. `signWithdrawal` and `WITHDRAW_TYPES` take a quote back from covr's gateway. They have nothing to do with the vault. |
| Amount | Above zero. A vault holding less fails the transfer. |
| Destination | A 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](https://docs.covr.markets/guides/cancel-quotes.md) 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

| Variable | Required | Meaning |
| --- | --- | --- |
| `RPC_URL`, `MAKER_ETH_ADDRESS`, `MAKER_AUTHORITY` | yes | As for the [expiry keeper](https://docs.covr.markets/guides/expiry-keeper.md#settings) |
| `AMOUNT_USDC` | yes | Amount in USDC, at most 6 decimals: `250`, `250.5` |
| `DESTINATION` | no | Your authority's USDC token account. Default: its associated token account, which must exist |
| `AUTHORITY_KEYPAIR` | live only | Path to your **authority's** `solana-keygen` keypair file |
| `ALLOW_SHORTFALL` | no | `1` lets the vault go below the strikes your open positions may still draw |
| `DRY_RUN` | no | `0` 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](https://docs.covr.markets/guides/expiry-keeper.md#run-it), 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`](https://docs.covr.markets/reference/sdk/setup.md#withdraw) from the SDK and sign with your authority. Do the same checks first.

## Next

- [Capital and settlement](https://docs.covr.markets/concepts/capital.md#what-your-vault-must-hold): what your vault must hold, and when.
- [Expiry keeper](https://docs.covr.markets/guides/expiry-keeper.md): exercise and release at expiry.

---

Source: https://docs.covr.markets/guides/withdraw · Part of covr Docs, https://docs.covr.markets/llms.txt
