Skip to content

Commit

Permalink
Ignore orders that reduce position in equity check
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredvu committed Nov 25, 2024
1 parent 72222b8 commit fd3aad0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.13.34"
version = "1.13.35"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import exchange.dydx.abacus.state.internalstate.InternalState
import exchange.dydx.abacus.state.internalstate.InternalSubaccountState
import exchange.dydx.abacus.state.internalstate.InternalTradeInputState
import exchange.dydx.abacus.state.manager.V4Environment
import exchange.dydx.abacus.utils.Logger
import exchange.dydx.abacus.utils.Numeric
import exchange.dydx.abacus.validator.BaseInputValidator
import exchange.dydx.abacus.validator.PositionChange
Expand Down Expand Up @@ -159,8 +160,9 @@ internal class TradeOrderInputValidator(
val currentFreeCollateral = subaccount.calculated.get(CalculationPeriod.current)?.freeCollateral ?: return null
val postFreeCollateral = subaccount.calculated.get(CalculationPeriod.post)?.freeCollateral ?: return null
val orderEquity = currentFreeCollateral - postFreeCollateral
val isReducingPosition = orderEquity < Numeric.double.ZERO

if (postFreeCollateral >= Numeric.double.ZERO && orderEquity < isolatedLimitOrderMinimumEquity) {
if (postFreeCollateral >= Numeric.double.ZERO && !isReducingPosition && orderEquity < isolatedLimitOrderMinimumEquity) {
return createTradeBoxWarningOrError(
errorLevel = ErrorType.error,
errorCode = "ISOLATED_MARGIN_LIMIT_ORDER_BELOW_MINIMUM",
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.13.34'
spec.version = '1.13.35'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down

0 comments on commit fd3aad0

Please sign in to comment.