Skip to content

Commit

Permalink
feat: add refresh to all actionboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
borcherd authored and chambaz committed Nov 21, 2024
1 parent 844bb91 commit 04a4bc1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const LoopBox = ({
setMaxLeverage,
setLeverage,
setIsLoading,
refreshSelectedBanks,
] = useLoopBoxStore((state) => [
state.leverage,
state.maxLeverage,
Expand All @@ -116,6 +117,7 @@ export const LoopBox = ({
state.setMaxLeverage,
state.setLeverage,
state.setIsLoading,
state.refreshSelectedBanks,
]);

const { priorityType, broadcastType, maxCap, maxCapType } = useActionContext();
Expand Down Expand Up @@ -299,6 +301,12 @@ export const LoopBox = ({
slippage,
]);

React.useEffect(() => {
if (marginfiClient) {
refreshSelectedBanks(banks);
}
}, [marginfiClient, banks, refreshSelectedBanks]);

return (
<>
{actionTxns.lastValidBlockHeight && blockProgress !== 0 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const RepayCollatBox = ({
setRepayAmount,
setMaxAmountCollateral,
setIsLoading,
refreshSelectedBanks,
] = useRepayCollatBoxStore((state) => [
state.maxAmountCollateral,
state.repayAmount,
Expand All @@ -107,6 +108,7 @@ export const RepayCollatBox = ({
state.setRepayAmount,
state.setMaxAmountCollateral,
state.setIsLoading,
state.refreshSelectedBanks,
]);

const { priorityType, broadcastType, maxCap, maxCapType } = useActionContext();
Expand Down Expand Up @@ -271,6 +273,12 @@ export const RepayCollatBox = ({
setPreviousTxn,
]);

React.useEffect(() => {
if (marginfiClient) {
refreshSelectedBanks(banks);
}
}, [marginfiClient, banks, refreshSelectedBanks]);

return (
<>
{actionTxns.lastValidBlockHeight && blockProgress !== 0 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ export const StakeBox = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [actionTxns]);

React.useEffect(() => {
if (marginfiClient) {
refreshSelectedBanks(banks);
}
}, [marginfiClient, banks, refreshSelectedBanks]);

return (
<>
<div className="mb-6">
Expand Down

0 comments on commit 04a4bc1

Please sign in to comment.