diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/AccountSupervisor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/AccountSupervisor.kt index 236854c26..bc01e69a6 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/AccountSupervisor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/AccountSupervisor.kt @@ -753,6 +753,56 @@ internal open class AccountSupervisor( } } + private fun transferNobleBalanceSkip(amount: BigDecimal) { + val url = helper.configs.skipV2MsgsDirect() + val fromChain = helper.configs.nobleChainId() + val fromToken = helper.configs.nobleDenom + val nobleAddress = accountAddress.toNobleAddress() ?: return + val chainId = helper.environment.dydxChainId ?: return + val dydxTokenDemon = helper.environment.tokens["usdc"]?.denom ?: return + val body: Map = mapOf( + "amount_in" to amount.toPlainString(), +// from noble denom and chain + "source_asset_denom" to fromToken, + "source_asset_chain_id" to fromChain, +// to dydx denom and chain + "dest_asset_denom" to dydxTokenDemon, + "dest_asset_chain_id" to chainId, + "chain_ids_to_addresses" to mapOf( + fromChain to nobleAddress, + chainId to accountAddress, + ), + "slippage_tolerance_percent" to SLIPPAGE_PERCENT, + ) + val header = + iMapOf( + "Content-Type" to "application/json", + ) + helper.post(url, header, body.toJsonPrettyPrint()) { _, response, code, _ -> + if (response == null) { + val json = helper.parser.decodeJsonObject(response) + if (json != null) { + val skipRoutePayloadProcessor = SkipRoutePayloadProcessor(parser = helper.parser) + val processedPayload = skipRoutePayloadProcessor.received(existing = mapOf(), payload = json) + val ibcPayload = + helper.parser.asString( + processedPayload.get("data"), + ) + if (ibcPayload != null) { + helper.transaction(TransactionType.SendNobleIBC, ibcPayload) { + val error = helper.parseTransactionResponse(it) + if (error != null) { + Logger.e { "transferNobleBalanceSkip error: $error" } + } + } + } + } + } else { + Logger.e { "transferNobleBalanceSkip error, code: $code" } + } + } + } + private fun handleComplianceResponse(response: String?, httpCode: Int): ComplianceStatus { var complianceStatus = ComplianceStatus.UNKNOWN var updatedAt: String? = null