covr.Docs

SDK reference

Markets

A MarketV3 account holds one option series: collateral mint, strike, expiry, exercise window, size cap and fee. Every RFQ names its market. Read that account from your own RPC, decode it with decodeMarketV3, and sign intents and quotes in that market's own EIP-712 domain (quoteDomain). The SDK also builds the instructions that create markets.

The SDK handles two settlement modes:

settlementModeNameExerciseWho quotes it today
0ordinaryatomic: one exercise_v3 pays strike and delivers collateraldesks (JitoSOL) and covr
1restrictedtwo steps: fund the strike, then deliver; carries a 7-day cancellation timeoutcovr only (tokenized stocks)

Since the program upgrade of 4 November 2026, MarketV3 accounts with mode 2 also exist: cash-secured put markets, quoted only by covr's own maker. Version 0.1.1 does not support them, and decodeMarketV3 throws maker-sdk: unknown settlement mode 2 on one. If you scan every MarketV3 account, catch that error and skip the market. See Program > Put markets.

decodeMarketV3

Decodes and validates a raw MarketV3 account. Use it on the market named in every RFQ before you price or sign anything.

ts
export declare function decodeMarketV3(marketAddress: string, raw: Uint8Array, d?: Deployment): Promise<DecodedMarketV3>;
NameTypeDescription
marketAddressstringThe account address you read.
rawUint8ArrayThe account data, exactly 376 bytes, read at finalized commitment.
dDeploymentOptional. Default MAINNET.

Returns: DecodedMarketV3: a MarketV3 when byte 10 is 0, or a RestrictedMarketV3 when it is 1.

The function checks the discriminator, the layout, the mainnet genesis hash and USDC mint, d.deploymentId, every term bound (window 60 to 3,600 s, strike and size above zero, fee at most 1,000 bps, a supported token program, no native SOL), the terms id of the mode, and that marketAddress is the canonical PDA of the creator and salt stored in the bytes.

Warning

It never sees the account owner. Confirm the owner is PROGRAM_ID yourself. It also does not check paused or expiry against your clock: skip a market that is paused or expired.

Throws:

ConditionMessage
raw is not a Uint8Arraymaker-sdk: market data must be bytes
raw is not 376 bytesmaker-sdk: market data must be exactly 376 bytes
Byte 10 is neither 0 nor 1, for example a put market (mode 2)maker-sdk: unknown settlement mode <n>
Wrong account discriminatorMarketV3 account schema (restricted: RestrictedV3: MarketV3 account schema)
Version is not 3, USDC decimals byte is not 6, or paused byte above 1MarketV3 schema (restricted: RestrictedV3: restricted MarketV3 schema)
Payment mint or program is not USDC / SPL Token, genesis is not mainnet, or deployment id differs from dMarketV3 identity (restricted: RestrictedV3: MarketV3 identity)
Collateral token program unsupported, or collateral is native SOLMarketV3 unsupported (restricted: RestrictedV3: MarketV3 unsupported)
Restricted terms id does not match the 7-day timeoutRestrictedV3: restricted terms identity
A term is out of bounds, or (ordinary) the terms id is not ORDINARY_TERMS_IDMarketV3 terms (restricted: RestrictedV3: MarketV3 terms)
marketAddress or bump is not the PDA of the stored creator and saltMarketV3 PDA (restricted: RestrictedV3: MarketV3 PDA)
d.deploymentId is not 32 bytesMarketV3 hash (restricted: RestrictedV3: nonzero hash required)
marketAddress is not valid base58SolanaError from @solana/kit

Account layout (all integers little-endian):

BytesFieldBytesField
0..8discriminator205..237genesisHash
8version (3)237..269deploymentId
9bump269..301termsId
10settlementMode301..333profileHash
11collateralDecimals333..341salt (u64)
12paymentDecimals (6)341..349expiry (i64, unix s)
13..45creator349..357window (u64, s)
45..77collateral357..365strikeE8 (u64)
77..109collateralProgram365..373maxQuantityAtoms (u64)
109..141payment373..375feeBps (u16)
141..173paymentProgram375paused (0 or 1)
173..205feeOwner
ts
import { createSolanaRpc, address } from '@solana/kit';
import { decodeMarketV3, PROGRAM_ID, type RfqSnapshot } from '@covrfun/maker-sdk';

declare const snapshot: RfqSnapshot; // from client.getRfq(id)
const rpc = createSolanaRpc('https://<your rpc>');

const { value } = await rpc
  .getAccountInfo(address(snapshot.market), { commitment: 'finalized', encoding: 'base64' })
  .send();
if (!value || value.owner !== PROGRAM_ID) throw new Error('not a covr market');
const market = await decodeMarketV3(snapshot.market, new Uint8Array(Buffer.from(value.data[0], 'base64')));
if (market.settlementMode !== 0 || market.paused) throw new Error('not an open ordinary market');

quoteDomain

Returns the EIP-712 domain for one decoded market. Intents and quotes for that market are signed in it.

ts
export declare function quoteDomain(market: DecodedMarketV3): TypedDataDomain;
NameTypeDescription
marketDecodedMarketV3From decodeMarketV3.

Returns: TypedDataDomain (ethers): name: 'SOL Covered Calls', version: '1', chainId: 2000000001, and a verifyingContract derived from every immutable term of this market. See How covr domains are built. Ordinary and restricted markets use different scope literals.

Throws: only for a market object you built by hand: MarketV3 hash, MarketV3 integer or MarketV3 fee (ordinary); RestrictedV3: nonzero hash required, RestrictedV3: integer out of range or RestrictedV3: MarketV3 fee (restricted); SolanaError for a bad address.

ts
import { quoteDomain, type DecodedMarketV3 } from '@covrfun/maker-sdk';

declare const market: DecodedMarketV3;
const domain = quoteDomain(market); // pass to signIntent and signQuote

marketDomain

Decodes raw market bytes and returns their domain in one call: decodeMarketV3 then quoteDomain.

ts
export declare function marketDomain(marketAddress: string, raw: Uint8Array, d?: Deployment): Promise<TypedDataDomain>;
NameTypeDescription
marketAddressstringThe account address you read.
rawUint8ArrayThe 376-byte account data.
dDeploymentOptional. Default MAINNET.

Returns: Promise<TypedDataDomain>.

Throws: every error of decodeMarketV3.

ts
import { marketDomain } from '@covrfun/maker-sdk';

declare const marketAddress: string;
declare const raw: Uint8Array; // finalized account data, owner checked
const domain = await marketDomain(marketAddress, raw);

createMarketV3

Builds create_market_v3, which creates an ordinary market. Any wallet may create one and pays its rent.

ts
export declare function createMarketV3(input: CreateMarketInput, d?: Deployment): Promise<{
    market: import("@solana/kit").Address<string>;
    instruction: import("@solana/kit").Instruction<string, readonly (import("@solana/kit").AccountLookupMeta<string, string> | import("@solana/kit").AccountMeta<string>)[]> & {
        accounts: NonNullable<import("@solana/kit").Instruction['accounts']>;
        data: Uint8Array;
    };
}>;
NameTypeDescription
inputCreateMarketInputCreator, salt, collateral, fee owner and terms, plus your clock.
dDeploymentOptional. Default MAINNET.

Returns: market (the PDA ["market-v3", creator, salt]) and the instruction. Accounts: creator (writable signer), market (writable), collateral mint, USDC mint, System program. Data: discriminator, salt (u64), feeOwner (32 bytes), expiry (i64), window (u64), strikeE8 (u64), maxQuantityAtoms (u64), feeBps (u16), all little-endian.

The program then checks the chain clock (60 <= expiry - now <= 7,776,000 s, which is 90 days) and requires a plain collateral mint: an 82-byte mint account (no Token-2022 extensions), not native SOL, with no freeze authority. It records the mint's token profile as profileHash.

Note

A market you create is valid on chain, but customers do not see it yet.

Throws:

ConditionMessage
nowUnix missing or not a bigint in [0, 2^63 - 1]maker-sdk: nowUnix (your clock, unix seconds) is required
salt is not a u64 bigintmaker-sdk: salt must be a u64 bigint
expiry - nowUnix is below 60 or above 7,776,000maker-sdk: expiry must be 60 s to 90 days after nowUnix
window is not 60 to 3,600maker-sdk: window must be 60..3600 seconds
strikeE8 is not a positive u64maker-sdk: strikeE8 must be a positive u64
maxQuantityAtoms is not a positive u64maker-sdk: maxQuantityAtoms must be a positive u64
feeBps is not an integer 0 to 1,000maker-sdk: feeBps must be an integer 0..1000
feeOwner is the zero keymaker-sdk: fee owner must not be the zero key
collateral is native SOL (classic or Token-2022)maker-sdk: native SOL mints are not supported collateral
expiry + window overflows i64MarketV3 terms
An address is not valid base58SolanaError from @solana/kit
ts
import { createMarketV3, JITOSOL_MINT } from '@covrfun/maker-sdk';

declare const creator: string; // your wallet, signs and pays rent
const nowUnix = BigInt(Math.floor(Date.now() / 1000));

const { market, instruction } = await createMarketV3({
  creator,
  salt: 1n,
  collateral: JITOSOL_MINT,
  feeOwner: creator,
  expiry: nowUnix + 7n * 86_400n, // one week from now, unix seconds
  window: 3600n, // exercise window, seconds
  strikeE8: 170_00000000n, // $170.00
  maxQuantityAtoms: 1_000_000_000n, // 1 JitoSOL per fill
  feeBps: 1000,
  nowUnix,
});

createRestrictedMarketV3

Builds create_restricted_market_v3, which creates a restricted market for freezable or tokenized-stock collateral with the approved 7-day cancellation timeout.

ts
export declare function createRestrictedMarketV3(input: CreateMarketInput & {
    cancellationTimeoutSeconds?: bigint;
}, d?: Deployment): Promise<{
    market: import("@solana/kit").Address<string>;
    termsId: Uint8Array<ArrayBufferLike>;
    recommendedComputeUnitLimit: 200000;
    instruction: import("../settlement/restricted-v3.js").RestrictedV3Instruction;
}>;
Note

Restricted (tokenized-stock) markets are covr-only today. This builder is documented for completeness.

NameTypeDescription
inputCreateMarketInputAs for createMarketV3.
input.cancellationTimeoutSecondsbigintOptional. Default and only accepted value: 604800n (RESTRICTED_CANCELLATION_TIMEOUT_SECONDS).
dDeploymentOptional. Default MAINNET.

Returns: market, termsId (32 bytes, equal to RESTRICTED_TERMS_ID), recommendedComputeUnitLimit (200,000) and the instruction. Accounts: creator (writable signer), market (writable), collateral mint, USDC mint, System program. Data: as create_market_v3, then the timeout (u64 LE).

Throws: every maker-sdk: error of createMarketV3, plus:

ConditionMessage
cancellationTimeoutSeconds is not 604800nRestrictedV3: timeout not in the approved restricted allowlist
A key is the zero keyRestrictedV3: zero identity
expiry + window overflows i64RestrictedV3: MarketV3 terms
ts
import { createRestrictedMarketV3, type CreateMarketInput } from '@covrfun/maker-sdk';

declare const terms: CreateMarketInput;
const { market, termsId, instruction } = await createRestrictedMarketV3(terms);