Skip to main content

Interactive Examples

Experience Saros SDKs with live testing and interactive components. All examples include working code that you can test directly in the browser.

🎮 Live SDK Playground​

Test any Saros SDK method with our interactive playground:

🔧 Interactive API Explorer

Test Saros SDK methods directly in your browser

getPoolInfo
Get detailed information about a specific pool
getAllPools
Retrieve all available Saros pools

getPoolInfo

PoolsReturns: PoolInfo
Get detailed information about a specific pool

Parameters

The public key of the pool to query

Code Example

import { Connection, PublicKey } from '@solana/web3.js';
import { SarosSDK } from '@saros-finance/sdk';

const connection = new Connection('https://api.devnet.solana.com');
const sdk = new SarosSDK(connection);

async function getPoolInfoExample() {
  try {
    const poolId = new PublicKey('YOUR_POOLID');

    const result = await sdk.getPoolInfo(poolId);
    
    console.log('Result:', result);
    return result;
  } catch (error) {
    console.error('Error:', error);
  }
}

📱 Mobile-Friendly Examples​

React Native Integration​

function SarosWalletConnect() {
const [connected, setConnected] = React.useState(false);

return (
<div style={{padding: '20px', border: '1px solid #ccc', borderRadius: '8px'}}>
<h3>Mobile Wallet Connection</h3>
<button onClick={() => setConnected(!connected)}>
{connected ? 'Disconnect' : 'Connect Wallet'}
</button>
{connected && (
<div style={{marginTop: '10px', color: 'green'}}>
✅ Wallet Connected - Ready for trading!
</div>
)}
</div>
);
}

Progressive Web App​

See our Getting Started Guide for building mobile-optimized DeFi applications.

🔧 Development Environment​

Prerequisites Setup​

Before running interactive examples, ensure you have:

# Node.js 18+
node --version

# Install dependencies
npm install @saros-finance/sdk @saros-finance/dlmm-sdk @solana/web3.js

# Environment variables
cp .env.example .env.local

Network Configuration​

// Development setup for interactive examples
import { Connection, clusterApiUrl } from '@solana/web3.js';
import { SarosSDK } from '@saros-finance/sdk';

const connection = new Connection(
process.env.SOLANA_RPC_URL || clusterApiUrl('devnet')
);

const sdk = new SarosSDK({
connection,
cluster: 'devnet', // Safe for testing
});

🎯 Performance Testing​

Interactive examples include performance benchmarks:

  • Swap Latency: ~300ms average on devnet
  • Position Creation: ~500ms for DLMM positions
  • Data Fetching: ~100ms for pool information
  • WebSocket Updates: Real-time price feeds at 10Hz

💻 Code Examples You Can Copy​

All our examples are fully functional and tested. Copy any example code directly from:

TypeScript SDK Examples​

DLMM SDK Examples​

Advanced Examples​

Rust SDK Examples​

💡 Tips for Interactive Development​

  1. Start with DevNet: All examples default to safe test environments
  2. Use Mock Data: Examples include realistic mock responses for faster development
  3. Test Incrementally: Build features step-by-step using our modular examples
  4. Monitor Performance: Use built-in timing utilities to optimize your code

🛟 Need Help?​


Ready to build? Start with our Getting Started Guide or jump straight into the API Explorer.