Lighter-only. Gains has no provisioning step — accounts are implicit. Skip this endpoint for Gains.
Provisions the signer’s Lighter sub-account API key + auth token. Run once per (L1 address, accountIndex) after the user’s first deposit so subsequent trades, withdrawals, etc. can authenticate against Lighter.
Account lifecycle on Lighter
A wallet (EOA) is not a Lighter account by default. Lighter only registers an account on-chain after the L1 address makes its first USDC deposit (≥ 5 USDC, a Lighter-side requirement). Once the deposit settles, Lighter assigns an accountIndex to that L1 address. The integrator must then call this endpoint with the discovered accountIndex to provision an API key + auth token — without it, every other Lighter perp endpoint (create-order, close-position, withdraw, …) will fail.End-to-end first-time setup:
Discover the accountIndex by polling Lighter’s account-lookup endpoint (the bridge takes a few seconds to settle on L2):
GET https://mainnet.zklighter.elliot.ai/api/v1/account?by=l1_address&value=<EOA address>Accept: application/json
Response shape (success): { "code": 200, "accounts": [{ "account_index": <number>, ... }] }. Poll every ~1s until accounts[0].account_index is present.
Coming soon. Mobula will expose a proxy endpoint so integrators don’t need to call Lighter directly. For now, hit Lighter’s URL above.
Provision the API key by calling this endpoint with the discovered accountIndex and submitting via /2/perp/execute-v2. The response payload may carry payload.MessageToSign — sign it, set payload.L1Sig, delete payload.MessageToSign, re-stringify, and sign execute-v2 over the new string.
The user’s wallet can now call all Lighter trade/withdraw endpoints.
Request Body
string
required
Must be lighter.
string
required
Must be lighter:304 (the only chain that accepts Lighter create-account today).
number
required
Lighter sub-account index (non-negative integer). Discovered via the Lighter /api/v1/account?by=l1_address&value=<EOA> lookup after the first deposit settles.
number
Lighter API key slot to provision (≥ 0). Pick any unused slot. Defaults server-side if omitted.
Authentication
Every /2/perp/payloads/<action> endpoint verifies the caller by requiring two extra fields in the request body alongside the action parameters:
number
required
Unix timestamp in milliseconds. Must be within 30 seconds of server time. Older timestamps are rejected to prevent replay.
string
required
Hex signature (EIP-191 personal_sign) of the message `${endpoint}-${timestamp}`, where endpoint is the path of this endpoint without the leading slash (e.g., for this page: api/2/perp/payloads/<this-action>). The recovered signer address becomes the user for the request. Single-use — replay returns 403 signature already used.
Every /2/perp/payloads/<action> endpoint returns the same envelope shape. You pass these fields verbatim into POST /2/perp/execute-v2 to execute the action.
Top-level shape. Successful (2xx) responses return { data: { ... } }. A success: true flag is only present inside the body of execute-v2’s response, not on the payload-build endpoints. Parse defensively: read body.data, then check for the action-specific fields you need (e.g. data.payloadStr).
object
Show data
string
Canonical action name — one of withdraw, create-account, deposit, create-order, close-position, cancel-order, update-margin, edit-order.
string
gains or lighter.
string
Chain where the action lands (e.g., evm:42161, lighter:301).
string
Mobula market identifier. Present when the action targets a specific market.
string
offchain-api — server submits to the DEX off-chain API on the user’s behalf (Lighter trades, Lighter withdraw, Lighter create-account). evm-tx — server broadcasts a user-signed EVM transaction (Lighter deposit bridge route, Gains trade actions). The Gains case requires a top-level signedTx on execute-v2; the Lighter deposit case injects signed txs insidepayloadStr.
string
JSON-stringified canonical envelope. For most actions you forward this byte-for-byte into /2/perp/execute-v2. Mutations are required for: Lighter deposit (inject payload.signedTxs), Lighter withdraw (sign payload.MessageToSign → payload.L1Sig, delete MessageToSign), Lighter create-account (same as withdraw only if payload.MessageToSign is present). After mutation, re-stringify and sign execute-v2 over the new string. Never alter the envelope metadata (action, dex, chainId, transport, marketId) — execute-v2 cross-checks it.
Endpoint-specific errors
Status
message
400
accountIndex must be a non-negative integer for lighter create-account — missing or invalid accountIndex
400
Invalid chainId "<value>" for lighter create-account — chainId other than lighter:304
payload action "create-account" not implemented yet — dex other than lighter
Full flow — provision a Lighter sub-account end-to-end
Assumes the wallet has already deposited ≥ 5 USDC and you have polled Lighter to discover its accountIndex. Snippet shows step 3 of the lifecycle above.
async function pollLighterAccountIndex(eoaAddress, { intervalMs = 1000, maxRetries = 200 } = {}) { for (let i = 0; i < maxRetries; i++) { const res = await fetch( `https://mainnet.zklighter.elliot.ai/api/v1/account?by=l1_address&value=${eoaAddress}`, { headers: { Accept: 'application/json' } }, ).then(r => r.json()).catch(() => null); if (res?.code === 200 && res.accounts?.[0]?.account_index != null) { return res.accounts[0].account_index; } await new Promise(r => setTimeout(r, intervalMs)); } throw new Error(`Lighter accountIndex not found for ${eoaAddress} after ${maxRetries} polls`);}
Body
application/json
timestamp
number
required
Unix ms timestamp; must be within 30s of server time.
signature
string
required
Hex signature of {endpoint}-{timestamp}. Recovered signer becomes the request user.
dex
enum<string>
required
Available options:
lighter
chainId
enum<string>
required
Must be lighter:304 (only chain that accepts Lighter create-account today).
Available options:
lighter:304
accountIndex
integer
required
Lighter sub-account index. Discover via Lighter's /api/v1/account?by=l1_address&value= after the first deposit settles.
Required range: x >= 0
apiKeyIndex
integer
Lighter API key slot to provision. Pick any unused slot. Defaults server-side if omitted.
Required range: x >= 0
Response
200 - application/json
Canonical payload envelope
success
boolean
required
data
object
required
Show child attributes
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Mobula API","colors":{"primary":"#5C7DF9","light":"#5C7DF9","dark":"#000000"},"logo":{"light":"https://mintcdn.com/mobulalabs/i4_lXsPzQR8eheLT/images/logo/light-logo.svg?fit=max\u0026auto=format\u0026n=i4_lXsPzQR8eheLT\u0026q=85\u0026s=f5099f8a6b3dd6665a32fe40d9288d81","dark":"https://mintcdn.com/mobulalabs/i4_lXsPzQR8eheLT/images/logo/dark-logo.svg?fit=max\u0026auto=format\u0026n=i4_lXsPzQR8eheLT\u0026q=85\u0026s=b1e6703d769cfe27914c2db40b46b332"},"favicon":"https://mintlify.s3.us-west-1.amazonaws.com/mobulalabs/favicon.png","api":{"openapi":["rest-api-reference/openapi.yaml"],"asyncapi":["asyncapi.yaml"]},"background":{"color":{"light":"#f5f5f5","dark":"#111524"}},"navbar":{"links":[{"href":"https://admin.mobula.io","label":"Generate free API key"}],"primary":{"type":"button","label":"Dashboard","href":"https://admin.mobula.io"}},"footer":{"socials":{"twitter":"https://x.com/mobulaio","telegram":"https://t.me/mobuladevelopers"}},"integrations":{"mixpanel":{"projectToken":"792afbf66aa630430016bdbd59c52ba7"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"mobulalabs","hasAudioNarration":false,"actualSubdomain":"mobulalabs","customDomains":["docs.mobula.io"],"gitSource":{"type":"github","owner":"fomo-family","repo":"mobula-monorepo","deployBranch":"dev","contentDirectory":"docs/mobula-api-docs","isPrivate":true,"mountPath":"","label":"","_id":"6b10a22c9ffae5051c3f8beb"},"entitlements":{"AI_CHAT":{"status":"DISABLED"},"WEB_MCP":{"status":"DISABLED"},"NARRATION":{"status":"DISABLED"}},"buildId":"6b06f5c9c90834d233c7c690","clientVersion":"0.0.4424","searchFilterCounts":[{"language":"default","tag":"Changelog","count":105},{"language":"default","tag":"2026","count":103},{"language":"default","tag":"Chains","count":97},{"language":"default","tag":"Supported Chains","count":96},{"language":"default","tag":"Overview","count":80},{"language":"default","tag":"Data","count":70},{"language":"default","tag":"Guides","count":67},{"language":"default","tag":"Spot","count":51},{"language":"default","tag":"Streams","count":46},{"language":"default","tag":"Perps","count":26}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false,"authValue":{"auth":{}}},"customCss":[{"filePath":"custom.css","content":"img[src*=\"util-badge\"]{width:32px;height:16px;min-width:32px;min-height:16px}"}]}
{"page":{"pagePath":"exec/perps/perp-payload-create-account","slug":"/exec/perps/perp-payload-create-account","pageMetadata":{"public":true,"title":"Build Create-Account Payload","openapi":"POST /2/perp/payloads/create-account","description":"Build a signed canonical payload to create/provision the user's account on a perpetual DEX (e.g., register a Lighter sub-account or API key).","href":"/exec/perps/perp-payload-create-account"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Build a signed canonical payload to create/provision the user’s account on a perpetual DEX (e.g., register a Lighter sub-account or API key).\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,..._provideComponents(),...props.components},{CodeBlock,Expandable,Heading,Info,Note,ParamField,ResponseField,Table}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Info)_missingMdxReference(`Info`,true);if(!Note)_missingMdxReference(`Note`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!ResponseField)_missingMdxReference(`ResponseField`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsxs(Note,{children:[_jsx(_components.strong,{children:`Lighter-only.`}),` Gains has no provisioning step — accounts are implicit. Skip this endpoint for Gains.`]}),`\n`,_jsxs(_components.p,{children:[`Provisions the signer’s Lighter sub-account API key + auth token. Run once per `,_jsx(_components.code,{children:`(L1 address, accountIndex)`}),` after the user’s first deposit so subsequent trades, withdrawals, etc. can authenticate against Lighter.`]}),`\n`,_jsx(Heading,{level:`2`,id:`account-lifecycle-on-lighter`,children:`Account lifecycle on Lighter`}),`\n`,_jsxs(_components.p,{children:[`A wallet (EOA) is `,_jsx(_components.strong,{children:`not`}),` a Lighter account by default. Lighter only registers an account on-chain after the L1 address makes its first USDC deposit (≥ `,_jsx(_components.strong,{children:`5 USDC`}),`, a Lighter-side requirement). Once the deposit settles, Lighter assigns an `,_jsx(_components.code,{children:`accountIndex`}),` to that L1 address. The integrator must then call this endpoint with the discovered `,_jsx(_components.code,{children:`accountIndex`}),` to provision an API key + auth token — without it, every other Lighter perp endpoint (`,_jsx(_components.code,{children:`create-order`}),`, `,_jsx(_components.code,{children:`close-position`}),`, `,_jsx(_components.code,{children:`withdraw`}),`, …) will fail.`]}),`\n`,_jsx(_components.p,{children:`End-to-end first-time setup:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Deposit`}),` ≥ 5 USDC via `,_jsx(_components.a,{href:`/rest-api-reference/endpoint/perp-payload-deposit`,children:_jsx(_components.code,{children:`/2/perp/payloads/deposit`})}),` → submit via `,_jsx(_components.code,{children:`/2/perp/execute-v2`}),` → poll `,_jsx(_components.a,{href:`/rest-api-reference/endpoint/perp-check-process`,children:_jsx(_components.code,{children:`/2/perp/check-process`})}),` until success.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[`Discover the `,_jsx(_components.code,{children:`accountIndex`})]}),` by polling Lighter’s account-lookup endpoint (the bridge takes a few seconds to settle on L2):`,`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`GET`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` https://mainnet.zklighter.elliot.ai/api/v1/account?by=l1_address\u0026value=\u003cEOA address>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`Accept`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` application/json`})]}),`\n`]})})}),`\n`,`Response shape (success): `,_jsx(_components.code,{children:`{ \"code\": 200, \"accounts\": [{ \"account_index\": \u003cnumber>, ... }] }`}),`. Poll every ~1s until `,_jsx(_components.code,{children:`accounts[0].account_index`}),` is present.\n`,_jsxs(Info,{children:[_jsx(_components.strong,{children:`Coming soon.`}),` Mobula will expose a proxy endpoint so integrators don’t need to call Lighter directly. For now, hit Lighter’s URL above.`]})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Provision the API key`}),` by calling this endpoint with the discovered `,_jsx(_components.code,{children:`accountIndex`}),` and submitting via `,_jsx(_components.code,{children:`/2/perp/execute-v2`}),`. The response payload may carry `,_jsx(_components.code,{children:`payload.MessageToSign`}),` — sign it, set `,_jsx(_components.code,{children:`payload.L1Sig`}),`, delete `,_jsx(_components.code,{children:`payload.MessageToSign`}),`, re-stringify, and sign execute-v2 over the new string.`]}),`\n`,_jsx(_components.li,{children:`The user’s wallet can now call all Lighter trade/withdraw endpoints.`}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`request-body`,children:`Request Body`}),`\n`,_jsxs(ParamField,{body:`dex`,type:`string`,required:true,id:`param-dex`,children:[`Must be `,_jsx(_components.code,{children:`lighter`}),`.`]}),`\n`,_jsx(ParamField,{body:`chainId`,type:`string`,required:true,id:`param-chain-id`,children:_jsxs(_components.p,{children:[`Must be `,_jsx(_components.code,{children:`lighter:304`}),` (the only chain that accepts Lighter `,_jsx(_components.code,{children:`create-account`}),` today).`]})}),`\n`,_jsx(ParamField,{body:`accountIndex`,type:`number`,required:true,id:`param-account-index`,children:_jsxs(_components.p,{children:[`Lighter sub-account index (non-negative integer). Discovered via the Lighter `,_jsx(_components.code,{children:`/api/v1/account?by=l1_address\u0026value=\u003cEOA>`}),` lookup after the first deposit settles.`]})}),`\n`,_jsx(ParamField,{body:`apiKeyIndex`,type:`number`,id:`param-api-key-index`,children:_jsx(_components.p,{children:`Lighter API key slot to provision (≥ 0). Pick any unused slot. Defaults server-side if omitted.`})}),`\n`,_jsx(Heading,{level:`3`,id:`authentication`,children:`Authentication`}),`\n`,_jsxs(_components.p,{children:[`Every `,_jsx(_components.code,{children:`/2/perp/payloads/\u003caction>`}),` endpoint verifies the caller by requiring two extra fields in the request body alongside the action parameters:`]}),`\n`,_jsx(ParamField,{body:`timestamp`,type:`number`,required:true,id:`param-timestamp`,children:_jsx(_components.p,{children:`Unix timestamp in milliseconds. Must be within 30 seconds of server time. Older timestamps are rejected to prevent replay.`})}),`\n`,_jsx(ParamField,{body:`signature`,type:`string`,required:true,id:`param-signature`,children:_jsxs(_components.p,{children:[`Hex signature (EIP-191 `,_jsx(_components.code,{children:`personal_sign`}),`) of the message `,_jsx(_components.code,{children:\"`${endpoint}-${timestamp}`\"}),`, where `,_jsx(_components.code,{children:`endpoint`}),` is the path `,_jsx(_components.strong,{children:`of this endpoint`}),` without the leading slash (e.g., for this page: `,_jsx(_components.code,{children:`api/2/perp/payloads/\u003cthis-action>`}),`). The recovered signer address becomes the `,_jsx(_components.code,{children:`user`}),` for the request. Single-use — replay returns `,_jsx(_components.code,{children:`403 signature already used`}),`.`]})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`14`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`14`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:\"// Replace `\u003caction>` with the action of THIS page (e.g. create-account, deposit, …)\"})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` endpoint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'api/2/perp/payloads/\u003caction>'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` timestamp`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Date`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`now`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` signature`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`signMessage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`endpoint`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`-`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`timestamp`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`https://api.mobula.io/\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`endpoint`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'POST'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'Content-Type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` body:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`stringify`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` timestamp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` signature`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // ...action-specific fields below`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`authentication-errors`,children:`Authentication errors`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Status`}),_jsx(_components.th,{children:_jsx(_components.code,{children:`message`})})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`403`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`timestamp expired`}),` — timestamp older than 30s`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`403`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`signature already used`}),` — replay attempt`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`400`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`zod validation failed`}),` — `,_jsx(_components.code,{children:`timestamp`}),`/`,_jsx(_components.code,{children:`signature`}),` shape invalid`]})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`response-envelope`,children:`Response envelope`}),`\n`,_jsxs(_components.p,{children:[`Every `,_jsx(_components.code,{children:`/2/perp/payloads/\u003caction>`}),` endpoint returns the same envelope shape. You pass these fields verbatim into `,_jsx(_components.code,{children:`POST /2/perp/execute-v2`}),` to execute the action.`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Top-level shape.`}),` Successful (2xx) responses return `,_jsx(_components.code,{children:`{ data: { ... } }`}),`. A `,_jsx(_components.code,{children:`success: true`}),` flag is only present inside the body of `,_jsx(_components.code,{children:`execute-v2`}),`’s response, not on the payload-build endpoints. Parse defensively: read `,_jsx(_components.code,{children:`body.data`}),`, then check for the action-specific fields you need (e.g. `,_jsx(_components.code,{children:`data.payloadStr`}),`).`]})}),`\n`,_jsx(ResponseField,{name:`data`,type:`object`,id:`param-data`,children:_jsxs(Expandable,{title:`data`,children:[_jsx(ResponseField,{name:`action`,type:`string`,id:`param-action`,children:_jsxs(_components.p,{children:[`Canonical action name — one of `,_jsx(_components.code,{children:`withdraw`}),`, `,_jsx(_components.code,{children:`create-account`}),`, `,_jsx(_components.code,{children:`deposit`}),`, `,_jsx(_components.code,{children:`create-order`}),`, `,_jsx(_components.code,{children:`close-position`}),`, `,_jsx(_components.code,{children:`cancel-order`}),`, `,_jsx(_components.code,{children:`update-margin`}),`, `,_jsx(_components.code,{children:`edit-order`}),`.`]})}),_jsxs(ResponseField,{name:`dex`,type:`string`,id:`param-dex-1`,children:[_jsx(_components.code,{children:`gains`}),` or `,_jsx(_components.code,{children:`lighter`}),`.`]}),_jsxs(ResponseField,{name:`chainId`,type:`string`,id:`param-chain-id-1`,children:[`Chain where the action lands (e.g., `,_jsx(_components.code,{children:`evm:42161`}),`, `,_jsx(_components.code,{children:`lighter:301`}),`).`]}),_jsx(ResponseField,{name:`marketId`,type:`string`,id:`param-market-id`,children:`Mobula market identifier. Present when the action targets a specific market.`}),_jsx(ResponseField,{name:`transport`,type:`string`,id:`param-transport`,children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`offchain-api`}),` — server submits to the DEX off-chain API on the user’s behalf (Lighter trades, Lighter `,_jsx(_components.code,{children:`withdraw`}),`, Lighter `,_jsx(_components.code,{children:`create-account`}),`).`,_jsx(`br`,{}),`\n`,_jsx(_components.code,{children:`evm-tx`}),` — server broadcasts a user-signed EVM transaction (Lighter `,_jsx(_components.code,{children:`deposit`}),` bridge route, Gains trade actions). The Gains case requires a top-level `,_jsx(_components.code,{children:`signedTx`}),` on execute-v2; the Lighter `,_jsx(_components.code,{children:`deposit`}),` case injects signed txs `,_jsx(_components.strong,{children:`inside`}),` `,_jsx(_components.code,{children:`payloadStr`}),`.`]})}),_jsx(ResponseField,{name:`payloadStr`,type:`string`,id:`param-payload-str`,children:_jsxs(_components.p,{children:[`JSON-stringified canonical envelope. For most actions you forward this byte-for-byte into `,_jsx(_components.code,{children:`/2/perp/execute-v2`}),`. Mutations are required for: Lighter `,_jsx(_components.code,{children:`deposit`}),` (inject `,_jsx(_components.code,{children:`payload.signedTxs`}),`), Lighter `,_jsx(_components.code,{children:`withdraw`}),` (sign `,_jsx(_components.code,{children:`payload.MessageToSign`}),` → `,_jsx(_components.code,{children:`payload.L1Sig`}),`, delete `,_jsx(_components.code,{children:`MessageToSign`}),`), Lighter `,_jsx(_components.code,{children:`create-account`}),` (same as `,_jsx(_components.code,{children:`withdraw`}),` only if `,_jsx(_components.code,{children:`payload.MessageToSign`}),` is present). After mutation, re-stringify and sign execute-v2 over the `,_jsx(_components.strong,{children:`new`}),` string. Never alter the envelope metadata (`,_jsx(_components.code,{children:`action`}),`, `,_jsx(_components.code,{children:`dex`}),`, `,_jsx(_components.code,{children:`chainId`}),`, `,_jsx(_components.code,{children:`transport`}),`, `,_jsx(_components.code,{children:`marketId`}),`) — execute-v2 cross-checks it.`]})})]})}),`\n`,_jsx(Heading,{level:`3`,id:`endpoint-specific-errors`,children:`Endpoint-specific errors`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Status`}),_jsx(_components.th,{children:_jsx(_components.code,{children:`message`})})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`400`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`accountIndex must be a non-negative integer for lighter create-account`}),` — missing or invalid `,_jsx(_components.code,{children:`accountIndex`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`400`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`Invalid chainId \"\u003cvalue>\" for lighter create-account`}),` — chainId other than `,_jsx(_components.code,{children:`lighter:304`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`400`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`create-account payload generation failed`}),` — Lighter rejected provisioning (e.g., slot already in use)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`501`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`payload action \"create-account\" not implemented yet`}),` — `,_jsx(_components.code,{children:`dex`}),` other than `,_jsx(_components.code,{children:`lighter`})]})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`full-flow-—-provision-a-lighter-sub-account-end-to-end`,children:`Full flow — provision a Lighter sub-account end-to-end`}),`\n`,_jsxs(_components.p,{children:[`Assumes the wallet has already deposited ≥ 5 USDC and you have polled Lighter to discover its `,_jsx(_components.code,{children:`accountIndex`}),`. Snippet shows step 3 of the lifecycle above.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`47`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`47`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// 1. Auth-sign + fetch the create-account payload`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` endpoint`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'api/2/perp/payloads/create-account'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` ts`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Date`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`now`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` authSig`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`signMessage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`endpoint`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`-`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ts`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`https://api.mobula.io/\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`endpoint`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'POST'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'Content-Type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` body:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`stringify`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` timestamp:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` ts`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` signature:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` authSig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` dex:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'lighter'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` chainId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'lighter:304'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` accountIndex`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// discovered from Lighter's /api/v1/account lookup`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` apiKeyIndex:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 100`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// any unused slot`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`then`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`r`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` =>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` r`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`());`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// 2. Mutate the envelope only if Lighter returns an L1 challenge`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` parsed`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`parse`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`payloadStr`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`let`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` finalPayloadStr`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`payloadStr`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`parsed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`payload`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`MessageToSign`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` parsed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`payload`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`L1Sig`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`signMessage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`parsed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`payload`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`MessageToSign`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` delete`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` parsed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`payload`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`MessageToSign`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` finalPayloadStr`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`stringify`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`parsed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// 3. Sign + submit execute-v2`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` execTs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Date`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`now`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` execSig`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`signMessage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `api/2/perp/execute-v2-\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`execTs`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`-`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`finalPayloadStr`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` execRes`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'https://api.mobula.io/api/2/perp/execute-v2'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'POST'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'Content-Type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` body:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`stringify`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` action:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`action`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` dex:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`dex`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` chainId:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chainId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` transport:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`transport`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` payloadStr:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` finalPayloadStr`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` timestamp:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` execTs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` signature:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` execSig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`then`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`r`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` =>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` r`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`());`})]}),`\n`]})})}),`\n`,_jsxs(Heading,{level:`3`,id:`helper-—-discover-accountindex-after-a-deposit`,children:[`Helper — discover `,_jsx(_components.code,{children:`accountIndex`}),` after a deposit`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`14`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`14`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` pollLighterAccountIndex`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`eoaAddress`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`intervalMs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`maxRetries`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {}) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`let`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` i`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`i`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` maxRetries`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`i`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`++`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` res`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `https://mainnet.zklighter.elliot.ai/api/v1/account?by=l1_address\u0026value=\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`eoaAddress`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Accept:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`then`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`r`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` =>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` r`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`catch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`code`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ===`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 200`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u0026\u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`accounts`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`account_index`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` !=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`accounts`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`account_index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Promise`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`r`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` =>`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` setTimeout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`r`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`intervalMs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`));`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` throw`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`Lighter accountIndex not found for \"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`eoaAddress`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` after `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`maxRetries`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" polls`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"public":true,"title":"Build Create-Account Payload","openapi":"POST /2/perp/payloads/create-account","description":"Build a signed canonical payload to create/provision the user's account on a perpetual DEX (e.g., register a Lighter sub-account or API key).","href":"/exec/perps/perp-payload-create-account"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Account lifecycle on Lighter","slug":"account-lifecycle-on-lighter","depth":2,"children":[{"title":"Request Body","slug":"request-body","depth":3,"children":[]},{"title":"Authentication","slug":"authentication","depth":3,"children":[]},{"title":"Authentication errors","slug":"authentication-errors","depth":3,"children":[]},{"title":"Response envelope","slug":"response-envelope","depth":3,"children":[]},{"title":"Endpoint-specific errors","slug":"endpoint-specific-errors","depth":3,"children":[]},{"title":"Full flow — provision a Lighter sub-account end-to-end","slug":"full-flow-—-provision-a-lighter-sub-account-end-to-end","depth":3,"children":[]},{"title":"Helper — discover accountIndex after a deposit","slug":"helper-—-discover-accountindex-after-a-deposit","depth":3,"children":[]}]}],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"tags":["V2 - Perps"],"summary":"Build create-account payload","description":"Build a signed canonical payload to create/provision the user's account on a perpetual DEX (e.g., register a Lighter sub-account or API key).","requestBody":"fef6cda6-cff4-4e0a-9264-4c739a84dc8f","responses":{"200":"71836859-681a-4138-9c5e-b6ac2a930a7f"},"method":"post","type":"path","servers":["c25b9009-8f4e-492f-b743-eb62a864816a","34680ce8-88e4-4b86-942f-2cc9fb5ef9e7"],"security":[],"path":"/2/perp/payloads/create-account","baseUrlOptions":["https://demo-api.mobula.io/api/","https://api.mobula.io/api/"],"title":"Build create-account payload","codeSamples":[],"requiredOnlyExamples":false,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"timestamp":{"type":"number","description":"Unix ms timestamp; must be within 30s of server time.","isRequired":true,"uniqueKey":"timestamp","typeLabel":"number"},"signature":{"type":"string","description":"Hex signature of `{endpoint}-{timestamp}`. Recovered signer becomes the request user.","isRequired":true,"uniqueKey":"signature","typeLabel":"string"},"dex":{"type":"string","enum":["lighter"],"isRequired":true,"uniqueKey":"dex","typeLabel":"enum\u003cstring>"},"chainId":{"type":"string","enum":["lighter:304"],"description":"Must be `lighter:304` (only chain that accepts Lighter create-account today).","isRequired":true,"uniqueKey":"chainId","typeLabel":"enum\u003cstring>"},"accountIndex":{"type":"integer","minimum":0,"description":"Lighter sub-account index. Discover via Lighter's /api/v1/account?by=l1_address\u0026value=\u003cEOA> after the first deposit settles.","isRequired":true,"uniqueKey":"accountIndex","typeLabel":"integer"},"apiKeyIndex":{"type":"integer","minimum":0,"description":"Lighter API key slot to provision. Pick any unused slot. Defaults server-side if omitted.","uniqueKey":"apiKeyIndex","typeLabel":"integer"}},"required":["timestamp","signature","dex","chainId","accountIndex"],"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"timestamp":123,"signature":"\u003cstring>","dex":"lighter","chainId":"lighter:304","accountIndex":1,"apiKeyIndex":1}}},"exampleType":"generated"}},"exampleType":"generated"},"responses":{"71836859-681a-4138-9c5e-b6ac2a930a7f":{"description":"Canonical payload envelope","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","isRequired":true,"uniqueKey":"success","typeLabel":"boolean"},"data":{"type":"object","properties":{"action":{"type":"string","isRequired":true,"uniqueKey":"data.action","typeLabel":"string"},"dex":{"type":"string","isRequired":true,"uniqueKey":"data.dex","typeLabel":"string"},"chainId":{"type":"string","isRequired":true,"uniqueKey":"data.chainId","typeLabel":"string"},"transport":{"type":"string","enum":["offchain-api","evm-tx"],"isRequired":true,"uniqueKey":"data.transport","typeLabel":"enum\u003cstring>"},"payloadStr":{"type":"string","isRequired":true,"uniqueKey":"data.payloadStr","typeLabel":"string"},"marketId":{"type":"string","uniqueKey":"data.marketId","typeLabel":"string"}},"required":["action","dex","chainId","transport","payloadStr"],"isRequired":true,"uniqueKey":"data","typeLabel":"object"}},"required":["success","data"],"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"success":true,"data":{"action":"\u003cstring>","dex":"\u003cstring>","chainId":"\u003cstring>","transport":"offchain-api","payloadStr":"\u003cstring>","marketId":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"}},"security":{},"servers":{"c25b9009-8f4e-492f-b743-eb62a864816a":{"url":"https://demo-api.mobula.io/api/","description":"Demo API (rate limited, for testing only)"},"34680ce8-88e4-4b86-942f-2cc9fb5ef9e7":{"url":"https://api.mobula.io/api/","description":"Production API (requires API key)"}}},"originalFileLocation":"rest-api-reference/openapi.yaml"},"subdomain":"docs.mobula.io","siteName":"Mobula API","title":"Build Create-Account Payload - Mobula API","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-14T12:21:07.536Z","originalFileLocation":"exec/perps/perp-payload-create-account.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Build a signed canonical payload to create/provision the user\u0026#x27;s account on a perpetual DEX (e.g., register a Lighter sub-account or API key).\">\u003cmeta data-mint-head name=\"application-name\" content=\"Mobula API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Build Create-Account Payload - Mobula API\">\u003cmeta data-mint-head property=\"og:description\" content=\"Build a signed canonical payload to create/provision the user\u0026#x27;s account on a perpetual DEX (e.g., register a Lighter sub-account or API key).\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Mobula API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.mobula.io/exec/perps/perp-payload-create-account\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://mobulalabs.mintlify.io/_mintlify/api/og/v2?division=Execution\u0026amp;title=Build+Create-Account+Payload\u0026amp;description=Build+a+signed+canonical+payload+to+create%2Fprovision+the+user%27s+account+on+a+perpetual+DEX+%28e.g.%2C+register+a+Lighter+sub-account+or+API+key%29.\u0026amp;theme=b31399aac8a2a0583f71b753\u0026amp;signature=3c1a62891c687b1a118b2b656b80c9fe3f387ffa829ddfa960bd2d81ef94a98a\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Build Create-Account Payload - Mobula API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Build a signed canonical payload to create/provision the user\u0026#x27;s account on a perpetual DEX (e.g., register a Lighter sub-account or API key).\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://mobulalabs.mintlify.io/_mintlify/api/og/v2?division=Execution\u0026amp;title=Build+Create-Account+Payload\u0026amp;description=Build+a+signed+canonical+payload+to+create%2Fprovision+the+user%27s+account+on+a+perpetual+DEX+%28e.g.%2C+register+a+Lighter+sub-account+or+API+key%29.\u0026amp;theme=b31399aac8a2a0583f71b753\u0026amp;signature=3c1a62891c687b1a118b2b656b80c9fe3f387ffa829ddfa960bd2d81ef94a98a\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/mobulalabs/HNvOu2NIIIAI8gec/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Mobula API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#5C7DF9\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.mobula.io/exec/perps/perp-payload-create-account\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/exec/perps/perp-payload-create-account.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.mobula.io/#organization\",\"name\":\"Mobula API\",\"url\":\"https://docs.mobula.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/mobulalabs/i4_lXsPzQR8eheLT/images/logo/light-logo.svg?fit=max\u0026auto=format\u0026n=i4_lXsPzQR8eheLT\u0026q=85\u0026s=f5099f8a6b3dd6665a32fe40d9288d81\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.mobula.io#website\",\"name\":\"Mobula API\",\"url\":\"https://docs.mobula.io\",\"publisher\":{\"@id\":\"https://docs.mobula.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.mobula.io/exec/perps/perp-payload-create-account#webpage\",\"url\":\"https://docs.mobula.io/exec/perps/perp-payload-create-account\",\"name\":\"Build Create-Account Payload\",\"description\":\"Build a signed canonical payload to create/provision the user's account on a perpetual DEX (e.g., register a Lighter sub-account or API key).\",\"dateModified\":\"2026-11-14T12:21:07.536Z\",\"isPartOf\":{\"@id\":\"https://docs.mobula.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.mobula.io/exec/perps/perp-payload-create-account#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.mobula.io/exec/perps/perp-payload-create-account#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Execution\",\"item\":\"https://docs.mobula.io/exec/perps/perp-quote\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Build Create-Account Payload\",\"item\":\"https://docs.mobula.io/exec/perps/perp-payload-create-account\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.mobula.io/exec/perps/perp-payload-create-account#apireference\",\"headline\":\"Build Create-Account Payload\",\"name\":\"Build Create-Account Payload\",\"description\":\"Build a signed canonical payload to create/provision the user's account on a perpetual DEX (e.g., register a Lighter sub-account or API key).\",\"url\":\"https://docs.mobula.io/exec/perps/perp-payload-create-account\",\"mainEntityOfPage\":{\"@id\":\"https://docs.mobula.io/exec/perps/perp-payload-create-account#webpage\"},\"dateModified\":\"2026-11-14T12:21:07.536Z\",\"publisher\":{\"@id\":\"https://docs.mobula.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.mobula.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Mobula API\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Mobula API\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/exec/perps/perp-payload-create-account.md","siteName":"Mobula API","nav":{"global":null,"tabs":[{"tab":"Overview","pages":[{"title":"Overview","href":"/introduction"}]},{"tab":"Data","pages":[{"title":"Data","href":"/data-introduction"}]},{"tab":"Streams","pages":[{"title":"Streams","href":"/indexing-stream/stream-introduction"}]},{"tab":"Spot","pages":[{"title":"Spot","href":"/spot-introduction"}]},{"tab":"Perps","groups":[{"group":"Introduction","pages":[{"title":"Perpetuals APIs","icon":"chart-mixed","href":"/perps-introduction"},{"title":"Perp Fees","sidebarTitle":"Fees","icon":"coins","href":"/perps-fees"}]},{"group":"Data","pages":[{"title":"Get Perp Pairs","openapi":"GET /2/perp/pairs","href":"/data/perps/perp-pairs"},{"title":"Get Perp Positions","openapi":"GET /2/wallet/positions/perp/open","href":"/data/perps/wallet-perp-positions"},{"title":"Get Perp Unfilled Orders","openapi":"GET /2/wallet/positions/perp/unfilled","href":"/data/perps/wallet-perp-orders"},{"title":"Get Funding Rate","openapi":"get /1/market/cefi/funding-rate","href":"/data/perps/market-cefi-funding-rate"},{"title":"Get Perp Chart","openapi":"GET /2/perp/ohlcv-history","href":"/data/perps/perp-chart"},{"title":"Generate Perp Chart Image","openapi":"POST /2/perp/chart","href":"/data/perps/perp-chart-image"},{"title":"Get Perp DEX Status","openapi":"GET /2/perp/dex-status","href":"/data/perps/perp-dex-status"}]},{"group":"Execution","pages":[{"title":"Get Perp Quote","openapi":"POST /2/perp/quote","description":"Get a non-binding quote for opening a perpetual position on a supported DEX (Gains Network, Lighter). Quotes do not authenticate the caller and are not used by the execution flow; they are purely informational and exposed to help clients pick a DEX, price, or slippage before building a real payload.","href":"/exec/perps/perp-quote"},{"public":true,"title":"Build Create-Account Payload","openapi":"POST /2/perp/payloads/create-account","href":"/exec/perps/perp-payload-create-account"},{"title":"Build Deposit Payload","openapi":"POST /2/perp/payloads/deposit","description":"Build a signed canonical payload to deposit USDC collateral into a perpetual DEX account (Lighter) or bridge USDC into a Gains account.","href":"/exec/perps/perp-payload-deposit"},{"title":"Build Withdraw Payload","openapi":"POST /2/perp/payloads/withdraw","href":"/exec/perps/perp-payload-withdraw"},{"title":"Build Create-Order Payload","openapi":"POST /2/perp/payloads/create-order","href":"/exec/perps/perp-payload-create-order"},{"title":"Build Close-Position Payload","openapi":"POST /2/perp/payloads/close-position","href":"/exec/perps/perp-payload-close-position"},{"title":"Build Cancel-Order Payload","openapi":"POST /2/perp/payloads/cancel-order","href":"/exec/perps/perp-payload-cancel-order"},{"title":"Build Edit-Order Payload","openapi":"POST /2/perp/payloads/edit-order","href":"/exec/perps/perp-payload-edit-order"},{"title":"Build Update-Margin Payload","openapi":"POST /2/perp/payloads/update-margin","href":"/exec/perps/perp-payload-update-margin"},{"title":"Execute Perp Action","openapi":"POST /2/perp/execute-v2","href":"/exec/perps/perp-execute"},{"title":"Check Perp Process","openapi":"GET /2/perp/check-process","href":"/exec/perps/perp-check-process"}]},{"group":"Cookbook","pages":[{"title":"Execute Perp Trades End-to-End","href":"/cookbooks/perp-execution-flow"},{"title":"Retrieve All Perp Markets","href":"/cookbooks/retrieve-perp-markets"}]},{"group":"Streams","pages":[{"title":"Perp Positions Stream","asyncapi":"streams/asyncapi.yaml perpPositions","href":"/streams/wss-perp-positions"},{"title":"Perp Events Stream","asyncapi":"streams/asyncapi.yaml perpEvents","href":"/streams/wss-perp-events"},{"title":"Funding Stream","asyncapi":"streams/asyncapi.yaml funding","href":"/streams/wss-funding"}]},{"group":"Reference","pages":[{"title":"Perpetuals (Perps)","href":"/indexing-stream/stream/data-model/perps-data-model"}]}]},{"tab":"Chains","pages":[{"title":"Chains","href":"/blockchains/intro-blockchains"}]},{"tab":"Cookbooks","pages":[{"title":"Cookbooks","href":"/cookbooks/introduction"}]},{"tab":"Almanac","pages":[{"title":"Almanac","href":"/almanac/understanding-trade-fees"}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog/introduction"}]}]},"basePath":"","title":"Build Create-Account Payload - Mobula API","deploymentId":"dpl_DCQc66XHNxkoUwtUo4heUXG9JN3R","buildId":"dpl_DCQc66XHNxkoUwtUo4heUXG9JN3R","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-B00R6m2w.js","snippetPresets-CqLrAt3u.js","utils-C6SyY4vr.js","style-to-object-BY3JEAdk.js","utils-DcM7X3d8.js","v4-DIgz8zy6.js","addTypeLabelsToSchema-wg6O_GGT.js","conditional-requirements-CFM0id0Q.js","cloneDeep-D1M_mEva.js","_Uint8Array-4XVPvAlA.js","isObject-FP1Yky1u.js","ApiExamples-Bnkv8klP.js","usePlaygroundInputsStore-CdxKaS-b.js","shallow-Dpku_zG5.js","isEqual-CVatu-Y4.js","CodeSnippets-C8QOaQsB.js","CodeSnippet-BI8c3Wcx.js","use-playground-group-access-BlXnD1_t.js","Page-DX7PVqUY.js","api-description-markdown-DyQ5oUAN.js","DynamicMarkdown-Dlqtvbwe.js","SectionHeading-CawHzc2U.js","MethodPill-CWsLcBdE.js","getPastedJson-DbC5ZvdO.js","Check2Icon-CeU_Q_BR.js","axios-CsQoIw0U.js","Markdown-UXPM-iKA.js","AssistantPageLink-DzGY38qP.js","dist-BqIp7CX0.js","lib-DMeTj1gb.js","lib-B8HbPgcC.js","katex-Dbtb6Wk7.js","html-void-elements-mCSPHezU.js","marked.esm-CZWythHk.js"]}