Skip to main content
Interact with Ranger Protocol to execute perpetual trading operations on Solana. Ranger provides a Smart Order Router (SOR) API that allows users to open, close, increase, and decrease positions across various venues like Flash, Jupiter, Drift, and Adrena.

Usage

Methods

openPerpTrade

Open a new perpetual trading position using Ranger SOR API.

Parameters

Example

closePerpTrade

Close an existing perpetual trading position.

Parameters

Example

increasePerpPosition

Increase the size of an existing perpetual position.

Parameters

Example

decreasePerpPosition

Decrease the size of an existing perpetual position.

Parameters

Example

withdrawBalance

Withdraw available balance from Ranger.

Parameters

Example

withdrawCollateral

Withdraw collateral from an existing position.

Parameters

Example

Example Implementation

Implementation Details

  • Smart Order Router (SOR): Ranger’s SOR optimizes trade execution across multiple venues.
  • Multiple Venues: Supports trading across various platforms including Flash, Jupiter, Drift, and Adrena.
  • Position Management: Complete toolkit for opening, closing, increasing, and decreasing perpetual positions.
  • Collateral Management: Functions for adding and withdrawing collateral from positions.
  • Data Access: Comprehensive data access for positions, quotes, trade history, and market metrics.

About Ranger Protocol

Ranger is a protocol designed to provide optimized perpetual trading on Solana. It offers a Smart Order Router (SOR) that routes orders across various trading venues to achieve the best execution. Key features include:
  1. Cross-venue execution: Trade across multiple venues with a single API
  2. Capital efficiency: Optimize collateral usage across positions
  3. Low slippage: Smart routing to minimize price impact
  4. Advanced position management: Sophisticated tools for managing perpetual positions
  5. Rich market data: Access to funding rates, liquidation data, and other market metrics

Error Handling

Best Practices

  1. API Key Management
    • Securely store and manage your Ranger API key
    • Never expose your API key in client-side code
    • Implement proper scoping and permissions for API keys
  2. Position Sizing
    • Use appropriate position sizes relative to your capital
    • Consider market volatility when determining leverage
    • Monitor positions regularly to manage risk
  3. Collateral Management
    • Maintain sufficient collateral to avoid liquidations
    • Use the withdrawCollateral function judiciously
    • Monitor health factors for positions
  4. Error Handling
    • Implement robust error handling for all API calls
    • Include retry logic for temporary failures
    • Monitor transaction status until confirmed

Common Market Symbols

  • SOL-PERP
  • BTC-PERP
  • ETH-PERP
  • BONK-PERP
  • JTO-PERP

Response Format

  • getBalance: Check token balances
  • getFundingRateArbs: Get funding rate arbitrage opportunities
  • getLiquidationsLatest: Get the latest liquidation events
  • getFundingRatesAccumulated: Get accumulated funding rates
  • getBorrowRatesAccumulated: Get accumulated borrow rates