> For the complete documentation index, see [llms.txt](https://nytshift.gitbook.io/nytshift-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nytshift.gitbook.io/nytshift-docs/hyperliquid/hyperliquid-leverage-update.md).

# Leverage update

## Preconditions

Keep execution disabled unless the independent testnet or mainnet gates in `local-production.md` are deliberately satisfied. Use only the configured signer account and an allowlisted live symbol. Confirm `/api/execution/status` reports fresh portfolio reconciliation, healthy metadata, current execution-store schema 8, SQLite integrity `ok` and journal mode `wal`.

Hyperliquid documents leverage update as its own signed exchange action. NIGHTSHIFT therefore treats it as a capital-setting mutation, not an order-preparation convenience.

## Review

1. Enter an order whose leverage differs from current `activeAssetData`.
2. Verify order preparation returns `HYPERLIQUID_LEVERAGE_UPDATE_REQUIRED`; it must not return an order confirmation ticket.
3. In the leverage dialog, compare network, exact symbol, active leverage, target leverage, unchanged cross/isolated margin mode and venue maximum.
4. Confirm the dialog states `NO ORDER IN THIS STEP`. Cancel if any value is unexpected.

## Confirm and reconcile

1. Confirm once. The BFF re-reads status, metadata and `activeAssetData` before consuming the one-use leverage token.
2. Treat only `applied` as completed. NIGHTSHIFT proves it by reading the target leverage with the same margin mode from `activeAssetData`.
3. If the result is `unknown`, do not confirm again. Refresh authoritative account state and inspect current leverage on Hyperliquid before taking any new action. A timeout or accepted SDK response is not finality.
4. After `applied`, choose `CONTINUE TO FRESH ORDER REVIEW`. Verify the new order review repeats current capacity, fees, portfolio generation and AEGIS policy before it exposes a separate order confirmation.

## Incident checks

* A changed margin mode, changed maximum leverage, expired review or target already active must fail before signer I/O.
* Reusing the same confirmation token must fail.
* A conflicting payload for the same leverage intent must fail in the signer store.
* A pending durable claim after interruption remains unknown and must never be automatically retried.
* Agent automation must continue to reject a leverage mismatch rather than invoke this endpoint.

Record only fixed outcome/reason codes and timestamps. Do not copy account addresses, private keys, confirmation tokens or raw venue responses into tickets or logs.

## Verification commands

```powershell
pnpm contracts:check
pnpm --filter @terminal/web test
pnpm test:py
pnpm test:signer
pnpm handoff:verify
pnpm local:restart
pnpm local:health
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://nytshift.gitbook.io/nytshift-docs/hyperliquid/hyperliquid-leverage-update.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
