import type { AcceptTermsParams } from './acceptTerms.js'; import type { ActionType, MarginMode, OrderSide, OrderStatus, OrderType, PerpsErrorCode, TimeInForce, TriggerCondition, TwapOrderStatus } from './enums.js'; import type { MarketDisplay, MarketRef } from './market.js'; import type { Address, Hex } from './primitives.js'; import type { PerpsTypedData } from './typedData.js'; export interface Eip712ActionStep { action: ActionType; typedData: PerpsTypedData; } export interface WasmBlobActionStep { action: ActionType; wasmSignParams: Record; } export interface EvmCall { chainId: number; to: Address; functionName: string; args: readonly unknown[]; abi: readonly string[]; } export interface EvmTxActionStep { action: ActionType; txParams: EvmCall; } export interface HmacActionStep { action: ActionType; request: { method: 'GET' | 'POST' | 'PUT' | 'DELETE'; path: string; body?: string; }; } export interface CreateDepositAddressSessionMarker { network: 'ethereum'; symbol: 'USDC'; depositDestination: { wallet: 'margin'; }; } export type SessionActionStep = { action: Exclude; session: Record; } | { action: ActionType.CREATE_DEPOSIT_ADDRESS; session: CreateDepositAddressSessionMarker; }; export interface SiweActionStep { action: ActionType; siwe: { challengeId: string; message: string; }; } export type ActionStep = Eip712ActionStep | WasmBlobActionStep | EvmTxActionStep | HmacActionStep | SessionActionStep | SiweActionStep; export interface Eip712SignedActionStep { action: ActionType; typedData: PerpsTypedData; signature: Hex; } export interface WasmBlobSignedActionStep { action: ActionType; wasmSignParams: Record; signedTx: { txType: number; txInfo: string; txHash: string; }; } export interface EvmTxSignedActionStep { action: ActionType; txParams: EvmCall; txHash: string; } export interface HmacSignedActionStep { action: ActionType; request: HmacActionStep['request']; hmac: { keyId: string; timestampMs: number; signature: string; }; } export interface SiweSignedActionStep { action: ActionType; siwe: SiweActionStep['siwe']; signature: Hex; } export type SignedActionStep = Eip712SignedActionStep | WasmBlobSignedActionStep | EvmTxSignedActionStep | HmacSignedActionStep | SiweSignedActionStep; export type ActionResult = { action: ActionType; success: true; orderId?: string; twapId?: string; txHash?: string; explorerLink?: string; } | { action: ActionType; success: false; error: string; errorCode?: PerpsErrorCode; }; export interface TriggerOrderInput { triggerPrice: string; limitPrice?: string; size?: string; } export interface ModifyOrderInput { id: string; price?: string; size?: string; triggerPrice?: string; limitPrice?: string; } export interface Order { orderId: string; market: MarketDisplay; side: OrderSide; type: OrderType; price?: string; originalSize: string; remainingSize: string; filledSize: string; timeInForce?: TimeInForce; expiresAt?: string; reduceOnly?: boolean; isTrigger?: boolean; triggerPrice?: string; triggerCondition?: TriggerCondition; status: OrderStatus; statusReason?: string; averagePrice?: string; createdAt: string; updatedAt: string; } export interface PlaceOrderParams { market: MarketRef; side: OrderSide; type?: Exclude; size: string; price?: string; leverage?: number; marginMode?: MarginMode; reduceOnly?: boolean; timeInForce?: TimeInForce; expiresAt?: string; takeProfit?: TriggerOrderInput; stopLoss?: TriggerOrderInput; } export interface PlaceTriggerOrderParams { market: MarketRef; side: OrderSide; takeProfit?: TriggerOrderInput; stopLoss?: TriggerOrderInput; } export interface PlaceTwapOrderParams { market: MarketRef; side: OrderSide; size: string; durationSeconds: number; reduceOnly?: boolean; randomize?: boolean; frequencySeconds?: number; minPrice?: string; maxPrice?: string; } export interface CancelTwapOrderParams { market: MarketRef; twapId: string; } export interface TwapOrder { twapId: string; market: MarketDisplay; side: OrderSide; totalSize: string; filledSize: string; avgFillPrice?: string; startedAt: string; durationSeconds: number; status: TwapOrderStatus; } export interface CancelOrderParams { ids: string[]; assetId?: string; } export interface ModifyOrderParams { modifications: ModifyOrderInput[]; } export interface UpdateLeverageParams { market: MarketRef; leverage: number; marginMode?: MarginMode; } export interface UpdatePositionMarginParams { market: MarketRef; action: 'add' | 'remove'; amount: string; } export interface UpdateAssetCollateralParams { assetId: string; enabled: boolean; } export interface WithdrawalParams { destination: Address; amount: string; } export interface DepositParams { amount: string; tokenAddress: Address; chainId: number; } export interface ApproveAgentParams { agentAddress: string; agentTtlMs?: number; } export interface AccountModeParams { mode: string; } export interface AccountTypeParams { tier: string; } export interface SendAssetParams { collateral: string; sourceDex: string; destinationDex: string; amount: string; } export interface CancelAllOrdersParams { timeInForce: number; timestampMs?: number; } export interface RegisterApiKeyParams { knownPublicKey?: string; } export interface ApproveReadOnlyTokenParams { accountIndex: number; expirySeconds: number; scope: 'single' | 'all'; } export interface ActionParamsMap { [ActionType.APPROVE_AGENT]: ApproveAgentParams; [ActionType.APPROVE_BUILDER_FEE]: Record; [ActionType.APPROVE_INTEGRATOR]: Record; [ActionType.SET_REFERRAL]: Record; [ActionType.ACCOUNT_MODE]: AccountModeParams; [ActionType.ACCOUNT_TYPE]: AccountTypeParams; [ActionType.SEND_ASSET]: SendAssetParams; [ActionType.WITHDRAWAL]: WithdrawalParams; [ActionType.TRANSFER]: Record; [ActionType.PLACE_ORDER]: PlaceOrderParams; [ActionType.PLACE_TRIGGER_ORDER]: PlaceTriggerOrderParams; [ActionType.PLACE_TWAP_ORDER]: PlaceTwapOrderParams; [ActionType.CANCEL_ORDER]: CancelOrderParams; [ActionType.CANCEL_ALL_ORDERS]: CancelAllOrdersParams; [ActionType.CANCEL_TWAP_ORDER]: CancelTwapOrderParams; [ActionType.MODIFY_ORDER]: ModifyOrderParams; [ActionType.UPDATE_LEVERAGE]: UpdateLeverageParams; [ActionType.UPDATE_POSITION_MARGIN]: UpdatePositionMarginParams; [ActionType.UPDATE_ASSET_COLLATERAL]: UpdateAssetCollateralParams; [ActionType.REGISTER_API_KEY]: RegisterApiKeyParams; [ActionType.APPROVE_READ_ONLY_TOKEN]: ApproveReadOnlyTokenParams; [ActionType.SIWE_LOGIN]: Record; [ActionType.CREATE_DEPOSIT_ADDRESS]: Record; [ActionType.ACCEPT_PROVIDER_TERMS]: Record; [ActionType.DEPOSIT]: DepositParams; [ActionType.META_ACCEPT_TERMS]: AcceptTermsParams; } export type CreateActionRequest = { [K in ActionType]: { provider: string; address: Address; signerAddress?: Address; action: K; params: ActionParamsMap[K]; }; }[ActionType]; export interface CreateActionResponse { actions: ActionStep[]; } export type ExecuteActionRequest = { [K in ActionType]: { provider: string; address: Address; signerAddress?: Address; action: K; actions: SignedActionStep[]; }; }[ActionType]; export interface ExecuteActionResponse { results: ActionResult[]; } //# sourceMappingURL=action.d.ts.map