From 30dd21357a527d2a9ecff645d07fa43119810c3c Mon Sep 17 00:00:00 2001 From: aleka Date: Mon, 17 Jun 2024 17:50:33 -0400 Subject: [PATCH] Remove margin usage validation (#450) Co-authored-by: mobile-build-bot-git --- build.gradle.kts | 2 +- .../validator/InputValidator.kt | 2 - .../trade/TradeAccountStateValidator.kt | 44 ------------------- 3 files changed, 1 insertion(+), 47 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 36a532fe8..d0c1fe8b0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.7.77" +version = "1.7.78" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/validator/InputValidator.kt b/src/commonMain/kotlin/exchange.dydx.abacus/validator/InputValidator.kt index fab57a4f8..f5a439a42 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/validator/InputValidator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/validator/InputValidator.kt @@ -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, diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeAccountStateValidator.kt b/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeAccountStateValidator.kt index 79cb71fc5..5846cd2cb 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeAccountStateValidator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeAccountStateValidator.kt @@ -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, @@ -86,42 +78,6 @@ internal class TradeAccountStateValidator( } } - private fun validateSubaccountMarginUsage( - parser: ParserProtocol, - subaccount: Map, - change: PositionChange, - ): Map? { - /* - 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,