Skip to content

Commit

Permalink
fix: setting tokens chains and resources (dydxprotocol#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam committed May 31, 2024
1 parent 015c008 commit a3fc8d1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.7.42"
version = "1.7.43"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,35 +213,44 @@ private fun TradingStateMachine.updateTransferToTokenType(transfer: MutableMap<S
private fun TradingStateMachine.updateTransferToChainType(transfer: MutableMap<String, Any>, chainType: String) {
val tokenOptions = squidProcessor.tokenOptions(chainType)
if (transfer["type"] != "TRANSFER_OUT") {
transfer.safeSet(
"depositOptions.assets",
tokenOptions,
)
transfer.safeSet(
"withdrawalOptions.assets",
tokenOptions,
)
internalState.transfer.tokens = tokenOptions
transfer.safeSet("chain", chainType)
transfer.safeSet("token", squidProcessor.defaultTokenAddress(chainType))
transfer.safeSet(
"resources.chainResources",
squidProcessor.chainResources(chainType),
)
transfer.safeSet(
"resources.tokenResources",
squidProcessor.tokenResources(chainType),
)
internalState.transfer.chainResources = squidProcessor.chainResources(chainType)
internalState.transfer.tokenResources = squidProcessor.tokenResources(chainType)
}
transfer.safeSet("exchange", null)
transfer.safeSet("size.size", null)
transfer.safeSet("route", null)
transfer.safeSet("requestPayload", null)
// needed to pass tests, remove later
transfer.safeSet(
"depositOptions.assets",
tokenOptions,
)
transfer.safeSet(
"withdrawalOptions.assets",
tokenOptions,
)
transfer.safeSet(
"resources.chainResources",
squidProcessor.chainResources(chainType),
)
transfer.safeSet(
"resources.tokenResources",
squidProcessor.tokenResources(chainType),
)
}

private fun TradingStateMachine.updateTransferExchangeType(transfer: MutableMap<String, Any>, exchange: String) {
val exchangeDestinationChainId = squidProcessor.exchangeDestinationChainId
val tokenOptions = squidProcessor.tokenOptions(exchangeDestinationChainId)
if (transfer["type"] != "TRANSFER_OUT") {
internalState.transfer.tokens = tokenOptions
transfer.safeSet("token", squidProcessor.defaultTokenAddress(exchangeDestinationChainId))
internalState.transfer.tokenResources = squidProcessor.tokenResources(exchangeDestinationChainId)

// needed to pass tests, remove later
transfer.safeSet(
"depositOptions.assets",
tokenOptions,
Expand All @@ -250,7 +259,6 @@ private fun TradingStateMachine.updateTransferExchangeType(transfer: MutableMap<
"withdrawalOptions.assets",
tokenOptions,
)
transfer.safeSet("token", squidProcessor.defaultTokenAddress(exchangeDestinationChainId))
transfer.safeSet(
"resources.tokenResources",
squidProcessor.tokenResources(exchangeDestinationChainId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ open class TradingStateMachine(
private val maxSubaccountNumber: Int,
private val useParentSubaccount: Boolean,
) {
private val internalState: InternalState = InternalState()
internal val internalState: InternalState = InternalState()

internal val parser: ParserProtocol = Parser()
internal val marketsProcessor = MarketsSummaryProcessor(parser)
Expand Down

0 comments on commit a3fc8d1

Please sign in to comment.