From 97ba0c2dedf829564df636518e4a44f165c7fcf0 Mon Sep 17 00:00:00 2001 From: jeremy lee Date: Wed, 5 Jun 2024 01:20:09 +0300 Subject: [PATCH] fix --- .../v2/supervisor/OnboardingSupervisor.kt | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) 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 1380f539d..9db4fe8c6 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 @@ -222,23 +222,24 @@ internal class OnboardingSupervisor( dydxTokenDemon != null && url != null ) { - val params: IMap = iMapOf( - "fromChain" to fromChain, - "fromToken" to fromToken, - "fromAmount" to fromAmountString, - "toChain" to chainId, - "toToken" to dydxTokenDemon, - "toAddress" to accountAddress, - "slippage" to "1", - "enableForecall" to "false", - "fromAddress" to sourceAddress, + val body: Map = mapOf( + "amount_in" to fromAmountString, + "source_asset_denom" to fromToken, + "source_asset_chain_id" to fromChain, + "dest_asset_denom" to dydxTokenDemon, + "dest_asset_chain_id" to chainId, + "chain_ids_to_addresses" to mapOf( + "fromChain" to sourceAddress, + "toChain" to accountAddress, + ), + "slippage_tolerance_percent" to SLIPPAGE_PERCENT, ) val oldState = stateMachine.state val header = iMapOf( "Content-Type" to "application/json", ) - helper.get(url, params, header) { _, response, code, headers -> + helper.get(url, body, header) { _, response, code, headers -> if (response != null) { val currentFromAmount = stateMachine.state?.input?.transfer?.size?.size val oldFromAmount = oldState?.input?.transfer?.size?.size @@ -265,21 +266,21 @@ internal class OnboardingSupervisor( // TODO: Consider creating generateArgs fun to reduce code duplication 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.routerProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) + val fromAmount = helper.parser.asDecimal(state?.input?.transfer?.size?.size)?.let { + val decimals = helper.parser.asInt(stateMachine.routerProcessor.selectedTokenDecimals(tokenAddress = fromToken, selectedChainId = fromChain)) if (decimals != null) { (it * Numeric.decimal.TEN.pow(decimals)).toBigInteger() } else { null } } - val chainId = environment.dydxChainId - val dydxTokenDemon = environment.tokens["usdc"]?.denom - val fromAmountString = parser.asString(fromAmount) + val chainId = helper.environment.dydxChainId + val dydxTokenDemon = helper.environment.tokens["usdc"]?.denom + val fromAmountString = helper.parser.asString(fromAmount) val nobleAddress = accountAddress?.toNobleAddress() - val url = configs.skipV2MsgsDirect() - val toChain = configs.nobleChainId() - val toToken = configs.nobleDenom() + val url = helper.configs.skipV2MsgsDirect() + val toChain = helper.configs.nobleChainId() + val toToken = helper.configs.nobleDenom() if (fromChain != null && fromToken != null && fromAmount != null && fromAmount > 0 && @@ -306,7 +307,7 @@ internal class OnboardingSupervisor( val header = iMapOf( "Content-Type" to "application/json", ) - post(url, header, body.toJsonPrettyPrint()) { _, response, code, headers -> + helper.post(url, header, body.toJsonPrettyPrint()) { _, response, code, headers -> if (response != null) { val currentFromAmount = stateMachine.state?.input?.transfer?.size?.size val oldFromAmount = oldState?.input?.transfer?.size?.size