Skip to content

Commit 91e3e2b

Browse files
committed
fix: issue in autosign with spot limit order chase
1 parent 3234421 commit 91e3e2b

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

packages/sdk-ts/src/core/modules/exchange/msgs/MsgBatchUpdateOrders.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,38 @@ const createBinaryOptionOrder = (
136136
}
137137

138138
const createMsgAndCancelOrders = (params: MsgBatchUpdateOrders.Params) => {
139+
const hasCancelAll =
140+
(params.spotMarketIdsToCancelAll &&
141+
params.spotMarketIdsToCancelAll.length > 0) ||
142+
(params.derivativeMarketIdsToCancelAll &&
143+
params.derivativeMarketIdsToCancelAll.length > 0) ||
144+
(params.binaryOptionsMarketIdsToCancelAll &&
145+
params.binaryOptionsMarketIdsToCancelAll.length > 0)
146+
139147
const message = InjectiveExchangeV1Beta1TxPb.MsgBatchUpdateOrders.create({
140148
sender: params.injectiveAddress,
141-
subaccountId: params.subaccountId,
149+
...(hasCancelAll && { subaccountId: params.subaccountId }),
142150
})
143151

144-
if (params.spotMarketIdsToCancelAll) {
152+
if (
153+
params.spotMarketIdsToCancelAll &&
154+
params.spotMarketIdsToCancelAll.length > 0
155+
) {
145156
message.spotMarketIdsToCancelAll = params.spotMarketIdsToCancelAll
146157
}
147158

148-
if (params.derivativeMarketIdsToCancelAll) {
159+
if (
160+
params.derivativeMarketIdsToCancelAll &&
161+
params.derivativeMarketIdsToCancelAll.length > 0
162+
) {
149163
message.derivativeMarketIdsToCancelAll =
150164
params.derivativeMarketIdsToCancelAll
151165
}
152166

153-
if (params.binaryOptionsMarketIdsToCancelAll) {
167+
if (
168+
params.binaryOptionsMarketIdsToCancelAll &&
169+
params.binaryOptionsMarketIdsToCancelAll.length > 0
170+
) {
154171
message.binaryOptionsMarketIdsToCancelAll =
155172
params.binaryOptionsMarketIdsToCancelAll
156173
}

0 commit comments

Comments
 (0)