Advanced Operations

Split, merge, partial sell, and repay operations.

Advanced Position Management

Beyond opening and closing, Lavarage supports several advanced operations for sophisticated trading strategies.

Split Position

Split one position into two at a given ratio. Useful for staged exits.

curl -X POST https://api.lavarage.xyz/api/v1/positions/split \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "positionAddress": "YOUR_POSITION",
    "userPublicKey": "YOUR_WALLET",
    "splitRatioBps": 5000
  }'

splitRatioBps: 5000 = 50/50 split. Use 3000 for a 30/70 split, etc.

Partial Sell (Split + Close)

Take partial profits atomically in a single Jito bundle:

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

This splits off 30% of the position and immediately closes it. The remaining 70% stays open.

Full Repay (No Swap)

Close a position by repaying the borrow directly, without swapping position tokens. Useful if you already hold the required quote token:

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

Partial Repay

Reduce your borrow (and risk) without fully closing:

curl -X POST https://api.lavarage.xyz/api/v1/positions/partial-repay \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "positionAddress": "YOUR_POSITION",
    "userPublicKey": "YOUR_WALLET",
    "repaymentBps": 5000
  }'

repaymentBps: 5000 = repay 50% of the outstanding borrow.