From 7949ce7d786fef47f1d0b87ea2bdc9632036a8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Wed, 14 Dec 2022 15:15:35 +0100 Subject: [PATCH] modify perp ix --- ts/client/src/client.ts | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 07080c7c0..e87c199b7 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -2623,4 +2623,49 @@ export class MangoClient { return healthRemainingAccounts; } + + public async modifyPerpOrder( + group: Group, + mangoAccount: MangoAccount, + perpMarketIndex: PerpMarketIndex, + orderId: BN, + side: PerpOrderSide, + price: number, + quantity: number, + maxQuoteQuantity?: number, + clientOrderId?: number, + orderType?: PerpOrderType, + reduceOnly?: boolean, + expiryTimestamp?: number, + limit?: number, + ): Promise { + const transactionInstructions: TransactionInstruction[] = []; + const [cancelOrderIx, placeOrderIx] = await Promise.all([ + this.perpCancelOrderIx(group, mangoAccount, perpMarketIndex, orderId), + this.perpPlaceOrderIx( + group, + mangoAccount, + perpMarketIndex, + side, + price, + quantity, + maxQuoteQuantity, + clientOrderId, + orderType, + reduceOnly, + expiryTimestamp, + limit, + ), + ]); + transactionInstructions.push(cancelOrderIx, placeOrderIx); + + return await sendTransaction( + this.program.provider as AnchorProvider, + transactionInstructions, + group.addressLookupTablesList, + { + postSendTxCallback: this.postSendTxCallback, + }, + ); + } }