Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

updateIsolatedMargin

Adds or removes margin on an existing isolated position.

POST/exchangetype updateIsolatedMargin

Add or remove margin on an existing isolated position.Agent-signed

Action fields
assetinteger · uint32required

Instrument's external id — the `index` value from `perpMeta`; Outcome markets use the `instrument_id`.

isBuybooleanrequired

`true` targets the long position, `false` the short.

ntlistringrequired

Signed USDC amount in integer wei, 6 decimals — positive adds margin, negative removes it. Must be an integer string.

typestringrequired

Must be `updateIsolatedMargin`.

"updateIsolatedMargin"
Request example
curl -X POST https://rpc.txflow-testnet.xyz/exchange \
  -H "Content-Type: application/json" \
  -H "x-api-version: 2026-08-16" \
  -d '{
  "action": {
    "type": "updateIsolatedMargin",
    "asset": 1,
    "isBuy": true,
    "ntli": "1000000000"
  },
  "signature": {
    "r": "0x<r>",
    "s": "0x<s>",
    "v": 27
  },
  "nonce": 1757992743994,
  "vaultAddress": null,
  "signatureChainId": null
}'
Try it
testnet · no account yet
Generates a throwaway key in your browser, claims testnet USDC and authorizes an agent key. The account is kept while you browse the docs and lost on reload.
Response · UpdateIsolatedMargin 200
codeinteger

`0` on success.

dataobject
dataobject
typestring

The action's internal name, which does not always match the request `type`.

"UpdateIsolatedMargin"
statusstring

A rejected request returns `err` with a non-zero `code` and the reason in `message` (or `response`).

"ok"
Response example
{
  "status": "ok",
  "code": 0,
  "data": {
    "type": "UpdateIsolatedMargin",
    "data": {
      "statuses": [
        "success"
      ]
    }
  }
}

ntli must be an integer string: "1000000" is 1 USDC, and "-1000000" removes 1 USDC. A decimal string such as "1.5" is rejected with Invalid ntli value. The example above adds 1,000 USDC.

Preconditions

ErrorCause
Position not foundNo isolated position on the requested instrument and side
Amount must be greater than 0ntli resolves to zero
Margin reduction exceeds the maximum allowable amount for this positionRemoval would drop margin below the position's required initial margin

When removing margin, the removable amount is the position's margin less its required initial margin (entryPrice × size / leverage). Unrealized losses reduce that headroom; unrealized profit does not increase it. Adding margin is additionally bounded by the account's available balance.

Next steps

Read the resulting position margin from clearinghouseState.