Token-Pair Endpoints

Open positions by token mint address — no offer lookup needed.

Overview

The token-pair endpoints accept a baseTokenMint instead of an explicit offerPublicKey. The server automatically selects the best matching liquidity pool (offer) — you never need to query offers directly.

For new integrations, always use these endpoints. The offerPublicKey endpoints (POST /positions/open) exist for advanced use cases but require you to discover and manage offer addresses manually.

POST /api/v1/positions/quote-by-token

Get a price preview without building a transaction. Use this to display expected entry price, slippage, and fees before asking the user to confirm.

Request:

{
  "baseTokenMint": "So11111111111111111111111111111111111111112",
  "userPublicKey": "GsbwXfJraMomNxBcjK7xK2xQx5MQgQx4Ld8QkLeNmA3v",
  "collateralAmount": "1000000000",
  "leverage": 3,
  "side": "LONG",
  "quoteTokenMint": "So11111111111111111111111111111111111111112",
  "slippageBps": 50
}
FieldTypeRequiredDescription
baseTokenMintstringYesToken mint you want to go long/short on (base58)
userPublicKeystringYesUser's wallet address (base58)
collateralAmountstringYesCollateral in the quote token's smallest units (lamports for SOL)
leveragenumberYesMultiplier between 1.1 and 100
sidestringYes"LONG" or "SHORT"
quoteTokenMintstringNoQuote token (default: WSOL for LONG, USDC for SHORT)
slippageBpsnumberNoSlippage tolerance in bps (default: 50, max: 1000)

Response: Returns a SwapQuote object:

{
  "inAmount": "1000000000",
  "outAmount": "2950000000",
  "priceImpactPct": "0.12",
  "otherAmountThreshold": "2920500000",
  "inputMint": "So11111111111111111111111111111111111111112",
  "outputMint": "So11111111111111111111111111111111111111112",
  "slippageBps": 50
}

POST /api/v1/positions/open-by-token

Build an unsigned Solana transaction to open a leveraged position. Takes the same request shape as quote-by-token.

Request: Identical to quote-by-token above.

Response:

{
  "transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAkP...",
  "positionAddress": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
  "lastValidBlockHeight": 285432100,
  "quote": { "outAmount": "9950000000", "priceImpactPct": 0.12, "slippageBps": 50 }
}

Deserialise with VersionedTransaction.deserialize(bs58.decode(response.transaction)), sign with the user's wallet, and submit.

How Offer Matching Works

When you call open-by-token, the server:

  1. Queries active offers for the requested token pair and side
  2. Filters by available liquidity (must cover collateralAmount × (leverage - 1))
  3. Sorts by best terms (highest leverage limit, lowest utilization)
  4. Selects the top offer and builds the transaction against it

If no matching offer exists, the server returns 404 NO_OFFER_FOR_TOKEN.

Supported Sides

SideCollateral TokenWhat Happens
LONGWSOL (default) or USDCProtocol borrows SOL/USDC, swaps into the target token. Profit when price rises.
SHORTUSDCProtocol borrows the volatile token, swaps to USDC. Profit when price falls.

Short position support is currently in beta. Contact [email protected] for access.