Documentation
Everything you need to integrate Fluxions into your Solana application.
# Quickstart
Get your first optimized swap route in under 5 minutes. Fluxions works with any Solana wallet adapter and requires no additional infrastructure.
1. Install the SDKbash
npm install @fluxions/sdk @solana/web3.js2. Initialize & Routetypescript
import { Fluxions } from '@fluxions/sdk';
import { Connection } from '@solana/web3.js';
const connection = new Connection(
'https://api.mainnet-beta.solana.com'
);
const fluxions = new Fluxions({ connection });
// Find the best route
const route = await fluxions.findRoute({
inputMint: 'So11111111111111111111111111111111111111112',
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: 1_000_000_000, // 1 SOL in lamports
slippageBps: 50, // 0.5%
});
console.log(route.outAmount); // Best output
console.log(route.priceImpact); // Price impact %
console.log(route.routePlan); // Hop-by-hop breakdown3. Execute the swaptypescript
// Build & send transaction
const { transaction } = await fluxions.buildTransaction({
route,
userPublicKey: wallet.publicKey,
wrapUnwrapSOL: true,
});
const signature = await wallet.sendTransaction(
transaction,
connection
);
console.log('Swap confirmed:', signature);# Installation
Fluxions SDK supports Node.js 18+ and modern browsers. Available on npm.
npmbash
npm install @fluxions/sdkyarnbash
yarn add @fluxions/sdkNote
Requires @solana/web3.js as a peer dependency. The SDK is tree-shakable and adds minimal bundle size.
# Route Discovery
The routing engine evaluates all possible paths through indexed DEXs and returns the optimal execution plan.
Parameters
| Param | Type | Description |
|---|---|---|
| inputMint | string | SPL token mint address to swap from |
| outputMint | string | SPL token mint address to swap to |
| amount | number | Input amount in smallest unit (lamports) |
| slippageBps | number | Max slippage in basis points (50 = 0.5%) |
| maxHops | number? | Max intermediate hops (default: 3) |
| excludeDexes | string[]? | DEX IDs to exclude from routing |
| onlyDirectRoutes | boolean? | Skip multi-hop routes |
Advanced routing optionstypescript
const route = await fluxions.findRoute({
inputMint: SOL_MINT,
outputMint: USDC_MINT,
amount: 10_000_000_000,
slippageBps: 100,
maxHops: 2,
excludeDexes: ['orca-v1'],
onlyDirectRoutes: false,
// MEV protection options
mevProtection: {
enabled: true,
provider: 'jito', // 'jito' | 'bloxroute'
tipLamports: 10_000, // Priority tip
},
});# Execution
After discovering a route, build and submit the transaction. All legs are bundled into a single atomic Solana transaction.
Transaction lifecycletypescript
// Build the transaction
const { transaction, signers } = await fluxions.buildTransaction({
route,
userPublicKey: wallet.publicKey,
wrapUnwrapSOL: true,
computeUnitLimit: 400_000,
computeUnitPrice: 50_000,
});
// Simulate first (optional)
const simulation = await connection.simulateTransaction(
transaction
);
if (simulation.value.err) {
throw new Error('Simulation failed');
}
// Send with confirmation
const signature = await wallet.sendTransaction(
transaction,
connection,
{ signers }
);
await connection.confirmTransaction(signature, 'confirmed');# Advanced
Custom RPC
const fluxions = new Fluxions({
connection,
rpcEndpoint: 'https://your-rpc.example.com',
commitment: 'confirmed',
timeout: 30_000,
});Streaming quotes
// Subscribe to real-time route updates
const unsubscribe = fluxions.streamRoutes(
{
inputMint: SOL_MINT,
outputMint: USDC_MINT,
amount: 1_000_000_000,
slippageBps: 50,
},
(route) => {
console.log('New best route:', route.outAmount);
// Update UI with latest quote
},
{ interval: 2000 } // Poll every 2s
);
// Later: unsubscribe();Webhooks
// Register a webhook for swap confirmations
await fluxions.webhooks.register({
url: 'https://your-api.com/fluxions/callback',
events: ['swap.confirmed', 'swap.failed'],
secret: 'whsec_...',
});# API Reference
REST API available for server-side integrations. All endpoints require an API key.
GET
/v1/quotePOST
/v1/swapGET
/v1/tokensGET
/v1/dexesPOST
/v1/webhooksExample: GET /v1/quotebash
curl -X GET 'https://api.fluxions.dev/v1/quote' \
-H 'Authorization: Bearer flx_...' \
-d inputMint=So111...1112 \
-d outputMint=EPjFW...Dt1v \
-d amount=1000000000 \
-d slippageBps=50