Skip to content

Commit

Permalink
fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-onthelawn committed Apr 24, 2024
1 parent 446c616 commit ea3edeb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package exchange.dydx.abacus.calculator

import abs
import exchange.dydx.abacus.calculator.SlippageConstants.MARKET_ORDER_MAX_SLIPPAGE
import exchange.dydx.abacus.calculator.SlippageConstants.STOP_MARKET_ORDER_SLIPPAGE_BUFFER
import exchange.dydx.abacus.calculator.SlippageConstants.STOP_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
import exchange.dydx.abacus.calculator.SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER
import exchange.dydx.abacus.calculator.SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
import exchange.dydx.abacus.protocols.ParserProtocol
import exchange.dydx.abacus.state.manager.EnvironmentFeatureFlags
import exchange.dydx.abacus.utils.Numeric
Expand Down Expand Up @@ -1408,9 +1413,9 @@ internal class TradeInputCalculator(
val side = parser.asString(trade["side"])
val payloadPrice = if (price != null) {
when (side) {
"BUY" -> price * (Numeric.double.ONE + SlippageConstants.MARKET_ORDER_MAX_SLIPPAGE)
"BUY" -> price * (Numeric.double.ONE + MARKET_ORDER_MAX_SLIPPAGE)

else -> price * (Numeric.double.ONE - SlippageConstants.MARKET_ORDER_MAX_SLIPPAGE)
else -> price * (Numeric.double.ONE - MARKET_ORDER_MAX_SLIPPAGE)
}
} else {
null
Expand Down Expand Up @@ -1510,16 +1515,15 @@ internal class TradeInputCalculator(
}
if (majorMarket) {
if (type == "STOP_MARKET") {
slippagePercentage + SlippageConstants.STOP_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
slippagePercentage + STOP_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
} else {
slippagePercentage +
SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
slippagePercentage + TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
}
} else {
if (type == "STOP_MARKET") {
slippagePercentage + SlippageConstants.STOP_MARKET_ORDER_SLIPPAGE_BUFFER
slippagePercentage + STOP_MARKET_ORDER_SLIPPAGE_BUFFER
} else {
slippagePercentage + SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER
slippagePercentage + TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package exchange.dydx.abacus.calculator

import abs
import exchange.dydx.abacus.calculator.SlippageConstants.STOP_MARKET_ORDER_SLIPPAGE_BUFFER
import exchange.dydx.abacus.calculator.SlippageConstants.STOP_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
import exchange.dydx.abacus.calculator.SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER
import exchange.dydx.abacus.calculator.SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
import exchange.dydx.abacus.output.input.OrderSide
import exchange.dydx.abacus.output.input.OrderType
import exchange.dydx.abacus.protocols.ParserProtocol
Expand Down Expand Up @@ -279,15 +283,15 @@ internal class TriggerOrdersInputCalculator(val parser: ParserProtocol) {
}
val slippagePercentage = if (majorMarket) {
if (type == OrderType.stopMarket) {
SlippageConstants.STOP_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
STOP_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
} else {
SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET
}
} else {
if (type == OrderType.stopMarket) {
SlippageConstants.STOP_MARKET_ORDER_SLIPPAGE_BUFFER
STOP_MARKET_ORDER_SLIPPAGE_BUFFER
} else {
SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER
TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER
}
}
val calculatedLimitPrice = if (triggerPrice != null) {
Expand Down

0 comments on commit ea3edeb

Please sign in to comment.