Interface: OvercastWriter<L, T>
Defined in: packages/overcast-core/src/protocol/writer.ts:72
The Overcast protocol's write operations, parameterised by the layer L they
run against and by what each call yields (the read counterpart is
OvercastReader).
The delegable calls (createCollateralOffer, createSettlementOffer,
closeCollateralOffer, closeSettlementOffer, exerciseOption,
redeemOption) take an optional SignedOperation (on the option calls,
as SettlementParams): omitted, the acting
party (offer maker / option taker) must sign the transaction itself; present,
the transaction may be submitted by anyone (an operator) and the chain
verifies the operation's off-chain signature instead. Build one with an
OvercastProtocolSigner's sign over the matching operation payload (see the
*Operation classes in operation.ts).
Extended by
Type Parameters
| Type Parameter | Default type |
|---|---|
L extends OvercastLayer | - |
T extends UnsignedTransaction | L["tx"] |
Methods
borrowCollateral()
borrowCollateral(
option,
amount,
metadata?): Promise<T[]>;
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
| 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<T[]>
cancelOffer()
cancelOffer(offer, operation?): Promise<T[]>;
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
| Parameter | Type | Description |
|---|---|---|
offer | Offer | the offer to close (must match the on-chain, content-addressed offer exactly). |
operation? | SignedOperation | delegated authorization by the offer's maker; the operation must have been signed over this offer's id. |
Returns
Promise<T[]>
createOffer()
createOffer(offer, operation?): Promise<T[]>;
Defined in: packages/overcast-core/src/protocol/writer.ts:82
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<T[]>
deposit()
deposit(deposit): Promise<T[]>;
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
| Parameter | Type | Description |
|---|---|---|
deposit | DepositParams | - |
Returns
Promise<T[]>
exerciseOption()
exerciseOption(
option,
amount,
params?): Promise<T[]>;
Defined in: packages/overcast-core/src/protocol/writer.ts:110
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<T[]>
matchOffer()
matchOffer(settlementOffer, collateralOffer): Promise<T[]>;
Defined in: packages/overcast-core/src/protocol/writer.ts:99
matches settlement and collateral offer
Parameters
| Parameter | Type | Description |
|---|---|---|
settlementOffer | Offer | - |
collateralOffer | Offer | - |
Returns
Promise<T[]>
redeemOption()
redeemOption(
option,
amount,
params?): Promise<T[]>;
Defined in: packages/overcast-core/src/protocol/writer.ts:124
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<T[]>
removeAuthorizedKey()
removeAuthorizedKey(key): Promise<T[]>;
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
| Parameter | Type | Description |
|---|---|---|
key | Bytes32 | the public key to deauthorize. |
Returns
Promise<T[]>
repayCollateral()
repayCollateral(option, amount): Promise<T[]>;
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
| 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<T[]>
setAuthorizedKey()
setAuthorizedKey(key, permissions?): Promise<T[]>;
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
| Parameter | Type | Description |
|---|---|---|
key | Bytes32 | the public key to authorize as a signer for this wallet. |
permissions? | number | the permissions bitmap - defaults to 0xFFFF granting all permissions. Build the bitmap with buildPermissionsBitmap |
Returns
Promise<T[]>
withdraw()
withdraw(withdraw, signedOperation?): Promise<T[]>;
Defined in: packages/overcast-core/src/protocol/writer.ts:181
withdraws funds from the withdrawer's protocol escrow vault
Parameters
| Parameter | Type | Description |
|---|---|---|
withdraw | WithdrawParams | - |
signedOperation? | SignedOperation | - |
Returns
Promise<T[]>