diff --git a/src/main/java/com/kryptokrauts/shared/BaseMapper.java b/src/main/java/com/kryptokrauts/shared/BaseMapper.java index 5edaa29..8400784 100644 --- a/src/main/java/com/kryptokrauts/shared/BaseMapper.java +++ b/src/main/java/com/kryptokrauts/shared/BaseMapper.java @@ -120,7 +120,21 @@ public static _PriceInfo buildPriceInfo( return null; } + /** + * rounding an unknown value yields an unknown value. + * + *

This used to unbox its argument and throw. That was harmless while every usd value was a + * number, but #7 made them null when no exchange rate exists for the token, and the callers that + * hand a usd value straight to this method started returning 500 instead - NFTService#getNFTDetail + * on any nft whose template has a floor listing priced in such a token, for one. + * + *

Guarding here rather than at each of the callers: there are more than twenty of them, they + * are spread over several repositories, and every one of them wants the same answer. + */ public static Double roundTo(Double value, int decimals) { + if (value == null) { + return null; + } return Math.round(value * Math.pow(10, decimals)) / Double.valueOf(Math.pow(10, decimals)); }