Skip to content

Commit

Permalink
Make order type a required arg for trigger orders (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipzeta authored Nov 10, 2023
1 parent 38a4706 commit fdf3952
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Version changes are pinned to SDK releases.

## Unreleased

## [1.11.8]

- Make orderType mandatory for trigger orders. ([#298](https://github.com/zetamarkets/sdk/pull/298))
- Add a more precise estimate for liquidation price (under the assumption that other mark prices remain static). ([#296](https://github.com/zetamarkets/sdk/pull/296))

## [1.11.7] 2023-11-06
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zetamarkets/sdk",
"repository": "https://github.com/zetamarkets/sdk/",
"version": "1.11.7",
"version": "1.11.8",
"description": "Zeta SDK",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
18 changes: 12 additions & 6 deletions src/cross-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@ export class CrossClient {
triggerTime: anchor.BN,
size: number,
side: types.Side,
orderType: types.OrderType,
options: types.TriggerOrderOptions = types.defaultTriggerOrderOptions()
): Promise<TransactionSignature> {
return await this.placeTriggerOrder(
Expand All @@ -1103,6 +1104,7 @@ export class CrossClient {
0,
types.TriggerDirection.UNINITIALIZED,
triggerTime,
orderType,
options
);
}
Expand All @@ -1114,6 +1116,7 @@ export class CrossClient {
triggerPrice: number,
size: number,
side: types.Side,
orderType: types.OrderType,
options: types.TriggerOrderOptions = types.defaultTriggerOrderOptions(),
triggerDirection: types.TriggerDirection = types.getDefaultTriggerDirection(
side
Expand All @@ -1127,6 +1130,7 @@ export class CrossClient {
triggerPrice,
triggerDirection,
new anchor.BN(0),
orderType,
options
);
}
Expand All @@ -1141,6 +1145,7 @@ export class CrossClient {
side
),
triggerTimestamp: anchor.BN,
orderType: types.OrderType,
options: types.TriggerOrderOptions = types.defaultTriggerOrderOptions()
): Promise<TransactionSignature> {
let triggerOrderBit = this.findAvailableTriggerOrderBit();
Expand Down Expand Up @@ -1178,9 +1183,7 @@ export class CrossClient {
triggerOrderBit,
size,
side,
options.orderType != undefined
? options.orderType
: types.OrderType.FILLORKILL,
orderType,
options.reduceOnly != undefined ? options.reduceOnly : false,
options.tag,
this.accountAddress,
Expand Down Expand Up @@ -1376,6 +1379,7 @@ export class CrossClient {
newTriggerTime: anchor.BN,
newSize: number,
newSide: types.Side,
newOrderType: types.OrderType,
newOptions: types.TriggerOrderOptions = types.defaultTriggerOrderOptions()
) {
await this.editTriggerOrder(
Expand All @@ -1386,6 +1390,7 @@ export class CrossClient {
0,
types.TriggerDirection.UNINITIALIZED,
newTriggerTime,
newOrderType,
newOptions
);
}
Expand All @@ -1397,6 +1402,7 @@ export class CrossClient {
newSize: number,
newSide: types.Side,
newDirection: types.TriggerDirection,
newOrderType: types.OrderType,
newOptions: types.TriggerOrderOptions = types.defaultTriggerOrderOptions()
) {
await this.editTriggerOrder(
Expand All @@ -1407,6 +1413,7 @@ export class CrossClient {
newTriggerPrice,
newDirection,
new anchor.BN(0),
newOrderType,
newOptions
);
}
Expand All @@ -1419,6 +1426,7 @@ export class CrossClient {
newTriggerPrice: number,
newDirection: types.TriggerDirection,
newTriggerTimestamp: anchor.BN,
newOrderType: types.OrderType,
newOptions: types.TriggerOrderOptions = types.defaultTriggerOrderOptions()
) {
let triggerAccount = utils.getTriggerOrder(
Expand All @@ -1434,9 +1442,7 @@ export class CrossClient {
newTriggerTimestamp,
newSize,
newSide,
newOptions.orderType != undefined
? newOptions.orderType
: types.OrderType.FILLORKILL,
newOrderType,
newOptions.reduceOnly != undefined ? newOptions.reduceOnly : false,
this._provider.wallet.publicKey,
triggerAccount
Expand Down
2 changes: 0 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ export interface OrderOptions {
}

export interface TriggerOrderOptions {
orderType?: types.OrderType;
reduceOnly?: boolean;
tag?: string;
blockhash?: { blockhash: string; lastValidBlockHeight: number };
Expand All @@ -432,7 +431,6 @@ export function getDefaultTriggerDirection(side: Side): TriggerDirection {

export function defaultTriggerOrderOptions(): TriggerOrderOptions {
return {
orderType: OrderType.FILLORKILL,
reduceOnly: true,
tag: constants.DEFAULT_ORDER_TAG,
blockhash: undefined,
Expand Down

0 comments on commit fdf3952

Please sign in to comment.