fix notifications, use accountsdb to fetch mango accts

This commit is contained in:
tjs 2022-03-24 01:50:33 -04:00
parent 577b917b48
commit af2965098b
3 changed files with 12 additions and 8 deletions

View File

@ -35,7 +35,7 @@ export const settlePosPnl = async (
const mangoClient = useMangoStore.getState().connection.client
try {
await mangoClient.settlePosPnl(
const txids = await mangoClient.settlePosPnl(
mangoGroup,
mangoCache,
mangoAccount,
@ -45,10 +45,15 @@ export const settlePosPnl = async (
mangoAccounts
)
actions.reloadMangoAccount()
notify({
title: t('pnl-success'),
description: '',
})
for (const txid of txids) {
if (txid) {
notify({
title: t('pnl-success'),
description: '',
txid,
})
}
}
} catch (e) {
console.log('Error settling PNL: ', `${e}`, `${perpAccount}`)
notify({

View File

@ -56,7 +56,7 @@ export const RedeemDropdown: React.FC = () => {
setSettlingPosPnl(true)
for (const p of unsettledPositivePositions) {
console.log('settlePosPnl', p)
await settlePosPnl([p.perpMarket], p.perpAccount, t, undefined)
await settlePosPnl([p.perpMarket], p.perpAccount, t, null)
}
setSettlingPosPnl(false)
}

View File

@ -91,8 +91,7 @@ const usePerpPositions = () => {
const mangoGroup = useMangoStore(mangoGroupSelector)
const mangoCache = useMangoStore(mangoCacheSelector)
const allMarkets = useMangoStore(marketsSelector)
const tradeHistory = useMangoStore.getState().tradeHistory.parsed
const tradeHistory = useMangoStore((s) => s.tradeHistory.parsed)
useEffect(() => {
if (
mangoAccount &&