Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam committed Jun 4, 2024
1 parent 0c2b6c3 commit 2865509
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ data class TransferInput(
)

val errors = parser.asString(route?.get("errors"))

val errorMessage: String? =
if (errors != null) {
val errorArray = parser.decodeJsonArray(errors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import exchange.dydx.abacus.state.manager.CctpConfig.cctpChainIds
import exchange.dydx.abacus.utils.mutable
import exchange.dydx.abacus.utils.safeSet


@Suppress("NotImplementedDeclaration", "ForbiddenComment")
internal class SkipProcessor(
parser: ParserProtocol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package exchange.dydx.abacus.processor.router.skip

import exchange.dydx.abacus.processor.base.BaseProcessor
import exchange.dydx.abacus.protocols.ParserProtocol
import exchange.dydx.abacus.utils.SLIPPAGE_PERCENT
import exchange.dydx.abacus.utils.safeSet
import kotlin.math.pow

Expand Down Expand Up @@ -66,7 +67,7 @@ internal class SkipRouteProcessor(internal val parser: ParserProtocol) {
// This is just hard coded in our params so we're keeping it to be at parity for now
// Fast follow squid -> skip migration project to removing max slippage
// because we already show the actual price impact.
modified.safeSet("slippage", "1")
modified.safeSet("slippage", SLIPPAGE_PERCENT)
modified.safeSet("requestPayload", payloadProcessor.received(null, payload))

val errorCode = parser.value(payload, "code")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import exchange.dydx.abacus.state.model.squidStatus
import exchange.dydx.abacus.utils.IMap
import exchange.dydx.abacus.utils.Logger
import exchange.dydx.abacus.utils.Numeric
import exchange.dydx.abacus.utils.SLIPPAGE_PERCENT
import exchange.dydx.abacus.utils.filterNotNull
import exchange.dydx.abacus.utils.iMapOf
import exchange.dydx.abacus.utils.mutable
Expand Down Expand Up @@ -251,7 +252,7 @@ private fun V4StateManagerAdaptor.retrieveSkipDepositRoute(state: PerpetualState
fromChain to sourceAddress.toString(),
toChain to nobleAddress,
),
"slippage_tolerance_percent" to "1",
"slippage_tolerance_percent" to SLIPPAGE_PERCENT,
)
val oldState = stateMachine.state
val header = iMapOf(
Expand Down
3 changes: 3 additions & 0 deletions src/commonMain/kotlin/exchange.dydx.abacus/utils/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ internal const val MAX_SUBACCOUNT_NUMBER = 128_000
internal const val SHORT_TERM_ORDER_DURATION = 10

internal const val QUANTUM_MULTIPLIER = 1_000_000

// Route Param Constants
internal const val SLIPPAGE_PERCENT = "1"
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SkipRouteProcessorTests {

@Test
fun testReceivedError() {
val payload = skipRouteMock.payload_error
val payload = skipRouteMock.payloadError
val result = skipRouteProcessor.received(existing = mapOf(), payload = templateToJson(payload), decimals = 6.0)
val expected = mapOf(
"slippage" to "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ internal class SkipRouteMock {
]
}
}"""
internal val payload_error = """
internal val payloadError = """
{
"code": 3,
"message": "difference in usd value of route input and output is too large. input usd value: 100000.00 output usd value: 98811.81",
Expand Down

0 comments on commit 2865509

Please sign in to comment.