Skip to main content

Interface: OvercastChain<L>

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

The protocol's on-chain surface: authoritative reads (OvercastReader) and signed writes (OvercastWriter, yielding one TxStep<L["receipt"]> per transaction the operation took — see SigningWriter), merged into one object. Everything here touches the settlement layer directly — it costs gas, needs the signer, and is chain-specific — as opposed to the cheap, curated backend reads exposed on app.api (an OvercastView).

Exposed to consumers as app.chain.

Extends

Type Parameters

Type ParameterDescription
L extends OvercastLayerthe OvercastLayer describing this settlement layer.

Properties

chainSigner

chainSigner: OvercastChainSigner<L>;

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


txBuilder

txBuilder: OvercastWriter<L, L["tx"]>;

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

Methods

balance()

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

Defined in: packages/overcast-core/src/protocol/reader.ts:30

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>

Inherited from

OvercastReader.balance


borrowCollateral()

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

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

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"][]>

Inherited from

OvercastWriter.borrowCollateral


borrowedCollateral()

borrowedCollateral(option): Promise<bigint>;

Defined in: packages/overcast-core/src/protocol/reader.ts:57

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>

Inherited from

OvercastReader.borrowedCollateral


cancelOffer()

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

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

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

Parameters

ParameterTypeDescription
offerOfferthe offer to close (must match the on-chain, content-addressed offer exactly).
operation?SignedOperationdelegated authorization by the offer's maker; the operation must have been signed over this offer's id.

Returns

Promise<L["receipt"][]>

Inherited from

OvercastWriter.cancelOffer


createOffer()

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

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

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"][]>

Inherited from

OvercastWriter.createOffer


deposit()

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

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

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"][]>

Inherited from

OvercastWriter.deposit


exerciseClaims()

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

Defined in: packages/overcast-core/src/protocol/reader.ts:123

returns the user balance of exercise claims for the given option

Parameters

ParameterTypeDescription
optionMarketOption-
userBytes32-

Returns

Promise<bigint>

Inherited from

OvercastReader.exerciseClaims


exerciseClaimsSupply()

exerciseClaimsSupply(option): Promise<bigint>;

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

Returns the total supply of exercise claims for the given option

Parameters

ParameterTypeDescription
optionMarketOption-

Returns

Promise<bigint>

Inherited from

OvercastReader.exerciseClaimsSupply


exerciseOption()

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

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

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"][]>

Inherited from

OvercastWriter.exerciseOption


getOptionBalances()

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

Defined in: packages/overcast-core/src/protocol/reader.ts:65

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; }>

Inherited from

OvercastReader.getOptionBalances


getOptionFees()

getOptionFees(option): Promise<bigint>;

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

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

Inherited from

OvercastReader.getOptionFees


getProtocolState()

getProtocolState(): Promise<ProtocolState>;

Defined in: packages/overcast-core/src/protocol/reader.ts:25

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>

Inherited from

OvercastReader.getProtocolState


matchOffer()

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

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

matches settlement and collateral offer

Parameters

ParameterTypeDescription
settlementOfferOffer-
collateralOfferOffer-

Returns

Promise<L["receipt"][]>

Inherited from

OvercastWriter.matchOffer


offerExists()

offerExists(id): Promise<boolean>;

Defined in: packages/overcast-core/src/protocol/reader.ts:85

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>

Inherited from

OvercastReader.offerExists


optionExists()

optionExists(option): Promise<boolean>;

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

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>

Inherited from

OvercastReader.optionExists


redeemClaims()

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

Defined in: packages/overcast-core/src/protocol/reader.ts:116

returns the user balance of redeem claims for the given option

Parameters

ParameterTypeDescription
optionMarketOption-
userBytes32-

Returns

Promise<bigint>

Inherited from

OvercastReader.redeemClaims


redeemClaimsSupply()

redeemClaimsSupply(option): Promise<bigint>;

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

Returns the total supply of redeem claims for the given option

Parameters

ParameterTypeDescription
optionMarketOption-

Returns

Promise<bigint>

Inherited from

OvercastReader.redeemClaimsSupply


redeemOption()

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

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

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"][]>

Inherited from

OvercastWriter.redeemOption


removeAuthorizedKey()

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

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

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"][]>

Inherited from

OvercastWriter.removeAuthorizedKey


repayCollateral()

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

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

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"][]>

Inherited from

OvercastWriter.repayCollateral


setAuthorizedKey()

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

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

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

ParameterTypeDescription
keyBytes32the public key to authorize as a signer for this wallet.
permissions?numberthe permissions bitmap - defaults to 0xFFFF granting all permissions. Build the bitmap with buildPermissionsBitmap

Returns

Promise<L["receipt"][]>

Inherited from

OvercastWriter.setAuthorizedKey


settlementLayerKind()

settlementLayerKind(settlementLayer): Promise<KnownSettlementLayer>;

Defined in: packages/overcast-core/src/protocol/reader.ts:97

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>

Inherited from

OvercastReader.settlementLayerKind


withdraw()

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

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

withdraws funds from the withdrawer's protocol escrow vault

Parameters

ParameterTypeDescription
withdrawWithdrawParams-
signedOperation?SignedOperation-

Returns

Promise<L["receipt"][]>

Inherited from

OvercastWriter.withdraw