Skip to content

Commit

Permalink
active check
Browse files Browse the repository at this point in the history
  • Loading branch information
brightiron committed Dec 9, 2024
1 parent 1067808 commit 4ee6298
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/views/Range/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,13 @@ export const RangeNextBeat = () => {
});
return { data, isFetched, isLoading };
};

export const useRangeCheckActive = () => {
const networks = useTestableNetworks();
const contract = RANGE_OPERATOR_CONTRACT.getEthersContract(networks.MAINNET);
const { data, isFetched, isLoading } = useQuery(["getRangeCheckActive", networks.MAINNET], async () => {
const active = await contract.active();
return active;
});
return { data, isFetched, isLoading };
};
12 changes: 11 additions & 1 deletion src/views/Range/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
RangeBondMaxPayout,
RangeData,
RangeNextBeat,
useRangeCheckActive,
} from "src/views/Range/hooks";
import RangeChart from "src/views/Range/RangeChart";
import RangeConfirmationModal from "src/views/Range/RangeConfirmationModal";
Expand All @@ -46,6 +47,7 @@ export const Range = () => {
const networks = useTestableNetworks();
const { chain = { id: 1 } } = useNetwork();
const { data: rangeData, isLoading: rangeDataLoading } = RangeData();
const { data: isActive } = useRangeCheckActive();
usePathForNetwork({ pathName: "range", networkID: chain.id, navigate });

const {
Expand Down Expand Up @@ -234,6 +236,13 @@ export const Range = () => {
</Box>
</Box>
)}
{!isActive && (
<Box display="flex" flexDirection="row" width="100%" justifyContent="center" mt="24px">
<Box display="flex" flexDirection="column" width="100%" maxWidth="476px">
<InfoNotification>RBS Operator is currently inactive</InfoNotification>
</Box>
</Box>
)}
</Box>
<form onSubmit={handleSubmit}>
<RangeInputForm
Expand Down Expand Up @@ -310,7 +319,8 @@ export const Range = () => {
amountAboveCapacity ||
amountAboveBalance ||
(sellActive && !rangeData.low.active) ||
(!sellActive && !rangeData.high.active)
(!sellActive && !rangeData.high.active) ||
!isActive
}
>
{amountAboveCapacity
Expand Down

0 comments on commit 4ee6298

Please sign in to comment.