Introduction
Welcome to the Lavarage API — Solana leveraged trading, programmable.
Welcome to the Lavarage API — the fastest way to build leveraged trading into any Solana application.
What is Lavarage?
Lavarage is a decentralized leveraged trading protocol on Solana. Users deposit collateral, pick a leverage multiplier (up to 100x on supported pools), and the protocol borrows additional tokens from liquidity providers to open a leveraged position — all settled on-chain.
The API at api.lavarage.xyz lets you do everything the Lavarage frontend can do, programmatically:
- Browse pools — discover available markets, leverage limits, and liquidity
- Open positions — build transactions for leveraged longs and shorts
- Close & manage — close, split, merge, partially sell, or repay positions
- Automate — set take-profit and stop-loss orders that execute server-side
- Export — download trade history as CSV
Base URL
https://api.lavarage.xyz
All API endpoints are prefixed with /api/v1/ except the health check at /health.
Authentication
Most endpoints require an x-api-key header:
curl https://api.lavarage.xyz/api/v1/positions \
-H "x-api-key: your-api-key-here"Public endpoints (offers, tokens, health) don't require a key.
Rate Limits
| Bucket | Limit |
|---|---|
| Global | 100 requests / 60s per IP |
| Public endpoints (offers, tokens) | 30 requests / 60s per IP |
How Positions Work
- Quote — call
/positions/quoteto preview the swap and entry price - Open — call
/positions/opento get an unsigned Solana transaction - Sign & Submit — sign the transaction with the user's wallet and submit to the network
- Monitor — query
/positionsto track PnL, set TP/SL orders - Close — call
/positions/closeto build the close transaction
All transactions are returned as bs58-encoded VersionedTransaction objects. Your client signs them and submits to the Solana network.
Collateral Units
All amounts are in smallest token units (lamports for SOL, 1e6 for USDC, etc.). Convert to/from human-readable amounts using the token's decimals field:
human_amount = raw_amount / (10 ^ decimals)
raw_amount = human_amount * (10 ^ decimals)
Long vs Short
| Long | Short | |
|---|---|---|
| Collateral | Volatile token (e.g. SOL) | Stable token (e.g. USDC) |
| Borrows | Stable token | Volatile token |
| Profits when | Price goes up | Price goes down |
Next Steps
- Quick Start — open your first position in 5 minutes
- API Reference — full endpoint documentation
- Code Examples — TypeScript, Python, and cURL
Updated 4 days ago