import React, {useCallback, useMemo} from 'react'; import Page from '../../components/Page'; import {createGlobalStyle} from 'styled-components'; import {Switch} from 'react-router-dom'; import {useWallet} from 'use-wallet'; import UnlockWallet from '../../components/UnlockWallet'; import ExchangeCard from './components/ExchangeCard'; import styled from 'styled-components'; import useRaffleStats from '../../hooks/useRaffleBalance'; import useUnicornFinance from '../../hooks/useUnicornFinance'; import {useTransactionAdder} from '../../state/transactions/hooks'; import HomeImage from '../../assets/img/fairybg.gif'; import {Card, Grid, CircularProgress} from '@material-ui/core'; import LaunchCountdown from '../../components/LaunchCountdown'; const BackgroundImage = createGlobalStyle` body { background: url(${HomeImage}) repeat !important; background-size: cover !important; // background: linear-gradient(90deg, rgba(144,17,105,1) 0%, rgba(95,17,144,1) 100%); } `; const Raffle: React.FC = () => { // compatible format for most browser + metamask browser. Needs to be YYYY-MM-ddTHH:mm:ssZ const startDate = new Date('2022-07-01T23:00:00Z'); const endDate = new Date('2022-07-05T00:00:00Z'); const raffleAddress = '0xA3F2C4D813d75E26335ddE70DcFd703996Ae25D8'; const {account} = useWallet(); const unicornFinance = useUnicornFinance(); const addTransaction = useTransactionAdder(); const raffleStats = useRaffleStats(account, raffleAddress); const startTime = Number(startDate); const endTime = Number(endDate); const unicornPrice = useMemo(() => (raffleStats ? Number(raffleStats.tokenInFtm).toFixed(2) : null), [raffleStats]); const raffleBals = useMemo(() => (raffleStats ? Number(raffleStats.totalSupply).toFixed(0) : null), [raffleStats]); const userBals = useMemo(() => (raffleStats ? Number(raffleStats.priceInDollars).toFixed(0) : null), [raffleStats]); const handleBuyBonds = useCallback( async (amount: string) => { const tx = await unicornFinance.sendUnicorn(amount, raffleAddress); addTransaction(tx, { summary: `Send ${Number(amount).toFixed(2)} UNICORN to the raffle ${amount} `, }); }, [unicornFinance, addTransaction], ); return ( {!!account ? ( <>

WINGS Raffle

Community raffle where you have the chance to win WINGS just by sending in your freely earned Unicorn rewards.



1 Unicorn = 1 entry and there are unlimited entries per address, the more Unicorn you send the more chance you have to win. The winner will be chosen at random.

Raffle address: {raffleAddress}

{Date.now() > endTime ? (

Raffle Closed

) : (

Raffle Open

)} {Date.now() < startTime ? ( ) : ( )}

Raffle Stats

6 WINGS up for grabs this raffle

Unicorn Price: $ {unicornPrice ? ( unicornPrice ) : ( )}

Total Unicorn Entered:{' '} {raffleBals ? ( raffleBals ) : ( )}

Your entries:{' '} {userBals ? userBals : }

Your account: {account}

startTime ? 'Raffle is open! 1 UNICORN = 1 Entry' : 'Raffle is currently closed' } disabled={Date.now() < endTime && Date.now() > startTime ? false : true} onExchange={handleBuyBonds} />
) : ( )}
); }; const StyledBond = styled.div` display: flex; @media (max-width: 768px) { width: 100%; flex-flow: column nowrap; align-items: center; } `; const StyledCardWrapper = styled.div` display: flex; flex: 1; flex-direction: column; @media (max-width: 768px) { width: 80%; } `; export default Raffle;