Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-30 13:45:45 +04:00
parent fb54de419b
commit 177da9798e
86 changed files with 183 additions and 154 deletions

View file

@ -1,6 +0,0 @@
package com.tangem.domain.staking.model
import kotlinx.serialization.Serializable
@Serializable
data class StakingID(val integrationId: String, val address: String)

View file

@ -1,72 +0,0 @@
package com.tangem.domain.staking.model.stakekit
enum class NetworkType {
AVALANCHE_C,
AVALANCHE_ATOMIC,
AVALANCHE_P,
ARBITRUM,
BINANCE,
CELO,
ETHEREUM,
ETHEREUM_GOERLI,
ETHEREUM_HOLESKY,
FANTOM,
HARMONY,
OPTIMISM,
POLYGON,
GNOSIS,
MOONRIVER,
OKC,
ZKSYNC,
VICTION,
AGORIC,
AKASH,
AXELAR,
BAND_PROTOCOL,
BITSONG,
CANTO,
CHIHUAHUA,
COMDEX,
COREUM,
COSMOS,
CRESCENT,
CRONOS,
CUDOS,
DESMOS,
DYDX,
EVMOS,
FETCH_AI,
GRAVITY_BRIDGE,
INJECTIVE,
IRISNET,
JUNO,
KAVA,
KI_NETWORK,
MARS_PROTOCOL,
NYM,
OKEX_CHAIN,
ONOMY,
OSMOSIS,
PERSISTENCE,
QUICKSILVER,
REGEN,
SECRET,
SENTINEL,
SOMMELIER,
STAFI,
STARGAZE,
STRIDE,
TERITORI,
TGRADE,
UMEE,
POLKADOT,
KUSAMA,
WESTEND,
BINANCEBEACON,
NEAR,
SOLANA,
TEZOS,
TRON,
TON,
UNKNOWN,
}

View file

@ -1,13 +1,14 @@
package com.tangem.domain.staking.model.stakekit
import com.tangem.domain.core.serialization.SerializedBigDecimal
import com.tangem.domain.models.staking.YieldToken
import kotlinx.serialization.Serializable
@Serializable
data class Yield(
val id: String,
val token: Token,
val tokens: List<Token>,
val token: YieldToken,
val tokens: List<YieldToken>,
val args: Args,
val status: Status,
val apy: SerializedBigDecimal,
@ -93,9 +94,9 @@ data class Yield(
val logoUri: String,
val description: String,
val documentation: String?,
val gasFeeToken: Token,
val token: Token,
val tokens: List<Token>,
val gasFeeToken: YieldToken,
val token: YieldToken,
val tokens: List<YieldToken>,
val type: String,
val rewardSchedule: RewardSchedule,
val cooldownPeriod: Period?,
@ -145,18 +146,6 @@ data class Yield(
}
}
@Serializable
data class Token(
val name: String,
val network: NetworkType,
val symbol: String,
val decimals: Int,
val address: String?,
val coinGeckoId: String?,
val logoURI: String?,
val isPoints: Boolean?,
)
@Serializable
data class AddressArgument(
val required: Boolean,

View file

@ -1,68 +0,0 @@
package com.tangem.domain.staking.model.stakekit
import com.tangem.domain.models.StatusSource
import com.tangem.domain.staking.model.StakingID
import kotlinx.serialization.Serializable
/**
* Represents a yield balance in the staking system
*/
@Serializable
sealed interface YieldBalance {
/** The unique identifier of the staking operation */
val stakingId: StakingID
/** The source of the status information */
val source: StatusSource
/**
* Represents a yield balance with actual data
*
* @property stakingId the unique identifier of the staking operation
* @property source the source of the status information
* @property balance the balance details of the yield
*/
@Serializable
data class Data(
override val stakingId: StakingID,
override val source: StatusSource,
val balance: YieldBalanceItem,
) : YieldBalance
/**
* Represents an empty yield balance
*
* @property stakingId the unique identifier of the staking operation
* @property source the source of the status information
*/
@Serializable
data class Empty(
override val stakingId: StakingID,
override val source: StatusSource,
) : YieldBalance
/**
* Represents an error state for the yield balance
*
* @property stakingId the unique identifier of the staking operation
*/
@Serializable
data class Error(override val stakingId: StakingID) : YieldBalance {
override val source: StatusSource = StatusSource.ACTUAL
}
/**
* Creates a copy of the current yield balance with a new status source
*
* @param source the new source of the status information
*/
fun copySealed(source: StatusSource): YieldBalance {
return when (this) {
is Data -> copy(source = source)
is Empty -> copy(source = source)
is Error,
-> this
}
}
}

View file

@ -1,130 +0,0 @@
package com.tangem.domain.staking.model.stakekit
import com.tangem.domain.core.serialization.SerializedBigDecimal
import com.tangem.domain.staking.model.stakekit.action.StakingActionType
import kotlinx.datetime.Instant
import kotlinx.serialization.Serializable
@Serializable
data class YieldBalanceItem(
val items: List<BalanceItem>,
val integrationId: String,
)
@Serializable
data class BalanceItem(
val groupId: String,
val token: Token,
val type: BalanceType,
val amount: SerializedBigDecimal,
val rawCurrencyId: String?,
val validatorAddress: String?,
val date: Instant?,
val pendingActions: List<PendingAction>,
val pendingActionsConstraints: List<PendingActionConstraints>,
val isPending: Boolean,
)
@Serializable
data class PendingActionConstraints(
val type: StakingActionType,
val amountArg: PendingAction.PendingActionArgs.Amount?,
)
@Serializable
data class PendingAction(
val type: StakingActionType,
val passthrough: String,
val args: PendingActionArgs?,
) {
@Serializable
data class PendingActionArgs(
val amount: Amount?,
val duration: Duration?,
val validatorAddress: Boolean?,
val validatorAddresses: Boolean?,
val tronResource: TronResource?,
val signatureVerification: Boolean?,
) {
@Serializable
data class Amount(
val required: Boolean,
val minimum: SerializedBigDecimal?,
val maximum: SerializedBigDecimal?,
)
@Serializable
data class Duration(
val required: Boolean,
val minimum: Int?,
val maximum: Int?,
)
@Serializable
data class TronResource(
val required: Boolean,
val options: List<String>,
)
}
}
/**
* IMPORTANT!!!
* Order is used to sort balances.
*/
@Serializable
@Suppress("MagicNumber")
enum class BalanceType(val order: Int) {
AVAILABLE(1),
STAKED(2),
PREPARING(3),
LOCKED(4),
UNSTAKING(5),
UNLOCKING(6),
UNSTAKED(7),
REWARDS(8),
UNKNOWN(9),
;
companion object {
fun BalanceType.isClickable() = when (this) {
STAKED,
UNSTAKED,
LOCKED,
-> true
AVAILABLE,
UNSTAKING,
PREPARING,
REWARDS,
UNLOCKING,
UNKNOWN,
-> false
}
}
}
@Serializable
enum class RewardBlockType {
NoRewards,
Rewards,
RewardsRequirementsError,
RewardUnavailable,
;
/**
* Indicated whether action can be performed on available reward
* For example, pending action CLAIM_REWARDS could be called
*/
val isActionable: Boolean
get() = when (this) {
NoRewards,
RewardUnavailable,
-> false
RewardsRequirementsError,
Rewards,
-> true
}
}

View file

@ -1,5 +1,6 @@
package com.tangem.domain.staking.model.stakekit.action
import com.tangem.domain.models.staking.action.StakingActionType
import com.tangem.domain.staking.model.stakekit.transaction.StakingTransaction
import org.joda.time.DateTime
import java.math.BigDecimal

View file

@ -1,50 +0,0 @@
package com.tangem.domain.staking.model.stakekit.action
enum class StakingActionType {
STAKE,
UNSTAKE,
CLAIM_REWARDS,
RESTAKE_REWARDS,
WITHDRAW,
RESTAKE,
CLAIM_UNSTAKED,
UNLOCK_LOCKED,
STAKE_LOCKED,
VOTE,
REVOKE,
VOTE_LOCKED,
REVOTE,
REBOND,
MIGRATE,
UNKNOWN,
;
val asAnalyticName
get() = when (this) {
STAKE -> "Stake"
UNSTAKE -> "Unstake"
CLAIM_REWARDS -> "Claim Rewards"
RESTAKE_REWARDS -> "Restake Rewards"
CLAIM_UNSTAKED,
WITHDRAW,
-> "Withdraw"
RESTAKE -> "Restake"
UNLOCK_LOCKED -> "Unlock Locked"
STAKE_LOCKED -> "Stake Locked"
VOTE -> "Vote"
REVOKE -> "Revoke"
VOTE_LOCKED -> "Vote Locked"
REVOTE -> "Revote"
REBOND -> "Rebond"
MIGRATE -> "Migrate"
UNKNOWN -> "Unknown"
}
val isRestake
get() = when (this) {
RESTAKE,
STAKE,
-> true
else -> false
}
}

View file

@ -1,8 +1,8 @@
package com.tangem.domain.staking.model.stakekit.transaction
import com.tangem.domain.staking.model.stakekit.Token
import com.tangem.domain.models.staking.YieldToken
import com.tangem.domain.models.staking.action.StakingActionType
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
import com.tangem.domain.staking.model.stakekit.action.StakingActionType
import java.math.BigDecimal
data class ActionParams(
@ -11,7 +11,7 @@ data class ActionParams(
val amount: BigDecimal,
val address: String,
val validatorAddress: String,
val token: Token,
val token: YieldToken,
val publicKey: String? = null,
val passthrough: String? = null,
val type: StakingActionType? = null,

View file

@ -1,10 +1,10 @@
package com.tangem.domain.staking.model.stakekit.transaction
import com.tangem.domain.staking.model.stakekit.Token
import com.tangem.domain.models.staking.YieldToken
import java.math.BigDecimal
data class StakingGasEstimate(
val amount: BigDecimal,
val token: Token,
val token: YieldToken,
val gasLimit: String?,
)

View file

@ -1,6 +1,6 @@
package com.tangem.domain.staking.model.stakekit.transaction
import com.tangem.domain.staking.model.stakekit.NetworkType
import com.tangem.domain.models.staking.NetworkType
data class StakingTransaction(
val id: String,