format srm balances correctly when multiple mango srm accounts exist
This commit is contained in:
parent
1ebae0eb07
commit
4f7e1b4990
|
@ -95,12 +95,15 @@ export default function useWallet() {
|
|||
if (!wallet) return
|
||||
wallet.on('connect', async () => {
|
||||
console.log('connected wallet')
|
||||
sleep(500)
|
||||
// wait for margin account before fetching trade history
|
||||
sleep(250)
|
||||
await actions.fetchMarginAccounts()
|
||||
actions.fetchWalletBalances()
|
||||
actions.fetchMangoSrmAccounts()
|
||||
setMangoStore((state) => {
|
||||
state.wallet.connected = true
|
||||
})
|
||||
// set connected before fetching data
|
||||
actions.fetchTradeHistory()
|
||||
actions.fetchMangoSrmAccounts()
|
||||
actions.fetchWalletBalances()
|
||||
notify({
|
||||
message: 'Wallet connected',
|
||||
description:
|
||||
|
@ -109,9 +112,6 @@ export default function useWallet() {
|
|||
'...' +
|
||||
wallet.publicKey.toString().substr(-5),
|
||||
})
|
||||
setMangoStore((state) => {
|
||||
state.wallet.connected = true
|
||||
})
|
||||
})
|
||||
wallet.on('disconnect', () => {
|
||||
console.log('disconnecting wallet')
|
||||
|
|
|
@ -212,13 +212,10 @@ const useMangoStore = create<MangoStore>((set, get) => ({
|
|||
set((state) => {
|
||||
state.wallet.srmAccountsForOwner = usersMangoSrmAccounts
|
||||
const totalSrmDeposits = usersMangoSrmAccounts.reduce(
|
||||
(prev, cur) => prev + cur.amount,
|
||||
(prev, cur) => prev + nativeToUi(cur.amount, SRM_DECIMALS),
|
||||
0
|
||||
)
|
||||
state.wallet.contributedSrm = nativeToUi(
|
||||
totalSrmDeposits,
|
||||
SRM_DECIMALS
|
||||
)
|
||||
state.wallet.contributedSrm = totalSrmDeposits
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue