diff --git a/build.gradle.kts b/build.gradle.kts index 955aff3ef..0fa829d04 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,7 +48,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.6.33" +version = "1.6.34" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/validator/TriggerOrdersInputValidator.kt b/src/commonMain/kotlin/exchange.dydx.abacus/validator/TriggerOrdersInputValidator.kt index fa23cc7ac..d4c60345e 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/validator/TriggerOrdersInputValidator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/validator/TriggerOrdersInputValidator.kt @@ -378,6 +378,7 @@ internal class TriggerOrdersInputValidator( triggerToIndex, oraclePrice, tickSize, + type, ), ) } @@ -390,6 +391,7 @@ internal class TriggerOrdersInputValidator( triggerToIndex, oraclePrice, tickSize, + type, ), ) } @@ -403,7 +405,8 @@ internal class TriggerOrdersInputValidator( private fun validateLimitPrice( triggerOrder: Map, ): List? { - return when (parser.asString(triggerOrder["type"])) { + val type = parser.asString(triggerOrder["type"]) + return when (type) { "STOP_LIMIT", "TAKE_PROFIT" -> { parser.asString(parser.value(triggerOrder, "side"))?.let { side -> parser.asDouble(parser.value(triggerOrder, "price.limitPrice")) @@ -417,8 +420,8 @@ internal class TriggerOrdersInputValidator( "LIMIT_MUST_ABOVE_TRIGGER_PRICE", listOf("price.triggerPrice"), "APP.TRADE.MODIFY_TRIGGER_PRICE", - "ERRORS.TRADE_BOX_TITLE.LIMIT_MUST_ABOVE_TRIGGER_PRICE", - "ERRORS.TRADE_BOX.LIMIT_MUST_ABOVE_TRIGGER_PRICE", + if (type === "STOP_LIMIT") "ERRORS.TRIGGERS_FORM_TITLE.STOP_LOSS_LIMIT_MUST_ABOVE_TRIGGER_PRICE" else "ERRORS.TRIGGERS_FORM_TITLE.TAKE_PROFIT_LIMIT_MUST_ABOVE_TRIGGER_PRICE", + if (type === "STOP_LIMIT") "ERRORS.TRIGGERS_FORM.STOP_LOSS_LIMIT_MUST_ABOVE_TRIGGER_PRICE" else "ERRORS.TRIGGERS_FORM.TAKE_PROFIT_LIMIT_MUST_ABOVE_TRIGGER_PRICE", ), ) } else if (side == "SELL" && limitPrice > triggerPrice) { @@ -428,8 +431,8 @@ internal class TriggerOrdersInputValidator( "LIMIT_MUST_BELOW_TRIGGER_PRICE", listOf("price.triggerPrice"), "APP.TRADE.MODIFY_TRIGGER_PRICE", - "ERRORS.TRADE_BOX_TITLE.LIMIT_MUST_BELOW_TRIGGER_PRICE", - "ERRORS.TRADE_BOX.LIMIT_MUST_BELOW_TRIGGER_PRICE", + if (type === "STOP_LIMIT") "ERRORS.TRIGGERS_FORM_TITLE.STOP_LOSS_LIMIT_MUST_BELOW_TRIGGER_PRICE" else "ERRORS.TRIGGERS_FORM_TITLE.TAKE_PROFIT_LIMIT_MUST_BELOW_TRIGGER_PRICE", + if (type === "STOP_LIMIT") "ERRORS.TRIGGERS_FORM.STOP_LOSS_LIMIT_MUST_BELOW_TRIGGER_PRICE" else "ERRORS.TRIGGERS_FORM.TAKE_PROFIT_LIMIT_MUST_BELOW_TRIGGER_PRICE", ), ) } else { @@ -528,6 +531,7 @@ internal class TriggerOrdersInputValidator( triggerToIndex: RelativeToPrice, oraclePrice: Double, tickSize: String, + type: String, ): Map { val fields = listOf("price.triggerPrice") val action = "APP.TRADE.MODIFY_TRIGGER_PRICE" @@ -545,8 +549,8 @@ internal class TriggerOrdersInputValidator( "TRIGGER_MUST_ABOVE_INDEX_PRICE", fields, action, - "ERRORS.TRADE_BOX_TITLE.TRIGGER_MUST_ABOVE_INDEX_PRICE", - "ERRORS.TRADE_BOX.TRIGGER_MUST_ABOVE_INDEX_PRICE", + if (type === "STOP_LIMIT" || type === "STOP_MARKET") "ERRORS.TRIGGERS_FORM_TITLE.STOP_LOSS_TRIGGER_MUST_ABOVE_INDEX_PRICE" else "ERRORS.TRIGGERS_FORM_TITLE.TAKE_PROFIT_TRIGGER_MUST_ABOVE_INDEX_PRICE", + if (type === "STOP_LIMIT" || type === "STOP_MARKET") "ERRORS.TRIGGERS_FORM.STOP_LOSS_TRIGGER_MUST_ABOVE_INDEX_PRICE" else "ERRORS.TRIGGERS_FORM.TAKE_PROFIT_TRIGGER_MUST_ABOVE_INDEX_PRICE", params, ) @@ -555,8 +559,8 @@ internal class TriggerOrdersInputValidator( "TRIGGER_MUST_BELOW_INDEX_PRICE", fields, action, - "ERRORS.TRADE_BOX_TITLE.TRIGGER_MUST_BELOW_INDEX_PRICE", - "ERRORS.TRADE_BOX.TRIGGER_MUST_BELOW_INDEX_PRICE", + if (type === "STOP_LIMIT" || type === "STOP_MARKET") "ERRORS.TRIGGERS_FORM_TITLE.STOP_LOSS_TRIGGER_MUST_BELOW_INDEX_PRICE" else "ERRORS.TRIGGERS_FORM_TITLE.TAKE_PROFIT_TRIGGER_MUST_BELOW_INDEX_PRICE", + if (type === "STOP_LIMIT" || type === "STOP_MARKET") "ERRORS.TRIGGERS_FORM.STOP_LOSS_TRIGGER_MUST_BELOW_INDEX_PRICE" else "ERRORS.TRIGGERS_FORM.TAKE_PROFIT_TRIGGER_MUST_BELOW_INDEX_PRICE", params, ) } diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/validation/TriggerOrdersInputValidationTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/validation/TriggerOrdersInputValidationTests.kt index 69ded18be..7fd3e0c3d 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/validation/TriggerOrdersInputValidationTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/validation/TriggerOrdersInputValidationTests.kt @@ -147,7 +147,18 @@ class TriggerOrdersInputValidationTests : V4BaseTests() { "errors": [ { "type": "ERROR", - "code": "TRIGGER_MUST_BELOW_INDEX_PRICE" + "code": "TRIGGER_MUST_BELOW_INDEX_PRICE", + "resources": { + "title": { + "stringKey": "ERRORS.TRIGGERS_FORM_TITLE.STOP_LOSS_TRIGGER_MUST_BELOW_INDEX_PRICE" + }, + "text": { + "stringKey": "ERRORS.TRIGGERS_FORM.STOP_LOSS_TRIGGER_MUST_BELOW_INDEX_PRICE" + }, + "action": { + "stringKey": "APP.TRADE.MODIFY_TRIGGER_PRICE" + } + } } ] } @@ -260,7 +271,18 @@ class TriggerOrdersInputValidationTests : V4BaseTests() { "errors": [ { "type": "ERROR", - "code": "LIMIT_MUST_BELOW_TRIGGER_PRICE" + "code": "LIMIT_MUST_BELOW_TRIGGER_PRICE", + "resources": { + "title": { + "stringKey": "ERRORS.TRIGGERS_FORM_TITLE.STOP_LOSS_LIMIT_MUST_BELOW_TRIGGER_PRICE" + }, + "text": { + "stringKey": "ERRORS.TRIGGERS_FORM.STOP_LOSS_LIMIT_MUST_BELOW_TRIGGER_PRICE" + }, + "action": { + "stringKey": "APP.TRADE.MODIFY_TRIGGER_PRICE" + } + } } ] } @@ -290,7 +312,18 @@ class TriggerOrdersInputValidationTests : V4BaseTests() { "errors": [ { "type": "ERROR", - "code": "TRIGGER_MUST_ABOVE_INDEX_PRICE" + "code": "TRIGGER_MUST_ABOVE_INDEX_PRICE", + "resources": { + "title": { + "stringKey": "ERRORS.TRIGGERS_FORM_TITLE.TAKE_PROFIT_TRIGGER_MUST_ABOVE_INDEX_PRICE" + }, + "text": { + "stringKey": "ERRORS.TRIGGERS_FORM.TAKE_PROFIT_TRIGGER_MUST_ABOVE_INDEX_PRICE" + }, + "action": { + "stringKey": "APP.TRADE.MODIFY_TRIGGER_PRICE" + } + } } ] } @@ -360,7 +393,18 @@ class TriggerOrdersInputValidationTests : V4BaseTests() { "errors": [ { "type": "ERROR", - "code": "LIMIT_MUST_BELOW_TRIGGER_PRICE" + "code": "LIMIT_MUST_BELOW_TRIGGER_PRICE", + "resources": { + "title": { + "stringKey": "ERRORS.TRIGGERS_FORM_TITLE.TAKE_PROFIT_LIMIT_MUST_BELOW_TRIGGER_PRICE" + }, + "text": { + "stringKey": "ERRORS.TRIGGERS_FORM.TAKE_PROFIT_LIMIT_MUST_BELOW_TRIGGER_PRICE" + }, + "action": { + "stringKey": "APP.TRADE.MODIFY_TRIGGER_PRICE" + } + } } ] } diff --git a/v4_abacus.podspec b/v4_abacus.podspec index f32ec8bf7..25e040a8f 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.6.33' + spec.version = '1.6.34' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''