Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-05 20:52:32 +05:00
parent 506c1bb737
commit 540ee066e2
7 changed files with 17 additions and 3 deletions

View file

@ -13,6 +13,8 @@ internal sealed class YieldSupplyFeeUM {
data class Content(
val transactionDataList: ImmutableList<TransactionData.Uncompiled>,
val feeFiatValue: TextReference,
// TODO move to FeePolicyUM
val estimatedFiatValue: TextReference,
val tokenFeeFiatValue: TextReference,
val maxNetworkFeeFiatValue: TextReference,
val minTopUpFiatValue: TextReference,

View file

@ -149,6 +149,7 @@ private class YieldSupplyActionContentPreviewProvider : PreviewParameterProvider
maxNetworkFeeFiatValue = stringReference("$8.50"),
minTopUpFiatValue = stringReference("$50"),
feeNoteValue = TextReference.EMPTY,
estimatedFiatValue = TextReference.EMPTY,
),
isPrimaryButtonEnabled = false,
isTransactionSending = false,

View file

@ -255,6 +255,7 @@ internal class YieldSupplyApproveModel @Inject constructor(
maxNetworkFeeFiatValue = TextReference.EMPTY,
minTopUpFiatValue = TextReference.EMPTY,
feeNoteValue = TextReference.EMPTY,
estimatedFiatValue = TextReference.EMPTY,
),
)
}

View file

@ -86,7 +86,7 @@ internal fun YieldSupplyFeePolicyContent(
.padding(horizontal = 16.dp),
) {
val currentFee = when (yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.tokenFeeFiatValue
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.estimatedFiatValue
YieldSupplyFeeUM.Error -> stringReference(StringsSigns.DASH_SIGN)
YieldSupplyFeeUM.Loading -> null
}
@ -184,6 +184,7 @@ private fun YieldSupplyFeePolicyContent_Preview() {
stringReference("2.46 USDT"),
),
),
estimatedFiatValue = stringReference("$8.50"),
),
tokenSymbol = "USDT",
modifier = Modifier.background(TangemTheme.colors.background.primary),

View file

@ -63,6 +63,7 @@ internal class YieldSupplyStartEarningModel @Inject constructor(
private val yieldSupplyActivateUseCase: YieldSupplyActivateUseCase,
private val yieldSupplyMinAmountUseCase: YieldSupplyMinAmountUseCase,
private val yieldSupplyGetMaxFeeUseCase: YieldSupplyGetMaxFeeUseCase,
private val yieldSupplyGetCurrentFeeUseCase: YieldSupplyGetCurrentFeeUseCase,
private val yieldSupplyRepository: YieldSupplyRepository,
) : Model(), YieldSupplyNotificationsComponent.ModelCallback {
@ -138,6 +139,7 @@ internal class YieldSupplyStartEarningModel @Inject constructor(
}
val maxFee = yieldSupplyGetMaxFeeUseCase(userWallet, cryptoCurrencyStatus).getOrNull() ?: return
val estimatedFee = yieldSupplyGetCurrentFeeUseCase(userWallet, cryptoCurrencyStatus).getOrNull() ?: return
val transactionListData = yieldSupplyStartEarningUseCase(
userWalletId = userWallet.walletId,
@ -187,6 +189,7 @@ internal class YieldSupplyStartEarningModel @Inject constructor(
updatedTransactionList = updatedTransactionList,
feeValue = feeSum,
maxNetworkFee = maxFee,
estimatedFeeValue = estimatedFee,
minAmount = minAmount,
),
)

View file

@ -25,6 +25,7 @@ internal class YieldSupplyStartEarningFeeContentTransformer(
private val appCurrency: AppCurrency,
private val updatedTransactionList: List<TransactionData.Uncompiled>,
private val feeValue: BigDecimal,
private val estimatedFeeValue: BigDecimal,
private val maxNetworkFee: YieldSupplyMaxFee,
private val minAmount: BigDecimal,
) : Transformer<YieldSupplyActionUM> {
@ -36,11 +37,14 @@ internal class YieldSupplyStartEarningFeeContentTransformer(
val feeFiat = feeFiatRate?.let(feeValue::multiply)
val feeFiatValueText = feeFiat.format { fiat(appCurrency.code, appCurrency.symbol) }
val estimatedFeeFiat = feeFiatRate?.let(estimatedFeeValue::multiply)
val estimatedFeeFiatValueText = estimatedFeeFiat.format { fiat(appCurrency.code, appCurrency.symbol) }
val tokenCryptoFee = tokenFiatRate?.let { rate ->
feeFiat?.divide(rate, cryptoCurrency.decimals, RoundingMode.HALF_UP)
estimatedFeeFiat?.divide(rate, cryptoCurrency.decimals, RoundingMode.HALF_UP)
}
val tokenCryptoFeeValueText = tokenCryptoFee.format { crypto(cryptoCurrency) }
val tokenFiatFeeValueText = feeFiat.format { fiat(appCurrency.code, appCurrency.symbol) }
val tokenFiatFeeValueText = estimatedFeeFiat.format { fiat(appCurrency.code, appCurrency.symbol) }
val maxFeeCryptoValueText = maxNetworkFee.tokenMaxFee.format { crypto(cryptoCurrency) }
val maxFiatFeeValueText = maxNetworkFee.fiatMaxFee.format { fiat(appCurrency.code, appCurrency.symbol) }
@ -79,6 +83,7 @@ internal class YieldSupplyStartEarningFeeContentTransformer(
minTopUpFiatValue = stringReference(minAmountFiatText),
feeNoteValue = feeNoteValue,
minFeeNoteValue = minFeeNoteValue,
estimatedFiatValue = stringReference(estimatedFeeFiatValueText),
),
)
}

View file

@ -38,6 +38,7 @@ internal class YieldSupplyStopEarningFeeContentTransformer(
maxNetworkFeeFiatValue = TextReference.EMPTY,
minTopUpFiatValue = TextReference.EMPTY,
feeNoteValue = TextReference.EMPTY,
estimatedFiatValue = TextReference.EMPTY,
),
)
}