fetch trade history after margin account is loaded

This commit is contained in:
Tyler Shipe 2021-04-20 17:52:13 -04:00
parent 7c4e913b50
commit 404794575b
3 changed files with 5 additions and 7 deletions

View File

@ -37,11 +37,9 @@ const useHydrateStore = () => {
new PublicKey(dexProgramId)
)
.then(async (market) => {
// @ts-ignore
const bidAccount = market._decoded.bids
const bidAccount = market['_decoded'].bids
const bidInfo = await websocketConnection.getAccountInfo(bidAccount)
// @ts-ignore
const askAccount = market._decoded.asks
const askAccount = market['_decoded'].asks
const askInfo = await websocketConnection.getAccountInfo(askAccount)
setMangoStore((state) => {
state.market.current = market

View File

@ -108,6 +108,7 @@ export default function useWallet() {
actions.fetchMangoGroup()
actions.fetchWalletBalances()
actions.fetchMangoSrmAccounts()
// wait for margin account before fetching trade history
await actions.fetchMarginAccounts()
actions.fetchTradeHistory()
})

View File

@ -172,7 +172,6 @@ const useMangoStore = create<MangoStore>((set, get) => ({
const wallet = get().wallet.current
const connected = get().wallet.connected
const set = get().set
console.log('fetching wallet balances')
if (wallet?.publicKey && connected) {
const ownerAddress = wallet.publicKey
@ -231,7 +230,7 @@ const useMangoStore = create<MangoStore>((set, get) => ({
if (!wallet?.publicKey || !wallet.publicKey) return
mangoClient
return mangoClient
.getMarginAccountsForOwner(
connection,
new PublicKey(programId),
@ -265,7 +264,7 @@ const useMangoStore = create<MangoStore>((set, get) => ({
const mangoGroupPk = new PublicKey(mangoGroupIds.mango_group_pk)
const srmVaultPk = new PublicKey(mangoGroupIds.srm_vault_pk)
mangoClient
return mangoClient
.getMangoGroup(connection, mangoGroupPk, srmVaultPk)
.then(async (mangoGroup) => {
const srmAccountInfo = await connection.getAccountInfo(