import type { BaseAPI } from "../api"; import type { OrderSide, OrderType, PositionSide } from "../trading"; export interface MarginAccountSummary { margin_account_id: string; account_state: string; equity: string; initial_margin_required: string; maintenance_margin_required: string; free_collateral: string; withdrawable_collateral: string; total_position_notional: string; unrealized_pnl: string; realized_pnl: string; updated_at: string; } export interface ListMarginAccountsParams { page?: number; page_size?: number; state?: string; } export interface ListMarginAccountsResponse { accounts: MarginAccountSummary[]; total: number; page: number; page_size: number; } export interface CreateMarginAccountRequest { label?: string; collateralAsset?: string; } export interface CreateMarginAccountResponse { margin_account_id: string; account_state: string; collateral_asset: string; created_at: string; } export interface GetAvailableCollateralParams { asset?: string; } export interface GetAvailableCollateralResponse { asset: string; wallet_available: string; wallet_locked: string; margin_transferable?: string; } export interface TransferCollateralRequest { asset: string; amount: string; } export interface TransferCollateralResponse { movement_id: string; margin_account_id: string; asset: string; amount: string; status: string; new_equity: string; } export interface GetMarginAccountMovementsParams { movement_type?: string; page?: number; page_size?: number; } export interface MarginAccountMovement { movement_id: string; margin_account_id: string; movement_type: string; asset: string; amount: string; created_at: string; } export interface GetMarginAccountMovementsResponse { movements: MarginAccountMovement[]; total: number; page: number; page_size: number; } export interface SimulateOrderRiskRequest { tradingPairId: string; side: OrderSide; positionSide: PositionSide; orderType: OrderType; price?: string; quantity: string; leverage: string; reduceOnly?: boolean; } export interface SimulateOrderRiskResponse { accepted: boolean; reject_reason?: string; equity_after: string; initial_margin_required_after: string; maintenance_margin_required_after: string; free_collateral_after: string; estimated_fee?: string; estimated_liquidation_price?: string; } export interface MarginAccountsAPI extends BaseAPI { listMarginAccounts(params?: ListMarginAccountsParams): Promise; createMarginAccount(request?: CreateMarginAccountRequest): Promise; getMarginAccountSummary(marginAccountId: string): Promise; getAvailableCollateral(params?: GetAvailableCollateralParams): Promise; transferCollateralToMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise; transferCollateralFromMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise; getMarginAccountMovements(marginAccountId: string, params?: GetMarginAccountMovementsParams): Promise; simulateOrderRisk(marginAccountId: string, request: SimulateOrderRiskRequest): Promise; }