diff --git a/build.gradle.kts b/build.gradle.kts index c037d55c9..133dd6876 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.13.43" +version = "1.13.44" 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 8d3047470..f7b6ada1c 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/validator/TriggerOrdersInputValidator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/validator/TriggerOrdersInputValidator.kt @@ -2,6 +2,7 @@ package exchange.dydx.abacus.validator import abs import exchange.dydx.abacus.calculator.CalculationPeriod +import exchange.dydx.abacus.output.Asset import exchange.dydx.abacus.output.input.ErrorType import exchange.dydx.abacus.output.input.InputType import exchange.dydx.abacus.output.input.OrderSide @@ -56,7 +57,7 @@ internal class TriggerOrdersInputValidator( val tickSize = market?.perpetualMarket?.configs?.tickSize ?: 0.01 val oraclePrice = market?.perpetualMarket?.oraclePrice ?: return null - validateTriggerOrders(triggerOrders, market)?.let { + validateTriggerOrders(triggerOrders, market, internalState.assets)?.let { errors.addAll(it) } @@ -64,12 +65,12 @@ internal class TriggerOrdersInputValidator( val stopLossOrder = triggerOrders.stopLossOrder if (takeProfitOrder != null) { - validateTriggerOrder(takeProfitOrder, market, oraclePrice, tickSize, position)?.let { + validateTriggerOrder(takeProfitOrder, market, internalState.assets, oraclePrice, tickSize, position)?.let { errors.addAll(it) } } if (stopLossOrder != null) { - validateTriggerOrder(stopLossOrder, market, oraclePrice, tickSize, position)?.let { + validateTriggerOrder(stopLossOrder, market, internalState.assets, oraclePrice, tickSize, position)?.let { errors.addAll(it) } } @@ -149,11 +150,12 @@ internal class TriggerOrdersInputValidator( private fun validateTriggerOrders( triggerOrders: InternalTriggerOrdersInputState, - market: InternalMarketState? + market: InternalMarketState?, + assets: Map?, ): List? { val errors = mutableListOf() - validateSize(triggerOrders.size, market)?.let { + validateSize(triggerOrders.size, market, assets)?.let { /* ORDER_SIZE_BELOW_MIN_SIZE */ @@ -180,6 +182,7 @@ internal class TriggerOrdersInputValidator( private fun validateTriggerOrder( triggerOrder: InternalTriggerOrderState, market: InternalMarketState?, + assets: Map?, oraclePrice: Double, tickSize: Double, position: InternalPerpetualPosition, @@ -193,7 +196,7 @@ internal class TriggerOrdersInputValidator( triggerErrors.addAll(it) } - validateSize(triggerOrder.summary?.size, market)?.let { + validateSize(triggerOrder.summary?.size, market, assets)?.let { /* ORDER_SIZE_BELOW_MIN_SIZE */ @@ -813,8 +816,10 @@ internal class TriggerOrdersInputValidator( private fun validateSize( orderSize: Double?, market: InternalMarketState?, + assets: Map?, ): List? { - val symbol = market?.perpetualMarket?.assetId ?: return null + val assetId = market?.perpetualMarket?.assetId ?: return null + val symbol = assets?.get(assetId)?.displayableAssetId ?: return null val orderSize = orderSize ?: return null val minOrderSize = market.perpetualMarket?.configs?.minOrderSize ?: return null diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeInputDataValidator.kt b/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeInputDataValidator.kt index 0e8916b0c..e20ba62a4 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeInputDataValidator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeInputDataValidator.kt @@ -1,6 +1,7 @@ package exchange.dydx.abacus.validator.trade import abs +import exchange.dydx.abacus.output.Asset import exchange.dydx.abacus.output.input.ErrorType import exchange.dydx.abacus.output.input.InputType import exchange.dydx.abacus.output.input.OrderSide @@ -60,6 +61,7 @@ internal class TradeInputDataValidator( validateSize( trade = internalState.input.trade, market = market, + assets = internalState.assets, )?.let { errors.addAll(it) } @@ -128,11 +130,13 @@ internal class TradeInputDataValidator( private fun validateSize( trade: InternalTradeInputState, market: InternalMarketState?, + assets: Map? ): List? { /* ORDER_SIZE_BELOW_MIN_SIZE */ - val symbol = market?.perpetualMarket?.assetId ?: return null + val assetId = market?.perpetualMarket?.assetId ?: return null + val symbol = assets?.get(assetId)?.displayableAssetId ?: return null val size = trade.size?.size ?: return null val minOrderSize = market.perpetualMarket?.configs?.minOrderSize ?: return null return if (size.abs() < minOrderSize) { diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradePositionStateValidator.kt b/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradePositionStateValidator.kt index 9027872d3..2f30f1bed 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradePositionStateValidator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradePositionStateValidator.kt @@ -1,6 +1,7 @@ package exchange.dydx.abacus.validator.trade import exchange.dydx.abacus.calculator.CalculationPeriod +import exchange.dydx.abacus.output.Asset import exchange.dydx.abacus.output.input.ErrorType import exchange.dydx.abacus.output.input.InputType import exchange.dydx.abacus.output.input.ValidationError @@ -42,6 +43,7 @@ internal class TradePositionStateValidator( validatePositionSize( position = position, market = internalState.marketsSummary.markets[trade.marketId], + assets = internalState.assets, )?.let { errors.add(it) } @@ -99,6 +101,7 @@ internal class TradePositionStateValidator( private fun validatePositionSize( position: InternalPerpetualPosition?, market: InternalMarketState?, + assets: Map?, ): ValidationError? { /* NEW_POSITION_SIZE_OVER_MAX @@ -108,7 +111,8 @@ internal class TradePositionStateValidator( if (maxSize == Numeric.double.ZERO) { return null } - val symbol = market?.perpetualMarket?.assetId ?: return null + val assetId = market?.perpetualMarket?.assetId ?: return null + val symbol = assets?.get(assetId)?.displayableAssetId ?: return null return if (size > maxSize) { error( type = ErrorType.error, diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeResctrictedValidator.kt b/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeResctrictedValidator.kt index 4f76b9898..b0ec6d531 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeResctrictedValidator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/validator/trade/TradeResctrictedValidator.kt @@ -1,5 +1,6 @@ package exchange.dydx.abacus.validator.trade +import exchange.dydx.abacus.output.Asset import exchange.dydx.abacus.output.input.ErrorType import exchange.dydx.abacus.output.input.InputType import exchange.dydx.abacus.output.input.ValidationError @@ -35,6 +36,7 @@ internal class TradeResctrictedValidator( val closeOnlyError = validateClosingOnly( market = market, + assets = internalState.assets, change = change, restricted = restricted, ) @@ -64,10 +66,12 @@ internal class TradeResctrictedValidator( private fun validateClosingOnly( market: InternalMarketState?, + assets: Map?, change: PositionChange, restricted: Boolean, ): ValidationError? { - val marketId = market?.perpetualMarket?.assetId ?: "" + val assetId = market?.perpetualMarket?.assetId ?: return null + val marketId = assets?.get(assetId)?.displayableAssetId ?: return null val canTrade = market?.perpetualMarket?.status?.canTrade ?: true val canReduce = market?.perpetualMarket?.status?.canReduce ?: true diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 3a05abb5f..187791824 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.13.43' + spec.version = '1.13.44' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''