Back to Documentation

DeFi Integration

Integrate Xandeum DeFi features into your applications.

Available Features

Liquid Staking

Stake SOL and receive XANDsol while earning ~7.2% APY.

Token Swaps

Swap tokens via Jupiter aggregator integration.

Price Feeds

Access real-time XAND and SOL price data.

Liquid Staking Integration

Integrate XANDsol liquid staking into your dApp:

Install SDK

npm install @xandeum/staking-sdk

Stake SOL

import { XandeumStaking } from '@xandeum/staking-sdk';

const staking = new XandeumStaking(connection);

// Stake 1 SOL
const tx = await staking.stake({
  amount: 1 * LAMPORTS_PER_SOL,
  wallet: userWallet,
});

// Returns XANDsol to user's wallet

Unstake

// Unstake XANDsol
const tx = await staking.unstake({
  amount: xandsolAmount,
  wallet: userWallet,
});

// SOL returned after 2-3 day cooldown

Swap Integration

Integrate token swaps using Jupiter:

import { Jupiter } from '@jup-ag/core';

const jupiter = await Jupiter.load({
  connection,
  cluster: 'mainnet-beta',
  user: userWallet,
});

// Get swap routes
const routes = await jupiter.computeRoutes({
  inputMint: SOL_MINT,
  outputMint: XAND_MINT,
  amount: 1 * LAMPORTS_PER_SOL,
  slippage: 0.5,
});

// Execute swap
const { execute } = await jupiter.exchange({
  routeInfo: routes.routesInfos[0],
});

const result = await execute();

Price Feeds

Access real-time price data via API:

// Fetch prices
const response = await fetch('/api/trading');
const { data } = await response.json();

console.log(data.xand.price);  // 0.0234
console.log(data.sol.price);   // 98.45

// WebSocket for real-time updates
const ws = new WebSocket('wss://api.xandeum.io/prices');
ws.onmessage = (event) => {
  const prices = JSON.parse(event.data);
  updateUI(prices);
};
Need API details?API Reference