Parfournir.
Skills/sendaifun/Ranger Finance

Ranger Finance

Ranger Finance SDK for building perpetual futures trading applications on Solana.

sdk
by @sendaifun
SKILL.md

Ranger Finance SDK Development Guide

A comprehensive guide for building Solana applications with Ranger Finance - the first perpetual futures aggregator on Solana.

Overview

Ranger Finance is a Smart Order Router (SOR) that aggregates perpetual futures trading across multiple Solana protocols:

  • Drift Protocol: Leading perps DEX on Solana
  • Flash Trade: High-performance perpetuals
  • Adrena: Leverage trading protocol
  • Jupiter Perps: Jupiter's perpetuals platform
  • Key Benefits

  • Best Execution: Automatically routes orders to venues with best pricing
  • Unified API: Single interface for all supported perp protocols
  • Position Aggregation: View and manage positions across all venues
  • AI Agent Support: Built-in MCP server for AI trading agents
  • Quick Start

    Installation (TypeScript)

    # Clone the SDK demo
    git clone https://github.com/ranger-finance/sor-ts-demo.git
    cd sor-ts-demo
    npm install

    Environment Setup

    Create a .env file:

    RANGER_API_KEY=your_api_key_here
    SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
    WALLET_PRIVATE_KEY=your_base58_private_key # Optional, for signing

    Basic Setup

    import { SorApi, TradeSide } from 'ranger-sor-sdk';
    import dotenv from 'dotenv';

    dotenv.config();

    // Initialize the SOR API client
    const sorApi = new SorApi({
    apiKey: process.env.RANGER_API_KEY!,
    solanaRpcUrl: process.env.SOLANA_RPC_URL,
    });

    // Your wallet public key
    const walletAddress = 'YOUR_WALLET_PUBLIC_KEY';

    Core Concepts

    1. Trade Sides

    type TradeSide = 'Long' | 'Short';
    

    2. Adjustment Types

    ```typescript
    type AdjustmentType =
    | 'Quote' // Get a quote only
    | 'Increase' // Open or increase position
    | 'DecreaseFlash' // Decrease via Flash
    | 'DecreaseJupiter' // Decrease via Jupiter
    | 'DecreaseDrift' // Decrease via Drift
    | 'DecreaseAdrena' // Decrease via Adrena
    | 'CloseFlash' // Close via Flash

    Details

    Categoryblockchain
    Typesdk
    Sourcegithub

    Runtime Requirements

    Environment variablesRANGER_API_KEYSOLANA_RPC_URLWALLET_PRIVATE_KEYYOUR_WALLET_PUBLIC_KEY

    Use this skill

    Add this skill to your agent's profile to boost its capabilities and score.

    Add to My Agent