Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TRA-329 Added position leverage and position margin to receipt lines (#…
Browse files Browse the repository at this point in the history
…403)

Co-authored-by: mobile-build-bot-git <mobile-build-bot-git@dydx.exchange>
Co-authored-by: Rui <102453770+ruixhuang@users.noreply.github.com>
Co-authored-by: Jared Vu <jaredvu@gmail.com>
4 people authored and yogurtandjam committed May 31, 2024
1 parent c0e5804 commit b2dc016
Showing 2 changed files with 50 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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,
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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(),

0 comments on commit b2dc016

Please sign in to comment.