diff --git a/components/BorrowForm.tsx b/components/BorrowForm.tsx index 2f113138..c61fc7b7 100644 --- a/components/BorrowForm.tsx +++ b/components/BorrowForm.tsx @@ -118,7 +118,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) { if (!mangoAccount || !group || !publicKey) return setSubmitting(true) try { - const tx = await client.tokenWithdraw( + const { signature: tx, slot } = await client.tokenWithdraw( group, mangoAccount, bank!.mint, @@ -130,7 +130,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) { type: 'success', txid: tx, }) - await actions.reloadMangoAccount() + await actions.reloadMangoAccount(slot) actions.fetchWalletTokens(publicKey) setSubmitting(false) onSuccess() diff --git a/components/DepositForm.tsx b/components/DepositForm.tsx index d4abcbed..810bdfc3 100644 --- a/components/DepositForm.tsx +++ b/components/DepositForm.tsx @@ -130,7 +130,7 @@ function DepositForm({ onSuccess, token }: DepositFormProps) { setSubmitting(true) try { - const tx = await client.tokenDeposit( + const { signature: tx, slot } = await client.tokenDeposit( group, mangoAccount, bank.mint, @@ -142,7 +142,7 @@ function DepositForm({ onSuccess, token }: DepositFormProps) { txid: tx, }) - await actions.reloadMangoAccount() + await actions.reloadMangoAccount(slot) actions.fetchWalletTokens(publicKey) setSubmitting(false) onSuccess() diff --git a/components/MangoProvider.tsx b/components/MangoProvider.tsx index 9a93f7d0..2bde3e2b 100644 --- a/components/MangoProvider.tsx +++ b/components/MangoProvider.tsx @@ -93,22 +93,24 @@ const HydrateStore = () => { async (info, context) => { if (info?.lamports === 0) return - const lastSeenSlot = mangoStore.getState().mangoAccount.lastSlot const mangoAccount = mangoStore.getState().mangoAccount.current if (!mangoAccount) return - - if (context.slot > lastSeenSlot) { - const newMangoAccount = await client.getMangoAccountFromAi( - mangoAccount.publicKey, - info, - ) + const newMangoAccount = client.getMangoAccountFromAi( + mangoAccount.publicKey, + info, + ) + // don't fetch serum3OpenOrders if the slot is old + if (context.slot > mangoStore.getState().mangoAccount.lastSlot) { if (newMangoAccount.serum3Active().length > 0) { await newMangoAccount.reloadSerum3OpenOrders(client) + // check again that the slot is still the most recent after the reloading open orders + if (context.slot > mangoStore.getState().mangoAccount.lastSlot) { + set((s) => { + s.mangoAccount.current = newMangoAccount + s.mangoAccount.lastSlot = context.slot + }) + } } - set((s) => { - s.mangoAccount.current = newMangoAccount - s.mangoAccount.lastSlot = context.slot - }) actions.fetchOpenOrders() } }, diff --git a/components/RepayForm.tsx b/components/RepayForm.tsx index fadd2902..c9e8e746 100644 --- a/components/RepayForm.tsx +++ b/components/RepayForm.tsx @@ -125,7 +125,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) { setSubmitting(true) try { - const tx = await client.tokenDeposit( + const { signature: tx, slot } = await client.tokenDeposit( group, mangoAccount, bank.mint, @@ -138,7 +138,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) { txid: tx, }) - await actions.reloadMangoAccount() + await actions.reloadMangoAccount(slot) actions.fetchWalletTokens(publicKey) setSubmitting(false) onSuccess() diff --git a/components/StatusBar.tsx b/components/StatusBar.tsx index 242efc2f..98125ca4 100644 --- a/components/StatusBar.tsx +++ b/components/StatusBar.tsx @@ -61,7 +61,7 @@ const StatusBar = ({ collapsed }: { collapsed: boolean }) => { rel="noreferrer noopener" target="_blank" > - v{IDL.version} + v{IDL.version} {latestCommit.sha && latestCommit.url ? ( diff --git a/components/TopBar.tsx b/components/TopBar.tsx index b5cbe3e6..29470648 100644 --- a/components/TopBar.tsx +++ b/components/TopBar.tsx @@ -108,11 +108,13 @@ const TopBar = () => { ) : null} */} - logo +
+ logo +
{!connected ? ( mangoAccount ? ( @@ -189,7 +191,7 @@ const TopBar = () => { {isUnownedAccount || (!connected && isMobile) ? null : isMobile ? ( ) : (