From 53f36914472e035b9efb90edc0b4e0d651087b37 Mon Sep 17 00:00:00 2001 From: Gorshtak Date: Mon, 23 Dec 2024 17:16:37 +0100 Subject: [PATCH] fix ts errors --- package.json | 2 +- src/utils/markets.ts | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 9448a6a..3e0248f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "overtime-live-trading-utils", - "version": "1.1.5", + "version": "1.1.6", "description": "", "main": "main.js", "scripts": { diff --git a/src/utils/markets.ts b/src/utils/markets.ts index 33f5b16..73f6273 100644 --- a/src/utils/markets.ts +++ b/src/utils/markets.ts @@ -58,13 +58,12 @@ export const processMarket = ( let finalProbability = probability; if (probability < 0.95) { - finalProbability = - leagueInfoByTypeId && leagueInfoByTypeId.addedSpread > 0 - ? (probability * (100 + leagueInfoByTypeId.addedSpread)) / 100 - : probability; - // edge case if added spread is bigger than 5%, it can happen that odd goes above 1, in that case return odd from api. - if (finalProbability >= 1) { - finalProbability = probability; + if (leagueInfoByTypeId && leagueInfoByTypeId.addedSpread) { + finalProbability = (probability * (100 + leagueInfoByTypeId.addedSpread)) / 100; + // edge case if added spread is bigger than 5%, it can happen that odd goes above 1, in that case return odd from api. + if (finalProbability >= 1) { + finalProbability = probability; + } } } @@ -110,12 +109,12 @@ export const processMarket = ( let finalProbability = probability; if (probability < 0.95) { - finalProbability = - leagueInfoByTypeId && leagueInfoByTypeId.addedSpread > 0 - ? (probability * (100 + leagueInfoByTypeId.addedSpread)) / 100 - : probability; - if (finalProbability >= 1) { - finalProbability = probability; + if (leagueInfoByTypeId && leagueInfoByTypeId.addedSpread) { + finalProbability = (probability * (100 + leagueInfoByTypeId.addedSpread)) / 100; + // edge case if added spread is bigger than 5%, it can happen that odd goes above 1, in that case return odd from api. + if (finalProbability >= 1) { + finalProbability = probability; + } } } return {