Skip to main content
All mutating operations — trading, withdrawals, leverage changes, position margin, account setup — flow through the same two service functions: createAction and executeAction. For trading actions, the Trading pages document the convenience wrappers (placeOrder, cancelOrders, etc.) that handle createAction, agent-signing, and executeAction automatically. Those wrappers are the supported public surface for trade dispatch — createAction/executeAction are documented here for completeness and for action types that don’t have a dedicated wrapper. Withdrawals and account setup also flow through these endpoints, but the SDK exposes higher-level helpers (withdraw, checkSetup / executeProviderSetup) that should be preferred.

Pattern

createAction → actions[] → sign each step → executeAction → results[]
  1. Create — call createAction() with the action type and params. Returns one or more ActionStep payloads. Each step’s shape depends on the action’s signingMethod: EIP-712 typed data (Hyperliquid and other EVM dexes), a WASM-signer blob (Lighter), or an EVM transaction (e.g. Lighter deposit).
  2. Sign — sign each step with the appropriate signer for its shape. For trade actions this is the SDK-managed agent (the high-level methods do this for you). For setup actions, withdrawals, and on-chain deposits it is the user’s L1 wallet. Use signProviderSetupAction to dispatch by step shape without embedding per-method logic.
  3. Execute — call executeAction() with the signed payloads. Returns success/failure for each action.

createAction

Build action payloads for signing.
import { createAction } from '@lifi/perps-sdk';

const { actions } = await createAction(client, {
  provider: 'hyperliquid',
  address: userAddress,
  action: 'placeOrder',
  params: {
    market: { marketId: 'BTC', categoryId: 'hyperliquid' },
    side: 'BUY',
    type: 'LIMIT',
    size: '0.1',
    price: '94000.00',
    timeInForce: 'GTC',
  },
});

// actions: ActionStep[] — one or more payloads to sign

Parameters

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client
params.providerstringYesProvider identifier
params.addressstringYesUser’s wallet address (account owner)
params.signerAddressstringNoAddress that will sign. For agent-signed trade actions this is the agent address; for user-signed setup actions it defaults to address.
params.actionActionTypeYesAction type (see Action Types)
params.paramsobjectYesAction-specific parameters (see Actions API)
optionsSDKRequestOptionsNoRequest options

Returns

CreateActionResponse{ actions: ActionStep[] }. ActionStep is a discriminated union by structural shape — the SDK dispatches to the correct signer based on which key is present. The variant that comes back is determined by the action’s signingMethod on the provider descriptor (see SigningMethod). Eip712ActionStep — EIP-712 typed-data flow (Hyperliquid; most actions):
FieldTypeDescription
actionActionTypeAction type
typedDataPerpsTypedDataEIP-712 typed data to sign
WasmBlobActionStep — WASM signer flow (Lighter):
FieldTypeDescription
actionActionTypeAction type
wasmSignParamsRecord<string, unknown>Parameters fed to the provider’s WASM signer
EvmTxActionStep — on-chain EVM transaction (e.g. Lighter deposit):
FieldTypeDescription
actionActionTypeAction type
txParamsRecord<string, unknown>Transaction parameters (chainId, to, functionName, args, abi) submitted by the SDK
A single createAction call may return multiple actions. For example, placeOrder with a leverage param different from the current setting returns both an updateLeverage and a placeOrder step.

executeAction

Submit signed action payloads.
import { executeAction } from '@lifi/perps-sdk';

const result = await executeAction(client, {
  provider: 'hyperliquid',
  address: userAddress,
  action: 'placeOrder',
  actions: signedActions,
});

for (const r of result.results) {
  console.log(r.action, r.success, r.orderId);
}

Parameters

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client
params.providerstringYesProvider identifier
params.addressstringYesUser’s wallet address (account owner)
params.signerAddressstringNoAddress that signed. For agent-signed actions this is the agent address; otherwise defaults to address.
params.actionActionTypeYesAction type from the create request
params.actionsSignedActionStep[]YesSigned payloads from createAction
optionsSDKRequestOptionsNoRequest options
SignedActionStep is a discriminated union that mirrors ActionStep — each variant carries the original payload plus its signed artefact. Eip712SignedActionStep:
FieldTypeDescription
actionActionTypeAction type from the create response
typedDataPerpsTypedDataOriginal typedData from createAction
signatureHexSigner’s signature of the typedData
WasmBlobSignedActionStep:
FieldTypeDescription
actionActionTypeAction type from the create response
wasmSignParamsRecord<string, unknown>Original wasmSignParams from createAction
signedTx{ txType, txInfo, txHash }Output of the provider’s WASM signer
EvmTxSignedActionStep:
FieldTypeDescription
actionActionTypeAction type from the create response
txParamsRecord<string, unknown>Original txParams from createAction
txHashstringOn-chain transaction hash after the SDK has broadcast the tx

Returns

ExecuteActionResponse{ results: ActionResult[] }: Each ActionResult:
FieldTypeDescription
actionActionTypeAction type
successbooleanWhether the action was accepted
orderIdstring?Order ID (for placeOrder and placeTriggerOrder)
errorstring?Error message if failed

Action Types

All action types from the provider’s setup, options, and actions arrays can be used with createAction/executeAction:
ActionCategoryDescription
approveAgentSetupAuthorize an agent wallet
approveBuilderFeeSetupApprove builder fee
accountModeOptionsSwitch account operating mode (e.g. Hyperliquid abstraction variant, Lighter UTA/Simple). Accepts either signer; the backend dispatches to the right typed-data builder based on which key signs.
accountTypeOptionsSwitch account fee/latency tier (e.g. Lighter standard/premium). Omitted by providers with no tiering.
registerApiKeySetupRegister or rotate a Lighter API-key slot
placeOrderTradingPlace a new order
placeTriggerOrderTradingPlace standalone TP/SL
cancelOrderTradingCancel orders by ID
cancelAllOrdersTradingCancel every open order on the account
modifyOrderTradingModify existing orders
updateLeverageTradingChange leverage (and optionally margin mode) for an asset
updatePositionMarginTradingAdd/remove margin on a position
withdrawalTransferWithdraw funds to L1
depositTransferFund the account via an L1 bridge transaction
transferTransferInternal balance transfer (provider-specific)
sendAssetTransferMove collateral between sub-exchanges
For parameter schemas per action type, see Actions API. For the high-level convenience wrappers that handle agent signing automatically, see SDK / Trading. API Reference: POST /createAction, POST /executeAction