Update logos and add HEZ/PEZ price fallback mechanism
- Update launcher icons (ic_launcher, ic_launcher_round, ic_launcher_foreground) - Update ic_pezkuwi_logo for all density buckets - Add priceId for HEZ (hezkurd) and PEZ (pezkuwi) tokens - Implement price fallback: if CoinGecko price is 0 or missing: - HEZ = DOT price / 3 - PEZ = DOT price / 10 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
@@ -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<String>, currency: Currency): Map<String, CoinRateChange?> {
|
||||
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? {
|
||||
|
||||
@@ -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",
|
||||
|
||||