Lighter requires the wallet to be a registered account before any trade/withdraw action.If the EOA has never deposited on Lighter, this endpoint will fail. First-time setup is a two-step prerequisite:
Deposit ≥ 5 USDC via /2/perp/payloads/deposit → Lighter creates an accountIndex on-chain once the bridge settles. (5 USDC is a Lighter requirement, not a Mobula limit.)
Sign payload.MessageToSign with the user’s wallet (standard EIP-191 personal_sign).
Set the resulting hex on payload.L1Sig and deletepayload.MessageToSign.
Re-stringify the envelope → finalPayloadStr.
Sign `api/2/perp/execute-v2-${timestamp}-${finalPayloadStr}` and call /2/perp/execute-v2 with thatpayloadStr (no top-level signedTx).
Request Body
string
required
Must be lighter.
string
required
Lighter chain (e.g., lighter:301).
string
required
USDC amount as a decimal string (e.g., "100"). Must be positive.
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.
USDC amount as a decimal string. Must be positive.
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-withdraw","slug":"/exec/perps/perp-payload-withdraw","pageMetadata":{"public":true,"title":"Build Withdraw Payload","openapi":"POST /2/perp/payloads/withdraw","description":"Build a signed canonical payload to withdraw USDC collateral from a perpetual DEX account back to the user's wallet.","href":"/exec/perps/perp-payload-withdraw"},"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 withdraw USDC collateral from a perpetual DEX account back to the user’s wallet.\"\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,Note,ParamField,ResponseField,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!ResponseField)_missingMdxReference(`ResponseField`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(Warning,{children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`Lighter requires the wallet to be a registered account before any trade/withdraw action.`})}),_jsx(_components.p,{children:`If the EOA has never deposited on Lighter, this endpoint will fail. First-time setup is a two-step prerequisite:`}),_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`})}),` → Lighter creates an `,_jsx(_components.code,{children:`accountIndex`}),` on-chain once the bridge settles. (5 USDC is a Lighter requirement, not a Mobula limit.)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Provision API key + auth token`}),` via `,_jsx(_components.a,{href:`/rest-api-reference/endpoint/perp-payload-create-account`,children:_jsx(_components.code,{children:`/2/perp/payloads/create-account`})}),` using that `,_jsx(_components.code,{children:`accountIndex`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`Read the `,_jsx(_components.a,{href:`/rest-api-reference/endpoint/perp-payload-create-account`,children:`Build Create-Account Payload`}),` page for the full setup flow including how to discover the `,_jsx(_components.code,{children:`accountIndex`}),` after a deposit.`]})]}),`\n`,_jsxs(Note,{children:[_jsx(_components.strong,{children:`Lighter-only.`}),` Gains withdraws collateral by closing positions — there is no separate withdraw endpoint. Skip this for Gains.`]}),`\n`,_jsx(_components.p,{children:`Moves free USDC from the user’s Lighter account back to their wallet. Only free margin (not locked by open positions/orders) can be withdrawn.`}),`\n`,_jsx(Heading,{level:`3`,id:`lighter-withdraw-payload-shape`,children:`Lighter withdraw payload shape`}),`\n`,_jsxs(_components.p,{children:[`The response’s `,_jsx(_components.code,{children:`payloadStr`}),` is an envelope whose `,_jsx(_components.code,{children:`payload`}),` includes an L1 authorization challenge:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`jsonc`,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:`jsonc`,children:_jsxs(_components.code,{language:`jsonc`,numberOfLines:`10`,children:[_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:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"action\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"withdraw\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"dex\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_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:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"chainId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"lighter:301\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"transport\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"offchain-api\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"payload\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"MessageToSign\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Lighter withdraw ... \u003cserver-generated challenge>\"`}),_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:` // other Lighter-native fields`})}),`\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(_components.p,{children:_jsx(_components.strong,{children:`Client workflow (Lighter):`})}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Parse `,_jsx(_components.code,{children:`payloadStr`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Sign `,_jsx(_components.code,{children:`payload.MessageToSign`}),` with the user’s wallet (standard EIP-191 `,_jsx(_components.code,{children:`personal_sign`}),`).`]}),`\n`,_jsxs(_components.li,{children:[`Set the resulting hex on `,_jsx(_components.code,{children:`payload.L1Sig`}),` and `,_jsx(_components.strong,{children:`delete`}),` `,_jsx(_components.code,{children:`payload.MessageToSign`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Re-stringify the envelope → `,_jsx(_components.code,{children:`finalPayloadStr`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Sign `,_jsx(_components.code,{children:\"`api/2/perp/execute-v2-${timestamp}-${finalPayloadStr}`\"}),` and call `,_jsx(_components.code,{children:`/2/perp/execute-v2`}),` with `,_jsx(_components.strong,{children:`that`}),` `,_jsx(_components.code,{children:`payloadStr`}),` (no top-level `,_jsx(_components.code,{children:`signedTx`}),`).`]}),`\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:[`Lighter chain (e.g., `,_jsx(_components.code,{children:`lighter:301`}),`).`]})}),`\n`,_jsx(ParamField,{body:`amountUsdc`,type:`string`,required:true,id:`param-amount-usdc`,children:_jsxs(_components.p,{children:[`USDC amount as a decimal string (e.g., `,_jsx(_components.code,{children:`\"100\"`}),`). Must be positive.`]})}),`\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`})})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`400`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`withdraw payload generation failed`}),` — insufficient free margin or DEX refusal`]})]})})]}),`\n`,_jsx(Heading,{level:`3`,id:`example-—-lighter-withdraw-100-usdc`,children:`Example — Lighter withdraw 100 USDC`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`42`,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:`42`,children:[_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/withdraw'`}),_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\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` payloadRes`}),_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\":`#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`,_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:301'`}),_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:` amountUsdc:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '100'`}),_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`,_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:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` payloadRes`}),_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:` envelope`}),_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`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Lighter L1 sig dance`})}),`\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:` 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:`envelope`}),_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:`envelope`}),_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:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` l1Sig`}),_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:` envelope`}),_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`,_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:` 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:`envelope`}),_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:` 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:`(`}),_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`}),`\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/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`,_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 Withdraw Payload","openapi":"POST /2/perp/payloads/withdraw","description":"Build a signed canonical payload to withdraw USDC collateral from a perpetual DEX account back to the user's wallet.","href":"/exec/perps/perp-payload-withdraw"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Lighter withdraw payload shape","slug":"lighter-withdraw-payload-shape","depth":3,"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":"Example — Lighter withdraw 100 USDC","slug":"example-—-lighter-withdraw-100-usdc","depth":3,"children":[]}],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"tags":["V2 - Perps"],"summary":"Build withdraw payload","description":"Build a signed canonical payload to withdraw USDC collateral from a perpetual DEX account back to the user's wallet.","requestBody":"7ec110d8-9577-4aee-a618-cf0c58fd974c","responses":{"200":"e7a1388a-a9c9-4511-b4b0-6ee131c7c249"},"method":"post","type":"path","servers":["c25b9009-8f4e-492f-b743-eb62a864816a","34680ce8-88e4-4b86-942f-2cc9fb5ef9e7"],"security":[],"path":"/2/perp/payloads/withdraw","baseUrlOptions":["https://demo-api.mobula.io/api/","https://api.mobula.io/api/"],"title":"Build withdraw payload","codeSamples":[],"requiredOnlyExamples":false,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"timestamp":{"type":"number","isRequired":true,"uniqueKey":"timestamp","typeLabel":"number"},"signature":{"type":"string","isRequired":true,"uniqueKey":"signature","typeLabel":"string"},"dex":{"type":"string","enum":["lighter"],"isRequired":true,"uniqueKey":"dex","typeLabel":"enum\u003cstring>"},"chainId":{"type":"string","description":"Lighter chain (e.g., lighter:301).","isRequired":true,"uniqueKey":"chainId","typeLabel":"string"},"amountUsdc":{"type":"string","description":"USDC amount as a decimal string. Must be positive.","isRequired":true,"uniqueKey":"amountUsdc","typeLabel":"string"}},"required":["timestamp","signature","dex","chainId","amountUsdc"],"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"timestamp":123,"signature":"\u003cstring>","dex":"lighter","chainId":"\u003cstring>","amountUsdc":"\u003cstring>"}}},"exampleType":"generated"}},"exampleType":"generated"},"responses":{"e7a1388a-a9c9-4511-b4b0-6ee131c7c249":{"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 Withdraw Payload - Mobula API","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-14T12:21:07.536Z","originalFileLocation":"exec/perps/perp-payload-withdraw.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 withdraw USDC collateral from a perpetual DEX account back to the user\u0026#x27;s wallet.\">\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 Withdraw Payload - Mobula API\">\u003cmeta data-mint-head property=\"og:description\" content=\"Build a signed canonical payload to withdraw USDC collateral from a perpetual DEX account back to the user\u0026#x27;s wallet.\">\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-withdraw\">\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+Withdraw+Payload\u0026amp;description=Build+a+signed+canonical+payload+to+withdraw+USDC+collateral+from+a+perpetual+DEX+account+back+to+the+user%27s+wallet.\u0026amp;theme=b31399aac8a2a0583f71b753\u0026amp;signature=a5eb3f6769c4ac118e51a0f0a4029b7917716d549c8ddc0a3cd652ccc90d89d2\">\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 Withdraw Payload - Mobula API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Build a signed canonical payload to withdraw USDC collateral from a perpetual DEX account back to the user\u0026#x27;s wallet.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://mobulalabs.mintlify.io/_mintlify/api/og/v2?division=Execution\u0026amp;title=Build+Withdraw+Payload\u0026amp;description=Build+a+signed+canonical+payload+to+withdraw+USDC+collateral+from+a+perpetual+DEX+account+back+to+the+user%27s+wallet.\u0026amp;theme=b31399aac8a2a0583f71b753\u0026amp;signature=a5eb3f6769c4ac118e51a0f0a4029b7917716d549c8ddc0a3cd652ccc90d89d2\">\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-withdraw\">\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-withdraw.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-withdraw#webpage\",\"url\":\"https://docs.mobula.io/exec/perps/perp-payload-withdraw\",\"name\":\"Build Withdraw Payload\",\"description\":\"Build a signed canonical payload to withdraw USDC collateral from a perpetual DEX account back to the user's wallet.\",\"dateModified\":\"2026-11-14T12:21:07.536Z\",\"isPartOf\":{\"@id\":\"https://docs.mobula.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.mobula.io/exec/perps/perp-payload-withdraw#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.mobula.io/exec/perps/perp-payload-withdraw#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Execution\",\"item\":\"https://docs.mobula.io/exec/perps/perp-quote\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Build Withdraw Payload\",\"item\":\"https://docs.mobula.io/exec/perps/perp-payload-withdraw\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.mobula.io/exec/perps/perp-payload-withdraw#apireference\",\"headline\":\"Build Withdraw Payload\",\"name\":\"Build Withdraw Payload\",\"description\":\"Build a signed canonical payload to withdraw USDC collateral from a perpetual DEX account back to the user's wallet.\",\"url\":\"https://docs.mobula.io/exec/perps/perp-payload-withdraw\",\"mainEntityOfPage\":{\"@id\":\"https://docs.mobula.io/exec/perps/perp-payload-withdraw#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-withdraw.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","href":"/exec/perps/perp-quote"},{"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"},{"public":true,"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","description":"Build a signed canonical payload to open a new perpetual position on Gains Network or Lighter. The response is submitted as-is to /2/perp/execute-v2.","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 Withdraw 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"]}