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 Parameter | Description |
|---|---|
L extends OvercastLayer | the 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
| Parameter | Type | Description |
|---|---|---|
signer | OvercastChainSigner<L> | undefined | - |
txBuilder | OvercastWriter<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. |
reader | OvercastReader | On-chain read operations, delegated to by the reader methods below. |
Returns
OvercastChainClient<L>
Overrides
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
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
writer
readonly writer: OvercastWriter<L>;
Defined in: packages/overcast-core/src/protocol/signing-writer.ts:34
Inherited from
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
Implementation of
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
user | Bytes32 | - |
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.address | string | The 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? | boolean | Whether or not the asset can be treated similar to cash |
asset.chain? | string | The 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? | string | CoinGecko id for price lookups, e.g. usd-coin. |
asset.decimals? | number | Number of decimal places in the asset's native units. |
asset.domain? | number | The 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? | number | Last 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? | string | Logo of the coin |
asset.name? | string | Human name of the asset. |
asset.rwa? | boolean | Whether the asset is a real-world asset (RWA) — e.g. tokenized private equity — rather than a native crypto asset. |
asset.symbol? | string | Human ticker, e.g. USDC. |
asset.volatility? | number | Volatility of the asset |
Returns
Promise<bigint>
Implementation of
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
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
amount | bigint | native (smallest-unit) amount of option.details.collateralAsset to borrow. |
metadata? | Metadata | opaque 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
| Parameter | Type |
|---|---|
option | MarketOption |
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
| Parameter | Type | Description |
|---|---|---|
collateralOffer | Offer | - |
operation? | SignedOperation | delegated authorization by the offer's maker; the operation must have been signed over this offer's id. |
Returns
Promise<L["receipt"][]>
Implementation of
Inherited from
createOffer()
createOffer(offer, operation?): Promise<L["receipt"][]>;
Defined in: packages/overcast-core/src/protocol/signing-writer.ts:49
creates a new offer
Parameters
| Parameter | Type | Description |
|---|---|---|
offer | Offer | - |
operation? | SignedOperation | delegated authorization by the offer's creator; the operation must have been signed over this exact offer. |
Returns
Promise<L["receipt"][]>
Implementation of
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
deposit | DepositParams | - |
Returns
Promise<L["receipt"][]>
Implementation of
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
user | Bytes32 | - |
Returns
Promise<bigint>
Implementation of
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
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
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
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
amount | bigint | - |
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
Inherited from
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
| Parameter | Type |
|---|---|
option | MarketOption |
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
| Parameter | Type |
|---|---|
option | MarketOption |
Returns
Promise<bigint>
fee in premium
Implementation of
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
| Parameter | Type | Description |
|---|---|---|
settlementOffer | Offer | - |
collateralOffer | Offer | - |
Returns
Promise<L["receipt"][]>
Implementation of
Inherited from
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
| Parameter | Type |
|---|---|
id | Bytes32 |
Returns
Promise<boolean>
Implementation of
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
| Parameter | Type |
|---|---|
option | MarketOption |
Returns
Promise<boolean>
Implementation of
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
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
user | Bytes32 | - |
Returns
Promise<bigint>
Implementation of
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
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
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
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
amount | bigint | - |
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
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
key | Bytes32 | the 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
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
amount | bigint | native (smallest-unit) amount of option.details.collateralAsset to repay; must not exceed the option's current outstanding borrow. |
Returns
Promise<L["receipt"][]>
Implementation of
Inherited from
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
key | Bytes32 | undefined | the public key to authorize as a signer for this wallet. |
permissions | number | 0xffff | the 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
| Parameter | Type |
|---|---|
settlementLayer | Bytes32 |
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
| Parameter | Type | Description |
|---|---|---|
withdraw | WithdrawParams | - |
signedOperation? | SignedOperation | - |
Returns
Promise<L["receipt"][]>