diff --git a/build.gradle.kts b/build.gradle.kts index a59f18c09..3fd446f8a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.13.37" +version = "1.13.38" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/input/TransferInputProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/input/TransferInputProcessor.kt index a89f8be63..89e4884da 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/input/TransferInputProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/input/TransferInputProcessor.kt @@ -32,7 +32,7 @@ internal class TransferInputProcessor( private val parser: ParserProtocol, private val calculator: TransferInputCalculatorV2 = TransferInputCalculatorV2(parser = parser), private val routerProcessor: IRouterProcessor, - private val environment: V4Environment? + private val environment: V4Environment?, ) { fun transfer( inputState: InternalInputState, @@ -250,8 +250,16 @@ internal class TransferInputProcessor( private fun updateWithdrawalOptions( transfer: InternalTransferInputState, ) { - val chains: IList = transfer.chains?.toIList() ?: iListOf() - val assets: IList = transfer.tokens?.toIList() ?: iListOf() + val chains: IList = if (environment?.isMainNet == true && environment?.featureFlags?.cctpWithdrawalOnly == true) { + transfer.cctpChains?.toIList() ?: iListOf() + } else { + transfer.chains?.toIList() ?: iListOf() + } + val assets: IList = if (environment?.isMainNet == true && environment?.featureFlags?.cctpWithdrawalOnly == true) { + transfer.cctpTokens?.toIList() ?: iListOf() + } else { + transfer.tokens?.toIList() ?: iListOf() + } var exchanges: IMutableList? = null exchangeList?.let { data -> exchanges = iMutableListOf() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessor.kt index 55fcd3c13..7feca70fa 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessor.kt @@ -47,6 +47,7 @@ internal class SkipProcessor( ): Map? { throw NotImplementedError("receivedV2SdkInfo is not implemented in SkipProcessor!") } + override fun receivedChains( existing: Map?, payload: Map diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalTransferInputState.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalTransferInputState.kt index 987001dda..272d570a9 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalTransferInputState.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalTransferInputState.kt @@ -10,6 +10,7 @@ import exchange.dydx.abacus.output.input.TransferInputTokenResource import exchange.dydx.abacus.output.input.TransferOutInputOptions import exchange.dydx.abacus.output.input.TransferType import exchange.dydx.abacus.output.input.WithdrawalInputOptions +import exchange.dydx.abacus.state.manager.CctpConfig internal data class InternalTransferInputState( var chains: List? = null, @@ -33,7 +34,19 @@ internal data class InternalTransferInputState( var summary: TransferInputSummary? = null, var resources: TransferInputResources? = null, var route: Map? = null, -) +) { + val cctpChains: List? // chains filtered by cctp.json + get() = + chains?.filter { chain -> + CctpConfig.cctpChainIds?.any { it.chainId == chain.type } == true + } + + val cctpTokens: List? // tokens filtered by cctp.json + get() = + tokens?.filter { token -> + CctpConfig.cctpChainIds?.any { it.tokenAddress.lowercase() == token.type.lowercase() } == true + } +} internal fun TransferInputSize.Companion.safeCreate(existing: TransferInputSize?): TransferInputSize { return existing ?: TransferInputSize( diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Environment.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Environment.kt index eb3e67f52..17fd06eae 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Environment.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Environment.kt @@ -138,6 +138,7 @@ data class EnvironmentLinks( data class EnvironmentFeatureFlags( val withdrawalSafetyEnabled: Boolean, val isSlTpLimitOrdersEnabled: Boolean, + val cctpWithdrawalOnly: Boolean, ) { companion object { fun parse( @@ -146,10 +147,12 @@ data class EnvironmentFeatureFlags( ): EnvironmentFeatureFlags { val withdrawalSafetyEnabled = parser.asBool(data?.get("withdrawalSafetyEnabled")) ?: false val isSlTpLimitOrdersEnabled = parser.asBool(data?.get("isSlTpLimitOrdersEnabled")) ?: false + val cctpWithdrawalOnly = parser.asBool(data?.get("CCTPWithdrawalOnly")) ?: false return EnvironmentFeatureFlags( withdrawalSafetyEnabled, isSlTpLimitOrdersEnabled, + cctpWithdrawalOnly, ) } } diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt b/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt index dca361d18..dfef1808e 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt @@ -132,6 +132,7 @@ class AbacusMockData { featureFlags = EnvironmentFeatureFlags( withdrawalSafetyEnabled = true, isSlTpLimitOrdersEnabled = true, + cctpWithdrawalOnly = true, ), ) } diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 9df69ed4a..b9814a9d6 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.13.37' + spec.version = '1.13.38' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''