From 00ae245c614f99e2ae7c19fe9e96a8dc1729fe4f Mon Sep 17 00:00:00 2001 From: jeremy lee Date: Wed, 5 Jun 2024 18:02:06 +0300 Subject: [PATCH] feat: router vendor env flag [OTE-351] --- .../processor/router/IRouterProcessor.kt | 10 ++++-- .../state/manager/StateManagerAdaptor.kt | 1 + .../manager/V4StateManagerAdaptor+Transfer.kt | 6 ++-- .../state/manager/V4StateManagerAdaptor.kt | 26 ++++++++++++++ .../state/manager/utils/Settings.kt | 6 ++++ .../state/model/PerpTradingStateMachine.kt | 3 +- .../state/model/TradingStateMachine+Squid.kt | 12 +++---- .../TradingStateMachine+TransferInput.kt | 30 ++++++++-------- .../state/model/TradingStateMachine.kt | 10 +++++- .../state/v2/manager/StateManagerAdaptorV2.kt | 2 ++ .../state/v2/supervisor/Configs.kt | 7 ++++ .../v2/supervisor/OnboardingSupervisor.kt | 7 ++-- .../exchange.dydx.abacus/payload/BaseTests.kt | 1 + .../payload/v4/V4BaseTests.kt | 2 +- .../payload/v4/V4SquidTests.kt | 12 +++---- .../state/model/TradingStateMachineTests.kt | 34 +++++++++++++++++++ .../supervisor/OnboardingSupervisorTests.kt | 9 +++++ v4_abacus.podspec | 4 +-- 18 files changed, 141 insertions(+), 41 deletions(-) create mode 100644 src/commonTest/kotlin/exchange.dydx.abacus/state/model/TradingStateMachineTests.kt create mode 100644 src/commonTest/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisorTests.kt diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt index 8e8d48f5a..010188635 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt @@ -1,5 +1,9 @@ package exchange.dydx.abacus.processor.router +import exchange.dydx.abacus.output.input.SelectionOption +import exchange.dydx.abacus.output.input.TransferInputChainResource +import exchange.dydx.abacus.output.input.TransferInputTokenResource + interface IRouterProcessor { var tokens: List? var chains: List? @@ -44,8 +48,8 @@ interface IRouterProcessor { fun selectedTokenDecimals(tokenAddress: String?, selectedChainId: String?): String? fun filteredTokens(chainId: String?): List? fun defaultTokenAddress(chainId: String?): String? - fun chainResources(chainId: String?): Map? - fun tokenResources(chainId: String?): Map? + fun chainResources(chainId: String?): Map? + fun tokenResources(chainId: String?): Map? fun chainOptions(): List - fun tokenOptions(chainId: String?): List + fun tokenOptions(chainId: String?): List } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/StateManagerAdaptor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/StateManagerAdaptor.kt index 94c9490ec..19412efab 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/StateManagerAdaptor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/StateManagerAdaptor.kt @@ -133,6 +133,7 @@ open class StateManagerAdaptor( Formatter(uiImplementations.formatter), 127, false, + useSkip = appConfigs.routerVendor == AppConfigs.RouterVendor.Skip, ) internal var indexerConfig: IndexerURIs? diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor+Transfer.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor+Transfer.kt index 038fb6385..938b52921 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor+Transfer.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor+Transfer.kt @@ -65,7 +65,7 @@ internal fun V4StateManagerAdaptor.retrieveDepositExchanges() { } } exchangeList = exchanges - stateMachine.squidProcessor.exchangeDestinationChainId = configs.nobleChainId() + stateMachine.routerProcessor.exchangeDestinationChainId = configs.nobleChainId() } } } @@ -86,7 +86,7 @@ private fun V4StateManagerAdaptor.retrieveDepositRouteV1(state: PerpetualState?) val fromChain = state?.input?.transfer?.chain val fromToken = state?.input?.transfer?.token val fromAmount = parser.asDecimal(state?.input?.transfer?.size?.size)?.let { - val decimals = parser.asInt(stateMachine.squidProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) + val decimals = parser.asInt(stateMachine.routerProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) if (decimals != null) { (it * Numeric.decimal.TEN.pow(decimals)).toBigInteger() } else { @@ -144,7 +144,7 @@ private fun V4StateManagerAdaptor.retrieveDepositRouteV2(state: PerpetualState?) val fromChain = state?.input?.transfer?.chain val fromToken = state?.input?.transfer?.token val fromAmount = parser.asDecimal(state?.input?.transfer?.size?.size)?.let { - val decimals = parser.asInt(stateMachine.squidProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) + val decimals = parser.asInt(stateMachine.routerProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) if (decimals != null) { (it * Numeric.decimal.TEN.pow(decimals)).toBigInteger() } else { diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor.kt index 1983d9002..f57cdc321 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor.kt @@ -29,6 +29,8 @@ import exchange.dydx.abacus.state.model.onChainStakingRewards import exchange.dydx.abacus.state.model.onChainUnbonding import exchange.dydx.abacus.state.model.onChainUserFeeTier import exchange.dydx.abacus.state.model.onChainUserStats +import exchange.dydx.abacus.state.model.routerChains +import exchange.dydx.abacus.state.model.routerTokens import exchange.dydx.abacus.state.model.squidV2SdkInfo import exchange.dydx.abacus.state.model.updateHeight import exchange.dydx.abacus.utils.CoroutineTimer @@ -305,6 +307,30 @@ class V4StateManagerAdaptor( } } + @Suppress("UnusedPrivateMember") + private fun retrieveSkipTransferChains() { + val oldState = stateMachine.state + val chainsUrl = configs.skipV1Chains() + get(chainsUrl, null, null) { _, response, httpCode, _ -> + if (success(httpCode) && response != null) { + update(stateMachine.routerChains(response), oldState) + } + } + } + + @Suppress("UnusedPrivateMember") + private fun retrieveSkipTransferTokens() { + val oldState = stateMachine.state + val tokensUrl = configs.skipV1Assets() +// add API key injection +// val header = iMapOf("authorization" to skipAPIKey) + get(tokensUrl, null, null) { _, response, httpCode, _ -> + if (success(httpCode) && response != null) { + update(stateMachine.routerTokens(response), oldState) + } + } + } + private fun bestEffortConnectChain() { findOptimalNode { url -> this.validatorUrl = url diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/utils/Settings.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/utils/Settings.kt index 8eed0e3ba..939412e19 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/utils/Settings.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/utils/Settings.kt @@ -16,6 +16,12 @@ class AppConfigs( } var squidVersion: SquidVersion = SquidVersion.V2 + enum class RouterVendor { + Skip, + Squid + } + var routerVendor: RouterVendor = RouterVendor.Squid + companion object { val forApp = AppConfigs(subscribeToCandles = true, loadRemote = true) val forAppDebug = AppConfigs(subscribeToCandles = true, loadRemote = false, enableLogger = true) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/PerpTradingStateMachine.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/PerpTradingStateMachine.kt index 53056577f..ac937bfec 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/PerpTradingStateMachine.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/PerpTradingStateMachine.kt @@ -10,8 +10,9 @@ class PerpTradingStateMachine( formatter: Formatter?, maxSubaccountNumber: Int, useParentSubaccount: Boolean, + useSkip: Boolean ) : - TradingStateMachine(environment, localizer, formatter, maxSubaccountNumber, useParentSubaccount) { + TradingStateMachine(environment, localizer, formatter, maxSubaccountNumber, useParentSubaccount, useSkip = useSkip) { /* Placeholder for now. Eventually, the code specifically for Perpetual will be in this class */ diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+Squid.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+Squid.kt index a65417958..943d5becc 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+Squid.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+Squid.kt @@ -9,7 +9,7 @@ import kotlinx.serialization.json.jsonObject internal fun TradingStateMachine.routerChains(payload: String): StateChanges? { val json = parser.decodeJsonObject(payload) return if (json != null) { - input = squidProcessor.receivedChains(input, json) + input = routerProcessor.receivedChains(input, json) StateChanges(iListOf(Changes.input)) } else { StateChanges.noChange @@ -19,7 +19,7 @@ internal fun TradingStateMachine.routerChains(payload: String): StateChanges? { internal fun TradingStateMachine.routerTokens(payload: String): StateChanges? { val json = parser.decodeJsonObject(payload) return if (json != null) { - input = squidProcessor.receivedTokens(input, json) + input = routerProcessor.receivedTokens(input, json) StateChanges(iListOf(Changes.input)) } else { StateChanges.noChange @@ -29,7 +29,7 @@ internal fun TradingStateMachine.routerTokens(payload: String): StateChanges? { internal fun TradingStateMachine.squidV2SdkInfo(payload: String): StateChanges? { val json = parser.decodeJsonObject(payload) return if (json != null) { - input = squidProcessor.receivedV2SdkInfo(input, json) + input = routerProcessor.receivedV2SdkInfo(input, json) StateChanges(iListOf(Changes.input)) } else { StateChanges.noChange @@ -43,7 +43,7 @@ internal fun TradingStateMachine.squidRoute( ): StateChanges? { val json = parser.decodeJsonObject(payload) return if (json != null) { - input = squidProcessor.receivedRoute(input, json, requestId) + input = routerProcessor.receivedRoute(input, json, requestId) StateChanges( iListOf(Changes.input, Changes.subaccount), subaccountNumbers = iListOf(subaccountNumber), @@ -60,7 +60,7 @@ internal fun TradingStateMachine.squidRouteV2( ): StateChanges? { val json = parser.decodeJsonObject(payload) return if (json != null) { - input = squidProcessor.receivedRouteV2(input, json, requestId) + input = routerProcessor.receivedRouteV2(input, json, requestId) StateChanges( iListOf(Changes.input, Changes.subaccount), subaccountNumbers = iListOf(subaccountNumber), @@ -75,6 +75,6 @@ internal fun TradingStateMachine.squidStatus( transactionId: String? ): StateChanges? { val json = Json.parseToJsonElement(payload).jsonObject.toMap() - transferStatuses = squidProcessor.receivedStatus(transferStatuses, json, transactionId) + transferStatuses = routerProcessor.receivedStatus(transferStatuses, json, transactionId) return StateChanges(iListOf(Changes.transferStatuses)) } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+TransferInput.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+TransferInput.kt index 89265d288..e9391f86e 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+TransferInput.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine+TransferInput.kt @@ -75,11 +75,11 @@ fun TradingStateMachine.transfer( transfer.safeSet("chain", "chain") transfer.safeSet("token", "usdc") } else { - val chainType = squidProcessor.defaultChainId() + val chainType = routerProcessor.defaultChainId() if (chainType != null) { updateTransferToChainType(transfer, chainType) } - transfer.safeSet("token", squidProcessor.defaultTokenAddress(chainType)) + transfer.safeSet("token", routerProcessor.defaultTokenAddress(chainType)) } } changes = StateChanges( @@ -200,11 +200,11 @@ private fun TradingStateMachine.updateTransferToTokenType(transfer: MutableMap, chainType: String) { - val tokenOptions = squidProcessor.tokenOptions(chainType) + val tokenOptions = routerProcessor.tokenOptions(chainType) if (transfer["type"] != "TRANSFER_OUT") { internalState.transfer.tokens = tokenOptions transfer.safeSet("chain", chainType) - transfer.safeSet("token", squidProcessor.defaultTokenAddress(chainType)) - internalState.transfer.chainResources = squidProcessor.chainResources(chainType) - internalState.transfer.tokenResources = squidProcessor.tokenResources(chainType) + transfer.safeSet("token", routerProcessor.defaultTokenAddress(chainType)) + internalState.transfer.chainResources = routerProcessor.chainResources(chainType) + internalState.transfer.tokenResources = routerProcessor.tokenResources(chainType) } transfer.safeSet("exchange", null) transfer.safeSet("size.size", null) @@ -235,21 +235,21 @@ private fun TradingStateMachine.updateTransferToChainType(transfer: MutableMap, exchange: String) { - val exchangeDestinationChainId = squidProcessor.exchangeDestinationChainId - val tokenOptions = squidProcessor.tokenOptions(exchangeDestinationChainId) + val exchangeDestinationChainId = routerProcessor.exchangeDestinationChainId + val tokenOptions = routerProcessor.tokenOptions(exchangeDestinationChainId) if (transfer["type"] != "TRANSFER_OUT") { internalState.transfer.tokens = tokenOptions - transfer.safeSet("token", squidProcessor.defaultTokenAddress(exchangeDestinationChainId)) - internalState.transfer.tokenResources = squidProcessor.tokenResources(exchangeDestinationChainId) + transfer.safeSet("token", routerProcessor.defaultTokenAddress(exchangeDestinationChainId)) + internalState.transfer.tokenResources = routerProcessor.tokenResources(exchangeDestinationChainId) // needed to pass tests, remove later transfer.safeSet( @@ -262,7 +262,7 @@ private fun TradingStateMachine.updateTransferExchangeType(transfer: MutableMap< ) transfer.safeSet( "resources.tokenResources", - squidProcessor.tokenResources(exchangeDestinationChainId), + routerProcessor.tokenResources(exchangeDestinationChainId), ) } transfer.safeSet("exchange", exchange) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt index fd0faeccf..2285d2e16 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt @@ -32,6 +32,8 @@ import exchange.dydx.abacus.processor.assets.AssetsProcessor import exchange.dydx.abacus.processor.configs.ConfigsProcessor import exchange.dydx.abacus.processor.launchIncentive.LaunchIncentiveProcessor import exchange.dydx.abacus.processor.markets.MarketsSummaryProcessor +import exchange.dydx.abacus.processor.router.IRouterProcessor +import exchange.dydx.abacus.processor.router.skip.SkipProcessor import exchange.dydx.abacus.processor.router.squid.SquidProcessor import exchange.dydx.abacus.processor.wallet.WalletProcessor import exchange.dydx.abacus.protocols.LocalizerProtocol @@ -81,6 +83,7 @@ open class TradingStateMachine( private val formatter: Formatter?, private val maxSubaccountNumber: Int, private val useParentSubaccount: Boolean, + val useSkip: Boolean, ) { internal val internalState: InternalState = InternalState() @@ -93,7 +96,7 @@ open class TradingStateMachine( } internal val walletProcessor = WalletProcessor(parser) internal val configsProcessor = ConfigsProcessor(parser) - internal val squidProcessor = SquidProcessor(parser, internalState.transfer) + internal val routerProcessor = constructRouterProcessor() internal val rewardsProcessor = RewardsProcessor(parser) internal val launchIncentiveProcessor = LaunchIncentiveProcessor(parser) @@ -258,6 +261,11 @@ open class TradingStateMachine( return socket(url, json, subaccountNumber, height) } + private fun constructRouterProcessor(): IRouterProcessor { + if (useSkip) return SkipProcessor(parser = parser, internalState = internalState.transfer) + return SquidProcessor(parser = parser, internalState = internalState.transfer) + } + @Throws(Exception::class) private fun socket( url: AbUrl, diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt index 1cbb0483b..1240014fe 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt @@ -49,6 +49,7 @@ import exchange.dydx.abacus.state.v2.supervisor.ConnectionDelegate import exchange.dydx.abacus.state.v2.supervisor.ConnectionsSupervisor import exchange.dydx.abacus.state.v2.supervisor.MarketsSupervisor import exchange.dydx.abacus.state.v2.supervisor.NetworkHelper +import exchange.dydx.abacus.state.v2.supervisor.OnboardingConfigs import exchange.dydx.abacus.state.v2.supervisor.OnboardingSupervisor import exchange.dydx.abacus.state.v2.supervisor.SystemSupervisor import exchange.dydx.abacus.state.v2.supervisor.accountAddress @@ -110,6 +111,7 @@ internal class StateManagerAdaptorV2( Formatter(uiImplementations.formatter), 127, appConfigs.accountConfigs.subaccountConfigs.useParentSubaccount, + useSkip = appConfigs.onboardingConfigs.routerVendor == OnboardingConfigs.RouterVendor.Skip, ) internal val jsonEncoder = JsonEncoder() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt index 7fdabee38..05791007a 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt @@ -171,6 +171,13 @@ data class OnboardingConfigs( var squidVersion: SquidVersion = SquidVersion.V2 + enum class RouterVendor { + Squid, + Skip + } + + var routerVendor: RouterVendor = RouterVendor.Squid + companion object { val forApp = OnboardingConfigs( retrieveSquidRoutes = true, diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt index 4214fb79b..7985afa00 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt @@ -95,6 +95,7 @@ internal class OnboardingSupervisor( } } + @Suppress("UnusedPrivateMember") private fun retrieveTransferAssets() { val oldState = stateMachine.state val url = helper.configs.squidV2Assets() @@ -147,7 +148,7 @@ internal class OnboardingSupervisor( } } ExchangeConfig.exchangeList = exchanges - stateMachine.squidProcessor.exchangeDestinationChainId = + stateMachine.routerProcessor.exchangeDestinationChainId = helper.configs.nobleChainId() } } @@ -197,7 +198,7 @@ internal class OnboardingSupervisor( val fromToken = state?.input?.transfer?.token val fromAmount = helper.parser.asDecimal(state?.input?.transfer?.size?.size)?.let { val decimals = - helper.parser.asInt(stateMachine.squidProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) + helper.parser.asInt(stateMachine.routerProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) if (decimals != null) { (it * Numeric.decimal.TEN.pow(decimals)).toBigInteger() } else { @@ -259,7 +260,7 @@ internal class OnboardingSupervisor( val fromToken = state?.input?.transfer?.token val fromAmount = helper.parser.asDecimal(state?.input?.transfer?.size?.size)?.let { val decimals = - helper.parser.asInt(stateMachine.squidProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) + helper.parser.asInt(stateMachine.routerProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) if (decimals != null) { (it * Numeric.decimal.TEN.pow(decimals)).toBigInteger() } else { diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/payload/BaseTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/BaseTests.kt index 32971647f..7489f68e4 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/BaseTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/BaseTests.kt @@ -122,6 +122,7 @@ open class BaseTests(private val maxSubaccountNumber: Int, internal val useParen formatter = null, maxSubaccountNumber = maxSubaccountNumber, useParentSubaccount = useParentSubaccount, + useSkip = false, ) } diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4BaseTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4BaseTests.kt index 1f1a2645e..77a7549a7 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4BaseTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4BaseTests.kt @@ -28,7 +28,7 @@ open class V4BaseTests(useParentSubaccount: Boolean = false) : BaseTests(127, us internal val testRestUrl = "https://indexer.v4staging.dydx.exchange" override fun createState(useParentSubaccount: Boolean): PerpTradingStateMachine { - return PerpTradingStateMachine(mock.v4Environment, null, null, 127, useParentSubaccount) + return PerpTradingStateMachine(mock.v4Environment, null, null, 127, useParentSubaccount, useSkip = false) } internal open fun loadMarkets(): StateResponse { diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4SquidTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4SquidTests.kt index 48280110a..c97043e6a 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4SquidTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4SquidTests.kt @@ -202,7 +202,7 @@ class V4SquidTests : V4BaseTests() { val stateChange = perp.routerTokens(mock.squidTokensMock.payload) assertNotNull(stateChange) - assertTrue(perp.squidProcessor.selectedTokenSymbol("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "should_not_matter") == "ETH") + assertTrue(perp.routerProcessor.selectedTokenSymbol("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "should_not_matter") == "ETH") } @Test @@ -212,7 +212,7 @@ class V4SquidTests : V4BaseTests() { val stateChange = perp.routerTokens(mock.squidTokensMock.payload) assertNotNull(stateChange) - assertTrue(perp.squidProcessor.selectedTokenDecimals("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "should_not_matter") == "18") + assertTrue(perp.routerProcessor.selectedTokenDecimals("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "should_not_matter") == "18") } @Test @@ -225,7 +225,7 @@ class V4SquidTests : V4BaseTests() { stateChange = perp.routerTokens(mock.squidTokensMock.payload) assertNotNull(stateChange) - assertTrue(perp.squidProcessor.defaultTokenAddress("1") == "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE") + assertTrue(perp.routerProcessor.defaultTokenAddress("1") == "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE") } @Test @@ -235,7 +235,7 @@ class V4SquidTests : V4BaseTests() { val stateChange = perp.routerChains(mock.squidChainsMock.payload) assertNotNull(stateChange) - val result = perp.squidProcessor.chainResources("1") + val result = perp.routerProcessor.chainResources("1") val resource = result?.get("1") assertTrue(resource?.chainId == 1) // Ethereum assertTrue(resource?.chainName == "Ethereum") // Ethereum @@ -251,7 +251,7 @@ class V4SquidTests : V4BaseTests() { stateChange = perp.routerTokens(mock.squidTokensMock.payload) assertNotNull(stateChange) - val result = perp.squidProcessor.tokenResources("1") + val result = perp.routerProcessor.tokenResources("1") assertTrue((result?.keys?.size ?: 0) > 0) } @@ -265,7 +265,7 @@ class V4SquidTests : V4BaseTests() { stateChange = perp.routerTokens(mock.squidTokensMock.payload) assertNotNull(stateChange) - val result = perp.squidProcessor.tokenOptions("1") + val result = perp.routerProcessor.tokenOptions("1") assertTrue(result.size > 0) } } diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/state/model/TradingStateMachineTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/state/model/TradingStateMachineTests.kt new file mode 100644 index 000000000..63a7f0c56 --- /dev/null +++ b/src/commonTest/kotlin/exchange.dydx.abacus/state/model/TradingStateMachineTests.kt @@ -0,0 +1,34 @@ +package exchange.dydx.abacus.state.model + +import exchange.dydx.abacus.processor.router.skip.SkipProcessor +import exchange.dydx.abacus.processor.router.squid.SquidProcessor +import kotlin.test.Test +import kotlin.test.assertTrue + +class TradingStateMachineTests { + @Test + fun testConstructRouterProcessorSkip() { + val tradingStateMachine = TradingStateMachine( + environment = null, + localizer = null, + formatter = null, + maxSubaccountNumber = 1, + useParentSubaccount = false, + useSkip = true, + ) + assertTrue(tradingStateMachine.routerProcessor is SkipProcessor) + } + + @Test + fun testConstructRouterProcessorSquid() { + val tradingStateMachine = TradingStateMachine( + environment = null, + localizer = null, + formatter = null, + maxSubaccountNumber = 1, + useParentSubaccount = false, + useSkip = false, + ) + assertTrue(tradingStateMachine.routerProcessor is SquidProcessor) + } +} diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisorTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisorTests.kt new file mode 100644 index 000000000..565aeab21 --- /dev/null +++ b/src/commonTest/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisorTests.kt @@ -0,0 +1,9 @@ +package exchange.dydx.abacus.state.v2.supervisor +import kotlin.test.Test + +class OnboardingSupervisorTests { + @Test + fun testSquidRoutes() { +// TODO: implement + } +} diff --git a/v4_abacus.podspec b/v4_abacus.podspec index e6044e131..add85d6cb 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.7.49' + spec.version = '1.7.52' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = '' @@ -11,7 +11,7 @@ Pod::Spec.new do |spec| - if false + if !Dir.exist?('build/cocoapods/framework/Abacus.framework') || Dir.empty?('build/cocoapods/framework/Abacus.framework') raise " Kotlin framework 'Abacus' doesn't exist yet, so a proper Xcode project can't be generated.