From 4ee62989e1e21310283b5f3fee885dbbee5b584e Mon Sep 17 00:00:00 2001 From: brightiron Date: Sun, 8 Dec 2024 21:06:20 -0600 Subject: [PATCH] active check --- src/views/Range/hooks.tsx | 10 ++++++++++ src/views/Range/index.tsx | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/views/Range/hooks.tsx b/src/views/Range/hooks.tsx index 98847f9dd..3e8a654e9 100644 --- a/src/views/Range/hooks.tsx +++ b/src/views/Range/hooks.tsx @@ -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 }; +}; diff --git a/src/views/Range/index.tsx b/src/views/Range/index.tsx index aaa726c67..430a79939 100644 --- a/src/views/Range/index.tsx +++ b/src/views/Range/index.tsx @@ -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"; @@ -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 { @@ -234,6 +236,13 @@ export const Range = () => { )} + {!isActive && ( + + + RBS Operator is currently inactive + + + )}
{ amountAboveCapacity || amountAboveBalance || (sellActive && !rangeData.low.active) || - (!sellActive && !rangeData.high.active) + (!sellActive && !rangeData.high.active) || + !isActive } > {amountAboveCapacity