Skip to main content

Class: SolanaReader

Defined in: solana-client/src/reader.ts:61

Solana implementation of OvercastReader: the read-only side of the protocol. It needs only an RPC Connection (no wallet), so it serves read-only clients too. PDAs are derived locally via the get*Pda helpers, mirroring the program's seeds = [..].

Vault balances live in per-user, per-mint protocol escrow token accounts; the per-asset SPL token program is resolved by reading each mint's owner so both legacy Token and Token-2022 assets are handled. An option's two claim mints use the permanent-delegate extension and are therefore always Token-2022.

Implements​

  • OvercastReader

Constructors​

Constructor​

new SolanaReader(program, feeHookProgramId?): SolanaReader;

Defined in: solana-client/src/reader.ts:73

The Anchor program is used purely for reads: deserializing the content-addressed offer / option accounts via its account coder. Its provider only needs a connection (no wallet), so this still serves read-only clients. Balances and claim supplies go through the raw Connection / SPL-token helpers below.

Parameters​

ParameterTypeDefault value
programProgram<OvercastCore>undefined
feeHookProgramIdstringFEE_HOOK_PROGRAM_ID

Returns​

SolanaReader

Properties​

connection​

readonly connection: Connection;

Defined in: solana-client/src/reader.ts:62


hookProgram​

readonly hookProgram: Program<OvercastFeeHook>;

Defined in: solana-client/src/reader.ts:64


programId​

readonly programId: PublicKey;

Defined in: solana-client/src/reader.ts:63

Methods​

balance()​

balance(user, asset): Promise<bigint>;

Defined in: solana-client/src/reader.ts:158

Gets the current balance for an asset in the protocols vault

Parameters​

ParameterType
userBytes32
asset{ address: string; cashLike?: boolean; chain?: string; coinGeckoId?: string; decimals?: number; domain?: number; lastKnownPriceUsd?: number; logoUrl?: string; name?: string; rwa?: boolean; symbol?: string; volatility?: number; }
asset.addressstring
asset.cashLike?boolean
asset.chain?string
asset.coinGeckoId?string
asset.decimals?number
asset.domain?number
asset.lastKnownPriceUsd?number
asset.logoUrl?string
asset.name?string
asset.rwa?boolean
asset.symbol?string
asset.volatility?number

Returns​

Promise<bigint>

Implementation of​

OvercastReader.balance

borrowedCollateral()​

borrowedCollateral(option): Promise<bigint>;

Defined in: solana-client/src/reader.ts:225

Outstanding borrow, read off the option's account — the one field on it that its terms do not already fix. A missing account reads as zero.

Parameters​

ParameterType
optionMarketOption

Returns​

Promise<bigint>

Implementation of​

OvercastReader.borrowedCollateral

exerciseClaims()​

exerciseClaims(option, user): Promise<bigint>;

Defined in: solana-client/src/reader.ts:205

returns the user balance of exercise claims for the given option

Parameters​

ParameterTypeDescription
optionMarketOption-
userBytes32-

Returns​

Promise<bigint>

Implementation of​

OvercastReader.exerciseClaims

exerciseClaimsSupply()​

exerciseClaimsSupply(option): Promise<bigint>;

Defined in: solana-client/src/reader.ts:190

Returns the total supply of exercise claims for the given option

Parameters​

ParameterTypeDescription
optionMarketOption-

Returns​

Promise<bigint>

Implementation of​

OvercastReader.exerciseClaimsSupply

getOptionBalances()​

getOptionBalances(option): Promise<{
collateral: bigint;
settlement: bigint;
}>;

Defined in: solana-client/src/reader.ts:102

Looks up how much collateral / settlement are locked in the option's escrow.

Takes the whole option for the same reason optionExists does. A missing option reads as zeros.

Parameters​

ParameterType
optionMarketOption

Returns​

Promise<{ collateral: bigint; settlement: bigint; }>

Implementation of​

OvercastReader.getOptionBalances

getOptionFees()​

getOptionFees(option): Promise<bigint>;

Defined in: solana-client/src/reader.ts:230

Calculates the fee that will be deduced on option creation. This is useful to know, what premium the end-user will actually receive. Option buyer/taker pays premium, fee is deduced from that. The leftover amount is paid to the maker of the option / the user. The fee is always denominated in the premium asset.

Parameters​

ParameterType
optionMarketOption

Returns​

Promise<bigint>

fee in premium

Implementation of​

OvercastReader.getOptionFees

getProtocolState()​

getProtocolState(): Promise<ProtocolState>;

Defined in: solana-client/src/reader.ts:97

The protocol's global state, read from the singleton ProtocolState PDA.

Its seeds carry no user input (getProtocolStatePda takes only the program id), so the address is fixed per deployment — one account, one fetch, no scan. A missing account means the program at this.programId was never initialized, which is a misconfiguration rather than an absent record, so this uses fetch and lets Anchor throw instead of returning null.

Returns​

Promise<ProtocolState>

Implementation of​

OvercastReader.getProtocolState

getUsedOperation()​

getUsedOperation(owner, salt): Promise<UsedOperation | null>;

Defined in: solana-client/src/reader.ts:309

A delegated operation's UsedOperation replay-protection record, or null when the PDA is already gone (never written, or closed to reclaim its rent). Solana-only.

Parameters​

ParameterTypeDescription
ownerBytes32the account the operation acted on behalf of.
saltBytes32the operation's replay nonce (see SignedOperation.salt).

Returns​

Promise<UsedOperation | null>


offerExists()​

offerExists(id): Promise<boolean>;

Defined in: solana-client/src/reader.ts:266

Whether an offer with this content-address Bytes32 exists on-chain.

Existence is all the chain has left to say: an offer is stored under the hash of its own terms, so a caller holding the id that resolves here already holds — or can fetch from the curated backend (app.api.getOffer) — every term it was created with.

Parameters​

ParameterType
idBytes32

Returns​

Promise<boolean>

Implementation of​

OvercastReader.offerExists

optionExists()​

optionExists(option): Promise<boolean>;

Defined in: solana-client/src/reader.ts:217

Whether the option's account exists.

The account is a PDA seeded with the option's (collateral, settlement) offer id pair, so the terms reach it directly — no scan, and no need for the option's own content-address id, which is not what the account is keyed by.

Parameters​

ParameterType
optionMarketOption

Returns​

Promise<boolean>

Implementation of​

OvercastReader.optionExists

protocolTokenAccounts()​

protocolTokenAccounts(mint): Promise<object[]>;

Defined in: solana-client/src/reader.ts:143

All token accounts owned by protocol_state for one mint — every escrow (vault, offer, option) shares that authority, so this is one RPC call instead of a program-wide scan.

Includes non-PDA accounts anyone could create with the same authority — callers must match addresses against their own derived escrow PDAs.

Parameters​

ParameterType
mintPublicKey

Returns​

Promise<object[]>


redeemClaims()​

redeemClaims(option, user): Promise<bigint>;

Defined in: solana-client/src/reader.ts:200

returns the user balance of redeem claims for the given option

Parameters​

ParameterTypeDescription
optionMarketOption-
userBytes32-

Returns​

Promise<bigint>

Implementation of​

OvercastReader.redeemClaims

redeemClaimsSupply()​

redeemClaimsSupply(option): Promise<bigint>;

Defined in: solana-client/src/reader.ts:195

Returns the total supply of redeem claims for the given option

Parameters​

ParameterTypeDescription
optionMarketOption-

Returns​

Promise<bigint>

Implementation of​

OvercastReader.redeemClaimsSupply

settlementLayerKind()​

settlementLayerKind(settlementLayer): Promise<KnownSettlementLayer>;

Defined in: solana-client/src/reader.ts:273

Classify a settlement-layer config (OptionDetails.settlementLayer) into its KnownSettlementLayer kind by inspecting the on-chain config account it points at.

An option commits to a settlement layer as a single opaque config Bytes32; this resolves that id to the abstract kind ("physical" / "oracle") without a caller needing to know the chain's layer programs. Throws if the account doesn't exist or isn't a recognized layer config.

Parameters​

ParameterType
settlementLayerBytes32

Returns​

Promise<KnownSettlementLayer>

Implementation of​

OvercastReader.settlementLayerKind