> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update leverage | Hyperliquid exchange

> Updates the leverage setting for a specific coin on the Hyperliquid exchange. You can adjust leverage for both cross and isolated margin modes.

<Info>
  You can only use this endpoint on the official Hyperliquid public API. It is not available through Chainstack, as the open-source node implementation does not support it yet. See [Hyperliquid methods](/docs/hyperliquid-methods) for the full availability breakdown.
</Info>

<Note>
  This endpoint requires signature authentication. See our comprehensive [Authentication via Signatures guide](/docs/hyperliquid-authentication-guide) for implementation details.
</Note>

Updates the leverage setting for a specific coin on the Hyperliquid exchange. You can adjust leverage for both cross and isolated margin modes.

## Parameters

### Required parameters

* `action` (object, required) — The update leverage action object containing:
  * `type` (string) — Must be `"updateLeverage"`
  * `asset` (number) — Asset index of the coin
  * `isCross` (boolean) — `true` for cross leverage, `false` for isolated leverage
  * `leverage` (number) — New leverage value (must be within allowed range for the asset)

* `nonce` (number, required) — Current timestamp in milliseconds (must be recent)

* `signature` (object, required) — EIP-712 signature of the action

### Optional parameters

* `vaultAddress` (string, optional) — Address when trading on behalf of a vault or subaccount
* `expiresAfter` (number, optional) — Timestamp in milliseconds after which the request is rejected

## Leverage constraints

Each asset has specific leverage constraints:

* **Minimum leverage** — Usually 1x
* **Maximum leverage** — Varies by asset (3x to 40x depending on liquidity and volatility)
* **Cross margin** — Shares margin across all positions
* **Isolated margin** — Margin isolated to specific position

## Returns

Returns an object with update status:

* `status` — `"ok"` if successful
* `response` — Contains update details:
  * `type` — `"default"`

## Example request

<CodeGroup>
  ```shell cURL theme={"system"}
  curl -X POST https://api.hyperliquid.xyz/exchange \
    -H "Content-Type: application/json" \
    -d '{
      "action": {
        "type": "updateLeverage",
        "asset": 0,
        "isCross": true,
        "leverage": 10
      },
      "nonce": 1234567890123,
      "signature": {...}
    }'
  ```

  ```python Python (hyperliquid-python-sdk) theme={"system"}
  from hyperliquid.exchange import Exchange
  from hyperliquid.utils import constants
  import eth_account

  # Initialize with your private key
  account = eth_account.Account.from_key("0x...")
  exchange = Exchange(account, constants.MAINNET_API_URL)

  # Update cross leverage for BTC to 10x
  update_result = exchange.update_leverage(
      leverage=10,
      name="BTC",
      is_cross=True,
  )

  # Update isolated leverage for ETH to 5x
  update_isolated = exchange.update_leverage(
      leverage=5,
      name="ETH",
      is_cross=False,
  )

  print(update_result)
  ```

  ```typescript TypeScript (@nktkas/hyperliquid) theme={"system"}
  import { ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
  import { privateKeyToAccount } from "viem/accounts";

  // Initialize with your private key
  const wallet = privateKeyToAccount("0x...");
  const transport = new HttpTransport();
  const exchange = new ExchangeClient({ transport, wallet });

  // Update cross leverage for asset 0 (BTC) to 10x
  const updateResult = await exchange.updateLeverage({
    asset: 0,
    isCross: true,
    leverage: 10,
  });

  // Update isolated leverage for asset 1 (ETH) to 5x
  const updateIsolated = await exchange.updateLeverage({
    asset: 1,
    isCross: false,
    leverage: 5,
  });

  console.log(updateResult);
  ```
</CodeGroup>

## Response example

```json theme={"system"}
{
  "status": "ok",
  "response": {
    "type": "default"
  }
}
```

## Important considerations

* **Existing positions** — Leverage changes affect margin requirements for existing positions
* **Liquidation risk** — Increasing leverage increases liquidation risk
* **Available margin** — Ensure sufficient margin before increasing leverage
* **Asset limits** — Each asset has different maximum leverage limits

## Use cases

* **Risk adjustment** — Dynamically adjust risk based on market conditions
* **Capital efficiency** — Optimize margin usage across positions
* **Strategy implementation** — Set appropriate leverage for different trading strategies
* **Position management** — Adjust leverage before opening new positions

<Note>
  Leverage is only checked when opening a position. After opening, monitor your positions to avoid liquidation as leverage effectively changes with unrealized PnL.
</Note>

<Warning>
  Increasing leverage on existing positions increases liquidation risk. Always ensure you have sufficient margin to support the new leverage level.
</Warning>


## OpenAPI

````yaml openapi/hyperliquid_node_api/hypercore_exchange/exchange_update_leverage.json post /exchange
openapi: 3.0.0
info:
  title: Hyperliquid Exchange API
  version: 1.0.0
  description: >-
    API for trading operations on Hyperliquid exchange requiring authentication.
    ⚠️ WARNING: These endpoints require EIP-712 signatures for authentication.
    The example values provided will NOT work without proper cryptographic
    signing. You must implement EIP-712 signing to use these endpoints
    successfully.
servers:
  - url: https://api.hyperliquid.xyz
security: []
paths:
  /exchange:
    post:
      tags:
        - hyperliquid exchange
      summary: Update leverage
      operationId: updateLeverage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: object
                  properties:
                    type:
                      type: string
                      default: updateLeverage
                      enum:
                        - updateLeverage
                      description: Action type for updating leverage
                    asset:
                      type: integer
                      description: Asset index to update leverage for
                    isCross:
                      type: boolean
                      description: >-
                        Whether to use cross margin (true) or isolated margin
                        (false)
                    leverage:
                      type: integer
                      description: >-
                        Leverage value (1-50 for isolated margin, 1-20 for cross
                        margin)
                  required:
                    - type
                    - asset
                    - isCross
                    - leverage
                nonce:
                  type: integer
                  description: Current timestamp in milliseconds
                signature:
                  type: object
                  description: EIP-712 signature of the action with r, s, v components
                  properties:
                    r:
                      type: string
                      description: ECDSA signature r component (hex string)
                      example: >-
                        0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
                    s:
                      type: string
                      description: ECDSA signature s component (hex string)
                      example: >-
                        0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321
                    v:
                      type: integer
                      description: ECDSA recovery id (27 or 28)
                      example: 27
                  required:
                    - r
                    - s
                    - v
                vaultAddress:
                  type: string
                  description: >-
                    Address when trading on behalf of a vault or subaccount
                    (optional)
                  nullable: true
              required:
                - action
                - nonce
                - signature
            example:
              action:
                type: updateLeverage
                asset: 0
                isCross: false
                leverage: 10
              nonce: 1705234567890
              signature:
                r: >-
                  0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
                s: >-
                  0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321
                v: 27
              vaultAddress: null
      responses:
        '200':
          description: Leverage update result
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Request status
                  response:
                    type: object
                    properties:
                      type:
                        type: string
                      data:
                        type: object
                        properties:
                          status:
                            type: string
                            description: Result status
                example:
                  status: ok
                  response:
                    type: updateLeverage
                    data:
                      status: success

````