Skip to content

Commit 7aea25a

Browse files
authored
Fix a race condition on tradeInMarket (#780)
1 parent 31c5283 commit 7aea25a

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ allprojects {
5252
}
5353

5454
group = "exchange.dydx.abacus"
55-
version = "1.13.53"
55+
version = "1.13.54"
5656

5757
repositories {
5858
google()

src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,12 @@ internal class StateManagerAdaptorV2(
256256
markets.marketId = value
257257

258258
if (value != null) {
259-
networkHelper.ioImplementations.threading?.async(ThreadingType.abacus) {
260-
val stateResponse = stateMachine.tradeInMarket(value, subaccountNumber)
261-
ioImplementations.threading?.async(ThreadingType.main) {
262-
stateNotification?.stateChanged(
263-
stateResponse.state,
264-
stateResponse.changes,
265-
)
266-
}
259+
val stateResponse = stateMachine.tradeInMarket(value, subaccountNumber)
260+
ioImplementations.threading?.async(ThreadingType.main) {
261+
stateNotification?.stateChanged(
262+
stateResponse.state,
263+
stateResponse.changes,
264+
)
267265
}
268266
}
269267
}

src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/SubaccountSupervisor.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,16 @@ internal class SubaccountSupervisor(
359359
type: ClosePositionInputField,
360360
) {
361361
helper.ioImplementations.threading?.async(ThreadingType.abacus) {
362-
val currentMarket =
362+
val currentMarket = if (stateMachine.staticTyping) {
363+
stateMachine.internalState.input.closePosition.marketId
364+
} else {
363365
helper.parser.asString(
364366
helper.parser.value(
365367
stateMachine.input,
366368
"closePosition.marketId",
367369
),
368370
)
371+
}
369372
var stateResponse = stateMachine.closePosition(data, type, subaccountNumber)
370373
if (type == ClosePositionInputField.market && currentMarket != data) {
371374
val nextResponse = stateMachine.closePosition(

v4_abacus.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'v4_abacus'
3-
spec.version = '1.13.53'
3+
spec.version = '1.13.54'
44
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
55
spec.source = { :http=> ''}
66
spec.authors = ''

0 commit comments

Comments
 (0)