/** * @example * { * account_id: "biz_xxxxxxxxxxxxxx", * type: "close" * } */ export interface CreateTradesRequest { /** The account or user whose wallet trades, prefixed `biz_` or `user_`. */ account_id: string; /** Only for a deposit or withdraw, and required for both. For a deposit, the USDT0 to send from the wallet, with at most 6 decimals. For a withdraw, the USDC to send back, at least 1 with at most 6 decimals, or `all`. */ amount?: string; /** Only for an order. Your own ID for the trade, 1 to 128 characters, unique for the account. Sending it again with the same order returns the same trade; with a different order it answers `409`. */ client_order_id?: string; /** `perpetual` or `spot`. Required for an order. A spot order first switches the trading account to Hyperliquid's unified account mode, where spot and perpetuals share one USDC balance. */ instrument_type?: CreateTradesRequest.InstrumentType; /** Only for a perpetual order. The cross leverage, from 1 to the market's maximum. Required unless `reduce_only`; not accepted on a reduce-only order. */ leverage?: number; /** The market: a perpetual such as `BTC`, or for spot a pair priced in USDC such as `HYPE/USDC`. Required for an order or close, and a close takes only a perpetual; not accepted for a deposit or withdraw. */ market?: string; /** Only for an order. Free-form string-to-string annotations: up to 50 keys of at most 40 characters, values up to 500 characters. */ metadata?: Record; /** Only for an order. The order value in USD, as a decimal string; the size is rounded down to the market's decimals. Send exactly one of `size` or `notional`. */ notional?: string; /** `market` fills now within `slippage_bps` of the mid price; `limit` fills now at `price` or better. Anything unfilled is canceled. Required for an order. */ order_type?: CreateTradesRequest.OrderType; /** Only for an order. The limit price in USD, as a decimal string Hyperliquid accepts without rounding. Required for a limit order; not accepted for a market order. */ price?: string; /** Only for a perpetual order. Only reduce an open position; defaults to `false`. A reduce-only order takes no `leverage`. */ reduce_only?: boolean; /** `buy` or `sell`. Required for an order. */ side?: CreateTradesRequest.Side; /** Only for an order. The size in units of the market, as a decimal string, with at most the market's size decimals. Send exactly one of `size` or `notional`. The order must be worth at least 10 USD, unless reduce-only, and at most 5000 USD. */ size?: string; /** Only for a market order or a close. The worst price as basis points from the mid price, from 1 to 1000; defaults to 100. */ slippage_bps?: number; /** `order` places one order from the trading balance, setting cross `leverage` first on a perpetual; when the balance is short, it bridges the USDT0 it needs from the wallet first. `deposit` bridges `amount` USDT0 from the wallet to the trading balance. `withdraw` sends `amount` USDC (or `all`) from the trading balance back to the wallet. `close` closes the whole position in `market` with a market reduce-only order; when the account is then flat, a `withdraw` trade sends the trading balance back to the wallet. */ type: CreateTradesRequest.Type; } export declare namespace CreateTradesRequest { /** `perpetual` or `spot`. Required for an order. A spot order first switches the trading account to Hyperliquid's unified account mode, where spot and perpetuals share one USDC balance. */ const InstrumentType: { readonly Perpetual: "perpetual"; readonly Spot: "spot"; }; type InstrumentType = (typeof InstrumentType)[keyof typeof InstrumentType]; /** `market` fills now within `slippage_bps` of the mid price; `limit` fills now at `price` or better. Anything unfilled is canceled. Required for an order. */ const OrderType: { readonly Market: "market"; readonly Limit: "limit"; }; type OrderType = (typeof OrderType)[keyof typeof OrderType]; /** `buy` or `sell`. Required for an order. */ const Side: { readonly Buy: "buy"; readonly Sell: "sell"; }; type Side = (typeof Side)[keyof typeof Side]; /** `order` places one order from the trading balance, setting cross `leverage` first on a perpetual; when the balance is short, it bridges the USDT0 it needs from the wallet first. `deposit` bridges `amount` USDT0 from the wallet to the trading balance. `withdraw` sends `amount` USDC (or `all`) from the trading balance back to the wallet. `close` closes the whole position in `market` with a market reduce-only order; when the account is then flat, a `withdraw` trade sends the trading balance back to the wallet. */ const Type: { readonly Close: "close"; readonly Order: "order"; readonly Deposit: "deposit"; readonly Withdraw: "withdraw"; }; type Type = (typeof Type)[keyof typeof Type]; }