Skip to content

Types

The SDK exports all TypeScript types for use in your application.

import type {
SDKConfig,
Priority,
BuyOptions,
SellOptions,
SwapOptions,
SwapMode,
TradeEstimates,
TradeAmounts,
TransactionResult,
ProfileResult,
RegisterResult,
} from '@darkfibre/sdk';

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)
}

Transaction priority level.

type Priority = 'economy' | 'fast' | 'faster' | 'fastest';
ValueSpeedFee
economyStandardAlmost free
fastOptimizedLower
fasterHigh priorityMedium
fastestMaximumHighest

Read more about priority.

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
}

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
}

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
}

Swap direction mode.

type SwapMode = 'exactIn' | 'exactOut';
ValueDescription
exactInAmount is the exact input. Output is estimated.
exactOutAmount is the exact output. Input is estimated.

Actual trade amounts from a transaction.

interface TradeAmounts {
inputAmount: number; // Amount spent
outputAmount: number; // Amount received
}

Pre-trade estimates (before execution).

interface TradeEstimates {
inputAmount: number; // Estimated input
outputAmount: number; // Estimated output
priceImpact: number; // Estimated price impact
}

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
}

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;
};
}

Result from the register() static method.

interface RegisterResult {
apiKey: string; // Your new API key
walletAddress: string; // Registered wallet address
}