Skip to main content

Class: MemoryStore

Defined in: packages/overcast-core/src/storage/memory.ts:78

In-memory reference implementation of the storage ports. Backs both the trusted write side (OvercastStore) and the public read side (OvercastView); a real deployment swaps this for a database-backed store implementing the same interfaces.

Reads return curated (display) shapes, so the store is constructed with an OvercastCurator — the asset metadata plus the address boundary, used only on the way out. The projections it folds events into are canonical (Bytes32 throughout, so getId needs nothing extra); curation is what turns those slots back into chain-formatted addresses and resolves each leg's asset. Filtering, sorting and pagination are done in JS here — the same query objects a SQL implementation would push down to the database.

The curator is per-domain on both halves because the event stream is not single-chain: whatever domains the indexer feeding it scans all land in the same maps, so the boundary and the asset metadata are picked per record from the domain its own terms name (OptionDetails.domain), and a domain with no layer registered curates through hex (see OvercastUtilsRegistry).

Implements

Constructors

Constructor

new MemoryStore(curator?): MemoryStore;

Defined in: packages/overcast-core/src/storage/memory.ts:130

Parameters

ParameterType
curatorOvercastCurator

Returns

MemoryStore

Properties

authorizedKeys

authorizedKeys: Map<string, AuthorizedKey>;

Defined in: packages/overcast-core/src/storage/memory.ts:112

Delegated signing keys, keyed ${domain}:${owner}:${authorizedKey} — the same key the SQL projection uses. Without the domain a revoke on one chain would deactivate the same pair on another.


checkpoints

checkpoints: Map<string, Checkpoint>;

Defined in: packages/overcast-core/src/storage/memory.ts:84

Resume cursors, keyed ${domain}:${kind} — a cursor is a position in one deployment's log, so domains keep their own (see OvercastStore.getCheckpoint).


offerCancelled

offerCancelled: Map<Bytes32, OfferCancelled>;

Defined in: packages/overcast-core/src/storage/memory.ts:91


offerCreated

offerCreated: Map<Bytes32, OfferCreated>;

Defined in: packages/overcast-core/src/storage/memory.ts:89

Indexed *Created events, retained for their createdAt (checkpoint ts).


offers

offers: Map<Bytes32, Offer>;

Defined in: packages/overcast-core/src/storage/memory.ts:106

Every offer ever created — open or closed; see lifecycleOf.


optionBorrow

optionBorrow: Map<Bytes32,
| OptionBorrowed
| OptionRepaid>;

Defined in: packages/overcast-core/src/storage/memory.ts:101

The newest borrow / repay event per option, in chain order — not the whole list. Both events carry outstandingBorrow, the debt left on the option after they applied, so the latest one alone states the current value; see applyOptionBorrow.


optionCreated

optionCreated: Map<Bytes32, MarketOptionCreated>;

Defined in: packages/overcast-core/src/storage/memory.ts:90


optionExercised

optionExercised: Map<Bytes32, OptionExercised[]>;

Defined in: packages/overcast-core/src/storage/memory.ts:93

Exercise / redeem events, keyed by the option id they belong to.


optionRedeemed

optionRedeemed: Map<Bytes32, OptionRedeemed[]>;

Defined in: packages/overcast-core/src/storage/memory.ts:94


options

options: Map<Bytes32, MarketOption>;

Defined in: packages/overcast-core/src/storage/memory.ts:104

Derived current-state projections.


quotes

quotes: Map<string, StoredQuote>;

Defined in: packages/overcast-core/src/storage/memory.ts:116


rfqs

rfqs: Map<string, StoredRfq>;

Defined in: packages/overcast-core/src/storage/memory.ts:115

Off-chain RFQ channel, persisted for after-the-fact fetches.

Methods

getCheckpoint()

getCheckpoint(domain, kind): Promise<Checkpoint | null>;

Defined in: packages/overcast-core/src/storage/memory.ts:228

One deployment's resume cursor for the given loop (see CheckpointKind). Cursors are keyed by (domain, kind): an indexer runs per deployment and its cursor is a position in that chain's log, so two deployments' loops must not share one.

Parameters

ParameterType
domainnumber
kindCheckpointKind

Returns

Promise<Checkpoint | null>

Implementation of

OvercastStorage.getCheckpoint

getOffer()

getOffer(id): Promise<
| WithId<CuratedOffer>
| null>;

Defined in: packages/overcast-core/src/storage/memory.ts:343

Parameters

ParameterTypeDescription
idBytes32the offer's content-address (see getId).

Returns

Promise< | WithId<CuratedOffer> | null>

Implementation of

OvercastStorage.getOffer

getOption()

getOption(id): Promise<CuratedMarketOption | null>;

Defined in: packages/overcast-core/src/storage/memory.ts:312

Parameters

ParameterTypeDescription
idBytes32the option's content-address (see getId).

Returns

Promise<CuratedMarketOption | null>

Implementation of

OvercastStorage.getOption

getOptionExercised()

getOptionExercised(option): Promise<OptionExercised[]>;

Defined in: packages/overcast-core/src/storage/memory.ts:407

Parameters

ParameterType
optionBytes32

Returns

Promise<OptionExercised[]>

Implementation of

OvercastEventHistory.getOptionExercised


getOptionRedeemed()

getOptionRedeemed(option): Promise<OptionRedeemed[]>;

Defined in: packages/overcast-core/src/storage/memory.ts:410

Parameters

ParameterType
optionBytes32

Returns

Promise<OptionRedeemed[]>

Implementation of

OvercastEventHistory.getOptionRedeemed


getOptionTotals()

getOptionTotals(option): Promise<OptionTotals>;

Defined in: packages/overcast-core/src/storage/memory.ts:413

Parameters

ParameterType
optionBytes32

Returns

Promise<OptionTotals>

Implementation of

OvercastEventHistory.getOptionTotals


getRfq()

getRfq(id): Promise<StoredRfq | null>;

Defined in: packages/overcast-core/src/storage/memory.ts:388

Parameters

ParameterType
idstring

Returns

Promise<StoredRfq | null>

Implementation of

OvercastStorage.getRfq

insertEvents()

insertEvents(events, _commitment): Promise<void>;

Defined in: packages/overcast-core/src/storage/memory.ts:140

Insert a batch of indexed on-chain events at the given commitment (default live), updating the derived offer / option / totals projections. Idempotent per event so re-indexing a range is safe; a finalized insert upgrades an existing live row.

Parameters

ParameterType
eventsIndexedEvents[]
_commitmentCommitment

Returns

Promise<void>

Implementation of

OvercastStorage.insertEvents

listAssets()

listAssets(query?): Promise<object[]>;

Defined in: packages/overcast-core/src/storage/memory.ts:399

The assets the deployment holds curated metadata for (GET /assets) — what raw OptionDetails asset addresses are resolved against. Drives a client's pick-from-list UX, symbol display and decimal scaling. Returned as a bare list (not paged) — it is small, curated reference data, not indexed data.

Not a permission list. An asset that is absent is uncurated, not unsupported: the protocol trades whatever an offer's terms name, so options are written over it all the same — its amounts simply render in native units against a bare address until someone describes it.

Filter by domain for one chain's assets; unfiltered returns every domain the deployment serves, each asset tagged with its own Asset.domain. A consumer pinned to one chain wants the filtered form — which is what OvercastApp.assets() asks for.

Parameters

ParameterType
query?AssetQuery

Returns

Promise<object[]>

Implementation of

OvercastStorage.listAssets

listAuthorizedKeys()

listAuthorizedKeys(query?): Promise<Page<AuthorizedKey>>;

Defined in: packages/overcast-core/src/storage/memory.ts:353

Delegated signing keys, paginated and filterable — the projection of the AuthorizedKeySet / AuthorizedKeyRemoved history. Revoked keys are included by default; filter on active to get only the live delegations.

This is a read of on-chain authorization state, not an authorization check: it says who an account has delegated to, and the protocol still verifies every SignedOperation against the chain itself.

Parameters

ParameterType
query?AuthorizedKeyQuery

Returns

Promise<Page<AuthorizedKey>>

Implementation of

OvercastStorage.listAuthorizedKeys

listOffers()

listOffers(query?): Promise<Page<WithId<CuratedOffer>>>;

Defined in: packages/overcast-core/src/storage/memory.ts:322

Offers, each tagged with its content-address id and its lifecycle OfferStatus. Matched and cancelled offers are included by default; filter on status for just the open book (open) or just the history (closed).

Parameters

ParameterType
query?OfferQuery

Returns

Promise<Page<WithId<CuratedOffer>>>

Implementation of

OvercastStorage.listOffers

listOptions()

listOptions(query?): Promise<Page<CuratedMarketOption>>;

Defined in: packages/overcast-core/src/storage/memory.ts:263

Curated market options, paginated and filterable.

Parameters

ParameterType
query?OptionQuery

Returns

Promise<Page<CuratedMarketOption>>

Implementation of

OvercastStorage.listOptions

listQuotes()

listQuotes(rfqId, page?): Promise<Page<StoredQuote>>;

Defined in: packages/overcast-core/src/storage/memory.ts:392

Quotes submitted against a given RFQ.

Parameters

ParameterType
rfqIdstring
page?Pagination

Returns

Promise<Page<StoredQuote>>

Implementation of

OvercastStorage.listQuotes

listRfqs()

listRfqs(query?): Promise<Page<StoredRfq>>;

Defined in: packages/overcast-core/src/storage/memory.ts:372

Persisted RFQs — both still-open and historical.

Parameters

ParameterType
query?RfqQuery

Returns

Promise<Page<StoredRfq>>

Implementation of

OvercastStorage.listRfqs

listUserDeposits()

listUserDeposits(_query?): Promise<Page<UserDepositWire>>;

Defined in: packages/overcast-core/src/storage/memory.ts:259

Live vault balances, paginated and filterable. Still uncurated — canonical slots and a decimal-string amount (UserDepositWire).

Parameters

ParameterType
_query?UserDepositQuery

Returns

Promise<Page<UserDepositWire>>

Implementation of

OvercastStorage.listUserDeposits

recordQuote()

recordQuote(quote): Promise<void>;

Defined in: packages/overcast-core/src/storage/memory.ts:195

Persist (or update) an off-chain quote submitted against an RFQ.

Parameters

ParameterType
quoteStoredQuote

Returns

Promise<void>

Implementation of

OvercastStorage.recordQuote

recordRfq()

recordRfq(rfq): Promise<void>;

Defined in: packages/overcast-core/src/storage/memory.ts:187

Persist (or update) an off-chain RFQ so it is fetchable after the fact.

Parameters

ParameterType
rfqStoredRfq

Returns

Promise<void>

Implementation of

OvercastStorage.recordRfq

setCheckpoint()

setCheckpoint(
domain,
kind,
checkpoint): Promise<void>;

Defined in: packages/overcast-core/src/storage/memory.ts:241

Write, or on null clear, one deployment's cursor for the given loop.

Parameters

ParameterType
domainnumber
kindCheckpointKind
checkpointCheckpoint | null

Returns

Promise<void>

Implementation of

OvercastStorage.setCheckpoint

setQuoteStatus()

setQuoteStatus(
quoteId,
status,
optionId?): Promise<void>;

Defined in: packages/overcast-core/src/storage/memory.ts:211

Transition a quote to a new status (and bind its optionId once accepted), stamping updatedAt. No-op if the quote is unknown.

Parameters

ParameterType
quoteIdstring
statusQuoteStatus
optionId?Bytes32

Returns

Promise<void>

Implementation of

OvercastStorage.setQuoteStatus

setRfqStatus()

setRfqStatus(rfqId, status): Promise<void>;

Defined in: packages/overcast-core/src/storage/memory.ts:203

Transition a persisted RFQ to a new lifecycle status, stamping updatedAt. A cheaper alternative to reconstructing the whole StoredRfq for a recordRfq upsert. No-op if the RFQ is unknown.

Parameters

ParameterType
rfqIdstring
statusRfqStatus

Returns

Promise<void>

Implementation of

OvercastStorage.setRfqStatus