UNPKG

@thespidercode/openbook-swap

Version:
43 lines (42 loc) 1.41 kB
import { Connection, Keypair, PublicKey, Transaction, TransactionInstruction } from "@solana/web3.js"; import { MarketDetails } from "./market"; export declare const getCloseOpenOrdersInstruction: (openOrders: PublicKey, market: PublicKey, owner: PublicKey) => TransactionInstruction | null; export declare const getSwapTransaction: (owner: PublicKey, side: Side, limit: number, size: number, marketDetails: MarketDetails, connection: Connection, onchain: boolean) => Promise<SwapTransaction | string>; export declare const newSwap: (owner: PublicKey, swap: Swap, lowestAsk: number, highestBid: number, connection: Connection) => Promise<SwapDetail>; export interface Swap { sell: boolean; market: MarketDetails; amounts: SwapAmounts; inputAmounts: InputAmounts; slotConsumed: number; } export interface InputAmounts { base: string; quote: string; } export interface SwapAmounts { base: number; quote: number; } export declare enum Side { Buy = "buy", Sell = "sell" } export interface SwapTransaction { transaction: Transaction; signers: Keypair[]; isNewOpenOrders: boolean; } export interface SwapDetail { message?: string; error?: string; transaction?: SwapTransaction; market?: MarketDetails; } export interface SwapTransactionResult { error?: boolean; message?: string; balances?: { [key: string]: number; }; }