Skip to content

Commit

Permalink
Add new arg for TPSL force cancels (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipzeta authored Apr 3, 2024
1 parent 3506027 commit f1a2c06
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,8 @@ export class Exchange {

public async adminCancelTriggerOrder(
orderIndex: number,
crossMarginAccount: PublicKey
crossMarginAccount: PublicKey,
enforceTpslConditions: boolean = true
) {
let triggerAccount = utils.getTriggerOrder(
this.programId,
Expand All @@ -1150,7 +1151,8 @@ export class Exchange {
orderIndex,
this._provider.wallet.publicKey,
triggerAccount,
crossMarginAccount
crossMarginAccount,
enforceTpslConditions
)
);
return await utils.processTransaction(this._provider, tx);
Expand Down
9 changes: 9 additions & 0 deletions src/idl/zeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5066,6 +5066,10 @@
{
"name": "triggerOrderBit",
"type": "u8"
},
{
"name": "enforceTpslConditions",
"type": "bool"
}
]
},
Expand Down Expand Up @@ -11152,6 +11156,11 @@
"code": 6166,
"name": "OORemainingEvents",
"msg": "Open orders has remaining events"
},
{
"code": 6167,
"name": "CannotForceCancelTriggerOrder",
"msg": "Cannot force cancel trigger order"
}
]
}
23 changes: 14 additions & 9 deletions src/program-instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,16 +797,21 @@ export function forceCancelTriggerOrderIx(
triggerOrderBit: number,
authority: PublicKey,
triggerOrder: PublicKey,
marginAccount: PublicKey
marginAccount: PublicKey,
enforceTpslConditions: boolean = true
): TransactionInstruction {
return Exchange.program.instruction.forceCancelTriggerOrder(triggerOrderBit, {
accounts: {
state: Exchange.stateAddress,
admin: authority,
triggerOrder: triggerOrder,
marginAccount: marginAccount,
},
});
return Exchange.program.instruction.forceCancelTriggerOrder(
triggerOrderBit,
enforceTpslConditions,
{
accounts: {
state: Exchange.stateAddress,
admin: authority,
triggerOrder: triggerOrder,
marginAccount: marginAccount,
},
}
);
}

export function editTriggerOrderIx(
Expand Down
18 changes: 18 additions & 0 deletions src/types/zeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5066,6 +5066,10 @@ export type Zeta = {
{
"name": "triggerOrderBit",
"type": "u8"
},
{
"name": "enforceTpslConditions",
"type": "bool"
}
]
},
Expand Down Expand Up @@ -11152,6 +11156,11 @@ export type Zeta = {
"code": 6166,
"name": "OORemainingEvents",
"msg": "Open orders has remaining events"
},
{
"code": 6167,
"name": "CannotForceCancelTriggerOrder",
"msg": "Cannot force cancel trigger order"
}
]
};
Expand Down Expand Up @@ -16224,6 +16233,10 @@ export const IDL: Zeta = {
{
"name": "triggerOrderBit",
"type": "u8"
},
{
"name": "enforceTpslConditions",
"type": "bool"
}
]
},
Expand Down Expand Up @@ -22310,6 +22323,11 @@ export const IDL: Zeta = {
"code": 6166,
"name": "OORemainingEvents",
"msg": "Open orders has remaining events"
},
{
"code": 6167,
"name": "CannotForceCancelTriggerOrder",
"msg": "Cannot force cancel trigger order"
}
]
};

0 comments on commit f1a2c06

Please sign in to comment.