Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
fix: applies better filter rounding (#337)
Browse files Browse the repository at this point in the history
Co-authored-by: Juraj Piar <[email protected]>
  • Loading branch information
jurajpiar and jurajpiar authored Sep 1, 2020
1 parent 6a37cde commit a171087
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/api/rif-marketplace-cache/rns/offers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ const fetchPriceLimit = async (service, limitType: LimitType): Promise<number> =
}
const results = await service.find({ query })

// Gets the result parses it io the correct decimal and ensures that the limits are always 1bigger/smaller than the actual largest/smallest price
// Gets the result parses it to the correct decimal and rounds it: up for max, down for min
return results.reduce(
(_, item: { priceString: string }): number => Math.round(parseToInt(item.priceString, 18)) - limitType,
(_, item: { priceString: string }): number => {
const round = limitType === LimitType.min ? Math.floor : Math.ceil
return round(parseToInt(item.priceString, 18))
},
0,
)
}
Expand Down

0 comments on commit a171087

Please sign in to comment.