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

updateLeverage

Sets the leverage the account uses for one instrument.

POST/exchangetype updateLeverage

Set leverage for one instrument (requires no open orders in scope).Agent-signed

Action fields
assetinteger · uint32required

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

leverageinteger · int32required

Target leverage. Must be positive in one-way mode; in hedge mode with isolated margin the sign selects which side is affected.

typestringrequired

Must be `updateLeverage`.

"updateLeverage"
marginModestringoptional

Defaults to the instrument's current mode.

"cross""isolated"
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": "updateLeverage",
    "asset": 1,
    "leverage": 20,
    "marginMode": "cross"
  },
  "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 · UpdateLeverage 200
codeinteger

`0` on success.

dataobject
dataobject
typestring

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

"UpdateLeverage"
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": "UpdateLeverage",
    "data": {
      "statuses": [
        "success"
      ]
    }
  }
}

Preconditions

The action is rejected while the scope it touches still has working orders:

ErrorCause
Cannot update leverage while you have open ordersNon-TWAP orders exist for that instrument and margin mode
Cannot update leverage while you have TPSL ordersTake-profit / stop-loss orders exist in scope
Cannot update leverage while you have trigger ordersTrigger orders exist in scope
Maximum leverage exceeded for <instrument>Above the margin tier's cap for the current position size
Margin tier not foundNo margin tier is configured for the instrument

With no open position, the cap is the first margin tier's maximum; with a position, it is the tier matching that position's size. Cancel the orders in scope first, then retry.

Next steps

Read the applied leverage back from clearinghouseState or activeAssetData.