From 08dcff2656d5f06343fb6113af843aca42a62ca3 Mon Sep 17 00:00:00 2001 From: Jared Vu Date: Mon, 17 Jun 2024 21:26:54 -0700 Subject: [PATCH] v1.7.83: Update order status enum strings (#454) Co-authored-by: mobile-build-bot-git --- build.gradle.kts | 2 +- .../calculator/AccountCalculator.kt | 1 + .../v2/supervisor/SubaccountSupervisor.kt | 28 +++++++++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c8d548cc0..a543bd113 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.7.82" +version = "1.7.83" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/AccountCalculator.kt b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/AccountCalculator.kt index 47bf2bd59..b3e349ca2 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/AccountCalculator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/AccountCalculator.kt @@ -177,6 +177,7 @@ class AccountCalculator(val parser: ParserProtocol, private val useParentSubacco } val orderStatus = parser.asString(parser.value(order, "status")) + if (!listOf("OPEN", "PENDING", "UNTRIGGERED", "PARTIALLY_FILLED").contains(orderStatus)) { continue } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SubaccountSupervisor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SubaccountSupervisor.kt index 2bf562908..87e55c70d 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SubaccountSupervisor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SubaccountSupervisor.kt @@ -64,6 +64,7 @@ import exchange.dydx.abacus.utils.GoodTil import exchange.dydx.abacus.utils.IList import exchange.dydx.abacus.utils.IMap import exchange.dydx.abacus.utils.IMutableList +import exchange.dydx.abacus.utils.Logger import exchange.dydx.abacus.utils.MAX_SUBACCOUNT_NUMBER import exchange.dydx.abacus.utils.NUM_PARENT_SUBACCOUNTS import exchange.dydx.abacus.utils.ParsingHelper @@ -556,7 +557,13 @@ internal class SubaccountSupervisor( val openPositions = subaccount.openPositions val openOrders = subaccount.orders?.filter { order -> val status = helper.parser.asString(order.status) - status == "open" || status == "pending" || status == "untriggered" || status == "partiallyFilled" + + iListOf( + OrderStatus.Open.name, + OrderStatus.Pending.name, + OrderStatus.Untriggered.name, + OrderStatus.PartiallyFilled.name, + ).contains(status) } val positionMarketIds = openPositions?.map { position -> @@ -1476,12 +1483,18 @@ internal class SubaccountSupervisor( return@mapValues 0.0 } + val quoteBalance = subaccount.value.quoteBalance?.current ?: 0.0 val openPositions = subaccount.value.openPositions + val openOrders = subaccount.value.orders?.filter { order -> val status = helper.parser.asString(order.status) - iListOf("open", "pending", "untriggered", "partiallyFilled").contains(status) + iListOf( + OrderStatus.Open.name, + OrderStatus.Pending.name, + OrderStatus.Untriggered.name, + OrderStatus.PartiallyFilled.name, + ).contains(status) } - val quoteBalance = subaccount.value.quoteBalance?.current ?: 0.0 // Only return a quoteBalance if the subaccount has no open positions or orders if (openPositions.isNullOrEmpty() && openOrders.isNullOrEmpty() && quoteBalance > 0.0) { @@ -1496,8 +1509,13 @@ internal class SubaccountSupervisor( val transferPayloadStrings = iMutableListOf() subaccountQuoteBalanceMap.forEach { - val childSubaccountNumber = it.key.toInt() - val amountToTransfer = it.value.toString() + val childSubaccountNumber = helper.parser.asInt(it.key) + val amountToTransfer = helper.parser.asString(it.value) + + if (childSubaccountNumber == null || amountToTransfer == null) { + Logger.e { "Child Subaccount Number or Amount to Transfer is null" } + return@forEach + } val transferPayload = HumanReadableSubaccountTransferPayload( childSubaccountNumber,