Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-01 20:05:51 +03:00
commit d0b35bc331
680 changed files with 26556 additions and 2709 deletions

View file

@ -0,0 +1,25 @@
package com.tangem.domain.yield.supply
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWalletId
/**
* Resolves the yield-module proxy address for a `(wallet, network)` pair and caches the result.
*
* The address is derived from on-chain state (factory contract + user's wallet) and is stable
* for the lifetime of the wallet, so caching the result avoids redundant blockchain calls.
*
* Call [invalidate] when the wallet's yield-module state may have changed (e.g. after a
* successful upgrade or removal of yield-supply).
*/
interface YieldModuleAddressProvider {
/**
* Returns the yield-module proxy address, or `null` if the address is currently unavailable
* (e.g. RPC failure inside the SDK).
*/
suspend fun getOrFetch(userWalletId: UserWalletId, network: Network): String?
/** Drops cached entries for [userWalletId], or the entire cache when [userWalletId] is `null`. */
fun invalidate(userWalletId: UserWalletId? = null)
}

View file

@ -1,9 +1,11 @@
package com.tangem.domain.yield.supply
import com.tangem.blockchain.common.TransactionData
import com.tangem.blockchain.common.smartcontract.SmartContractCallData
import com.tangem.blockchain.common.transaction.Fee
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWalletId
import java.math.BigDecimal
@ -24,4 +26,14 @@ interface YieldSupplyTransactionRepository {
suspend fun getYieldContractAddress(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency): String?
suspend fun getEffectiveProtocolBalance(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency): BigDecimal?
/**
* Checks the version status of the user's yield-module contract and wraps [callData] with an
* upgrade transaction if the deployed version is out of date.
*/
suspend fun wrapYieldSwapCallDataWithUpgradeIfNeeded(
userWalletId: UserWalletId,
network: Network,
callData: SmartContractCallData,
): SmartContractCallData
}

View file

@ -0,0 +1,25 @@
package com.tangem.domain.yield.supply.usecase
import com.tangem.blockchain.common.smartcontract.SmartContractCallData
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.yield.supply.YieldSupplyTransactionRepository
/**
* Wraps a yield-swap call data with a yield-module upgrade transaction when the user's deployed
* yield-module contract version is out of date.
*/
class WrapYieldSwapCallDataWithUpgradeUseCase(
private val yieldSupplyTransactionRepository: YieldSupplyTransactionRepository,
) {
suspend operator fun invoke(
userWalletId: UserWalletId,
network: Network,
callData: SmartContractCallData,
): SmartContractCallData = yieldSupplyTransactionRepository.wrapYieldSwapCallDataWithUpgradeIfNeeded(
userWalletId = userWalletId,
network = network,
callData = callData,
)
}