Skip to content

Commit

Permalink
update cancelOrder params
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepuppy committed Oct 18, 2023
1 parent 8bf824e commit b2b0b53
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions v4-client-js/src/clients/composite-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,8 @@ export class CompositeClient {
clientId: number,
orderFlags: OrderFlags,
marketId: string,
goodTilBlock: number,
goodTilTimeInSeconds: number,
goodTilBlock?: number,
goodTilTimeInSeconds?: number,
): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {

const marketsResponse = await this.indexerClient.markets.getPerpetualMarkets(marketId);
Expand All @@ -625,7 +625,7 @@ export class CompositeClient {

let goodTilBlockTime;
if (isStatefulOrder(orderFlags)) {
if (goodTilTimeInSeconds === 0) {
if (goodTilTimeInSeconds === undefined || goodTilTimeInSeconds === 0) {
throw new Error('goodTilTimeInSeconds must be set for LONG_TERM or CONDITIONAL order');
}
if (goodTilBlock !== 0) {
Expand All @@ -636,10 +636,10 @@ export class CompositeClient {
}
goodTilBlockTime = this.calculateGoodTilBlockTime(goodTilTimeInSeconds);
} else {
if (goodTilBlock === 0) {
if (goodTilBlock === undefined || goodTilBlock === 0) {
throw new Error('goodTilBlock must be non-zero for SHORT_TERM orders');
}
if (goodTilTimeInSeconds !== 0) {
if (goodTilTimeInSeconds !== undefined && goodTilTimeInSeconds !== 0) {
throw new Error('goodTilTimeInSeconds should be zero since SHORT_TERM orders use goodTilBlock instead of goodTilTimeInSeconds.');
}
}
Expand Down

0 comments on commit b2b0b53

Please sign in to comment.