more frequent mango acct updates

This commit is contained in:
Tyler Shipe 2021-08-16 18:10:06 -04:00
parent f44acbab27
commit 17d73fc3cf
2 changed files with 14 additions and 4 deletions

View File

@ -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',

View File

@ -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 }
}