Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-15 22:43:52 +03:00
commit d6f9f59866
1729 changed files with 67614 additions and 9361 deletions

View file

@ -7,11 +7,6 @@ plugins {
android {
namespace = "com.tangem.domain.yield.supply"
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
dependencies {
/** Core */
implementation(projects.core.ui)
@ -39,9 +34,8 @@ dependencies {
implementation(deps.arrow.core)
/** tests */
testImplementation(projects.common.test)
testImplementation(projects.test.core)
testImplementation(deps.test.junit5)
testRuntimeOnly(deps.test.junit5.engine)
testImplementation(deps.test.coroutine)
testImplementation(deps.test.truth)
testImplementation(deps.test.mockk)

View file

@ -1,7 +1,5 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>NullableToStringCall:YieldMarketToken.kt$YieldMarketToken$${backendId}</ID>
</CurrentIssues>
<CurrentIssues/>
</SmellBaseline>

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,
)
}

View file

@ -2,7 +2,7 @@ package com.tangem.domain.yield.supply.usecase
import arrow.core.Either
import com.google.common.truth.Truth.assertThat
import com.tangem.common.test.TestAppCoroutineScope
import com.tangem.test.core.TestAppCoroutineScope
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWalletId