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

# Setup

> Account setup for Lighter deployments with provider-owned signing

Before trading on `lighter` or `lighter-rh`, use the provider metadata and `checkSetup()` flow. The plugin owns the native signing key, encrypted persistence, WASM signer, and read-only token lifecycle; applications supply the user wallet only when a descriptor includes `USER`.

A brand-new address must complete its [first-deposit flow](/providers/lighter/deposits) before setup. `REGISTER_API_KEY` needs the venue-assigned `account_index`, so an unfunded account returns `accountExists: false` with no setup steps.

```typescript theme={null}
const required = await perps.checkSetup({
  provider: 'lighter', // or 'lighter-rh'
  address: userAddress,
});

if (!required.accountExists) {
  // Complete getDepositFlow() before setup.
} else {
  for (const step of required.setup) {
    await perps.executeProviderSetupAction({
      provider: 'lighter',
      address: userAddress,
      step,
    });
  }
}
```

`checkSetup()` drains SDK-only internal steps such as `setReferrer` itself. It returns user-facing steps in descriptor sequence order.

## Setup descriptors

### `registerApiKey`

Registers a provider-native Lighter keypair at an on-chain key slot. The new key signs the WASM `ChangePubKey` blob and the user's L1 wallet countersigns the EIP-191 authorization.

|                    |                                                                          |
| ------------------ | ------------------------------------------------------------------------ |
| **Title**          | Register Trading API Key                                                 |
| **Signers**        | `USER`, `SDK`                                                            |
| **Signing method** | `wasmBlob`                                                               |
| **Sequence**       | `10`                                                                     |
| **When needed**    | First setup, or when the local key no longer matches the registered slot |

The default slot is `42`. Re-registering the same slot replaces its prior key. Each provider instance namespaces its persisted key, so `lighter` and `lighter-rh` credentials never collide.

### `setReferrer`

Applies LI.FI's configured referral code through the Lighter native signer. This descriptor is omitted unless both the referral code and referral X handle are configured. It is an internal `SDK` step: `checkSetup()` attempts it inline and does not render it as a wallet action.

|                    |            |
| ------------------ | ---------- |
| **Signers**        | `SDK`      |
| **Signing method** | `wasmBlob` |
| **Sequence**       | `20`       |

### `approveIntegrator`

Authorizes LI.FI's integrator account and maximum fee cap. Lighter requires both the native WASM signature and the L1 owner's EIP-191 signature when the integrator belongs to another address with non-zero fee caps.

|                    |                                                                                            |
| ------------------ | ------------------------------------------------------------------------------------------ |
| **Title**          | Authorise LI.FI Fees                                                                       |
| **Signers**        | `USER`, `SDK`                                                                              |
| **Signing method** | `wasmBlob`                                                                                 |
| **Sequence**       | `30`                                                                                       |
| **When needed**    | When the deployment has an integrator configured and the existing approval is insufficient |

## Options descriptors

Options never gate trading and are read through `getAccount().settings`.

### `accountMode`

Switches between Unified Trading Account (cross-asset margin) and Simple Trading Account (segregated margin). Lighter rejects changes while positions or pending orders exist.

|                    |                                                 |
| ------------------ | ----------------------------------------------- |
| **Signer**         | `SDK`                                           |
| **Signing method** | `wasmBlob`                                      |
| **Param**          | `mode`                                          |
| **Values**         | `unifiedTradingAccount`, `simpleTradingAccount` |

### `accountType`

Switches between Standard and Premium. Lighter enforces no open positions, no pending orders, and a 24-hour cooldown. The public option does not expose the venue's Plus tier.

|                    |                                 |
| ------------------ | ------------------------------- |
| **Signer**         | `SDK`                           |
| **Signing method** | `wasmBlob`                      |
| **Param**          | `tier`                          |
| **Values**         | `standard` (default), `premium` |
