Quick Start

Open your first leveraged position in 5 minutes.

Open your first leveraged position in 5 minutes.

Prerequisites

  • A Lavarage API key (contact the team or use the Partners API)
  • A Solana wallet with SOL for collateral and transaction fees
  • Node.js 18+ or any HTTP client

Step 1: Find a Pool

Browse available offers to find a market you want to trade:

curl https://api.lavarage.xyz/api/v1/offers?includeTokens=true&search=SOL&limit=5

Pick an offer and note the publicKey, maxLeverage, and availableForOpen.

Step 2: Get a Quote

Preview the expected entry price:

curl -X POST https://api.lavarage.xyz/api/v1/positions/quote \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "offerPublicKey": "POOL_ADDRESS",
    "userPublicKey": "YOUR_WALLET",
    "collateralAmount": "1000000000",
    "leverage": 3,
    "side": "LONG",
    "slippageBps": 50
  }'

1000000000 lamports = 1 SOL. Adjust collateral based on the token's decimals.

Step 3: Open the Position

curl -X POST https://api.lavarage.xyz/api/v1/positions/open \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "offerPublicKey": "POOL_ADDRESS",
    "userPublicKey": "YOUR_WALLET",
    "collateralAmount": "1000000000",
    "leverage": 3,
    "side": "LONG",
    "slippageBps": 50
  }'

This returns a transaction field — a bs58-encoded VersionedTransaction. Sign and submit it:

import { Connection, VersionedTransaction } from '@solana/web3.js';
import bs58 from 'bs58';

const tx = VersionedTransaction.deserialize(bs58.decode(response.transaction));
tx.sign([yourKeypair]);

const connection = new Connection('https://api.mainnet-beta.solana.com');
const sig = await connection.sendTransaction(tx);
console.log('Position opened:', sig);

Step 4: Monitor Your Position

curl https://api.lavarage.xyz/api/v1/positions?status=OPEN&owner=YOUR_WALLET \
  -H "x-api-key: YOUR_KEY"

Step 5: Close the Position

curl -X POST https://api.lavarage.xyz/api/v1/positions/close \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "positionAddress": "POSITION_ADDRESS",
    "userPublicKey": "YOUR_WALLET",
    "slippageBps": 50
  }'

Sign and submit the returned transaction the same way.

What's Next?