From dbb2a8c2d8d9f6f97bce020abc010ef7d5d3a111 Mon Sep 17 00:00:00 2001 From: Anxo Rodriguez Date: Thu, 5 Dec 2024 18:50:11 +0000 Subject: [PATCH] feat: show id of order and tx hash when posting the discrete order (#169) # Description This PR is the most pressing change in the proposal to improve debuggability of watch-tower described in https://docs.google.com/document/d/1rNM4pqS-d17Yx1Ei_RMMvER5vJfK1c8I7Ik74PbOHSc/edit?tab=t.0 Basically, this PR allows us to connect the discrete orders with the programmatic order that created them. This is really important, because we can connect some issues on some orders that are wrongly created by a smart contract, with the smart contract that created them in the first place. --- src/domain/polling/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/domain/polling/index.ts b/src/domain/polling/index.ts index a575019..1453af3 100644 --- a/src/domain/polling/index.ts +++ b/src/domain/polling/index.ts @@ -317,6 +317,7 @@ async function _processConditionalOrder( ): Promise { const { provider, orderBookApi, dryRun, chainId } = context; const { handler } = conditionalOrder.params; + const log = getLogger( "checkForAndPlaceOrder:_processConditionalOrder", orderRef @@ -412,6 +413,7 @@ async function _processConditionalOrder( if (!conditionalOrder.orders.has(orderUid)) { // Place order const placeOrderResult = await _placeOrder({ + conditionalOrder, orderUid, order: { ...orderToSubmit, from: owner, signature }, orderBookApi, @@ -500,6 +502,7 @@ export const _printUnfilledOrders = (orders: Map) => { * @param apiUrl rest api url */ async function _placeOrder(params: { + conditionalOrder: ConditionalOrder; orderUid: string; order: any; orderBookApi: OrderBookApi; @@ -509,6 +512,7 @@ async function _placeOrder(params: { metricLabels: string[]; }): Promise | PollResultErrors> { const { + conditionalOrder, orderUid, order, orderBookApi, @@ -518,7 +522,6 @@ async function _placeOrder(params: { metricLabels, } = params; const log = getLogger("checkForAndPlaceOrder:_placeOrder", orderRef); - const { chainId } = orderBookApi.context; try { const postOrder: OrderCreation = { kind: order.kind, @@ -539,7 +542,9 @@ async function _placeOrder(params: { }; // If the operation is a dry run, don't post to the API - log.info(`Post order ${orderUid} to OrderBook on chain ${chainId}`); + log.info( + `Post order ${orderUid} (ID=${conditionalOrder.id}, TX=${conditionalOrder.tx})` + ); log.debug(`Post order ${orderUid} details`, postOrder); if (!dryRun) { const orderUid = await orderBookApi.sendOrder(postOrder);