diff --git a/src/config/abi/board.json b/src/config/abi/board.json index 5442bd1..21f6f06 100644 --- a/src/config/abi/board.json +++ b/src/config/abi/board.json @@ -91,7 +91,9 @@ "outputs": [ { "internalType": "uint256", "name": "accHCCPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "totalAmount", "type": "uint256" }, - { "internalType": "uint256", "name": "num", "type": "uint256" } + { "internalType": "uint256", "name": "totalReward", "type": "uint256" }, + { "internalType": "uint256", "name": "curAmount", "type": "uint256" }, + { "internalType": "uint256", "name": "holderNum", "type": "uint256" } ], "stateMutability": "view", "type": "function" @@ -177,7 +179,8 @@ "outputs": [ { "internalType": "uint256", "name": "amount", "type": "uint256" }, { "internalType": "uint256", "name": "rewardDebt", "type": "uint256" }, - { "internalType": "uint256", "name": "unLockTime", "type": "uint256" } + { "internalType": "uint256", "name": "unLockTime", "type": "uint256" }, + { "internalType": "uint256", "name": "receiveReward", "type": "uint256" } ], "stateMutability": "view", "type": "function" diff --git a/src/config/abi/holder.json b/src/config/abi/holder.json index d41fb18..54db896 100644 --- a/src/config/abi/holder.json +++ b/src/config/abi/holder.json @@ -91,7 +91,9 @@ "outputs": [ { "internalType": "uint256", "name": "accHCCPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "totalAmount", "type": "uint256" }, - { "internalType": "uint256", "name": "num", "type": "uint256" } + { "internalType": "uint256", "name": "totalReward", "type": "uint256" }, + { "internalType": "uint256", "name": "curAmount", "type": "uint256" }, + { "internalType": "uint256", "name": "holderNum", "type": "uint256" } ], "stateMutability": "view", "type": "function" @@ -162,7 +164,8 @@ "name": "userInfo", "outputs": [ { "internalType": "uint256", "name": "amount", "type": "uint256" }, - { "internalType": "uint256", "name": "rewardDebt", "type": "uint256" } + { "internalType": "uint256", "name": "rewardDebt", "type": "uint256" }, + { "internalType": "uint256", "name": "receiveReward", "type": "uint256" } ], "stateMutability": "view", "type": "function" diff --git a/src/config/constants/contracts.ts b/src/config/constants/contracts.ts index 11e8b54..4521a28 100644 --- a/src/config/constants/contracts.ts +++ b/src/config/constants/contracts.ts @@ -8,7 +8,7 @@ export default { 56: '0x6ab8463a4185b80905e05a9ff80a2d6b714b9e95', }, boardChef: { - 97: '0x0e28f80e6560f0ebbba4bbdf155a946053e5056a', + 97: '0x733240108a3626f6f4871328f168281040655d08', 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会合约 }, boardRewardChef: { @@ -16,7 +16,7 @@ export default { 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会分红合约 }, holderChef: { - 97: '0xafa64f22a09fc197949c45281b2ad381a2b623a3', + 97: '0xa319dfdab0d4ed9a82f6bf85cc94e7d260ac0859', 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 持币人 }, holderRewardChef: { diff --git a/src/state/boards/fetchBoardsUser.ts b/src/state/boards/fetchBoardsUser.ts index 5979eb5..1ad0788 100644 --- a/src/state/boards/fetchBoardsUser.ts +++ b/src/state/boards/fetchBoardsUser.ts @@ -59,6 +59,7 @@ export const fetchBoardUserInfo = async (account: string) => { unLockTime: userInfo.unLockTime ? new BigNumber(userInfo.unLockTime._hex).toNumber() : 0, estimatedProfit: new BigNumber(estimatedProfit).toJSON(), name: board.name, + receiveReward: userInfo.receiveReward ? new BigNumber(userInfo.receiveReward._hex).toNumber() : 0, amount: getBalanceAmount(new BigNumber(userInfo.amount?._hex)).toNumber(), rewardDebt: getBalanceAmount(new BigNumber(userInfo.rewardDebt?._hex)).toNumber(), } diff --git a/src/state/boards/index.ts b/src/state/boards/index.ts index 1bc6486..8a4d493 100644 --- a/src/state/boards/index.ts +++ b/src/state/boards/index.ts @@ -52,6 +52,7 @@ export const fetchBoardUserDataAsync = (account) => async (dispatch) => { name: userInfo[index].name, amount: userInfo[index].amount, rewardDebt: userInfo[index].rewardDebt, + receiveReward: userInfo[index].receiveReward, } }) dispatch(setBoardsUserData({ arrayOfUserDataObjects })) diff --git a/src/views/Announcement/index.tsx b/src/views/Announcement/index.tsx index a7164ad..80a1ea8 100644 --- a/src/views/Announcement/index.tsx +++ b/src/views/Announcement/index.tsx @@ -14,7 +14,6 @@ interface DetailProps { } const ContainerMain = styled.div` background: ${({ theme }) => theme.colors.gradients.bubblegum}; - padding: 30px 0; ` const MainDiv = styled.div` width: 100%; diff --git a/src/views/Board/components/BoardCard/BoardCard.tsx b/src/views/Board/components/BoardCard/BoardCard.tsx index e7c2e01..99dae1f 100644 --- a/src/views/Board/components/BoardCard/BoardCard.tsx +++ b/src/views/Board/components/BoardCard/BoardCard.tsx @@ -94,12 +94,15 @@ interface NodeCardProps { removed: boolean provider?: ProviderType account?: string + boardsData?: any } -const BoardCard: React.FC = ({ board, account }) => { +const BoardCard: React.FC = ({ board, account, boardsData }) => { const { t } = useTranslation() const [countDown, setCountDown] = useState('') - + const [boardsDataCurAmount] = boardsData.filter((item) => { + return item.pid === board.pid + }) useEffect(() => { const interval = setInterval(() => { if (board.userData?.unlockTime) { @@ -125,17 +128,19 @@ const BoardCard: React.FC = ({ board, account }) => { const [showExpandableSection, setShowExpandableSection] = useState(false) return ( - + {account && (
- {board.userData?.name === 'Board' ? ( - - ) : ( - '' - )} - + {board.pid === 1 ? : ''} + {/* */} +
)} diff --git a/src/views/Board/components/BoardCard/CardHeading.tsx b/src/views/Board/components/BoardCard/CardHeading.tsx index 0843d7f..6aa77d2 100644 --- a/src/views/Board/components/BoardCard/CardHeading.tsx +++ b/src/views/Board/components/BoardCard/CardHeading.tsx @@ -9,6 +9,7 @@ export interface ExpandableSectionProps { isCommunityFarm?: boolean img?: string tokenSymbol?: string + amount?: number } const Wrapper = styled(Flex)` @@ -67,7 +68,7 @@ const Wrapper = styled(Flex)` ` const HeaderFlex = styled(Flex)`` -const CardHeading: React.FC = ({ name, img, tokenSymbol }) => { +const CardHeading: React.FC = ({ name, img, tokenSymbol, amount }) => { const { t } = useTranslation() return ( @@ -77,9 +78,11 @@ const CardHeading: React.FC = ({ name, img, tokenSymbol {name} {/* */} - {/*
-
{t('Staked')}
-
*/} + {amount > 0 && ( +
+
{t('Staked')}
+
+ )} ) } diff --git a/src/views/Board/index.tsx b/src/views/Board/index.tsx index 4ea6d0c..5b5ec6f 100644 --- a/src/views/Board/index.tsx +++ b/src/views/Board/index.tsx @@ -43,7 +43,6 @@ const FlexLayoutMain = styled(FlexLayout)` const Boards: React.FC = () => { const { t } = useTranslation() const boardsList = useBoards() - // console.log('boardsList', boardsList) const account = useAccount() const dispatch = useDispatch() @@ -56,6 +55,8 @@ const Boards: React.FC = () => { const [boardNum, setBoardNum] = useState(0) const [holderNum, setHolder] = useState(0) + const [boardsDataList, setBoardsDataList] = useState([]) + // 获取分红总额 const fetchBoardShares = async () => { const boardsData = await Promise.all( @@ -75,25 +76,31 @@ const Boards: React.FC = () => { ]) return { pid: boardConfig.pid, - totalAmount: getBalanceAmount(new BigNumber(boardPoolInfo.totalAmount._hex)).toNumber(), - num: new BigNumber(boardPoolInfo?.num?._hex).toNumber(), + curAmount: getBalanceAmount(new BigNumber(boardPoolInfo.curAmount._hex)).toNumber(), + // totalAmount: getBalanceAmount(new BigNumber(boardPoolInfo.totalAmount._hex)).toNumber(), + holderNum: new BigNumber(boardPoolInfo?.holderNum?._hex).toNumber(), waitWithdrawAmount: getBalanceAmount(new BigNumber(waitWithdrawAmount.balance._hex)).toNumber(), + totalReward: new BigNumber(boardPoolInfo?.totalReward?._hex).toNumber(), } }), ) + let total = 0 let waitWithdrawAmountValue = 0 + let totalReward = 0 boardsData.forEach((item) => { - total += item.totalAmount + total += item.curAmount + totalReward += item.totalReward waitWithdrawAmountValue += item.waitWithdrawAmount if (item.pid === 1) { - setBoardNum(item.num) + setBoardNum(item.holderNum) } else if (item.pid === 2) { - setHolder(item.num) + setHolder(item.holderNum) } }) + setBoardsDataList(boardsData) setTotalAmount(total) - setShareOutBonus(waitWithdrawAmountValue) + setShareOutBonus(totalReward) } useEffect(() => { dispatch(fetchBoardsPublicDataAsync()) @@ -108,7 +115,7 @@ const Boards: React.FC = () => {
{boardsList.map((board) => ( - + ))}
diff --git a/src/views/Referral/components/Connected.tsx b/src/views/Referral/components/Connected.tsx index dc135fd..a4eebc4 100644 --- a/src/views/Referral/components/Connected.tsx +++ b/src/views/Referral/components/Connected.tsx @@ -1,5 +1,8 @@ import React, { useState } from 'react' import styled from 'styled-components' +import { useDispatch } from 'react-redux' +import { fetchReferralInfoAsync } from 'state/actions' +import { useAccount } from 'state/userInfo/hooks' import { formatDivNumber } from 'utils/formatBalance' import { useTranslation } from 'contexts/Localization' import useToast from 'hooks/useToast' @@ -54,6 +57,8 @@ const TextDiv = styled(Text)` ` const ConnectedCom: React.FC = () => { + const dispatch = useDispatch() + const account = useAccount() const { t } = useTranslation() const [onBuyModal] = useModal() const referralNormalConfigInfo = useReferralNormalConfigInfo() @@ -65,6 +70,7 @@ const ConnectedCom: React.FC = () => { setLoading(true) try { await withdraw() + dispatch(fetchReferralInfoAsync(account)) setLoading(false) toastSuccess(t('Successfully claimed!')) } catch (error) {