Skip to main content

Class: OvercastChainClient<L>

Defined in: packages/overcast-core/src/protocol/chain.ts:46

Concrete OvercastChain: a SigningWriter (signer + transaction writer, build → sign → submit) with the layer's OvercastReader folded in, so on-chain reads and signed writes live behind a single object. Built by OvercastApp from the pieces a ProtocolFactory resolves.

signer is omitted for a read-only app: the reads and txBuilder below work unchanged, while the inherited write methods throw a MissingSignerError (see SigningWriter).

Extends​

Type Parameters​

Type ParameterDescription
L extends OvercastLayerthe OvercastLayer describing this settlement layer.

Implements​

Constructors​

Constructor​

new OvercastChainClient<L>(
signer,
txBuilder,
reader): OvercastChainClient<L>;

Defined in: packages/overcast-core/src/protocol/chain.ts:50

Parameters​

ParameterTypeDescription
signerOvercastChainSigner<L> | undefined-
txBuilderOvercastWriter<L>The build-only writer behind the signed writes: it yields the layer's unsigned tx instead of submitting, so a caller owning its own submission path (browser wallet, relayer, multisig) — including a read-only app with no signer at all — can build through it.
readerOvercastReaderOn-chain read operations, delegated to by the reader methods below.

Returns​

OvercastChainClient<L>

Overrides​

SigningWriter.constructor

Properties​

reader​

readonly reader: OvercastReader;

Defined in: packages/overcast-core/src/protocol/chain.ts:60

On-chain read operations, delegated to by the reader methods below.


signer​

readonly signer: OvercastChainSigner<L> | undefined;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:33

Inherited from​

SigningWriter.signer


txBuilder​

readonly txBuilder: OvercastWriter<L>;

Defined in: packages/overcast-core/src/protocol/chain.ts:58

The build-only writer behind the signed writes: it yields the layer's unsigned tx instead of submitting, so a caller owning its own submission path (browser wallet, relayer, multisig) — including a read-only app with no signer at all — can build through it.

Implementation of​

OvercastChain.txBuilder


writer​

readonly writer: OvercastWriter<L>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:34

Inherited from​

SigningWriter.writer

Accessors​

chainSigner​

Get Signature​

get chainSigner(): OvercastChainSigner<L>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:44

The signer every write below submits through, narrowed to non-undefined: the single place a read-only app is turned away, so no method can reach a submit without one.

Throws​

when the app was built without a chain signer.

Returns​

OvercastChainSigner<L>

Implementation of​

OvercastChain.chainSigner

Inherited from​

SigningWriter.chainSigner

Methods​

balance()​

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

Defined in: packages/overcast-core/src/protocol/chain.ts:75

Gets the current balance for an asset in the protocols vault

Parameters​

ParameterTypeDescription
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.addressstringThe on-chain address (mint) identifying the asset, in the layer's own encoding (base58 on Solana, 0x… on an EVM chain) — see Address.
asset.cashLike?booleanWhether or not the asset can be treated similar to cash
asset.chain?stringThe chain the asset lives on, e.g. "base". A display label only — it is a caller-chosen name (see ChainName), carried by no wire payload and never used to key or look up an asset. domain is the identity.
asset.coinGeckoId?stringCoinGecko id for price lookups, e.g. usd-coin.
asset.decimals?numberNumber of decimal places in the asset's native units.
asset.domain?numberThe protocol domain the asset lives on — the same separator OptionDetails.domain carries and every indexed event is tagged with, and the first half of the asset's key in an AssetRegistry. Optional because a single-domain deployment has nothing to disambiguate; such an asset registers as a wildcard, matching any domain that has no asset of its own at that address. Populate it as soon as one backend serves two domains — an address is only unique within a domain.
asset.lastKnownPriceUsd?numberLast known USD price, sourced best-effort from an external feed (CoinGecko). Untrusted — do not use for settlement, signing, valuation, or any value transfer. It is informational only (e.g. showing an approximate notional in a picker), may be stale, missing, or wrong, and is never part of the canonical, content-addressed asset identity. Present only once a price has actually been fetched for the asset.
asset.logoUrl?stringLogo of the coin
asset.name?stringHuman name of the asset.
asset.rwa?booleanWhether the asset is a real-world asset (RWA) — e.g. tokenized private equity — rather than a native crypto asset.
asset.symbol?stringHuman ticker, e.g. USDC.
asset.volatility?numberVolatility of the asset

Returns​

Promise<bigint>

Implementation of​

OvercastChain.balance


borrowCollateral()​

borrowCollateral(
option,
amount,
metadata?): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:96

borrows collateral out of the option's escrow into the taker's own collateral token account, tracking an outstanding-borrow debt on the option. Only permitted while option.details.borrowAllowed is set and before the option's exercise window starts (option.details.startTimestamp); the settlement layer additionally decides whether the borrow is allowed. Repayment is trusted, not enforced on chain — only take a borrow-enabled option from a taker you trust to honor it. The option is neither exercisable nor redeemable until all borrowed collateral is repaid. The taker must sign this transaction themselves (not delegable).

Parameters​

ParameterTypeDescription
optionMarketOption-
amountbigintnative (smallest-unit) amount of option.details.collateralAsset to borrow.
metadata?Metadataopaque settlement-layer metadata, forwarded to the layer's borrow check verbatim (see exerciseOption). Defaults to empty.

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.borrowCollateral

Inherited from​

SigningWriter.borrowCollateral


borrowedCollateral()​

borrowedCollateral(option): Promise<bigint>;

Defined in: packages/overcast-core/src/protocol/chain.ts:99

Native (smallest-unit) amount of option.details.collateralAsset currently borrowed out of the option's collateral escrow and not yet repaid — the one mutable part of a live option.

Zero for an option that never borrowed and for one that does not exist: an unset ledger entry and a fully repaid loan are the same thing on-chain. Use optionExists to tell those apart.

Parameters​

ParameterType
optionMarketOption

Returns​

Promise<bigint>

Implementation of​

OvercastChain.borrowedCollateral


cancelOffer()​

cancelOffer(collateralOffer, operation?): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:58

cancels an open offer, refunding its escrowed collateral/premium to the creator's deposit vault

Parameters​

ParameterTypeDescription
collateralOfferOffer-
operation?SignedOperationdelegated authorization by the offer's maker; the operation must have been signed over this offer's id.

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.cancelOffer

Inherited from​

SigningWriter.cancelOffer


createOffer()​

createOffer(offer, operation?): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:49

creates a new offer

Parameters​

ParameterTypeDescription
offerOffer-
operation?SignedOperationdelegated authorization by the offer's creator; the operation must have been signed over this exact offer.

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.createOffer

Inherited from​

SigningWriter.createOffer


deposit()​

deposit(deposit): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:115

deposits funds into the depositor's protocol escrow vault

The one operation that is routinely more than one transaction: where the chain gates the pull on a standing allowance (ERC-20 on EVM), the returned list is [approve, deposit] — the approval for exactly deposit.amount, omitted when the existing allowance already covers it. See TxStep.

Parameters​

ParameterTypeDescription
depositDepositParams-

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.deposit

Inherited from​

SigningWriter.deposit


exerciseClaims()​

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

Defined in: packages/overcast-core/src/protocol/chain.ts:91

returns the user balance of exercise claims for the given option

Parameters​

ParameterTypeDescription
optionMarketOption-
userBytes32-

Returns​

Promise<bigint>

Implementation of​

OvercastChain.exerciseClaims


exerciseClaimsSupply()​

exerciseClaimsSupply(option): Promise<bigint>;

Defined in: packages/overcast-core/src/protocol/chain.ts:79

Returns the total supply of exercise claims for the given option

Parameters​

ParameterTypeDescription
optionMarketOption-

Returns​

Promise<bigint>

Implementation of​

OvercastChain.exerciseClaimsSupply


exerciseOption()​

exerciseOption(
option,
amount,
params?): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:76

exercises an option with the given amount

Parameters​

ParameterTypeDescription
optionMarketOption-
amountbigint-
params?SettlementParams<L>SettlementParams: the layer metadata, an optional delegating operation by the option's taker (signed over the exercise payload — option offer ids, amount and metadata exactly as passed here), and the layer's chain-specific settlement context.

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.exerciseOption

Inherited from​

SigningWriter.exerciseOption


getOptionBalances()​

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

Defined in: packages/overcast-core/src/protocol/chain.ts:103

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​

OvercastChain.getOptionBalances


getOptionFees()​

getOptionFees(option): Promise<bigint>;

Defined in: packages/overcast-core/src/protocol/chain.ts:71

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​

OvercastChain.getOptionFees


getProtocolState()​

getProtocolState(): Promise<ProtocolState>;

Defined in: packages/overcast-core/src/protocol/chain.ts:67

Reads the protocol's global ProtocolState — the live ProtocolConfig (authority, pause authority, option-creation hook and both pause bitmasks) together with the immutable domain.

This is the authoritative answer to the questions no per-record read can settle: whether the action a caller is about to submit is currently paused, whether a fee hook is configured (and so whether a premium will be skimmed), who may change either, and which domain an offer's terms must name to be accepted here.

Always present on a deployed protocol — initialization creates it, and nothing can remove it — so this resolves to a state rather than null, and throws if the protocol is not initialized at the configured address.

Returns​

Promise<ProtocolState>

Implementation of​

OvercastChain.getProtocolState


matchOffer()​

matchOffer(settlementOffer, collateralOffer): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:67

matches settlement and collateral offer

Parameters​

ParameterTypeDescription
settlementOfferOffer-
collateralOfferOffer-

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.matchOffer

Inherited from​

SigningWriter.matchOffer


offerExists()​

offerExists(id): Promise<boolean>;

Defined in: packages/overcast-core/src/protocol/chain.ts:109

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​

OvercastChain.offerExists


optionExists()​

optionExists(option): Promise<boolean>;

Defined in: packages/overcast-core/src/protocol/chain.ts:95

Whether the given option exists on-chain.

Takes the option's whole terms rather than an id because that is what both chains need to reach the record: EVM keys options by the content-address of their terms, Solana by the (collateralOffer, settlementOffer) pair its account's PDA is seeded with. Neither is derivable from the other, and the terms carry both.

Only existence, not the stored option: nothing about a live option is on-chain that the terms don't already say, apart from borrowedCollateral, which has its own read. Fetch the terms themselves from the curated backend (app.api.getOption).

Parameters​

ParameterType
optionMarketOption

Returns​

Promise<boolean>

Implementation of​

OvercastChain.optionExists


redeemClaims()​

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

Defined in: packages/overcast-core/src/protocol/chain.ts:87

returns the user balance of redeem claims for the given option

Parameters​

ParameterTypeDescription
optionMarketOption-
userBytes32-

Returns​

Promise<bigint>

Implementation of​

OvercastChain.redeemClaims


redeemClaimsSupply()​

redeemClaimsSupply(option): Promise<bigint>;

Defined in: packages/overcast-core/src/protocol/chain.ts:83

Returns the total supply of redeem claims for the given option

Parameters​

ParameterTypeDescription
optionMarketOption-

Returns​

Promise<bigint>

Implementation of​

OvercastChain.redeemClaimsSupply


redeemOption()​

redeemOption(
option,
amount,
params?): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:86

redeems an option with the given amount

Parameters​

ParameterTypeDescription
optionMarketOption-
amountbigint-
params?SettlementParams<L>SettlementParams, as for exerciseOption, except the delegating operation is the option's maker's and is signed over the redeem payload.

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.redeemOption

Inherited from​

SigningWriter.redeemOption


removeAuthorizedKey()​

removeAuthorizedKey(key): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:137

revokes a key previously authorized via setAuthorizedKey, closing its signing-key record (the rent is refunded to the wallet). Operations signed with key are rejected afterwards. The wallet must sign this transaction itself.

Parameters​

ParameterTypeDescription
keyBytes32the public key to deauthorize.

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.removeAuthorizedKey

Inherited from​

SigningWriter.removeAuthorizedKey


repayCollateral()​

repayCollateral(option, amount): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:106

repays previously borrowed collateral back into the option's escrow, reducing the outstanding-borrow debt tracked on the option. Permissionless — any signer holding the collateral asset may repay on the taker's behalf; the repaying wallet must sign this transaction itself.

Parameters​

ParameterTypeDescription
optionMarketOption-
amountbigintnative (smallest-unit) amount of option.details.collateralAsset to repay; must not exceed the option's current outstanding borrow.

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.repayCollateral

Inherited from​

SigningWriter.repayCollateral


setAuthorizedKey()​

setAuthorizedKey(key, permissions?): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:128

authorizes key to sign SignedOperations on the calling wallet's behalf. Registers a signing-key record owned by the wallet; thereafter an operator may submit that wallet's delegable calls (createCollateralOffer, createSettlementOffer, exerciseOption) by presenting an operation signed with key. The wallet must sign this transaction itself — you can only authorize keys for yourself.

Parameters​

ParameterTypeDefault valueDescription
keyBytes32undefinedthe public key to authorize as a signer for this wallet.
permissionsnumber0xffffthe permissions bitmap - defaults to 0xFFFF granting all permissions. Build the bitmap with buildPermissionsBitmap

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.setAuthorizedKey

Inherited from​

SigningWriter.setAuthorizedKey


settlementLayerKind()​

settlementLayerKind(settlementLayer): Promise<KnownSettlementLayer>;

Defined in: packages/overcast-core/src/protocol/chain.ts:113

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​

OvercastChain.settlementLayerKind


withdraw()​

withdraw(withdraw, signedOperation?): Promise<L["receipt"][]>;

Defined in: packages/overcast-core/src/protocol/signing-writer.ts:119

withdraws funds from the withdrawer's protocol escrow vault

Parameters​

ParameterTypeDescription
withdrawWithdrawParams-
signedOperation?SignedOperation-

Returns​

Promise<L["receipt"][]>

Implementation of​

OvercastChain.withdraw

Inherited from​

SigningWriter.withdraw