diff --git a/domain/yield-supply/src/main/java/com/tangem/domain/yield/supply/usecase/YieldSupplyGetMaxFeeUseCase.kt b/domain/yield-supply/src/main/java/com/tangem/domain/yield/supply/usecase/YieldSupplyGetMaxFeeUseCase.kt index b7f7417185..ed746b30a4 100644 --- a/domain/yield-supply/src/main/java/com/tangem/domain/yield/supply/usecase/YieldSupplyGetMaxFeeUseCase.kt +++ b/domain/yield-supply/src/main/java/com/tangem/domain/yield/supply/usecase/YieldSupplyGetMaxFeeUseCase.kt @@ -61,20 +61,18 @@ class YieldSupplyGetMaxFeeUseCase( .firstOrNull { it.yieldSupplyKey == token.yieldSupplyKey() } val marketToken = cachedMarketToken ?: yieldSupplyRepository.getTokenStatus(token) val maxFeeNative = marketToken.maxFeeNative - val maxFeeToken = maxFeeNative.multiply(nativeFiatRate) + val fiatMaxFee = maxFeeNative.multiply(nativeFiatRate) - val rateRatio = nativeFiatRate.divide( + val maxFeeToken = fiatMaxFee.divide( fiatRate, cryptoCurrencyStatus.currency.decimals, RoundingMode.HALF_UP, ) - val tokenValue = rateRatio.multiply(maxFeeNative) - YieldSupplyMaxFee( nativeMaxFee = maxFeeNative, tokenMaxFee = maxFeeToken, - fiatMaxFee = tokenValue.stripTrailingZeros(), + fiatMaxFee = fiatMaxFee.stripTrailingZeros(), ) } } \ No newline at end of file diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/common/entity/YieldSupplyFeeUM.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/common/entity/YieldSupplyFeeUM.kt index ee74e2b820..20e09cc6cb 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/common/entity/YieldSupplyFeeUM.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/common/entity/YieldSupplyFeeUM.kt @@ -15,7 +15,6 @@ internal sealed class YieldSupplyFeeUM { val feeFiatValue: TextReference, // TODO move to FeePolicyUM val estimatedFiatValue: TextReference, - val tokenFeeFiatValue: TextReference, val maxNetworkFeeFiatValue: TextReference, val minTopUpFiatValue: TextReference, val feeNoteValue: TextReference = TextReference.EMPTY, diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/common/ui/YieldSupplyActionContent.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/common/ui/YieldSupplyActionContent.kt index d2b8c520de..71645d1247 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/common/ui/YieldSupplyActionContent.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/common/ui/YieldSupplyActionContent.kt @@ -149,7 +149,6 @@ private class YieldSupplyActionContentPreviewProvider : PreviewParameterProvider yieldSupplyFeeUM = YieldSupplyFeeUM.Content( transactionDataList = persistentListOf(), feeFiatValue = stringReference("$0.99"), - tokenFeeFiatValue = stringReference("$1.45"), maxNetworkFeeFiatValue = stringReference("$8.50"), minTopUpFiatValue = stringReference("$50"), feeNoteValue = TextReference.EMPTY, diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/active/model/transformers/YieldSupplyActiveFeeContentTransformer.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/active/model/transformers/YieldSupplyActiveFeeContentTransformer.kt index dbabb4a9f5..44e98e521f 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/active/model/transformers/YieldSupplyActiveFeeContentTransformer.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/active/model/transformers/YieldSupplyActiveFeeContentTransformer.kt @@ -37,11 +37,12 @@ internal class YieldSupplyActiveFeeContentTransformer( val tokenFiatFeeValueText = tokenFiatFee.format { fiat(appCurrency.code, appCurrency.symbol) } val maxFeeCryptoValueText = maxNetworkFee.tokenMaxFee.format { crypto(cryptoCurrency) } - val maxFiatFeeValueText = maxNetworkFee.fiatMaxFee.format { fiat( - appCurrency.code, - appCurrency - .symbol, - ) } + val maxFiatFeeValueText = maxNetworkFee.fiatMaxFee.format { + fiat( + appCurrency.code, + appCurrency.symbol, + ) + } val feeNoteValue: TextReference = resourceReference( id = R.string.yield_module_fee_policy_sheet_fee_note, diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/approve/model/YieldSupplyApproveModel.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/approve/model/YieldSupplyApproveModel.kt index e2c89da4c0..baa31bd4fd 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/approve/model/YieldSupplyApproveModel.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/approve/model/YieldSupplyApproveModel.kt @@ -254,7 +254,6 @@ internal class YieldSupplyApproveModel @Inject constructor( approvalTransitionData.copy(fee = transactionFee.normal), ), feeFiatValue = stringReference(fiatFee), - tokenFeeFiatValue = TextReference.EMPTY, maxNetworkFeeFiatValue = TextReference.EMPTY, minTopUpFiatValue = TextReference.EMPTY, feeNoteValue = TextReference.EMPTY, diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/feepolicy/ui/YieldSupplyFeePolicyContent.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/feepolicy/ui/YieldSupplyFeePolicyContent.kt index f00297a2f9..d4593e4ca6 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/feepolicy/ui/YieldSupplyFeePolicyContent.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/feepolicy/ui/YieldSupplyFeePolicyContent.kt @@ -171,7 +171,6 @@ private fun YieldSupplyFeePolicyContent_Preview() { transactionDataList = persistentListOf(), feeFiatValue = stringReference("$1.45"), maxNetworkFeeFiatValue = stringReference("$8.50"), - tokenFeeFiatValue = stringReference("$1.45"), minTopUpFiatValue = stringReference("$50"), feeNoteValue = resourceReference( id = R.string.yield_module_fee_policy_sheet_fee_note, diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/YieldSupplyStartEarningModel.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/YieldSupplyStartEarningModel.kt index 3446144179..bc56f86994 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/YieldSupplyStartEarningModel.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/YieldSupplyStartEarningModel.kt @@ -192,7 +192,7 @@ internal class YieldSupplyStartEarningModel @Inject constructor( updatedTransactionList = updatedTransactionList, feeValue = feeSum, maxNetworkFee = maxFee, - estimatedFeeValue = estimatedFee, + estimatedFeeValueInTokenCurrency = estimatedFee, minAmount = minAmount, ), ) diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/transformers/YieldSupplyStartEarningFeeContentTransformer.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/transformers/YieldSupplyStartEarningFeeContentTransformer.kt index 782c6b2d3e..58aba7dc22 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/transformers/YieldSupplyStartEarningFeeContentTransformer.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/transformers/YieldSupplyStartEarningFeeContentTransformer.kt @@ -16,7 +16,6 @@ import com.tangem.features.yield.supply.impl.common.entity.YieldSupplyFeeUM import com.tangem.utils.transformer.Transformer import kotlinx.collections.immutable.toPersistentList import java.math.BigDecimal -import java.math.RoundingMode @Suppress("LongParameterList") internal class YieldSupplyStartEarningFeeContentTransformer( @@ -25,7 +24,7 @@ internal class YieldSupplyStartEarningFeeContentTransformer( private val appCurrency: AppCurrency, private val updatedTransactionList: List, private val feeValue: BigDecimal, - private val estimatedFeeValue: BigDecimal, + private val estimatedFeeValueInTokenCurrency: BigDecimal, private val maxNetworkFee: YieldSupplyMaxFee, private val minAmount: BigDecimal, ) : Transformer { @@ -37,14 +36,10 @@ internal class YieldSupplyStartEarningFeeContentTransformer( val feeFiat = feeFiatRate?.let(feeValue::multiply) val feeFiatValueText = feeFiat.format { fiat(appCurrency.code, appCurrency.symbol) } - val estimatedFeeFiat = estimatedFeeValue - val estimatedFeeFiatValueText = estimatedFeeFiat.format { fiat(appCurrency.code, appCurrency.symbol) } - - val tokenCryptoFee = tokenFiatRate?.let { rate -> - estimatedFeeFiat.divide(rate, cryptoCurrency.decimals, RoundingMode.HALF_UP) - } - val tokenCryptoFeeValueText = tokenCryptoFee.format { crypto(cryptoCurrency) } - val tokenFiatFeeValueText = estimatedFeeFiat.format { fiat(appCurrency.code, appCurrency.symbol) } + val estimatedFeeToken = estimatedFeeValueInTokenCurrency + val estimatedFeeTokenValueText = estimatedFeeToken.format { crypto(cryptoCurrency) } + val estimatedFiatFee = tokenFiatRate?.let(estimatedFeeToken::multiply) + val estimatedFeeFiatValueText = estimatedFiatFee.format { fiat(appCurrency.code, appCurrency.symbol) } val maxFeeCryptoValueText = maxNetworkFee.tokenMaxFee.format { crypto(cryptoCurrency) } val maxFiatFeeValueText = maxNetworkFee.fiatMaxFee.format { fiat(appCurrency.code, appCurrency.symbol) } @@ -56,8 +51,8 @@ internal class YieldSupplyStartEarningFeeContentTransformer( val feeNoteValue = resourceReference( id = R.string.yield_module_fee_policy_sheet_fee_note, formatArgs = wrappedList( - tokenFiatFeeValueText, - tokenCryptoFeeValueText, + estimatedFeeFiatValueText, + estimatedFeeTokenValueText, maxFiatFeeValueText, maxFeeCryptoValueText, ), @@ -78,7 +73,6 @@ internal class YieldSupplyStartEarningFeeContentTransformer( yieldSupplyFeeUM = YieldSupplyFeeUM.Content( transactionDataList = updatedTransactionList.toPersistentList(), feeFiatValue = stringReference(feeFiatValueText), - tokenFeeFiatValue = stringReference(tokenFiatFeeValueText), maxNetworkFeeFiatValue = stringReference(maxFiatFeeValueText), minTopUpFiatValue = stringReference(minAmountFiatText), feeNoteValue = feeNoteValue, diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/stopearning/model/transformer/YieldSupplyStopEarningFeeContentTransformer.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/stopearning/model/transformer/YieldSupplyStopEarningFeeContentTransformer.kt index 6c1881f305..51d0fc112d 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/stopearning/model/transformer/YieldSupplyStopEarningFeeContentTransformer.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/stopearning/model/transformer/YieldSupplyStopEarningFeeContentTransformer.kt @@ -34,7 +34,6 @@ internal class YieldSupplyStopEarningFeeContentTransformer( yieldSupplyFeeUM = YieldSupplyFeeUM.Content( transactionDataList = transactions.toPersistentList(), feeFiatValue = stringReference(fiatFeeText), - tokenFeeFiatValue = TextReference.EMPTY, maxNetworkFeeFiatValue = TextReference.EMPTY, minTopUpFiatValue = TextReference.EMPTY, feeNoteValue = TextReference.EMPTY,