Skip to content

Commit

Permalink
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 <[email protected]>
Co-authored-by: Rui <[email protected]>
Co-authored-by: Jared Vu <[email protected]>
  • Loading branch information
4 people authored and yogurtandjam committed May 31, 2024
1 parent b12e37b commit 38fd098
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,14 @@ class V4ParentSubaccountTests : V4BaseTests(true) {
"options": {
"needsMarginMode": false
}
}
},
"receiptLines": [
"LIQUIDATION_PRICE",
"POSITION_MARGIN",
"POSITION_LEVERAGE",
"FEE",
"REWARD"
]
}
}
""".trimIndent(),
Expand All @@ -303,7 +310,13 @@ class V4ParentSubaccountTests : V4BaseTests(true) {
"options": {
"needsMarginMode": false
}
}
},
"receiptLines": [
"BUYING_POWER",
"MARGIN_USAGE",
"FEE",
"REWARD"
]
}
}
""".trimIndent(),
Expand Down

0 comments on commit 38fd098

Please sign in to comment.