Position Partial Sell

This allows users to sell a portion of their leveraged position while keeping the rest active.

How It Works:

The partial sell feature uses two API endpoints, which can be bundled together using Jito on the front-end:

  1. Split Position - Divides a position into two separate positions

  2. Sell Manual Build - Sells one of the split positions

API Endpoints:

1. Split Position

POST /positions/split

Request Body:

{
"positionId": string,        // Position address to split
"userPubKey": string,        // User's wallet public key
"splitRatioBps": number,     // Split ratio in basis points (2500 = 25%)
"quoteToken": string         // Quote token mint address
}

Example Request:

{
  "positionId": "AezAHf5e6Cfiyyvu35KkWKEuZKLsEAN4XWzA36NvvCBw",
  "userPubKey": "CL7LTBpFgEcMrDkTfQpet9VvsGJas1iTxRJ6m1tXrTA9",
  "splitRatioBps": 2500,
  "quoteToken": "So11111111111111111111111111111111111111112"
}

Response:

Example Response:

2. Sell Manual Build

POST /positions/sell-manual-build

Request Body:

Example Request Body:

Response:

Implementation Steps:

  1. Get Split Transaction & Position Data

    • Call /positions/split with desired split ratio (in basis points)

    • Receive the transaction and new position details

  2. Get Sell Transaction

    • Use the newPosition1 data from split response

    • Call /positions/sell-manual-build with the position details

  3. Bundle with Jito

    • Get latest blockhash

    • Deserialize both transactions

    • Add Jito tip transaction (recommended: use 1.5x of 99th percentile tip floor)

    • Sign all three transactions

    • Submit bundle to Jito

Jito Bundle Implementation Example:

Last updated