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

# Ensure 1x cross leverage

> Check leverage and prepare an updateLeverage action if not 1x cross.

If the asset is already at 1x cross leverage, returns leverage_ok=true
with null typed_data — no signing needed. Otherwise, returns EIP-712
typed data for the user to sign. After signing, submit the signature
via the /execute endpoint.



## OpenAPI

````yaml /v2/combined_spec.json post /v2/global_markets_perps/ensure_leverage
openapi: 3.1.0
info:
  title: Compass API
  description: Compass Labs DeFi API
  version: 0.0.1
servers:
  - url: https://api.compasslabs.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v2/global_markets_perps/ensure_leverage:
    post:
      tags:
        - Global Markets Perps
      summary: Ensure 1x cross leverage
      description: |-
        Check leverage and prepare an updateLeverage action if not 1x cross.

        If the asset is already at 1x cross leverage, returns leverage_ok=true
        with null typed_data — no signing needed. Otherwise, returns EIP-712
        typed data for the user to sign. After signing, submit the signature
        via the /execute endpoint.
      operationId: v2_global_markets_perps_ensure_leverage
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GlobalMarketsPerpsEnsureLeverageRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GlobalMarketsPerpsEnsureLeverageResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            from compass_api_sdk import CompassAPI


            with CompassAPI(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as compass_api:

                res = compass_api.global_markets_perps.global_markets_perps_ensure_leverage(owner="<value>", asset="<value>")

                # Handle response
                print(res)
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { CompassApiSDK } from "@compass-labs/api-sdk";

            const compassApiSDK = new CompassApiSDK({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await compassApiSDK.globalMarketsPerps.globalMarketsPerpsEnsureLeverage({
                owner: "<value>",
                asset: "<value>",
              });

              console.log(result);
            }

            run();
components:
  schemas:
    GlobalMarketsPerpsEnsureLeverageRequest:
      properties:
        owner:
          type: string
          title: Owner
          description: User's EOA address
        asset:
          type: string
          title: Asset
          description: Asset ticker (e.g. 'AAPL', 'CL')
      type: object
      required:
        - owner
        - asset
      title: GlobalMarketsPerpsEnsureLeverageRequest
      description: >-
        Request to check and set leverage to 1x cross on a global markets perps
        asset.
    GlobalMarketsPerpsEnsureLeverageResponse:
      properties:
        leverage_ok:
          type: boolean
          title: Leverage Ok
          description: True if leverage is already 1x cross, false if update needed
        typed_data:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Typed Data
          description: EIP-712 typed data for wallet signing, or null if already 1x cross
        action:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Action
          description: >-
            Raw Hyperliquid action (passed back to the execute endpoint), or
            null
        nonce:
          anyOf:
            - type: integer
            - type: 'null'
          title: Nonce
          description: Timestamp-based nonce, or null if no action needed
      type: object
      required:
        - leverage_ok
      title: GlobalMarketsPerpsEnsureLeverageResponse
      description: >-
        Returned by the ensure_leverage endpoint.


        If the asset is already at 1x cross leverage, typed_data/action/nonce
        are null.

        If not (or no position exists), they contain the EIP-712 payload the
        user must sign.
      example:
        action:
          asset: 12
          isCross: true
          leverage: 1
          type: updateLeverage
        leverage_ok: false
        nonce: 1747010983250
        typed_data:
          domain:
            chainId: 1337
            name: Exchange
            verifyingContract: '0x0000000000000000000000000000000000000000'
            version: '1'
          message:
            connectionId: '0xc4e1f04d6b1bf2f2f7a6c0e8a5f3b1d2c9e0a4b7d1c3e5f7a9b1d3e5f7a9e9a2'
            source: a
          primaryType: Agent
          types:
            Agent:
              - name: source
                type: string
              - name: connectionId
                type: bytes32
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Compass API Key. Get your key
        [here](https://www.compasslabs.ai/dashboard).

````