@thespidercode/openbook-swap
Version:
Ready-to-use swap tool using Openbook DEX
49 lines (48 loc) • 1.53 kB
TypeScript
import { SwapDetail } from "./swap";
import { MarketDetails, SwapMarket } from "./market";
import { Connection, PublicKey } from "@solana/web3.js";
import React from "react";
import { WalletContextState } from "@solana/wallet-adapter-react";
import '@thespidercode/openbook-swap/src/css/openbookswap.css';
export declare function SwapContainer(props: SwapContainerProps): React.JSX.Element;
export interface SwapContainerProps {
title: string;
connection: Connection;
onSwapSuccess: (success: SwapSuccess) => void;
onSwapError: (error: SwapError) => void;
onSwapLoading: (loading: SwapLoading) => void;
colors?: SwapContainerColors;
markets: SwapMarket[];
wallet?: WalletContextState;
manualTransaction?: PublicKey;
onSwap?: (swap: ManualSwap) => void;
}
export interface SwapContainerColors {
background?: string;
swapButton?: string;
primary?: string;
secondary?: string;
text?: string;
}
export interface SwapCallback {
message: string;
signature?: string;
}
export interface SwapLoading extends SwapCallback {
swapResult: SwapDetail;
}
export interface SwapError extends SwapCallback {
}
export interface ManualSwap {
swapResult: SwapDetail;
setLoadingSwap: React.Dispatch<React.SetStateAction<boolean>>;
refreshUserBalances: (owner: PublicKey) => void;
}
export interface SwapSuccess extends SwapCallback {
market: MarketDetails;
signature: string;
differences: {
base: number | null;
quote: number | null;
};
}