Skip to main content

Class: SigningWriter<L>

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

Composes a transaction-building OvercastWriter with an OvercastChainSigner: each operation builds the layer's transaction(s) via writer, then signs + submits them via signer, yielding the signer's receipts. The result is itself an OvercastWriter<receipt>, so callers no longer juggle the build-then-submit two-step.

signer is optional: a read-only app (no key material in its OvercastConfig) has none, and every method here then throws a MissingSignerError instead of silently submitting with a wallet that cannot sign. The writer is always present, so such an app can still build transactions and submit them by its own means.

Extended by

Type Parameters

Type ParameterDescription
L extends OvercastLayerthe OvercastLayer describing this settlement layer.

Implements

Constructors

Constructor

new SigningWriter<L>(signer, writer): SigningWriter<L>;

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

Parameters

ParameterType
signerOvercastChainSigner<L> | undefined
writerOvercastWriter<L>

Returns

SigningWriter<L>

Properties

signer

readonly signer: OvercastChainSigner<L> | undefined;

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


writer

readonly writer: OvercastWriter<L>;

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

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>

Methods

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

OvercastWriter.borrowCollateral


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

OvercastWriter.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

OvercastWriter.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

OvercastWriter.deposit


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

OvercastWriter.exerciseOption


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

OvercastWriter.matchOffer


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

OvercastWriter.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

OvercastWriter.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

OvercastWriter.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

OvercastWriter.setAuthorizedKey


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

OvercastWriter.withdraw