From 7f97702d833ca308598dd571a997aae245ce88f2 Mon Sep 17 00:00:00 2001 From: Prashan Dharmasena Date: Thu, 17 Oct 2024 10:35:49 -0700 Subject: [PATCH] Use correct side for position notifications. --- .../kotlin/exchange.dydx.abacus/output/input/TradeInput.kt | 5 +++++ .../notification/providers/FillsNotificationProvider.kt | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/output/input/TradeInput.kt b/src/commonMain/kotlin/exchange.dydx.abacus/output/input/TradeInput.kt index dbad270dc..e5a4724cc 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/output/input/TradeInput.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/output/input/TradeInput.kt @@ -775,6 +775,11 @@ enum class OrderSide(val rawValue: String) { Buy("BUY"), Sell("SELL"); + fun opposite() = when (this) { + Buy -> Sell + Sell -> Buy + } + companion object { operator fun invoke(rawValue: String?) = OrderSide.values().firstOrNull { it.rawValue == rawValue } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/notification/providers/FillsNotificationProvider.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/notification/providers/FillsNotificationProvider.kt index aa1b663d4..5ee66d4f8 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/notification/providers/FillsNotificationProvider.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/notification/providers/FillsNotificationProvider.kt @@ -156,8 +156,11 @@ class FillsNotificationProvider( val asset = stateMachine.state?.assetOfMarket(marketId) ?: return null val assetText = asset.name val marketImageUrl = asset.resources?.imageUrl - val side = fill.side.rawValue + + // opposite because these notifications are all about positions, not the fill that triggered the notif. + val side = fill.side.opposite().rawValue val sideText = uiImplementations.localizer?.localize("APP.GENERAL.$side") + val amountText = parser.asString(fill.size) val priceText = parser.asString(fill.price) val fillType = fill.type.rawValue