From 17d73fc3cf2d486ada2ce9a4439cdfaf9a7629ca Mon Sep 17 00:00:00 2001 From: Tyler Shipe Date: Mon, 16 Aug 2021 18:10:06 -0400 Subject: [PATCH] more frequent mango acct updates --- components/TradeForm.tsx | 9 +++++++-- hooks/useWallet.tsx | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/TradeForm.tsx b/components/TradeForm.tsx index ce3f4867..4d4cb05e 100644 --- a/components/TradeForm.tsx +++ b/components/TradeForm.tsx @@ -6,7 +6,7 @@ import { PerpMarket, } from '@blockworks-foundation/mango-client' import { notify } from '../utils/notifications' -import { calculateMarketPrice, getDecimalCount } from '../utils' +import { calculateMarketPrice, getDecimalCount, sleep } from '../utils' import FloatingElement from './FloatingElement' import { floorToDecimal } from '../utils/index' import useMangoStore, { mangoClient } from '../stores/useMangoStore' @@ -226,6 +226,9 @@ export default function TradeForm() { baseSize, orderType ) + sleep(2000).then(() => { + actions.fetchMangoAccounts() + }) } else { txid = await mangoClient.placePerpOrder( mangoGroup, @@ -238,12 +241,14 @@ export default function TradeForm() { baseSize, orderType ) + sleep(3000).then(() => { + actions.fetchMangoAccounts() + }) } notify({ title: 'Successfully placed trade', txid }) setPrice('') onSetBaseSize('') - actions.fetchMangoAccounts() } catch (e) { notify({ title: 'Error placing order', diff --git a/hooks/useWallet.tsx b/hooks/useWallet.tsx index 98535ca2..3cf53ffd 100644 --- a/hooks/useWallet.tsx +++ b/hooks/useWallet.tsx @@ -137,11 +137,16 @@ export default function useWallet() { useInterval(() => { if (connected && mangoAccount) { - actions.fetchMangoAccounts() actions.fetchWalletTokens() + } + }, 60 * SECONDS) + + useInterval(() => { + if (connected && mangoAccount) { + actions.fetchMangoAccounts() actions.fetchTradeHistory() } - }, 180 * SECONDS) + }, 30 * SECONDS) return { connected, wallet } }