diff --git a/src/custom/pages/Profile/LockedGnoVesting/hooks.ts b/src/custom/pages/Profile/LockedGnoVesting/hooks.ts index 714dafd2e2..56aa573265 100644 --- a/src/custom/pages/Profile/LockedGnoVesting/hooks.ts +++ b/src/custom/pages/Profile/LockedGnoVesting/hooks.ts @@ -19,7 +19,7 @@ const COW = COW_TOKENS[SupportedChainId.MAINNET] export const MERKLE_DROP_CONTRACT_ADDRESSES: Record = { [SupportedChainId.MAINNET]: '0x64646f112FfD6F1B7533359CFaAF7998F23C8c40', [SupportedChainId.RINKEBY]: '0x5444c4AFb2ec7f7367C10F7732b8558650c5899F', - [SupportedChainId.XDAI]: '0x3d610e917130f9D036e85A030596807f57e11093', + [SupportedChainId.XDAI]: '0x48D8566887F8c7d99757CE29c2cD39962bfd9547', } const useMerkleDropContract = () => useContract(MERKLE_DROP_CONTRACT_ADDRESSES, MERKLE_DROP_ABI, true) @@ -56,7 +56,7 @@ export const useAllocation = (): CurrencyAmount => { const START_TIME = 1644584715000 const DURATION = 126144000000 -export const useBalances = () => { +export const useCowFromLockedGnoBalances = () => { const { account } = useActiveWeb3React() const allocated = useAllocation() const vested = allocated.multiply(Math.min(Date.now() - START_TIME, DURATION)).divide(DURATION) @@ -80,7 +80,7 @@ interface ClaimCallbackParams { closeModal: () => void isFirstClaim: boolean } -export function useClaimCallback({ +export function useClaimCowFromLockedGnoCallback({ openModal, closeModal, isFirstClaim, diff --git a/src/custom/pages/Profile/LockedGnoVesting/index.tsx b/src/custom/pages/Profile/LockedGnoVesting/index.tsx index e41307ad3b..9dd24f2dc4 100644 --- a/src/custom/pages/Profile/LockedGnoVesting/index.tsx +++ b/src/custom/pages/Profile/LockedGnoVesting/index.tsx @@ -13,10 +13,11 @@ import { OperationType } from 'components/TransactionConfirmationModal' import { useErrorModal } from 'hooks/useErrorMessageAndModal' import CopyHelper from 'components/Copy' import { getBlockExplorerUrl } from 'utils' +import { formatDateWithTimezone } from 'utils/time' import { SupportedChainId as ChainId } from 'constants/chains' import { useActiveWeb3React } from 'hooks/web3' -import { MERKLE_DROP_CONTRACT_ADDRESSES } from 'pages/Profile/LockedGnoVesting/hooks' -import { useBalances, useClaimCallback } from './hooks' +import { MERKLE_DROP_CONTRACT_ADDRESSES, TOKEN_DISTRO_CONTRACT_ADDRESSES } from 'pages/Profile/LockedGnoVesting/hooks' +import { useCowFromLockedGnoBalances, useClaimCowFromLockedGnoCallback } from './hooks' enum ClaimStatus { INITIAL, @@ -33,7 +34,7 @@ interface Props { const LockedGnoVesting: React.FC = ({ openModal, closeModal }: Props) => { const { chainId = ChainId.MAINNET } = useActiveWeb3React() const [status, setStatus] = useState(ClaimStatus.INITIAL) - const { allocated, vested, claimed, loading: loadingBalances } = useBalances() + const { allocated, vested, claimed, loading: loadingBalances } = useCowFromLockedGnoBalances() const unvested = allocated.subtract(vested) const allocatedFormatted = formatSmartLocaleAware(allocated, AMOUNT_PRECISION) || '0' const vestedFormatted = formatSmartLocaleAware(vested, AMOUNT_PRECISION) || '0' @@ -45,12 +46,18 @@ const LockedGnoVesting: React.FC = ({ openModal, closeModal }: Props) => const { handleSetError, handleCloseError, ErrorModal } = useErrorModal() - const claimCallback = useClaimCallback({ + const isFirstClaim = claimed.equalTo(0) + + const claimCallback = useClaimCowFromLockedGnoCallback({ openModal, closeModal, - isFirstClaim: claimed.equalTo(0), + isFirstClaim, }) + const contractAddress = isFirstClaim + ? MERKLE_DROP_CONTRACT_ADDRESSES[chainId] + : TOKEN_DISTRO_CONTRACT_ADDRESSES[chainId] + const handleClaim = useCallback(async () => { handleCloseError() if (!claimCallback) { @@ -114,16 +121,16 @@ const LockedGnoVesting: React.FC = ({ openModal, closeModal }: Props) => - Vested{' '} + Claimable{' '}

- COW vesting from the GNO lock is vested linearly over four years, starting on Fri - Feb 11 2022 at 13:05:15 GMT. + COW vesting from the GNO lock is vested linearly over four years, starting on{' '} + {formatDateWithTimezone(new Date('02-11-2022 13:05:15 GMT'))}.

-

Each time you claim, you will receive the entire vested amount.

+

Each time you claim, you will receive the entire claimable amount.

} > @@ -150,11 +157,9 @@ const LockedGnoVesting: React.FC = ({ openModal, closeModal }: Props) =>
- - View contract ↗ - - -
Copy contract
+ View contract ↗ + +
Copy contract