Class: EvmReader
Defined in: evm-client/src/reader.ts:47
EVM implementation of OvercastReader: the read-only side of the protocol. It needs only a viem PublicClient (no account), so it serves read-only clients too.
Everything the protocol stores lives in the one Core contract — vault
balances, both claim ledgers, and, for offers and options, no more than the
id they are keyed by — so unlike Solana, where each is its own account
behind a derived PDA, every read here is a view call to a single address.
What is derived off-chain is that key: getId from @overcast-xyz/core,
unchanged. Since the canonical domain types are 32-byte slots throughout,
they hold exactly the bytes Serialization.sol hashes, so this package has no
serialization of its own; utils.ts converts addresses at the boundary and
core does the rest.
Because core keeps ids and not terms, there is nothing here that fetches an offer or an option: offerExists / optionExists answer the only question the chain can, borrowedCollateral the one live value a record still carries, and the terms themselves come from the curated backend.
Implements
OvercastReader
Constructors
Constructor
new EvmReader(client, coreAddress): EvmReader;
Defined in: evm-client/src/reader.ts:59
Parameters
| Parameter | Type | Description |
|---|---|---|
client | { } | a viem public client on the chain core is deployed to. Only readContract is used, so an account-less transport is enough. |
coreAddress | string | the deployed Core proxy address (see EvmConfig.overcastCoreAddress) — not the implementation behind it. A chain-encoded 0x… address, since it comes from a deployment config rather than from core's canonical form. |
Returns
EvmReader
Properties
coreAddress
readonly coreAddress: `0x${string}`;
Defined in: evm-client/src/reader.ts:49
The deployed Core proxy every read below is addressed to.
Methods
balance()
balance(user, asset): Promise<bigint>;
Defined in: evm-client/src/reader.ts:99
Gets the current balance for an asset in the protocols vault
Parameters
| Parameter | Type |
|---|---|
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 |
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: evm-client/src/reader.ts:137
The option's outstanding borrow, out of core's OptionRecord — the only
mutable part of a live option, and the reason there is a read here at all
rather than just the terms the caller already holds.
An unknown option reads as zero: the record's borrowedCollateral is unset
either way, and core does not revert on a missing id.
Parameters
| Parameter | Type |
|---|---|
option | MarketOption |
Returns
Promise<bigint>
Implementation of
OvercastReader.borrowedCollateral
escrowBalances()
escrowBalances(
asset,
escrows,
blockNumber?): Promise<{
balances: bigint[];
custody: bigint;
}>;
Defined in: evm-client/src/reader.ts:192
What each of escrows holds of asset in core's ledgers (same order), and
core's actual token balance of asset. All read at blockNumber (latest
by default), so the two can be compared: core guarantees the ledgers never
sum to more than custody.
Parameters
| Parameter | Type |
|---|---|
asset | Bytes32 |
escrows | EvmEscrowKey[] |
blockNumber? | bigint |
Returns
Promise<{
balances: bigint[];
custody: bigint;
}>
exerciseClaims()
exerciseClaims(option, user): Promise<bigint>;
Defined in: evm-client/src/reader.ts:356
returns the user balance of exercise claims for the given option
Parameters
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
user | Bytes32 | - |
Returns
Promise<bigint>
Implementation of
OvercastReader.exerciseClaims
exerciseClaimsSupply()
exerciseClaimsSupply(option): Promise<bigint>;
Defined in: evm-client/src/reader.ts:329
Returns the total supply of exercise claims for the given option
Parameters
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
Returns
Promise<bigint>
Implementation of
OvercastReader.exerciseClaimsSupply
getOptionBalances()
getOptionBalances(option): Promise<{
collateral: bigint;
settlement: bigint;
}>;
Defined in: evm-client/src/reader.ts:155
The collateral and settlement still escrowed against an option.
Each leg is a separate ledger keyed by (optionId, leg, asset), so the two
reads name the asset their leg holds — taken from the option's own terms. A
missing option reads as zeros: an unset ledger entry and a fully drained
escrow are the same thing on-chain, and the return type cannot express
absence.
Parameters
| Parameter | Type |
|---|---|
option | MarketOption |
Returns
Promise<{
collateral: bigint;
settlement: bigint;
}>
Implementation of
OvercastReader.getOptionBalances
getOptionFees()
getOptionFees(_option): Promise<bigint>;
Defined in: evm-client/src/reader.ts:262
TODO: quote the configured IOptionCreationHook.
Always 0n for now, which is the true answer whenever
ProtocolConfig.optionCreationHook is unset — and it is unset on every
current deployment. Once a hook ships, this becomes a onCreateOption
simulation against the hook getProtocolState reports, whose
FeeResolution carries the premiumFeeAmount this returns.
Parameters
| Parameter | Type |
|---|---|
_option | MarketOption |
Returns
Promise<bigint>
Implementation of
OvercastReader.getOptionFees
getProtocolState()
getProtocolState(): Promise<ProtocolState>;
Defined in: evm-client/src/reader.ts:80
The protocol's global state, read straight off core's Governance module.
Two calls rather than one: the module exposes the mutable config and the
immutable domain as separate views (they live in the same ERC-7201
namespace but there is no getter returning both), so they are issued
concurrently. That makes the pair non-atomic in principle — a config update
landing between them would be read half-old — but only config can move at
all, so the two halves can never disagree with each other.
A Core proxy that was never initialized answers both views with zeros
rather than reverting, which surfaces as an all-zero authority and
domain: 0. That is left as-is instead of being turned into a throw: unlike
Solana, where the state account's absence is unambiguous, there is no
on-chain marker here that separates "uninitialized" from a deployment whose
domain genuinely is 0.
Returns
Promise<ProtocolState>
Implementation of
OvercastReader.getProtocolState
offerExists()
offerExists(id): Promise<boolean>;
Defined in: evm-client/src/reader.ts:273
Whether core has an offer stored under id.
Core keeps only the id — mapping(bytes32 => bool) — so this is the whole
of what it can answer about an offer; its terms come from the curated
backend, or from whoever handed over the id.
Parameters
| Parameter | Type |
|---|---|
id | Bytes32 |
Returns
Promise<boolean>
Implementation of
OvercastReader.offerExists
optionExists()
optionExists(option): Promise<boolean>;
Defined in: evm-client/src/reader.ts:120
Whether core has an option registered under these terms.
Core keys an option by the sha256 of its terms and stores nothing else
about it that the terms don't say, so reaching it is a local hash — getId
— followed by one view. No offer reads, and no dependence on the two
offers still being in core's registry.
Parameters
| Parameter | Type |
|---|---|
option | MarketOption |
Returns
Promise<boolean>
Implementation of
OvercastReader.optionExists
redeemClaims()
redeemClaims(option, user): Promise<bigint>;
Defined in: evm-client/src/reader.ts:347
returns the user balance of redeem claims for the given option
Parameters
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
user | Bytes32 | - |
Returns
Promise<bigint>
Implementation of
OvercastReader.redeemClaims
redeemClaimsSupply()
redeemClaimsSupply(option): Promise<bigint>;
Defined in: evm-client/src/reader.ts:338
Returns the total supply of redeem claims for the given option
Parameters
| Parameter | Type | Description |
|---|---|---|
option | MarketOption | - |
Returns
Promise<bigint>
Implementation of
OvercastReader.redeemClaimsSupply
settlementLayerKind()
settlementLayerKind(settlementLayer): Promise<KnownSettlementLayer>;
Defined in: evm-client/src/reader.ts:293
Classify a settlement layer by asking it.
On EVM a layer is a contract rather than a config account, so its kind
comes from the layerType() view every ISettlementLayer implements —
there is no storage layout to read a discriminant out of. Anything that
fails to answer is not a layer this protocol can settle against, so it
throws rather than guessing.
Parameters
| Parameter | Type |
|---|---|
settlementLayer | Bytes32 |
Returns
Promise<KnownSettlementLayer>
Implementation of
OvercastReader.settlementLayerKind