Updated on 2026-08-14
This commit is contained in:
parent
a80542d5da
commit
3d832ddd3e
13 changed files with 88 additions and 24 deletions
|
|
@ -19,6 +19,7 @@ dependencies {
|
|||
implementation(projects.domain.tokens.models)
|
||||
implementation(projects.domain.txhistory.models)
|
||||
implementation(projects.domain.wallets.models)
|
||||
implementation(projects.domain.staking.models)
|
||||
|
||||
/** Project - Data */
|
||||
implementation(projects.core.datasource)
|
||||
|
|
|
|||
|
|
@ -6,13 +6,17 @@ import com.tangem.blockchain.common.MinimumSendAmountProvider
|
|||
import com.tangem.blockchain.common.ReserveAmountProvider
|
||||
import com.tangem.blockchain.common.UtxoAmountLimitProvider
|
||||
import com.tangem.data.tokens.converters.UtxoConverter
|
||||
import com.tangem.domain.staking.model.stakekit.YieldBalance
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.CurrencyAmount
|
||||
import com.tangem.domain.tokens.model.Network
|
||||
import com.tangem.domain.tokens.model.blockchains.UtxoAmountLimit
|
||||
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning
|
||||
import com.tangem.domain.tokens.repository.CurrencyChecksRepository
|
||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.extensions.isZero
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
|
@ -118,4 +122,23 @@ internal class DefaultCurrencyChecksRepository(
|
|||
}
|
||||
return utxoAmount?.let(UtxoConverter()::convert)
|
||||
}
|
||||
|
||||
override suspend fun getRentInfoWarning(
|
||||
userWalletId: UserWalletId,
|
||||
currencyStatus: CryptoCurrencyStatus,
|
||||
balanceAfterTransaction: BigDecimal?,
|
||||
): CryptoCurrencyWarning.Rent? {
|
||||
val rentData = walletManagersFacade.getRentInfo(userWalletId, currencyStatus.currency.network) ?: return null
|
||||
val balanceValue = currencyStatus.value as? CryptoCurrencyStatus.Loaded ?: return null
|
||||
val stakingTotalBalance =
|
||||
(balanceValue.yieldBalance as? YieldBalance.Data)?.getTotalStakingBalance() ?: BigDecimal.ZERO
|
||||
val amount = balanceAfterTransaction ?: balanceValue.amount
|
||||
return when {
|
||||
amount.isZero() && stakingTotalBalance.isZero() -> null
|
||||
amount < rentData.exemptionAmount && stakingTotalBalance.isZero() -> {
|
||||
CryptoCurrencyWarning.Rent(rentData.rent, rentData.exemptionAmount)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue