Updated on 2026-08-14

This commit is contained in:
Tangem 2026-05-06 10:35:39 +02:00
parent a107f9299d
commit 13f139afa8
3 changed files with 63 additions and 2 deletions

View file

@ -15,6 +15,7 @@ import com.tangem.domain.markets.TokenMarket
import com.tangem.features.feed.impl.R
import com.tangem.features.feed.model.market.list.state.MarketsListUM
import com.tangem.utils.converter.Converter
import com.tangem.utils.logging.TangemLogger
import kotlinx.collections.immutable.toImmutableList
import java.math.BigDecimal
import java.math.RoundingMode
@ -92,7 +93,15 @@ internal class MarketsTokenItemConverter(
private fun TokenMarket.getCurrentPrice(prev: TokenMarket? = null): MarketsListItemUM.Price {
val prevPrice = prev?.tokenQuotesShort?.currentPrice
val priceText = tokenQuotesShort.currentPrice.format {
val currentPrice = tokenQuotesShort.currentPrice
if (currentPrice < BigDecimal.ZERO) {
TangemLogger.withTag(MARKETS_PRICE_LOG_TAG).w(
messageString = "Unexpected non-positive price for tokenId=$id, symbol=$symbol, " +
"currency=${appCurrency.code}, value=${currentPrice.toPlainString()}",
)
}
val priceText = currentPrice.format {
fiat(
fiatCurrencyCode = appCurrency.code,
fiatCurrencySymbol = appCurrency.symbol,
@ -162,4 +171,8 @@ internal class MarketsTokenItemConverter(
return percent.format { percent() }
}
private companion object {
const val MARKETS_PRICE_LOG_TAG = "MarketsTokenItemConverter"
}
}