Skip to content

Commit

Permalink
Remove margin usage validation (#450)
Browse files Browse the repository at this point in the history
Co-authored-by: mobile-build-bot-git <[email protected]>
  • Loading branch information
aforaleka and mobile-build-bot authored Jun 17, 2024
1 parent 3783479 commit 30dd213
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 47 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.7.77"
version = "1.7.78"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ internal class InputValidator(
"LIMIT_MUST_BELOW_TRIGGER_PRICE" to 1043,
"PRICE_MUST_POSITIVE" to 1044,

"INVALID_NEW_ACCOUNT_MARGIN_USAGE" to 1053,

"BUY_TRIGGER_TOO_CLOSE_TO_LIQUIDATION_PRICE" to 1060,
"SELL_TRIGGER_TOO_CLOSE_TO_LIQUIDATION_PRICE" to 1061,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ internal class TradeAccountStateValidator(
}
}
false -> {
val marginError = validateSubaccountMarginUsage(
parser,
subaccount,
change,
)
if (marginError != null) {
errors.add(marginError)
}
val crossOrdersError = validateSubaccountCrossOrders(
parser,
subaccount,
Expand All @@ -86,42 +78,6 @@ internal class TradeAccountStateValidator(
}
}

private fun validateSubaccountMarginUsage(
parser: ParserProtocol,
subaccount: Map<String, Any>,
change: PositionChange,
): Map<String, Any>? {
/*
INVALID_NEW_ACCOUNT_MARGIN_USAGE
*/
return when (change) {
PositionChange.CLOSING, PositionChange.DECREASING -> null
else -> {
val equity = parser.asDouble(parser.value(subaccount, "equity.postOrder"))
val marginUsage = parser.asDouble(parser.value(subaccount, "marginUsage.postOrder"))
if (equity != null &&
(
equity == Numeric.double.ZERO ||
marginUsage == null ||
marginUsage < Numeric.double.ZERO ||
marginUsage > Numeric.double.ONE
)
) {
error(
"ERROR",
"INVALID_NEW_ACCOUNT_MARGIN_USAGE",
listOf("size.size"),
"APP.TRADE.MODIFY_SIZE_FIELD",
"ERRORS.TRADE_BOX_TITLE.INVALID_NEW_ACCOUNT_MARGIN_USAGE",
"ERRORS.TRADE_BOX.INVALID_NEW_ACCOUNT_MARGIN_USAGE",
)
} else {
null
}
}
}
}

private fun validateSubaccountCrossOrders(
parser: ParserProtocol,
subaccount: Map<String, Any>,
Expand Down

0 comments on commit 30dd213

Please sign in to comment.