diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt index 0d824bed3..172991588 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt @@ -912,24 +912,46 @@ open class TradingStateMachine( "trade" -> { val trade = parser.asNativeMap(input["trade"]) ?: return null val type = parser.asString(trade["type"]) ?: return null + val isolatedMargin = parser.asString(trade["marginMode"]) == "ISOLATED" return when (type) { "MARKET", "STOP_MARKET", "TAKE_PROFIT_MARKET", "TRAILING_STOP" -> { - listOf( - ReceiptLine.BuyingPower.rawValue, - ReceiptLine.MarginUsage.rawValue, - ReceiptLine.ExpectedPrice.rawValue, - ReceiptLine.Fee.rawValue, - ReceiptLine.Reward.rawValue, - ) + if (isolatedMargin) { + listOf( + ReceiptLine.ExpectedPrice.rawValue, + ReceiptLine.LiquidationPrice.rawValue, + ReceiptLine.PositionMargin.rawValue, + ReceiptLine.PositionLeverage.rawValue, + ReceiptLine.Fee.rawValue, + ReceiptLine.Reward.rawValue, + ) + } else { + listOf( + ReceiptLine.BuyingPower.rawValue, + ReceiptLine.MarginUsage.rawValue, + ReceiptLine.ExpectedPrice.rawValue, + ReceiptLine.Fee.rawValue, + ReceiptLine.Reward.rawValue, + ) + } } else -> { - listOf( - ReceiptLine.BuyingPower.rawValue, - ReceiptLine.MarginUsage.rawValue, - ReceiptLine.Fee.rawValue, - ReceiptLine.Reward.rawValue, - ) + if (isolatedMargin) { + listOf( + ReceiptLine.LiquidationPrice.rawValue, + ReceiptLine.PositionMargin.rawValue, + ReceiptLine.PositionLeverage.rawValue, + ReceiptLine.Fee.rawValue, + ReceiptLine.Reward.rawValue, + ) + } else { + listOf( + ReceiptLine.BuyingPower.rawValue, + ReceiptLine.MarginUsage.rawValue, + ReceiptLine.Fee.rawValue, + ReceiptLine.Reward.rawValue, + ) + } } } } diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt index 05ae61fe7..0f29a6531 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt @@ -284,7 +284,14 @@ class V4ParentSubaccountTests : V4BaseTests(true) { "options": { "needsMarginMode": false } - } + }, + "receiptLines": [ + "LIQUIDATION_PRICE", + "POSITION_MARGIN", + "POSITION_LEVERAGE", + "FEE", + "REWARD" + ] } } """.trimIndent(), @@ -303,7 +310,13 @@ class V4ParentSubaccountTests : V4BaseTests(true) { "options": { "needsMarginMode": false } - } + }, + "receiptLines": [ + "BUYING_POWER", + "MARGIN_USAGE", + "FEE", + "REWARD" + ] } } """.trimIndent(),