From e33e7ba2e699b25efdd7e16dd779b57d802e5971 Mon Sep 17 00:00:00 2001 From: Jack Peterson Date: Mon, 23 Oct 2017 15:10:24 -0700 Subject: [PATCH] Added if exists with nonzero length check to last price lookup --- src/blockchain/log-processors/order-filled.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/blockchain/log-processors/order-filled.ts b/src/blockchain/log-processors/order-filled.ts index 873a4f1d7..94d6aaeaa 100644 --- a/src/blockchain/log-processors/order-filled.ts +++ b/src/blockchain/log-processors/order-filled.ts @@ -75,6 +75,7 @@ export function calculateProfitLossInOutcome(augur: Augur, trx: Knex.Transaction if (err) return callback(err); trx.select("price").from("outcomes").where({ marketID, outcome }).asCallback((err: Error|null, outcomesRows?: Array): void => { if (err) return callback(err); + if (!outcomesRows || !outcomesRows.length) return callback(null); const { price } = outcomesRows![0]; callback(null, augur.trading.calculateProfitLoss({ trades: userTradingHistory, lastPrice: price })); });