Skip to content

Types

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

import type {
SDKConfig,
Priority,
BuyOptions,
SellOptions,
SwapOptions,
SwapMode,
MintInput,
TradeEstimates,
TradeAmounts,
TransactionResult,
ProfileResult,
RegisterResult,
} from '@darkfibre/sdk';
// Mint constants are exported as values
import { Mints } 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, must include /v1)
}

Default baseUrl: https://api.darkfibre.dev/v1

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'

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

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
}

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
}

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 (or fallback to estimates)
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
}