UNPKG

@okx-dex/okx-dex-sdk

Version:
252 lines (251 loc) 5.97 kB
export interface TokenInfo { decimal: string; isHoneyPot: boolean; taxRate: string; tokenContractAddress: string; tokenSymbol: string; tokenUnitPrice: string; } export type TokenInfoList = TokenInfo; export type TokenListInfo = TokenListResponse; export interface TokenListResponse { decimals: string; tokenContractAddress: string; tokenLogoUrl?: string; tokenName?: string; tokenSymbol: string; } export interface RouterResult { chainId: string; dexRouterList: DexRouter[]; estimateGasFee: string; fromToken: TokenInfo; toToken: TokenInfo; fromTokenAmount: string; toTokenAmount: string; priceImpactPercentage: string; quoteCompareList: ComparisonQuote[]; tradeFee: string; } export interface DexProtocol { dexName: string; percent: string; } export interface SubRouterInfo { dexProtocol: DexProtocol[]; fromToken: TokenInfo; toToken: TokenInfo; } export interface DexRouter { router: string; routerPercent: string; subRouterList: SubRouterInfo[]; } export interface ComparisonQuote { amountOut: string; dexLogo: string; dexName: string; tradeFee: string; } export interface QuoteData { chainId: string; dexRouterList: DexRouter[]; estimateGasFee: string; fromToken: TokenInfo; toToken: TokenInfo; fromTokenAmount: string; toTokenAmount: string; priceImpactPercentage: string; quoteCompareList: ComparisonQuote[]; tradeFee: string; routerResult?: RouterResult; tx?: TransactionData; } export interface ChainData { chainId: string; chainName: string; dexTokenApproveAddress: string | null; } export interface SwapResponseData { data: { routerResult: { chainId: string; dexRouterList: DexRouter[]; estimateGasFee: string; fromToken: TokenInfo; toToken: TokenInfo; fromTokenAmount: string; toTokenAmount: string; priceImpactPercentage: string; quoteCompareList: ComparisonQuote[]; tradeFee: string; }; tx?: TransactionData; }[]; code: string; msg: string; } export interface SwapExecutionData { routerResult: { chainId: string; dexRouterList: DexRouter[]; estimateGasFee: string; fromToken: TokenInfo; toToken: TokenInfo; fromTokenAmount: string; toTokenAmount: string; priceImpactPercentage: string; quoteCompareList: ComparisonQuote[]; tradeFee: string; }; tx?: TransactionData; } export interface TransactionData { data: string; from: string; gas: string; gasPrice: string; maxPriorityFeePerGas: string; minReceiveAmount: string; signatureData: string[]; slippage: string; to: string; value: string; } export interface APIResponse<T> { code: string; msg: string; data: T[]; } export interface SolanaConfig { connection: { rpcUrl: string; wsEndpoint?: string; confirmTransactionInitialTimeout?: number; }; walletAddress: string; privateKey: string; computeUnits?: number; maxRetries?: number; } export interface SuiConfig { privateKey: string; walletAddress: string; connection?: { rpcUrl: string; wsEndpoint?: string; }; } export interface EVMConfig { walletAddress: string; privateKey: string; gasMultiplier?: number; connection?: { rpcUrl: string; wsEndpoint?: string; }; } export interface ChainConfig { id: string; explorer: string; defaultSlippage: string; maxSlippage: string; computeUnits?: number; confirmationTimeout?: number; maxRetries?: number; dexContractAddress?: string; } export interface NetworkConfigs { [chainId: string]: ChainConfig; } export interface OKXConfig { apiKey: string; secretKey: string; apiPassphrase: string; projectId: string; baseUrl?: string; networks?: NetworkConfigs; solana?: SolanaConfig; sui?: SuiConfig; evm?: EVMConfig; timeout?: number; maxRetries?: number; } export interface APIRequestParams { [key: string]: string | undefined; } export interface SlippageOptions { slippage?: string; autoSlippage?: boolean; maxAutoSlippage?: string; } export interface BaseParams { chainId: string; fromTokenAddress: string; toTokenAddress: string; amount: string; userWalletAddress?: string; } export interface SwapParams extends BaseParams { slippage?: string; autoSlippage?: boolean; maxAutoSlippage?: string; } export interface QuoteParams extends BaseParams { slippage: string; } export interface SwapResult { success: boolean; transactionId: string; explorerUrl: string; details?: { fromToken: { symbol: string; amount: string; decimal: string; }; toToken: { symbol: string; amount: string; decimal: string; }; priceImpact: string; }; } export interface FormattedSwapResponse { success: boolean; quote: { fromToken: { symbol: string; amount: string; decimal: string; unitPrice: string; }; toToken: { symbol: string; amount: string; decimal: string; unitPrice: string; }; priceImpact: string; dexRoutes: { dex: string; amountOut: string; fee: string; }[]; }; summary: string; tx?: { data: string; }; } export interface ApproveTokenParams { chainId: string; tokenContractAddress: string; approveAmount: string; } export interface ApproveTokenResult { success: boolean; transactionHash: string; explorerUrl: string; }