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:
settlementMode | Name | Exercise | Who quotes it today |
|---|---|---|---|
0 | ordinary | atomic: one exercise_v3 pays strike and delivers collateral | desks (JitoSOL) and covr |
1 | restricted | two steps: fund the strike, then deliver; carries a 7-day cancellation timeout | covr 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.
export declare function decodeMarketV3(marketAddress: string, raw: Uint8Array, d?: Deployment): Promise<DecodedMarketV3>;| Name | Type | Description |
|---|---|---|
marketAddress | string | The account address you read. |
raw | Uint8Array | The account data, exactly 376 bytes, read at finalized commitment. |
d | Deployment | Optional. 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.
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:
| Condition | Message |
|---|---|
raw is not a Uint8Array | maker-sdk: market data must be bytes |
raw is not 376 bytes | maker-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 discriminator | MarketV3 account schema (restricted: RestrictedV3: MarketV3 account schema) |
| Version is not 3, USDC decimals byte is not 6, or paused byte above 1 | MarketV3 schema (restricted: RestrictedV3: restricted MarketV3 schema) |
Payment mint or program is not USDC / SPL Token, genesis is not mainnet, or deployment id differs from d | MarketV3 identity (restricted: RestrictedV3: MarketV3 identity) |
| Collateral token program unsupported, or collateral is native SOL | MarketV3 unsupported (restricted: RestrictedV3: MarketV3 unsupported) |
| Restricted terms id does not match the 7-day timeout | RestrictedV3: restricted terms identity |
A term is out of bounds, or (ordinary) the terms id is not ORDINARY_TERMS_ID | MarketV3 terms (restricted: RestrictedV3: MarketV3 terms) |
marketAddress or bump is not the PDA of the stored creator and salt | MarketV3 PDA (restricted: RestrictedV3: MarketV3 PDA) |
d.deploymentId is not 32 bytes | MarketV3 hash (restricted: RestrictedV3: nonzero hash required) |
marketAddress is not valid base58 | SolanaError from @solana/kit |
Account layout (all integers little-endian):
| Bytes | Field | Bytes | Field |
|---|---|---|---|
| 0..8 | discriminator | 205..237 | genesisHash |
| 8 | version (3) | 237..269 | deploymentId |
| 9 | bump | 269..301 | termsId |
| 10 | settlementMode | 301..333 | profileHash |
| 11 | collateralDecimals | 333..341 | salt (u64) |
| 12 | paymentDecimals (6) | 341..349 | expiry (i64, unix s) |
| 13..45 | creator | 349..357 | window (u64, s) |
| 45..77 | collateral | 357..365 | strikeE8 (u64) |
| 77..109 | collateralProgram | 365..373 | maxQuantityAtoms (u64) |
| 109..141 | payment | 373..375 | feeBps (u16) |
| 141..173 | paymentProgram | 375 | paused (0 or 1) |
| 173..205 | feeOwner |
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.
export declare function quoteDomain(market: DecodedMarketV3): TypedDataDomain;| Name | Type | Description |
|---|---|---|
market | DecodedMarketV3 | From 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.
import { quoteDomain, type DecodedMarketV3 } from '@covrfun/maker-sdk';
declare const market: DecodedMarketV3;
const domain = quoteDomain(market); // pass to signIntent and signQuotemarketDomain
Decodes raw market bytes and returns their domain in one call: decodeMarketV3 then quoteDomain.
export declare function marketDomain(marketAddress: string, raw: Uint8Array, d?: Deployment): Promise<TypedDataDomain>;| Name | Type | Description |
|---|---|---|
marketAddress | string | The account address you read. |
raw | Uint8Array | The 376-byte account data. |
d | Deployment | Optional. Default MAINNET. |
Returns: Promise<TypedDataDomain>.
Throws: every error of decodeMarketV3.
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.
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;
};
}>;| Name | Type | Description |
|---|---|---|
input | CreateMarketInput | Creator, salt, collateral, fee owner and terms, plus your clock. |
d | Deployment | Optional. 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.
A market you create is valid on chain, but customers do not see it yet.
Throws:
| Condition | Message |
|---|---|
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 bigint | maker-sdk: salt must be a u64 bigint |
expiry - nowUnix is below 60 or above 7,776,000 | maker-sdk: expiry must be 60 s to 90 days after nowUnix |
window is not 60 to 3,600 | maker-sdk: window must be 60..3600 seconds |
strikeE8 is not a positive u64 | maker-sdk: strikeE8 must be a positive u64 |
maxQuantityAtoms is not a positive u64 | maker-sdk: maxQuantityAtoms must be a positive u64 |
feeBps is not an integer 0 to 1,000 | maker-sdk: feeBps must be an integer 0..1000 |
feeOwner is the zero key | maker-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 i64 | MarketV3 terms |
| An address is not valid base58 | SolanaError from @solana/kit |
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.
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;
}>;Restricted (tokenized-stock) markets are covr-only today. This builder is documented for completeness.
| Name | Type | Description |
|---|---|---|
input | CreateMarketInput | As for createMarketV3. |
input.cancellationTimeoutSeconds | bigint | Optional. Default and only accepted value: 604800n (RESTRICTED_CANCELLATION_TIMEOUT_SECONDS). |
d | Deployment | Optional. 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:
| Condition | Message |
|---|---|
cancellationTimeoutSeconds is not 604800n | RestrictedV3: timeout not in the approved restricted allowlist |
| A key is the zero key | RestrictedV3: zero identity |
expiry + window overflows i64 | RestrictedV3: MarketV3 terms |
import { createRestrictedMarketV3, type CreateMarketInput } from '@covrfun/maker-sdk';
declare const terms: CreateMarketInput;
const { market, termsId, instruction } = await createRestrictedMarketV3(terms);