UNPKG

@renegade-fi/core

Version:
27 lines 1.42 kB
import invariant from 'tiny-invariant'; import { toHex } from 'viem'; import { ADMIN_CREATE_ORDER_IN_MATCHING_POOL_ROUTE } from '../constants.js'; import { stringifyForWasm } from '../utils/bigJSON.js'; import { postRelayerWithAdmin } from '../utils/http.js'; import { getBackOfQueueWallet } from './getBackOfQueueWallet.js'; import { getWalletId } from './getWalletId.js'; export async function createOrderInMatchingPool(config, parameters) { const { id = '', base, quote, side, amount, worstCasePrice = '', minFillSize = BigInt(0), allowExternalMatches = false, matchingPool, } = parameters; const { getBaseUrl, utils, state: { seed }, } = config; invariant(seed, 'Seed is required'); const walletId = getWalletId(config); const wallet = await getBackOfQueueWallet(config); const body = await utils.new_order_in_matching_pool(seed, stringifyForWasm(wallet), id, base, quote, side, toHex(amount), worstCasePrice, toHex(minFillSize), allowExternalMatches, matchingPool); try { const res = await postRelayerWithAdmin(config, getBaseUrl(ADMIN_CREATE_ORDER_IN_MATCHING_POOL_ROUTE(walletId)), body); console.log(`task update-wallet(${res.task_id}): ${walletId}`); return { taskId: res.task_id }; } catch (error) { console.error(`${walletId}`, { error, }); throw error; } } //# sourceMappingURL=createOrderInMatchingPool.js.map