Build a signed canonical payload to add or remove collateral from an open perpetual position (Lighter) or change its per-trade leverage (Gains).
Adjusts margin on an open position. The exact semantics depend on the DEX:Documentation Index
Fetch the complete documentation index at: https://docs.mobula.io/llms.txt
Use this file to discover all available pages before exploring further.
usdcAmount and increase to add or remove USDC collateral on the market’s position.newLeverage to change the trade’s leverage, which effectively adjusts its collateral.gains or lighter.true to add margin, false to remove it./2/perp/payloads/<action> endpoint verifies the caller by requiring two extra fields in the request body alongside the action parameters:
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.| Status | message |
|---|---|
| 403 | timestamp expired — timestamp older than 30s |
| 403 | signature already used — replay attempt |
| 400 | zod validation failed — timestamp/signature shape invalid |
/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.
| Status | message |
|---|---|
| 400 | update-margin payload action failed — missing position, wrong leg supplied for the DEX, or DEX refusal |
usdcAmount+increase, Gains evm-tx with newLeverage). The flow branches on data.transport.
gains, lighter Gains trade index. Required for Gains.
Lighter only. USDC amount to add or remove (> 0).
Lighter only. true = add margin, false = remove.
Gains only. New per-trade leverage (> 0).