From b4e2c0691861f7e6429e56d4d425157832f7cefb Mon Sep 17 00:00:00 2001 From: John Huang Date: Thu, 30 May 2024 16:50:57 -0700 Subject: [PATCH] Added liquidation price --- .../state/model/TradingStateMachine.kt | 69 ++++++++++--------- .../payload/v4/V4ParentSubaccountTests.kt | 5 +- 2 files changed, 37 insertions(+), 37 deletions(-) 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 fb8092d6e..c08d384fa 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt @@ -912,45 +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") + val isolatedMargin = parser.asString(trade["marginMode"]) == "ISOLATED" return when (type) { "MARKET", "STOP_MARKET", "TAKE_PROFIT_MARKET", "TRAILING_STOP" -> { - listOfNotNull( - ReceiptLine.BuyingPower.rawValue, - ReceiptLine.MarginUsage.rawValue, - if (isolatedMargin) { - ReceiptLine.PositionLeverage.rawValue - } else { - null - }, - if (isolatedMargin) { - ReceiptLine.PositionMargin.rawValue - } else { - null - }, - 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 -> { - listOfNotNull( - ReceiptLine.BuyingPower.rawValue, - ReceiptLine.MarginUsage.rawValue, - if (isolatedMargin) { - ReceiptLine.PositionLeverage.rawValue - } else { - null - }, - if (isolatedMargin) { - ReceiptLine.PositionMargin.rawValue - } else { - null - }, - 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 c29799040..0f29a6531 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt @@ -286,10 +286,9 @@ class V4ParentSubaccountTests : V4BaseTests(true) { } }, "receiptLines": [ - "BUYING_POWER", - "MARGIN_USAGE", - "POSITION_LEVERAGE", + "LIQUIDATION_PRICE", "POSITION_MARGIN", + "POSITION_LEVERAGE", "FEE", "REWARD" ]