Updated on 2026-08-14
This commit is contained in:
commit
6780c4a7f7
10 changed files with 21 additions and 33 deletions
|
|
@ -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(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -107,8 +107,8 @@ class YieldSupplyGetRewardsBalanceUseCaseTest {
|
|||
chainId = 1,
|
||||
apy = BigDecimal.ZERO,
|
||||
isActive = true,
|
||||
maxFeeNative = "0",
|
||||
maxFeeUSD = "0",
|
||||
maxFeeNative = BigDecimal.ZERO,
|
||||
maxFeeUSD = BigDecimal.ZERO,
|
||||
backendId = "id",
|
||||
),
|
||||
)
|
||||
|
|
@ -152,8 +152,8 @@ class YieldSupplyGetRewardsBalanceUseCaseTest {
|
|||
chainId = 1,
|
||||
apy = apy,
|
||||
isActive = true,
|
||||
maxFeeNative = "0",
|
||||
maxFeeUSD = "0",
|
||||
maxFeeNative = BigDecimal.ZERO,
|
||||
maxFeeUSD = BigDecimal.ZERO,
|
||||
backendId = "id",
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ internal class YieldSupplyStartEarningModel @Inject constructor(
|
|||
updatedTransactionList = updatedTransactionList,
|
||||
feeValue = feeSum,
|
||||
maxNetworkFee = maxFee,
|
||||
estimatedFeeValue = estimatedFee,
|
||||
estimatedFeeValueInTokenCurrency = estimatedFee,
|
||||
minAmount = minAmount,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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<TransactionData.Uncompiled>,
|
||||
private val feeValue: BigDecimal,
|
||||
private val estimatedFeeValue: BigDecimal,
|
||||
private val estimatedFeeValueInTokenCurrency: BigDecimal,
|
||||
private val maxNetworkFee: YieldSupplyMaxFee,
|
||||
private val minAmount: BigDecimal,
|
||||
) : Transformer<YieldSupplyActionUM> {
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue