调整董事会合约

This commit is contained in:
myf 2022-05-09 23:46:57 +08:00
parent 07dd68e03a
commit 5e9b7e99a1
10 changed files with 56 additions and 28 deletions

View File

@ -91,7 +91,9 @@
"outputs": [ "outputs": [
{ "internalType": "uint256", "name": "accHCCPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "accHCCPerShare", "type": "uint256" },
{ "internalType": "uint256", "name": "totalAmount", "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", "stateMutability": "view",
"type": "function" "type": "function"
@ -177,7 +179,8 @@
"outputs": [ "outputs": [
{ "internalType": "uint256", "name": "amount", "type": "uint256" }, { "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "uint256", "name": "rewardDebt", "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", "stateMutability": "view",
"type": "function" "type": "function"

View File

@ -91,7 +91,9 @@
"outputs": [ "outputs": [
{ "internalType": "uint256", "name": "accHCCPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "accHCCPerShare", "type": "uint256" },
{ "internalType": "uint256", "name": "totalAmount", "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", "stateMutability": "view",
"type": "function" "type": "function"
@ -162,7 +164,8 @@
"name": "userInfo", "name": "userInfo",
"outputs": [ "outputs": [
{ "internalType": "uint256", "name": "amount", "type": "uint256" }, { "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", "stateMutability": "view",
"type": "function" "type": "function"

View File

@ -8,7 +8,7 @@ export default {
56: '0x6ab8463a4185b80905e05a9ff80a2d6b714b9e95', 56: '0x6ab8463a4185b80905e05a9ff80a2d6b714b9e95',
}, },
boardChef: { boardChef: {
97: '0x0e28f80e6560f0ebbba4bbdf155a946053e5056a', 97: '0x733240108a3626f6f4871328f168281040655d08',
56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会合约 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会合约
}, },
boardRewardChef: { boardRewardChef: {
@ -16,7 +16,7 @@ export default {
56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会分红合约 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会分红合约
}, },
holderChef: { holderChef: {
97: '0xafa64f22a09fc197949c45281b2ad381a2b623a3', 97: '0xa319dfdab0d4ed9a82f6bf85cc94e7d260ac0859',
56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 持币人 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 持币人
}, },
holderRewardChef: { holderRewardChef: {

View File

@ -59,6 +59,7 @@ export const fetchBoardUserInfo = async (account: string) => {
unLockTime: userInfo.unLockTime ? new BigNumber(userInfo.unLockTime._hex).toNumber() : 0, unLockTime: userInfo.unLockTime ? new BigNumber(userInfo.unLockTime._hex).toNumber() : 0,
estimatedProfit: new BigNumber(estimatedProfit).toJSON(), estimatedProfit: new BigNumber(estimatedProfit).toJSON(),
name: board.name, name: board.name,
receiveReward: userInfo.receiveReward ? new BigNumber(userInfo.receiveReward._hex).toNumber() : 0,
amount: getBalanceAmount(new BigNumber(userInfo.amount?._hex)).toNumber(), amount: getBalanceAmount(new BigNumber(userInfo.amount?._hex)).toNumber(),
rewardDebt: getBalanceAmount(new BigNumber(userInfo.rewardDebt?._hex)).toNumber(), rewardDebt: getBalanceAmount(new BigNumber(userInfo.rewardDebt?._hex)).toNumber(),
} }

View File

@ -52,6 +52,7 @@ export const fetchBoardUserDataAsync = (account) => async (dispatch) => {
name: userInfo[index].name, name: userInfo[index].name,
amount: userInfo[index].amount, amount: userInfo[index].amount,
rewardDebt: userInfo[index].rewardDebt, rewardDebt: userInfo[index].rewardDebt,
receiveReward: userInfo[index].receiveReward,
} }
}) })
dispatch(setBoardsUserData({ arrayOfUserDataObjects })) dispatch(setBoardsUserData({ arrayOfUserDataObjects }))

View File

@ -14,7 +14,6 @@ interface DetailProps {
} }
const ContainerMain = styled.div` const ContainerMain = styled.div`
background: ${({ theme }) => theme.colors.gradients.bubblegum}; background: ${({ theme }) => theme.colors.gradients.bubblegum};
padding: 30px 0;
` `
const MainDiv = styled.div` const MainDiv = styled.div`
width: 100%; width: 100%;

View File

@ -94,12 +94,15 @@ interface NodeCardProps {
removed: boolean removed: boolean
provider?: ProviderType provider?: ProviderType
account?: string account?: string
boardsData?: any
} }
const BoardCard: React.FC<NodeCardProps> = ({ board, account }) => { const BoardCard: React.FC<NodeCardProps> = ({ board, account, boardsData }) => {
const { t } = useTranslation() const { t } = useTranslation()
const [countDown, setCountDown] = useState('') const [countDown, setCountDown] = useState('')
const [boardsDataCurAmount] = boardsData.filter((item) => {
return item.pid === board.pid
})
useEffect(() => { useEffect(() => {
const interval = setInterval(() => { const interval = setInterval(() => {
if (board.userData?.unlockTime) { if (board.userData?.unlockTime) {
@ -125,17 +128,19 @@ const BoardCard: React.FC<NodeCardProps> = ({ board, account }) => {
const [showExpandableSection, setShowExpandableSection] = useState(false) const [showExpandableSection, setShowExpandableSection] = useState(false)
return ( return (
<FCard> <FCard>
<CardHeading name={t(board.name)} img={board.img} tokenSymbol={board.tokenSymbol} /> <CardHeading
name={t(board.name)}
img={board.img}
tokenSymbol={board.tokenSymbol}
amount={board.userData?.amount}
/>
<ContentDiv> <ContentDiv>
{account && ( {account && (
<div> <div>
<FlexText name={t('HCC Currency amount')} value={board.userData?.amount} /> <FlexText name={t('HCC Currency amount')} value={board.userData?.amount} />
{board.userData?.name === 'Board' ? ( {board.pid === 1 ? <FlexText name={t('Lock up time')} value={countDown} /> : ''}
<FlexText name={t('Lock up time')} value={board.userData?.unlockTime} /> {/* <FlexText name={t('possess LP')} value={board.userData?.amount} /> */}
) : ( <FlexText name={t('possess LP')} value={board.userData?.amount / boardsDataCurAmount?.curAmount || 0} />
''
)}
<FlexText name={t('possess LP')} value={board.userData?.rewardDebt} />
</div> </div>
)} )}
<CardActionsContainer board={board} account={account} /> <CardActionsContainer board={board} account={account} />

View File

@ -9,6 +9,7 @@ export interface ExpandableSectionProps {
isCommunityFarm?: boolean isCommunityFarm?: boolean
img?: string img?: string
tokenSymbol?: string tokenSymbol?: string
amount?: number
} }
const Wrapper = styled(Flex)` const Wrapper = styled(Flex)`
@ -67,7 +68,7 @@ const Wrapper = styled(Flex)`
` `
const HeaderFlex = styled(Flex)`` const HeaderFlex = styled(Flex)``
const CardHeading: React.FC<ExpandableSectionProps> = ({ name, img, tokenSymbol }) => { const CardHeading: React.FC<ExpandableSectionProps> = ({ name, img, tokenSymbol, amount }) => {
const { t } = useTranslation() const { t } = useTranslation()
return ( return (
@ -77,9 +78,11 @@ const CardHeading: React.FC<ExpandableSectionProps> = ({ name, img, tokenSymbol
<Heading mb="4px">{name}</Heading> <Heading mb="4px">{name}</Heading>
{/* <Question text={t('To join board, you need to stake at least 0.1% total supply of Token')} /> */} {/* <Question text={t('To join board, you need to stake at least 0.1% total supply of Token')} /> */}
</HeaderFlex> </HeaderFlex>
{/* <div className="ribbon"> {amount > 0 && (
<div className="ribbon">
<div className="ribbon1">{t('Staked')}</div> <div className="ribbon1">{t('Staked')}</div>
</div> */} </div>
)}
</Wrapper> </Wrapper>
) )
} }

View File

@ -43,7 +43,6 @@ const FlexLayoutMain = styled(FlexLayout)`
const Boards: React.FC = () => { const Boards: React.FC = () => {
const { t } = useTranslation() const { t } = useTranslation()
const boardsList = useBoards() const boardsList = useBoards()
// console.log('boardsList', boardsList)
const account = useAccount() const account = useAccount()
const dispatch = useDispatch() const dispatch = useDispatch()
@ -56,6 +55,8 @@ const Boards: React.FC = () => {
const [boardNum, setBoardNum] = useState(0) const [boardNum, setBoardNum] = useState(0)
const [holderNum, setHolder] = useState(0) const [holderNum, setHolder] = useState(0)
const [boardsDataList, setBoardsDataList] = useState([])
// 获取分红总额 // 获取分红总额
const fetchBoardShares = async () => { const fetchBoardShares = async () => {
const boardsData = await Promise.all( const boardsData = await Promise.all(
@ -75,25 +76,31 @@ const Boards: React.FC = () => {
]) ])
return { return {
pid: boardConfig.pid, pid: boardConfig.pid,
totalAmount: getBalanceAmount(new BigNumber(boardPoolInfo.totalAmount._hex)).toNumber(), curAmount: getBalanceAmount(new BigNumber(boardPoolInfo.curAmount._hex)).toNumber(),
num: new BigNumber(boardPoolInfo?.num?._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(), waitWithdrawAmount: getBalanceAmount(new BigNumber(waitWithdrawAmount.balance._hex)).toNumber(),
totalReward: new BigNumber(boardPoolInfo?.totalReward?._hex).toNumber(),
} }
}), }),
) )
let total = 0 let total = 0
let waitWithdrawAmountValue = 0 let waitWithdrawAmountValue = 0
let totalReward = 0
boardsData.forEach((item) => { boardsData.forEach((item) => {
total += item.totalAmount total += item.curAmount
totalReward += item.totalReward
waitWithdrawAmountValue += item.waitWithdrawAmount waitWithdrawAmountValue += item.waitWithdrawAmount
if (item.pid === 1) { if (item.pid === 1) {
setBoardNum(item.num) setBoardNum(item.holderNum)
} else if (item.pid === 2) { } else if (item.pid === 2) {
setHolder(item.num) setHolder(item.holderNum)
} }
}) })
setBoardsDataList(boardsData)
setTotalAmount(total) setTotalAmount(total)
setShareOutBonus(waitWithdrawAmountValue) setShareOutBonus(totalReward)
} }
useEffect(() => { useEffect(() => {
dispatch(fetchBoardsPublicDataAsync()) dispatch(fetchBoardsPublicDataAsync())
@ -108,7 +115,7 @@ const Boards: React.FC = () => {
<div> <div>
<FlexLayout> <FlexLayout>
{boardsList.map((board) => ( {boardsList.map((board) => (
<BoardCard key={board.pid} board={board} account={account} removed /> <BoardCard boardsData={boardsDataList} key={board.pid} board={board} account={account} removed />
))} ))}
</FlexLayout> </FlexLayout>
</div> </div>

View File

@ -1,5 +1,8 @@
import React, { useState } from 'react' import React, { useState } from 'react'
import styled from 'styled-components' 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 { formatDivNumber } from 'utils/formatBalance'
import { useTranslation } from 'contexts/Localization' import { useTranslation } from 'contexts/Localization'
import useToast from 'hooks/useToast' import useToast from 'hooks/useToast'
@ -54,6 +57,8 @@ const TextDiv = styled(Text)`
` `
const ConnectedCom: React.FC = () => { const ConnectedCom: React.FC = () => {
const dispatch = useDispatch()
const account = useAccount()
const { t } = useTranslation() const { t } = useTranslation()
const [onBuyModal] = useModal(<BuyNftModal />) const [onBuyModal] = useModal(<BuyNftModal />)
const referralNormalConfigInfo = useReferralNormalConfigInfo() const referralNormalConfigInfo = useReferralNormalConfigInfo()
@ -65,6 +70,7 @@ const ConnectedCom: React.FC = () => {
setLoading(true) setLoading(true)
try { try {
await withdraw() await withdraw()
dispatch(fetchReferralInfoAsync(account))
setLoading(false) setLoading(false)
toastSuccess(t('Successfully claimed!')) toastSuccess(t('Successfully claimed!'))
} catch (error) { } catch (error) {