solana-options
Version:
Minting of options contract NFTs on the Solana blockchain
81 lines • 4.61 kB
TypeScript
import { Keypair, Signer } from "@solana/web3.js";
import { Connection, PublicKey } from "@solana/web3.js";
import { print_contract, get_contract_from_blockchain, verify_contract } from "./utils";
export { get_contract_from_blockchain, verify_contract, print_contract };
import { publish_doc, create_doc_img } from "./doc";
export { publish_doc, create_doc_img };
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
export interface Contract {
strike: number;
expiry: number;
multiple: number;
instrument: PublicKey;
strike_instrument: PublicKey;
nft_id?: PublicKey;
nft_account?: PublicKey;
account_id?: PublicKey;
collateral_acc?: PublicKey;
writer_recv_acc: PublicKey;
writer: PublicKey;
kind: OptionType;
}
export declare enum OptionType {
call = 0,
put = 1
}
/**
*
* @param connection
* @param strike
* @param expiry
* @param multiple
* @param creator_account
* @param instrument
* @param strike_instrument
* @param creator_instrument_acc
* @param creator_strike_instrument_acc
* @returns
*/
export declare function create_call(connection: Connection, strike: number, expiry: number, multiple: number, creator_account: Signer | SignerWalletAdapter, instrument: PublicKey | string | null, strike_instrument: PublicKey | string | null, creator_instrument_acc: PublicKey | null, creator_strike_instrument_acc: PublicKey | null): Promise<[string, Contract]>;
/**
*
* @param connection
* @param strike
* @param expiry
* @param multiple
* @param creator_account
* @param instrument
* @param strike_instrument
* @param creator_instrument_acc
* @param creator_strike_instrument_acc
* @returns
*/
export declare function create_put(connection: Connection, strike: number, expiry: number, multiple: number, creator_account: Signer | SignerWalletAdapter, instrument: PublicKey | string | null, strike_instrument: PublicKey | string | null, creator_instrument_acc: PublicKey | null, creator_strike_instrument_acc: PublicKey | null): Promise<[string, Contract]>;
export declare function create_new_nft_mint(connection: Connection, multiple: number, creator_account: Signer | SignerWalletAdapter): Promise<(string | PublicKey | Keypair)[]>;
export declare function create_option(connection: Connection, strike: number, expiry: number, multiple: number, creator_account: Signer | SignerWalletAdapter, instrument: PublicKey | string | null, strike_instrument: PublicKey | string | null, creator_instrument_acc: PublicKey | null, creator_strike_instrument_acc: PublicKey, kind: OptionType): Promise<[string, Contract]>;
export declare function exercise_call(connection: Connection, contract: Contract, buyer_acc: Signer | SignerWalletAdapter, buyer_nft_acc: PublicKey, buyer_receive_acc: PublicKey, buyer_send_acc: PublicKey): Promise<string>;
export declare function exercise_put(connection: Connection, contract: Contract, buyer_acc: Signer | SignerWalletAdapter, buyer_nft_acc: PublicKey, buyer_receive_acc: PublicKey, buyer_send_acc: PublicKey): Promise<string>;
/**
* Exercises the options contract
* @param connection connection to the cluster
* @param contract the Contract
* @param buyer_acc buyer's account or buyers wallet
* @param buyer_nft_acc the buyer's account that holds the ownership nft. This get burned by the exercise instruction
* @param buyer_receive_acc account the buyers expects to receive the options collateral
* @param buyer_send_acc the account holding the tokens the buyer is sending to exercise this contract
* @param kind call or put
* @returns signature
*/
export declare function exercise_option(connection: Connection, contract: Contract, buyer_acc: Signer | SignerWalletAdapter, buyer_nft_acc: PublicKey, buyer_receive_acc: PublicKey, buyer_send_acc: PublicKey, kind: OptionType): Promise<string>;
/**
* Creators call this to close expired contracts. This instruction returns the collateral to the creator if the contract is expired and
* hasn't been exercised yet, and returns any lamport used to create the options program account back to the creator and cleans out its data.
* Exercised contracts are automatically closed
* @param connection Connection to cluster
* @param contract Contract
* @param creator_acc The creators keypair
* @param creator_receive_acc the receiving account where the released collateral will be sent back
* @returns signature
*/
export declare function close_option(connection: Connection, contract: Contract, creator_acc: Signer | SignerWalletAdapter, creator_receive_acc: PublicKey): Promise<string>;
//# sourceMappingURL=index.d.ts.map