Types
The SDK exports all TypeScript types for use in your application.
Importing Types
Section titled “Importing Types”import type { SDKConfig, Priority, BuyOptions, SellOptions, SwapOptions, SwapMode, TradeEstimates, TradeAmounts, TransactionResult, ProfileResult, RegisterResult,} from '@darkfibre/sdk';Type Reference
Section titled “Type Reference”SDKConfig
Section titled “SDKConfig”Configuration for the SDK constructor.
interface SDKConfig { apiKey: string; // Your Darkfibre API key privateKey: string; // Base58-encoded Solana private key baseUrl?: string; // API base URL (optional)}Priority
Section titled “Priority”Transaction priority level.
type Priority = 'economy' | 'fast' | 'faster' | 'fastest';| Value | Speed | Fee |
|---|---|---|
economy | Standard | Almost free |
fast | Optimized | Lower |
faster | High priority | Medium |
fastest | Maximum | Highest |
Read more about priority.
BuyOptions
Section titled “BuyOptions”Options for the buy() method.
interface BuyOptions { mint: string; // Token mint address solAmount: number; // SOL amount to spend slippage: number; // Slippage tolerance (0.05 = 5%) priority: Priority; // Transaction priority maxPriceImpact?: number; // Max price impact (0.1 = 10%) maxPriorityCost?: number; // Max priority fee in SOL}SellOptions
Section titled “SellOptions”Options for the sell() method.
interface SellOptions { mint: string; // Token mint address tokenAmount: number; // Token amount to sell slippage: number; // Slippage tolerance (0.05 = 5%) priority: Priority; // Transaction priority maxPriceImpact?: number; // Max price impact (0.1 = 10%) maxPriorityCost?: number; // Max priority fee in SOL}SwapOptions
Section titled “SwapOptions”Options for the swap() method.
interface SwapOptions { inputMint: string; // Input token mint outputMint: string; // Output token mint amount: number; // Amount to swap swapMode: SwapMode; // 'exactIn' or 'exactOut' slippage: number; // Slippage tolerance (0.05 = 5%) priority: Priority; // Transaction priority maxPriceImpact?: number; // Max price impact (0.1 = 10%) maxPriorityCost?: number; // Max priority fee in SOL}SwapMode
Section titled “SwapMode”Swap direction mode.
type SwapMode = 'exactIn' | 'exactOut';| Value | Description |
|---|---|
exactIn | Amount is the exact input. Output is estimated. |
exactOut | Amount is the exact output. Input is estimated. |
TradeAmounts
Section titled “TradeAmounts”Actual trade amounts from a transaction.
interface TradeAmounts { inputAmount: number; // Amount spent outputAmount: number; // Amount received}TradeEstimates
Section titled “TradeEstimates”Pre-trade estimates (before execution).
interface TradeEstimates { inputAmount: number; // Estimated input outputAmount: number; // Estimated output priceImpact: number; // Estimated price impact}TransactionResult
Section titled “TransactionResult”Result returned by trading methods.
interface TransactionResult { signature: string; // Transaction signature status: string; // Transaction status slot: number; // Solana slot number platform: string; // Trading platform inputMint: string; // Input mint address outputMint: string; // Output mint address tradeResult: TradeAmounts; // Actual trade amounts priorityCost: number; // Priority fee in SOL}ProfileResult
Section titled “ProfileResult”Result from the getProfile() method.
interface ProfileResult { walletAddress: string; createdAt: string; volume: { sol30d: number; trades30d: number; }; fee: { bps: number; decimal: number; nextBps: number | null; nextThresholdSol: number | null; };}RegisterResult
Section titled “RegisterResult”Result from the register() static method.
interface RegisterResult { apiKey: string; // Your new API key walletAddress: string; // Registered wallet address}