Perp Isolated

Cash-in trade

POST/perp/isolated/trade/cash-inPrivate

Move amount sats from a running trade to your balance. Funds are first taken from the trade's P&L (if any), valued at the Mark price, then from its margin. Cashing in increases the trade's leverage, so the whole margin isn't available since leverage is bounded. Returns the updated trade.

Permissions: futures:isolated:write

Request Body

application/json
  1. body
id*string

Trade ID

Match^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
Formatuuid
amount*integer

Amount of margin to remove

Range0 < value
instrument*string

Instrument of the market

Value in"inverse_perp""quanto_perp"
pair*string

Pair of the market

Response Body

OK

application/json
  1. response

A running trade

id*string

Internal trade ID

Match^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
Formatuuid
instrument*string

Instrument of the market

Value in"inverse_perp""quanto_perp"
pair*string

Pair of the market

type*string

Trade type

Value in"market""limit"
side*string

Trade side

Value in"buy""sell"
openingFee*integer

Fee paid when opening the position

closingFee*integer

Fee for closing the position (0 while running)

maintenanceMargin*integer

Minimum margin required to keep the position open

quantity*number

Number of contracts in the trade

entryNotionalUsd*number

Notional value at entry (in USD)

exitNotionalUsd*|

Notional value at exit (in USD), null until the trade is closed

margin*integer

Current margin for the position

leverage*number

Leverage multiplier applied to the position

price*number

Price when the trade was filled (in USD)

liquidation*number

Price at which the position will be liquidated (in USD)

stoploss*number

Stop loss price level (0 if not set, in USD)

takeprofit*number

Take profit price level (0 if not set, in USD)

stoplossTrailingDistance*number

Trailing stop distance as a fraction of price (0 if not trailing)

exitPrice*|

Price when exiting the position (0 while running, in USD)

pl*integer

Unrealized profit and loss of the running position, valued at the Mark price

createdAt*string

Timestamp when the trade was created

Formatdate-time
filledAt*string

Timestamp when the trade was filled in the market

Formatdate-time
closedAt*null

Timestamp when the trade was closed (null while running)

entryPrice*number

Price when entering the position (in USD)

entryMargin*integer

Initial margin when entering the position

entryBtcPrice*number

Bitcoin price the sats amounts of the trade are valued at (in USD)

open*boolean

Whether the trade is open (not yet filled)

running*boolean

Whether the trade is running (filled but not closed)

canceled*boolean

Whether the trade was canceled before being filled

closed*boolean

Whether the trade is closed (position exited)

sumFundingFees*integer

Total funding fees accumulated for the position

sumQuantoAdjustmentFees*integer

Total quanto adjustment fees accumulated for the position

sumCashInPl*integer

Total amount cashed in from PL over the trade lifetime

sumCashInMargin*integer

Total amount cashed in from margin over the trade lifetime

clientId*|

Optional custom data field (max 64 characters)

label*|

Optional free label (max 64 characters) to group or tag trades, e.g. by strategy. Not unique.

Defaultnull
import { createHttpClient } from '@ln-markets/sdk/rest/v3'

const client = createHttpClient({
  key: 'your-key',
  secret: 'your-secret',
  passphrase: 'your-passphrase',
})

const result = await client.perp.isolated.cashIn({
  id: 'd0b9f9a0-4f6e-4a5a-8b7a-7f0f5f9a8a1e',
  amount: 100,
  instrument: 'inverse_perp',
  pair: 'btc_usd'
})
{
  "id": "d0b9f9a0-4f6e-4a5a-8b7a-7f0f5f9a8a1e",
  "instrument": "inverse_perp",
  "pair": "btc_usd",
  "type": "market",
  "side": "buy",
  "openingFee": 10,
  "closingFee": 0,
  "maintenanceMargin": 1000,
  "quantity": 100,
  "entryNotionalUsd": 100,
  "exitNotionalUsd": null,
  "margin": 1000,
  "leverage": 10,
  "price": 20000,
  "liquidation": 18000,
  "stoploss": 10,
  "takeprofit": 10,
  "stoplossTrailingDistance": 0,
  "exitPrice": 0,
  "pl": 2,
  "createdAt": "2025-09-01T15:04:21.129Z",
  "filledAt": "2025-09-01T15:04:21.129Z",
  "closedAt": null,
  "entryPrice": 20000,
  "entryMargin": 1000,
  "entryBtcPrice": 100000,
  "open": false,
  "running": true,
  "canceled": false,
  "closed": false,
  "sumFundingFees": 10,
  "sumQuantoAdjustmentFees": 0,
  "sumCashInPl": 0,
  "sumCashInMargin": 0,
  "clientId": "test-client-id-123",
  "label": "strategy-a"
}