diff --git a/src/hooks/useCheckBonusEligibility.ts b/src/hooks/useCheckBonusEligibility.ts index 8f0aeac92..e1d982b6a 100644 --- a/src/hooks/useCheckBonusEligibility.ts +++ b/src/hooks/useCheckBonusEligibility.ts @@ -1,9 +1,7 @@ import { useEffect } from "react" import { BigNumber, BigNumberish, Event, constants } from "ethers" import { - PRE_DEPLOYMENT_BLOCK, T_STAKING_CONTRACT_DEPLOYMENT_BLOCK, - usePREContract, useTStakingContract, } from "../web3/hooks" import { getAddress, getContractPastEvents } from "../web3/utils" @@ -29,7 +27,6 @@ export const useCheckBonusEligibility = () => { (state: RootState) => state.rewards.stakingBonus ) const dispatch = useDispatch() - const preContract = usePREContract() const merkleDropContract = useMerkleDropContract() const tStakingContract = useTStakingContract() @@ -38,7 +35,6 @@ export const useCheckBonusEligibility = () => { if ( !stakingProviders || stakingProviders.length === 0 || - !preContract || !tStakingContract || !merkleDropContract || (hasFetched && !isFetching) @@ -56,11 +52,6 @@ export const useCheckBonusEligibility = () => { ).map((_) => getAddress(_.args?.stakingProvider as string)) ) - const operatorConfirmedEvents = await getContractPastEvents(preContract, { - eventName: "OperatorConfirmed", - fromBlock: PRE_DEPLOYMENT_BLOCK, - filterParams: [stakingProviders], - }) const stakedEvents = await getContractPastEvents(tStakingContract, { eventName: "Staked", fromBlock: T_STAKING_CONTRACT_DEPLOYMENT_BLOCK, @@ -79,10 +70,6 @@ export const useCheckBonusEligibility = () => { filterParams: [stakingProviders], }) - const stakingProviderToPREConfig = getStakingProviderToPREConfig( - operatorConfirmedEvents - ) - const stakingProviderToStakedAmount = getStakingProviderToStakedInfo(stakedEvents) @@ -124,9 +111,7 @@ export const useCheckBonusEligibility = () => { eligibleStakeAmount, reward: calculateStakingBonusReward(eligibleStakeAmount), isRewardClaimed: claimedRewards.has(stakingProviderAddress), - isEligible: Boolean( - hasActiveStake && !hasUnstakeAfterBonusDeadline - ), + isEligible: Boolean(hasActiveStake && !hasUnstakeAfterBonusDeadline), } } dispatch(setStakingBonus(stakingProvidersInfo)) @@ -167,31 +152,6 @@ const getStakingProviderToStakedInfo = ( return stakingProviderToStakedAmount } -interface StakingProviderToPREConfig { - [address: string]: { - operator: string - operatorConfirmedAtBlock: number - transactionHash: string - } -} - -const getStakingProviderToPREConfig = ( - events: Event[] -): StakingProviderToPREConfig => { - const stakingProviderToPREConfig: StakingProviderToPREConfig = {} - for (const event of events) { - const stakingProvider = getAddress(event.args?.stakingProvider) - - stakingProviderToPREConfig[stakingProvider] = { - operator: event.args?.operator, - operatorConfirmedAtBlock: event.blockNumber, - transactionHash: event.transactionHash, - } - } - - return stakingProviderToPREConfig -} - interface StakingProviderToTopUps { [address: string]: { amount: BigNumberish diff --git a/src/hooks/useFetchOwnerStakes.ts b/src/hooks/useFetchOwnerStakes.ts index e06a379f6..defba8cf0 100644 --- a/src/hooks/useFetchOwnerStakes.ts +++ b/src/hooks/useFetchOwnerStakes.ts @@ -1,14 +1,12 @@ import { useCallback } from "react" import { StakeData } from "../types/staking" import { setStakes } from "../store/staking" -import { useFetchPreConfigData } from "./useFetchPreConfigData" import { useThreshold } from "../contexts/ThresholdContext" import { useAppDispatch } from "./store" export const useFetchOwnerStakes = () => { const threshold = useThreshold() const dispatch = useAppDispatch() - const fetchPreConfigData = useFetchPreConfigData() return useCallback( async (address?: string): Promise => { @@ -19,7 +17,6 @@ export const useFetchOwnerStakes = () => { const stakes = await threshold.staking.getOwnerStakes(address) const stakingProviders = stakes.map((stake) => stake.stakingProvider) - const preConfigData = await fetchPreConfigData(stakingProviders) const _stakes: StakeData[] = stakes.map((stake) => ({ ...stake, @@ -29,13 +26,12 @@ export const useFetchOwnerStakes = () => { totalInTStake: stake.totalInTStake.toString(), possibleKeepTopUpInT: stake.possibleKeepTopUpInT.toString(), possibleNuTopUpInT: stake.possibleNuTopUpInT.toString(), - preConfig: preConfigData[stake.stakingProvider], })) dispatch(setStakes(_stakes)) return _stakes }, - [threshold, fetchPreConfigData, dispatch] + [threshold, dispatch] ) } diff --git a/src/hooks/useFetchPreConfigData.ts b/src/hooks/useFetchPreConfigData.ts deleted file mode 100644 index dd0fffdc9..000000000 --- a/src/hooks/useFetchPreConfigData.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { useCallback } from "react" -import { usePREContract } from "../web3/hooks" -import { PreConfigData } from "../types/staking" -import { useThreshold } from "../contexts/ThresholdContext" - -export const useFetchPreConfigData = (): (( - stakingProviders: string[] -) => Promise) => { - const preContract = usePREContract() - const threshold = useThreshold() - - return useCallback( - async (stakingProviders) => { - if (!stakingProviders || stakingProviders.length === 0 || !preContract) { - return {} as PreConfigData - } - - const preConfigDataRaw = await threshold.multicall.aggregate( - stakingProviders.map((stakingProvider) => { - return { - interface: preContract.interface, - address: preContract.address, - method: "stakingProviderInfo", - args: [stakingProvider], - } - }) - ) - - return preConfigDataRaw.reduce( - (finalData: PreConfigData, _, idx): PreConfigData => { - finalData[stakingProviders[idx]] = { - operator: _.operator, - isOperatorConfirmed: _.operatorConfirmed, - operatorStartTimestamp: _.operatorStartTimestamp.toString(), - } - return finalData - }, - {} - ) - }, - [preContract, threshold] - ) -} diff --git a/src/hooks/useFetchTvl.ts b/src/hooks/useFetchTvl.ts index fc21632da..88b7715cb 100644 --- a/src/hooks/useFetchTvl.ts +++ b/src/hooks/useFetchTvl.ts @@ -23,7 +23,6 @@ interface TvlRawData { keepStakingTvl: string tStakingTvl: string tBTC: string - // TODO: add PRE and NU TVL } interface TvlData { diff --git a/src/store/staking/effects.ts b/src/store/staking/effects.ts index 97dc954ef..51368ea0f 100644 --- a/src/store/staking/effects.ts +++ b/src/store/staking/effects.ts @@ -71,11 +71,6 @@ const fetchStake = async ( keepInTStake: stake.keepInTStake.toString(), nuInTStake: stake.nuInTStake.toString(), totalInTStake: stake.totalInTStake.toString(), - preConfig: { - operator: AddressZero, - isOperatorConfirmed: false, - operatorStartTimestamp: "0", - }, possibleKeepTopUpInT: "0", possibleNuTopUpInT: "0", } as StakeData, diff --git a/src/store/staking/stakingSlice.ts b/src/store/staking/stakingSlice.ts index c2d7a006a..89f347301 100644 --- a/src/store/staking/stakingSlice.ts +++ b/src/store/staking/stakingSlice.ts @@ -71,12 +71,6 @@ export const stakingSlice = createSlice({ newStake.possibleKeepTopUpInT = "0" newStake.possibleNuTopUpInT = "0" - newStake.preConfig = { - operator: AddressZero, - isOperatorConfirmed: false, - operatorStartTimestamp: "0", - } - state.stakes = [newStake, ...state.stakes] state.stakedBalance = calculateStakedBalance(state.stakes) }, diff --git a/src/types/staking.ts b/src/types/staking.ts index c7306e40b..36c9cbec6 100644 --- a/src/types/staking.ts +++ b/src/types/staking.ts @@ -1,5 +1,5 @@ import { BigNumberish } from "@ethersproject/bignumber" -import { StakeType, TopUpType, UnstakeType } from "../enums" +import { TopUpType, UnstakeType } from "../enums" import { Stake } from "../threshold-ts/staking" import { UpdateStateActionPayload } from "./state" @@ -26,20 +26,7 @@ export interface UseStakingState { } } -export interface PreConfig { - // TODO THEREF - operator: string - isOperatorConfirmed: boolean - operatorStartTimestamp: string -} - -export interface PreConfigData { - [stakingProvider: string]: PreConfig -} - -export interface StakeData extends Stake { - preConfig: PreConfig -} +export interface StakeData extends Stake {} export interface ProviderStakedEvent { stakeType: number @@ -59,7 +46,6 @@ export type ProviderStakedActionPayload = ProviderStakedEvent & | "tStake" | "amount" | "totalInTStake" - | "preConfig" | "possibleKeepTopUpInT" | "possibleNuTopUpInT" > diff --git a/src/web3/hooks/index.ts b/src/web3/hooks/index.ts index b9aa469fe..d6b4f2e6e 100644 --- a/src/web3/hooks/index.ts +++ b/src/web3/hooks/index.ts @@ -18,6 +18,5 @@ export * from "./useKeepAssetPoolContract" export * from "./useTBTCTokenContract" export * from "./useTStakingContract" export * from "./useKeepTokenStakingContract" -export * from "./usePREContract" export * from "./useClaimMerkleRewardsTransaction" export * from "./useGetBlock" diff --git a/src/web3/hooks/usePREContract.ts b/src/web3/hooks/usePREContract.ts deleted file mode 100644 index 16de6d4c0..000000000 --- a/src/web3/hooks/usePREContract.ts +++ /dev/null @@ -1,28 +0,0 @@ -import SimplePREApplicationABI from "../abi/SimplePreApplication.json" -import { useContract } from "./useContract" -import { supportedChainId } from "../../utils/getEnvVariable" -import { ChainID } from "../../enums" -import { AddressZero } from "../utils" - -export const PRE_DEPLOYMENT_BLOCK = supportedChainId === "1" ? 14141140 : 0 - -const PRE_ADDRESSESS = { - // https://etherscan.io/address/0x7E01c9c03FD3737294dbD7630a34845B0F70E5Dd - [ChainID.Ethereum.valueOf().toString()]: - "0x7E01c9c03FD3737294dbD7630a34845B0F70E5Dd", - // https://goerli.etherscan.io/address/0x829fdCDf6Be747FEA37518fBd83dF70EE371fCf2 - // As NuCypher hasn't depoyed the `SimplePreApplication` contract on Goerli, - // we're using a stub contract. - [ChainID.Goerli.valueOf().toString()]: - "0x829fdCDf6Be747FEA37518fBd83dF70EE371fCf2", - // Set the correct `SimplePREApplication` contract address. If you deployed - // the `@threshold-network/solidity-contracts` to your local chain and linked - // package using `yarn link @threshold-network/solidity-contracts` you can - // find the contract address at - // `node_modules/@threshold-network/solidity-contracts/artifacts/SimplePREApplication.json`. - [ChainID.Localhost.valueOf().toString()]: AddressZero, -} as Record - -export const usePREContract = () => { - return useContract(PRE_ADDRESSESS[supportedChainId], SimplePREApplicationABI) -}