update unsettled balances when open orders are updated

This commit is contained in:
tjs 2022-12-14 13:46:01 -05:00
parent fdd0d9a020
commit 1cb810a2f4
2 changed files with 8 additions and 6 deletions

View File

@ -34,6 +34,7 @@ const HydrateStore = () => {
useEffect(() => {
const connection = mangoStore.getState().connection
const client = mangoStore.getState().client
const set = mangoStore.getState().set
if (!mangoAccount) return
@ -68,12 +69,9 @@ const HydrateStore = () => {
// newMangoAccount.spotOpenOrdersAccounts =
// mangoAccount.spotOpenOrdersAccounts
// newMangoAccount.advancedOrders = mangoAccount.advancedOrders
mangoStore.setState({
mangoAccount: {
...mangoStore.getState().mangoAccount,
current: newMangoAccount,
lastSlot: context.slot,
},
set((s) => {
s.mangoAccount.current = newMangoAccount
s.mangoAccount.lastSlot = context.slot
})
}
}

View File

@ -939,6 +939,10 @@ const mangoStore = create<MangoStore>()(
)
mangoStore.subscribe((state) => state.mangoAccount.current, spotBalancesUpdater)
mangoStore.subscribe(
(state) => state.mangoAccount.openOrderAccounts,
spotBalancesUpdater
)
mangoStore.subscribe(
(state) => state.mangoAccount.current,
perpPositionsUpdater