diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index cde7433..f85e921 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png index 0f00e74..e83a569 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png index cde7433..f85e921 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index 9c68418..0cc44bd 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png index 1645756..cd264cf 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png index 9c68418..0cc44bd 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index bf0fba0..eea1b2a 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png index 985aaa8..35bfaa8 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png index bf0fba0..eea1b2a 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 0240ebb..cbb3b16 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png index 417a8ea..4ab468b 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png index 0240ebb..cbb3b16 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index bf920ca..72240bd 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png index 83569e2..6e1d780 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png index bf920ca..72240bd 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/common/src/main/res/drawable-hdpi/ic_pezkuwi_logo.png b/common/src/main/res/drawable-hdpi/ic_pezkuwi_logo.png index 167cfe4..f36906b 100644 Binary files a/common/src/main/res/drawable-hdpi/ic_pezkuwi_logo.png and b/common/src/main/res/drawable-hdpi/ic_pezkuwi_logo.png differ diff --git a/common/src/main/res/drawable-ldpi/ic_pezkuwi_logo.png b/common/src/main/res/drawable-ldpi/ic_pezkuwi_logo.png index c75c738..35e260c 100644 Binary files a/common/src/main/res/drawable-ldpi/ic_pezkuwi_logo.png and b/common/src/main/res/drawable-ldpi/ic_pezkuwi_logo.png differ diff --git a/common/src/main/res/drawable-mdpi/ic_pezkuwi_logo.png b/common/src/main/res/drawable-mdpi/ic_pezkuwi_logo.png index 331d8dc..5305480 100644 Binary files a/common/src/main/res/drawable-mdpi/ic_pezkuwi_logo.png and b/common/src/main/res/drawable-mdpi/ic_pezkuwi_logo.png differ diff --git a/common/src/main/res/drawable-xhdpi/ic_pezkuwi_logo.png b/common/src/main/res/drawable-xhdpi/ic_pezkuwi_logo.png index 9c55c82..1b2f8f1 100644 Binary files a/common/src/main/res/drawable-xhdpi/ic_pezkuwi_logo.png and b/common/src/main/res/drawable-xhdpi/ic_pezkuwi_logo.png differ diff --git a/common/src/main/res/drawable-xxhdpi/ic_pezkuwi_logo.png b/common/src/main/res/drawable-xxhdpi/ic_pezkuwi_logo.png index 86f3861..968feb8 100644 Binary files a/common/src/main/res/drawable-xxhdpi/ic_pezkuwi_logo.png and b/common/src/main/res/drawable-xxhdpi/ic_pezkuwi_logo.png differ diff --git a/common/src/main/res/drawable-xxxhdpi/ic_pezkuwi_logo.png b/common/src/main/res/drawable-xxxhdpi/ic_pezkuwi_logo.png index 4074336..f861c18 100644 Binary files a/common/src/main/res/drawable-xxxhdpi/ic_pezkuwi_logo.png and b/common/src/main/res/drawable-xxxhdpi/ic_pezkuwi_logo.png differ diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/source/RealCoinPriceDataSource.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/source/RealCoinPriceDataSource.kt index 45332ab..e624102 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/source/RealCoinPriceDataSource.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/source/RealCoinPriceDataSource.kt @@ -11,8 +11,15 @@ import io.novafoundation.nova.feature_wallet_api.data.repository.PricePeriod import io.novafoundation.nova.feature_wallet_api.data.source.CoinPriceRemoteDataSource import io.novafoundation.nova.feature_wallet_api.domain.model.CoinRateChange import io.novafoundation.nova.feature_wallet_api.domain.model.HistoricalCoinRate +import java.math.BigDecimal import kotlin.time.Duration.Companion.milliseconds +private const val PRICE_ID_HEZ = "hezkurd" +private const val PRICE_ID_PEZ = "pezkuwi" +private const val PRICE_ID_DOT = "polkadot" +private val HEZ_DOT_DIVISOR = BigDecimal(3) +private val PEZ_DOT_DIVISOR = BigDecimal(10) + class RealCoinPriceDataSource( private val priceApi: ProxyPriceApi, private val coingeckoApi: CoingeckoApi, @@ -38,16 +45,50 @@ class RealCoinPriceDataSource( } override suspend fun getCoinRates(priceIds: Set, currency: Currency): Map { - val sortedPriceIds = priceIds.toList().sorted() - return apiCall { coingeckoApi.getAssetPrice(sortedPriceIds.asQueryParam(), currency = currency.coingeckoId, includeRateChange = true) } - .mapValues { - val price = it.value[currency.coingeckoId].orZero() - val recentRate = it.value[CoingeckoApi.getRecentRateFieldName(currency.coingeckoId)].orZero() - CoinRateChange( - recentRate.toBigDecimal(), - price.toBigDecimal() - ) + // Ensure DOT is included for fallback calculation if HEZ or PEZ is requested + val needsFallback = priceIds.contains(PRICE_ID_HEZ) || priceIds.contains(PRICE_ID_PEZ) + val allPriceIds = if (needsFallback) priceIds + PRICE_ID_DOT else priceIds + + val sortedPriceIds = allPriceIds.toList().sorted() + val rawRates = apiCall { coingeckoApi.getAssetPrice(sortedPriceIds.asQueryParam(), currency = currency.coingeckoId, includeRateChange = true) } + + val rates = rawRates.mapValues { + val price = it.value[currency.coingeckoId].orZero() + val recentRate = it.value[CoingeckoApi.getRecentRateFieldName(currency.coingeckoId)].orZero() + CoinRateChange( + recentRate.toBigDecimal(), + price.toBigDecimal() + ) + }.toMutableMap() + + // Apply fallback pricing for HEZ and PEZ if their prices are zero or missing + val dotRate = rates[PRICE_ID_DOT] + if (dotRate != null && dotRate.rate > BigDecimal.ZERO) { + // HEZ fallback: 1 HEZ = DOT / 3 + if (priceIds.contains(PRICE_ID_HEZ)) { + val hezRate = rates[PRICE_ID_HEZ] + if (hezRate == null || hezRate.rate <= BigDecimal.ZERO) { + rates[PRICE_ID_HEZ] = CoinRateChange( + recentRateChange = dotRate.recentRateChange, + rate = dotRate.rate.divide(HEZ_DOT_DIVISOR, 10, java.math.RoundingMode.HALF_UP) + ) + } } + + // PEZ fallback: 1 PEZ = DOT / 10 + if (priceIds.contains(PRICE_ID_PEZ)) { + val pezRate = rates[PRICE_ID_PEZ] + if (pezRate == null || pezRate.rate <= BigDecimal.ZERO) { + rates[PRICE_ID_PEZ] = CoinRateChange( + recentRateChange = dotRate.recentRateChange, + rate = dotRate.rate.divide(PEZ_DOT_DIVISOR, 10, java.math.RoundingMode.HALF_UP) + ) + } + } + } + + // Return only requested priceIds + return rates.filterKeys { it in priceIds } } override suspend fun getCoinRate(priceId: String, currency: Currency): CoinRateChange? { diff --git a/pezkuwi-config/chains.json b/pezkuwi-config/chains.json index 6354b06..84db3e1 100644 --- a/pezkuwi-config/chains.json +++ b/pezkuwi-config/chains.json @@ -39,7 +39,7 @@ "symbol": "HEZ", "precision": 12, "name": "Hezkurd", - "priceId": null, + "priceId": "hezkurd", "staking": [ "relaychain", "nomination-pools" @@ -91,7 +91,7 @@ "symbol": "HEZ", "precision": 12, "name": "Hezkurd", - "priceId": null, + "priceId": "hezkurd", "staking": null, "type": "Native", "icon": "https://pezkuwichain.io/tokens/HEZ.png", @@ -104,7 +104,7 @@ "symbol": "PEZ", "precision": 12, "name": "Pezkuwi", - "priceId": null, + "priceId": "pezkuwi", "staking": null, "type": "Statemine", "icon": "https://pezkuwichain.io/tokens/PEZ.png", @@ -168,7 +168,7 @@ "symbol": "HEZ", "precision": 12, "name": "Hezkurd", - "priceId": null, + "priceId": "hezkurd", "staking": null, "type": "Native", "icon": "https://pezkuwichain.io/tokens/HEZ.png",