Skip to content

Conversation

gambinish
Copy link
Contributor

@gambinish gambinish commented Sep 29, 2025

Description

Hyperliquid contracts have limitations on the amount of margin for each token

Contract specs: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/contract-specifications

Market orders:

$15,000,000 for max leverage >= 25

$5,000,000 for max leverage in [20, 25)

$2,000,000 for max leverage in [10, 20)

otherwise $500,000

Limit orders:

10 * maximum market order value

Changelog

CHANGELOG entry: Add max order error messaging

Related issues

Fixes:

Manual testing steps

Best way to test this is by manually hardcoding available balance in hyperLiquidAdapter to 100000000 and then attempting to submit an order with max leverages that fit the above constraints. Not all perps have max 40x leverage. So you'll need to go through various perps to catch all cases.

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Screenshot 2025-09-29 at 2 23 42 PM

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Adds leverage-based max order value checks for HyperLiquid orders, with new constants, validation logic, tests, and localized error messaging.

  • Perps Validation:
    • Add getMaxOrderValue(maxLeverage, orderType) in utils/hyperLiquidValidation.ts to compute order value caps (limit = 10× market cap).
    • Integrate max order value check in HyperLiquidProvider.validateOrder using getMaxOrderValue and formatPerpsFiat.
  • Constants:
    • Introduce HYPERLIQUID_ORDER_LIMITS in constants/perpsConfig.ts (market caps by leverage tier; limit multiplier = 10).
  • i18n:
    • Add perps.order.validation.max_order_value string in en.json.
  • Tests:
    • Expand hyperLiquidValidation.test.ts with comprehensive cases for getMaxOrderValue across leverage tiers, order types, and edge conditions.

Written by Cursor Bugbot for commit 33d4511. This will update automatically on new commits. Configure here.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@gambinish gambinish changed the title Perps/tat 1627 max order error msg feat: Perps max order error messaging Sep 29, 2025
@gambinish gambinish marked this pull request as ready for review September 29, 2025 22:13
@gambinish gambinish requested a review from a team as a code owner September 29, 2025 22:13
cursor[bot]

This comment was marked as outdated.

@github-actions github-actions bot added size-M and removed size-S labels Sep 30, 2025
Copy link

@gambinish gambinish added this pull request to the merge queue Oct 1, 2025
Merged via the queue into main with commit 4b26130 Oct 1, 2025
106 of 112 checks passed
@gambinish gambinish deleted the perps/tat-1627-max-order-error-msg branch October 1, 2025 15:12
@github-actions github-actions bot locked and limited conversation to collaborators Oct 1, 2025
@metamaskbot metamaskbot added the release-7.57.0 Issue or pull request that will be included in release 7.57.0 label Oct 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.57.0 Issue or pull request that will be included in release 7.57.0 size-M team-assets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants