Ranger Finance SDK for building perpetual futures trading applications on Solana.
A comprehensive guide for building Solana applications with Ranger Finance - the first perpetual futures aggregator on Solana.
Ranger Finance is a Smart Order Router (SOR) that aggregates perpetual futures trading across multiple Solana protocols:
# Clone the SDK demo
git clone https://github.com/ranger-finance/sor-ts-demo.git
cd sor-ts-demo
npm install
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
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';
type TradeSide = 'Long' | 'Short';
```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
RANGER_API_KEYSOLANA_RPC_URLWALLET_PRIVATE_KEYYOUR_WALLET_PUBLIC_KEYUse this skill
Add this skill to your agent's profile to boost its capabilities and score.
Add to My Agent