Skip to main content

Class: SolanaWriter

Defined in: solana-client/src/writer.ts:75

Solana implementation of OvercastWriter.

Each method maps an Overcast domain object onto the corresponding on-chain instruction and returns the prepared transaction. PDAs are derived locally via the ./pda helpers (mirroring the program's seeds = [..]), and the per-asset SPL token program is resolved by reading each mint's owner so both legacy Token and Token-2022 assets are handled. The protocol's claim mints use the permanent-delegate extension and are therefore always Token-2022.

Domain types carry asset / account references as base58 Id strings; offers and options are content-addressed, so MarketOption.collateralOffer / settlementOffer are the 32-byte offer ids whose bytes seed the PDAs.

The signer / fee payer is taken from the program's provider wallet. This is the write side only; on-chain reads live in SolanaReader.

Implements

Constructors

Constructor

new SolanaWriter(program): SolanaWriter;

Defined in: solana-client/src/writer.ts:76

Parameters

ParameterType
programProgram<OvercastCore>

Returns

SolanaWriter

Methods

acceptOffer()

acceptOffer(settlementOffer, collateralOffer): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:263

matches settlement and collateral offer

Parameters

ParameterTypeDescription
settlementOfferSettlementOffer-
collateralOfferCollateralOffer-

Returns

Promise<Transaction>

Implementation of

OvercastWriter.acceptOffer

addAuthorizedKey()

addAuthorizedKey(key): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:662

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

ParameterTypeDescription
keystringthe public key to authorize as a signer for this wallet.

Returns

Promise<Transaction>

Implementation of

OvercastWriter.addAuthorizedKey

closeCollateralOffer()

closeCollateralOffer(collateralOffer, operation?): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:172

closes an open collateral offer, refunding its escrowed collateral to the maker's deposit vault

Parameters

ParameterTypeDescription
collateralOfferCollateralOfferthe offer to close (must match the on-chain, content-addressed offer exactly).
operation?SignedOperationdelegated authorization by the offer's maker; the operation must have been signed over this offer's id.

Returns

Promise<Transaction>

Implementation of

OvercastWriter.closeCollateralOffer

closeSettlementOffer()

closeSettlementOffer(settlementOffer, operation?): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:219

closes an open settlement offer, refunding its escrowed premium to the taker's deposit vault

Parameters

ParameterTypeDescription
settlementOfferSettlementOfferthe offer to close (must match the on-chain, content-addressed offer exactly).
operation?SignedOperationdelegated authorization by the offer's taker; the operation must have been signed over this offer's id.

Returns

Promise<Transaction>

Implementation of

OvercastWriter.closeSettlementOffer

createCollateralOffer()

createCollateralOffer(collateralOffer, operation?): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:78

creates a new collateral offer

Parameters

ParameterTypeDescription
collateralOfferCollateralOffer-
operation?SignedOperationdelegated authorization by the offer's maker; the operation must have been signed over this exact offer.

Returns

Promise<Transaction>

Implementation of

OvercastWriter.createCollateralOffer

createSettlementOffer()

createSettlementOffer(settlementOffer, operation?): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:127

creates a new settlement offer

Parameters

ParameterTypeDescription
settlementOfferSettlementOffer-
operation?SignedOperationdelegated authorization by the offer's taker; the operation must have been signed over this exact offer.

Returns

Promise<Transaction>

Implementation of

OvercastWriter.createSettlementOffer

deposit()

deposit(deposit): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:599

deposits funds into the depositor's protocol escrow vault

Parameters

ParameterTypeDescription
depositDepositParams-

Returns

Promise<Transaction>

Implementation of

OvercastWriter.deposit

exerciseOption()

exerciseOption(
option,
amount,
metadata?,
operation?): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:380

exercies an option with the given amount

Parameters

ParameterTypeDescription
optionMarketOption-
amountbigint-
metadataMetadataopaque settlement-layer metadata, forwarded to the layer verbatim (no interpretation). Defaults to empty; a physical layer needs none. Build it yourself or via OvercastSettlementLayer.buildMetadata.
operation?SignedOperationdelegated authorization by the option's taker; the operation must have been signed over the exercise payload (option offer ids, amount and metadata exactly as passed here).

Returns

Promise<Transaction>

Implementation of

OvercastWriter.exerciseOption

redeemOption()

redeemOption(
option,
amount,
metadata?,
operation?): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:480

redeems an option with the given amount

Parameters

ParameterTypeDescription
optionMarketOption-
amountbigint-
metadataMetadataopaque settlement-layer metadata, forwarded to the layer verbatim (see exerciseOption).
operation?SignedOperationdelegated authorization by the option's maker; the operation must have been signed over the redeem payload (option offer ids, amount and metadata exactly as passed here).

Returns

Promise<Transaction>

Implementation of

OvercastWriter.redeemOption

removeAuthorizedKey()

removeAuthorizedKey(key): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:685

revokes a key previously authorized via addAuthorizedKey, 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
keystringthe public key to deauthorize.

Returns

Promise<Transaction>

Implementation of

OvercastWriter.removeAuthorizedKey

withdraw()

withdraw(withdraw): Promise<Transaction>;

Defined in: solana-client/src/writer.ts:631

withdraws funds from the withdrawer's protocol escrow vault

Parameters

ParameterTypeDescription
withdrawWithdrawParams-

Returns

Promise<Transaction>

Implementation of

OvercastWriter.withdraw