From c28f3cd07af2256ed21dac5407f20979bf7d3b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Sat, 7 Jan 2023 03:01:11 +0100 Subject: [PATCH] fixes for open order creation when placing order --- ts/client/src/client.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index f64f95dcb..4aa386699 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -1211,20 +1211,15 @@ export class MangoClient { this.program.programId, mangoAccount.publicKey, ); - const tokenIndex = - serum3Market[ - side == Serum3Side.bid ? 'baseTokenIndex' : 'quoteTokenIndex' - ]; + const tokenIndex = serum3Market['baseTokenIndex']; const baseBank = group.getFirstBankByTokenIndex(tokenIndex); // only push bank/oracle if no deposit has been previously made for same token - const hasBaseBank = - mangoAccount.tokens[tokenIndex].tokenIndex !== - TokenPosition.TokenIndexUnset; + const wasTokenInUseBefore = mangoAccount.getToken(tokenIndex); additionalAccounts = { - banks: !hasBaseBank ? [baseBank.publicKey] : [], - oracles: !hasBaseBank ? [baseBank.oracle] : [], + banks: !wasTokenInUseBefore ? [baseBank.publicKey] : [], + oracles: !wasTokenInUseBefore ? [baseBank.oracle] : [], openOrders: [ooPk], perps: [], };