export type TradingPlaceOrderSendReqDto = {stockAddress: string, side: 'Buy' | 'Sell', type: 'Limit' | 'Market', quantity?: number | undefined, notional?: number | undefined, price?: number | undefined, timeInForce?: ('DAY' | 'GTC' | 'OPG' | 'IOC' | 'FOK' | 'GTX' | 'GTD' | 'CLS') | undefined, deadline: number, gasLimit?: number | undefined, deferred?: boolean | undefined}; export type CreateApiApiV1OrdersSendArgs = {body: TradingPlaceOrderSendReqDto}; export type CreateApiApiV1OrdersSendOptions = {baseUrl?: string | undefined, TradingApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send place order transaction through One Click * * POST /api/v1/orders/send * * Also accepts auth: TradingApiNonce, TradingApiTimestamp, TradingApiSignature, ApiChainId, ApiProductType */ export const createApiApiV1OrdersSend = async (args: CreateApiApiV1OrdersSendArgs, options?: CreateApiApiV1OrdersSendOptions) => { const {baseUrl = "https://rwa-api.anchored.finance/rwa/trading", fetch: fetchFn = fetch, TradingApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (TradingApiKey !== undefined) headers.set("x-api-key", TradingApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/orders/send${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };