Skip to content

docs(perps): explain Lighter API key slots for local setup - #36980

Merged
abretonc7s merged 1 commit into
mainfrom
docs/perps-lighter-api-keys
Sep 30, 2026
Merged

abretonc7s merged 1 commit into
mainfrom
docs/perps-lighter-api-keys

Conversation

@abretonc7s

@abretonc7s abretonc7s commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Lighter orders are signed by a trading key (Lighter's "API key") that the embedded signer registers in a numbered slot of the account, with one personal_sign from the wallet. A key only works on the device that created it, so simulators, devices and scripts sharing an account need different slots. When the configured slot already holds another device's key, the app stops with "Lighter API key slot N already contains a different key", which is hard to understand without context.

This adds docs/perps/lighter-api-keys.md (what a slot is, local setup, how to check a free slot, the error and its fix, testnet resets) and points the MM_PERPS_LIGHTER_API_KEY_INDEX comment in .js.env.example to it. The perps-controller README gets the same explanation in MetaMask/core#10559.

Changelog

CHANGELOG entry: null

Related issues

Refs: MetaMask/core#10559

Manual testing steps

N/A: documentation only. The fix it describes was checked on an iOS simulator against Lighter testnet: with the configured slot held by another device's key the app stopped with the error above, and with MM_PERPS_LIGHTER_API_KEY_INDEX set to a free slot the app registered its own key there.

Screenshots/Recordings

N/A: documentation only.

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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

Low Risk
Documentation and env example comments only; no runtime or security logic changes.

Overview
Adds docs/perps/lighter-api-keys.md so developers understand Lighter trading key slots: how signing works vs the wallet, local env setup (MM_PERPS_LIGHTER_PROVIDER_ENABLED, MM_PERPS_LIGHTER_API_KEY_INDEX, account index), one slot per device/simulator/script, curl checks for free slots, what to do when "Lighter API key slot N already contains a different key" appears, and account index behavior after testnet resets.

Updates the MM_PERPS_LIGHTER_API_KEY_INDEX comment in .js.env.example to call it a Lighter trading key slot, note the controller default (7), and link to the new doc.

Reviewed by Cursor Bugbot for commit ec3ad2a. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown
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.

@abretonc7s
abretonc7s marked this pull request as ready for review September 29, 2026 09:38
@abretonc7s
abretonc7s requested a review from a team as a code owner September 29, 2026 09:38
@metamask-ci metamask-ci Bot added the team-perps Perps team label Sep 29, 2026
@metamask-ci

metamask-ci Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@github-actions github-actions Bot added the risk:low AI analysis: low risk label Sep 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Smart E2E Test Selection

AI Confidence: 98

E2E reasoning

Expand to read

This PR contains only two files, both of which are documentation/comment-only changes with zero functional impact on the app:

  1. .js.env.example — A comment clarification for the MM_PERPS_LIGHTER_API_KEY_INDEX environment variable. The comment was expanded to mention the default value (7) and link to the new docs file. This is a comment-only change in an example env file — it is cosmetic per the COSMETIC CHANGES rule and has no runtime effect. Grep searches confirmed this env var is not referenced in any app source, test, or CI files in a way that would be affected by this comment change.

  2. docs/perps/lighter-api-keys.md — A new developer documentation file (38 lines) explaining Lighter API key slot management for local development. It contains no app code, no test code, no configuration that affects runtime behavior. find_related_files confirmed no files import or reference this doc. It is purely a developer guide.

No app source code, test infrastructure, controllers, hooks, components, navigation, or CI workflows were modified. No E2E smoke tests or performance tests are warranted.

Performance reasoning

Expand to read

No app code was changed. Both files are documentation/comment-only. The .js.env.example change is a comment clarification (cosmetic). The docs/perps/lighter-api-keys.md is a new developer documentation file. Neither affects any runtime behavior, rendering path, or performance scenario.

View run

@sonarqubecloud

Copy link
Copy Markdown

@abretonc7s
abretonc7s added this pull request to the merge queue Sep 30, 2026
Merged via the queue into main with commit 5a9145a Sep 30, 2026
102 checks passed
@abretonc7s
abretonc7s deleted the docs/perps-lighter-api-keys branch September 30, 2026 09:45
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 30, 2026
@metamask-ci metamask-ci Bot added the release-8.15.0 Issue or pull request that will be included in release 8.15.0 label Sep 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.15.0 Issue or pull request that will be included in release 8.15.0 risk:low AI analysis: low risk size-XS team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants