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, MintInput, TradeEstimates, TradeAmounts, TransactionResult, ProfileResult, RegisterResult,} from '@darkfibre/sdk';
// Mint constants are exported as valuesimport { Mints } 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, must include /v1)}Default baseUrl: https://api.darkfibre.dev/v1
MintInput
Section titled “MintInput”Quote currency or mint address passed to buy(), sell() and swap().
type MintInput = 'SOL' | 'WSOL' | 'USDC' | string;Use string aliases ('SOL', 'WSOL', 'USDC') or raw mint addresses. Named constants are exported as Mints:
import { Mints } from '@darkfibre/sdk';
Mints.SOL; // 'So11111111111111111111111111111111111111112'Mints.WSOL; // 'So11111111111111111111111111111111111111112'Mints.USDC; // 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'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 quoteAmount: number; // Quote currency amount to spend quoteMint: MintInput; // Quote currency (SOL, WSOL, USDC or mint) 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 quoteMint: MintInput; // Quote currency to receive 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: MintInput; // Input token mint outputMint: MintInput; // 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 (or fallback to estimates) 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}