Skip to content

Commit

Permalink
v1.7.83: Update order status enum strings (#454)
Browse files Browse the repository at this point in the history
Co-authored-by: mobile-build-bot-git <[email protected]>
  • Loading branch information
jaredvu and mobile-build-bot authored Jun 18, 2024
1 parent 0eaef03 commit 08dcff2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.7.82"
version = "1.7.83"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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) {
Expand All @@ -1496,8 +1509,13 @@ internal class SubaccountSupervisor(
val transferPayloadStrings = iMutableListOf<String>()

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,
Expand Down

0 comments on commit 08dcff2

Please sign in to comment.