Updated on 2026-08-14
This commit is contained in:
parent
721ab042e0
commit
7d599256d1
27 changed files with 366 additions and 454 deletions
|
|
@ -27,7 +27,6 @@ import com.tangem.lib.crypto.BlockchainUtils
|
|||
import com.tangem.lib.crypto.BlockchainUtils.isTon
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.datetime.Instant
|
||||
import java.math.BigDecimal
|
||||
|
|
@ -197,7 +196,11 @@ internal class StakingBalanceEntryConverter(
|
|||
private fun StakingBalanceEntry.getPendingActions(): List<PendingAction> {
|
||||
return when (val actions = this.actions) {
|
||||
is StakingEntryActions.StakeKit -> actions.pendingActions
|
||||
is StakingEntryActions.P2PEthPool -> persistentListOf()
|
||||
is StakingEntryActions.P2PEthPool -> if (type == StakingEntryType.WITHDRAWABLE) {
|
||||
listOf(STUB_WITHDRAW_ACTION)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -223,6 +226,11 @@ internal class StakingBalanceEntryConverter(
|
|||
}
|
||||
|
||||
private companion object {
|
||||
val STUB_WITHDRAW_ACTION = PendingAction(
|
||||
StakingActionType.WITHDRAW,
|
||||
passthrough = "",
|
||||
args = null,
|
||||
)
|
||||
const val DAY_IN_MILLIS = 24 * 60 * 60 * 1000
|
||||
}
|
||||
}
|
||||
|
|
@ -81,14 +81,7 @@ internal class YieldBalancesConverter(
|
|||
|
||||
private fun getRewardBlockType(stakingBalance: StakingBalance?): RewardBlockType {
|
||||
val blockchainId = cryptoCurrencyStatus.currency.network.rawId
|
||||
|
||||
if (stakingBalance is StakingBalance.Data.P2PEthPool) {
|
||||
return if (isStakingRewardUnavailable(blockchainId)) {
|
||||
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable
|
||||
} else {
|
||||
RewardBlockType.NoRewards
|
||||
}
|
||||
}
|
||||
val isCoin = cryptoCurrencyStatus.currency.id.isCoin
|
||||
|
||||
val stakeKitBalance = stakingBalance as? StakingBalance.Data.StakeKit
|
||||
val rewards = stakeKitBalance?.balance?.items
|
||||
|
|
@ -98,7 +91,7 @@ internal class YieldBalancesConverter(
|
|||
val isRewardsClaimable = rewards?.isNotEmpty() == true
|
||||
|
||||
return when {
|
||||
isStakingRewardUnavailable(blockchainId) -> {
|
||||
isStakingRewardUnavailable(blockchainId, isCoin) -> {
|
||||
if (BlockchainUtils.isSolana(blockchainId)) {
|
||||
RewardBlockType.RewardUnavailable.SolanaRewardUnavailable
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -75,13 +75,20 @@ internal class P2PEthPoolTransactionCreator @Inject constructor(
|
|||
)
|
||||
}
|
||||
is StakingActionCommonType.Exit -> {
|
||||
p2pEthPoolRepository.createWithdrawTransaction(
|
||||
p2pEthPoolRepository.createUnstakeTransaction(
|
||||
network = network,
|
||||
stakerAddress = sourceAddress,
|
||||
delegatorAddress = sourceAddress,
|
||||
vaultAddress = vaultAddress,
|
||||
amount = amount.toPlainString(),
|
||||
)
|
||||
}
|
||||
is StakingActionCommonType.Pending -> {
|
||||
Either.Left(StakingError.DomainError("Pending actions not supported for P2PEthPool"))
|
||||
p2pEthPoolRepository.createWithdrawTransaction(
|
||||
network = network,
|
||||
delegatorAddress = sourceAddress,
|
||||
vaultAddress = vaultAddress,
|
||||
amount = amount.toPlainString(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue