---
updatedAt: 2026-03-26T17:10:47.000Z
agentTools:
  projectIndex: https://lavarage-api.readme.io/llms.txt
---

# 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:

```bash
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

1. **Quote** — call `/positions/quote` to preview the swap and entry price
2. **Open** — call `/positions/open` to get an unsigned Solana transaction
3. **Sign & Submit** — sign the transaction with the user's wallet and submit to the network
4. **Monitor** — query `/positions` to track PnL, set TP/SL orders
5. **Close** — call `/positions/close` to build the close transaction

Position endpoints return **base58-encoded VersionedTransaction** objects. Sign them and submit to Solana. Note: `/swap/transaction` returns base64, and bundle submission (`/bundle/submit`, `/bundle`) expects base64.

## 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](https://lavarage-api.readme.io/docs/quick-start) — open your first position in 5 minutes
* [API Reference](/reference) — full endpoint documentation
* [Code Examples](https://lavarage-api.readme.io/docs/code-examples) — TypeScript, Python, and cURL