Skip to content

Commit

Permalink
1.6.34: Update SL/TP trigger/limit price errors to be SL/TP specific (#…
Browse files Browse the repository at this point in the history
…294)

* update limit error wording

* bump v
  • Loading branch information
moo-onthelawn authored Apr 9, 2024
1 parent ed1bc72 commit 3e662f9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.6.33"
version = "1.6.34"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ internal class TriggerOrdersInputValidator(
triggerToIndex,
oraclePrice,
tickSize,
type,
),
)
}
Expand All @@ -390,6 +391,7 @@ internal class TriggerOrdersInputValidator(
triggerToIndex,
oraclePrice,
tickSize,
type,
),
)
}
Expand All @@ -403,7 +405,8 @@ internal class TriggerOrdersInputValidator(
private fun validateLimitPrice(
triggerOrder: Map<String, Any>,
): List<Any>? {
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"))
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -528,6 +531,7 @@ internal class TriggerOrdersInputValidator(
triggerToIndex: RelativeToPrice,
oraclePrice: Double,
tickSize: String,
type: String,
): Map<String, Any> {
val fields = listOf("price.triggerPrice")
val action = "APP.TRADE.MODIFY_TRIGGER_PRICE"
Expand All @@ -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,
)

Expand All @@ -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,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
]
}
Expand Down Expand Up @@ -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"
}
}
}
]
}
Expand Down Expand Up @@ -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"
}
}
}
]
}
Expand Down Expand Up @@ -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"
}
}
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion v4_abacus.podspec
Original file line number Diff line number Diff line change
@@ -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 = ''
Expand Down

0 comments on commit 3e662f9

Please sign in to comment.