部分董事会
This commit is contained in:
commit
25c5e7a4ca
|
|
@ -1,21 +1,22 @@
|
||||||
REACT_APP_CHAIN_ID = "56"
|
REACT_APP_CHAIN_ID = "97"
|
||||||
REACT_APP_GTAG = "GTM-TLF66T4"
|
REACT_APP_GTAG = "GTM-PXLD3XW"
|
||||||
|
|
||||||
# 10+ nodes balanced, US/EU
|
# 10+ nodes balanced, US/EU
|
||||||
REACT_APP_NODE_1 = "https://bsc-dataseed1.ninicoin.io"
|
REACT_APP_NODE_1 = "https://data-seed-prebsc-1-s1.binance.org:8545"
|
||||||
|
|
||||||
# 10+ nodes balanced, US/EU
|
# 10+ nodes balanced, US/EU
|
||||||
REACT_APP_NODE_2 = "https://bsc-dataseed1.defibit.io"
|
REACT_APP_NODE_2 = "https://data-seed-prebsc-1-s1.binance.org:8545"
|
||||||
|
|
||||||
# 10+ nodes balanced in each region, global
|
# 10+ nodes balanced in each region, global
|
||||||
REACT_APP_NODE_3 = "https://bsc-dataseed.binance.org"
|
REACT_APP_NODE_3 = "https://data-seed-prebsc-1-s1.binance.org:8545"
|
||||||
|
|
||||||
REACT_APP_GRAPH_API_PROFILE = "https://api.thegraph.com/subgraphs/name/pancakeswap/profile"
|
REACT_APP_GRAPH_API_PROFILE = "https://api.thegraph.com/subgraphs/name/pancakeswap/profile"
|
||||||
REACT_APP_GRAPH_API_PREDICTION = "https://api.thegraph.com/subgraphs/name/pancakeswap/prediction"
|
REACT_APP_GRAPH_API_PREDICTION = "https://api.thegraph.com/subgraphs/name/pancakeswap/prediction"
|
||||||
REACT_APP_GRAPH_API_LOTTERY = "https://api.thegraph.com/subgraphs/name/pancakeswap/lottery"
|
REACT_APP_GRAPH_API_LOTTERY = "https://api.thegraph.com/subgraphs/name/pancakeswap/lottery"
|
||||||
|
|
||||||
REACT_APP_SNAPSHOT_BASE_URL = "https://hub.snapshot.page"
|
REACT_APP_SNAPSHOT_BASE_URL = "https://testnet.snapshot.org"
|
||||||
REACT_APP_SNAPSHOT_VOTING_API = "https://voting-api.pancakeswap.info/api"
|
REACT_APP_SNAPSHOT_VOTING_API = "https://xtjyd0liqe.execute-api.ap-northeast-1.amazonaws.com/dev/api"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
REACT_APP_REQUEST_URL = 'http://101.35.117.69:9090'
|
REACT_APP_REQUEST_URL = 'http://101.35.117.69:9090'
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ import { getBalanceAmount } from 'utils/formatBalance'
|
||||||
export const fetchBoardUserAllowances = async (account: string) => {
|
export const fetchBoardUserAllowances = async (account: string) => {
|
||||||
const calls = boardsConfig.map((board) => {
|
const calls = boardsConfig.map((board) => {
|
||||||
const tokenAddresses = getAddress(board.tokenAddresses)
|
const tokenAddresses = getAddress(board.tokenAddresses)
|
||||||
const boardChefAdress = getAddress(board.contractAddress)
|
const boardChefAddress = getAddress(board.contractAddress)
|
||||||
return { address: tokenAddresses, name: 'allowance', params: [account, boardChefAdress] }
|
return { address: tokenAddresses, name: 'allowance', params: [account, boardChefAddress] }
|
||||||
})
|
})
|
||||||
|
|
||||||
const rawLpAllowances = await multicall(erc20ABI, calls)
|
const rawLpAllowances = await multicall(erc20ABI, calls)
|
||||||
|
|
@ -40,15 +40,15 @@ export const fetchBoardUserTokenBalances = async (account: string) => {
|
||||||
export const fetchBoardUserInfo = async (account: string) => {
|
export const fetchBoardUserInfo = async (account: string) => {
|
||||||
const data = await Promise.all(
|
const data = await Promise.all(
|
||||||
boardsConfig.map(async (board) => {
|
boardsConfig.map(async (board) => {
|
||||||
const boardChefAdress = getAddress(board.contractAddress)
|
const boardChefAddress = getAddress(board.contractAddress)
|
||||||
const calls = [
|
const calls = [
|
||||||
{
|
{
|
||||||
address: boardChefAdress,
|
address: boardChefAddress,
|
||||||
name: 'userInfo',
|
name: 'userInfo',
|
||||||
params: [account],
|
params: [account],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
address: boardChefAdress,
|
address: boardChefAddress,
|
||||||
name: 'pendingHCC',
|
name: 'pendingHCC',
|
||||||
params: [account],
|
params: [account],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,14 @@ export interface ReferralConfigInfo {
|
||||||
dividendSecond?: number
|
dividendSecond?: number
|
||||||
receiveLimit?: number
|
receiveLimit?: number
|
||||||
id?: number
|
id?: number
|
||||||
properties?: Record<string, unknown>
|
properties?: {
|
||||||
|
cover?: string
|
||||||
|
name?: string
|
||||||
|
price?: {
|
||||||
|
HCC: string
|
||||||
|
USDT: string
|
||||||
|
}
|
||||||
|
}
|
||||||
type?: string
|
type?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ export const unstakeBoard = async (masterChefContract) => {
|
||||||
return receipt.status
|
return receipt.status
|
||||||
}
|
}
|
||||||
|
|
||||||
export const harvestBoard = async (masterChefContract, pid) => {
|
export const harvestBoard = async (masterChefContract) => {
|
||||||
const tx = await masterChefContract.harvest(pid, '0', options)
|
const tx = await masterChefContract.harvest(options)
|
||||||
const receipt = await tx.wait()
|
const receipt = await tx.wait()
|
||||||
return receipt.status
|
return receipt.status
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { useERC20 } from 'hooks/useContract'
|
||||||
import UnlockButton from 'components/UnlockButton'
|
import UnlockButton from 'components/UnlockButton'
|
||||||
import useApproveBoard from '../../hooks/useApproveBoard'
|
import useApproveBoard from '../../hooks/useApproveBoard'
|
||||||
import StakeAction from './StakeAction'
|
import StakeAction from './StakeAction'
|
||||||
|
import HarvestAction from './HarvestAction'
|
||||||
|
|
||||||
const Action = styled.div`
|
const Action = styled.div`
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
|
|
@ -57,14 +58,10 @@ const CardActions: React.FC<NodeCardActionsProps> = ({ board, account }) => {
|
||||||
</Flex>
|
</Flex>
|
||||||
<StakeAction stakedBalance={stakedBalance} tokenBalance={tokenBalance} pid={pid} />
|
<StakeAction stakedBalance={stakedBalance} tokenBalance={tokenBalance} pid={pid} />
|
||||||
<Flex flexDirection="column" alignItems="flex-start" mt="10">
|
<Flex flexDirection="column" alignItems="flex-start" mt="10">
|
||||||
<Flex>
|
|
||||||
<Text color="textSubtle" fontSize="12px">
|
<Text color="textSubtle" fontSize="12px">
|
||||||
{t('TotalProfit')}
|
{t('TotalProfit')}
|
||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
<HarvestAction earnings={new BigNumber(estimatedProfit)} pid={pid} />
|
||||||
<Text bold textTransform="uppercase" fontSize="20px">
|
|
||||||
{getBalanceNumber(new BigNumber(estimatedProfit))}
|
|
||||||
</Text>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
import BigNumber from 'bignumber.js'
|
||||||
|
import { Button, Flex, Heading } from '@pancakeswap/uikit'
|
||||||
|
import { useTranslation } from 'contexts/Localization'
|
||||||
|
import { useAppDispatch } from 'state'
|
||||||
|
import { fetchFarmUserDataAsync } from 'state/farms'
|
||||||
|
import useToast from 'hooks/useToast'
|
||||||
|
import { getBalanceAmount } from 'utils/formatBalance'
|
||||||
|
import { BIG_ZERO } from 'utils/bigNumber'
|
||||||
|
import { useWeb3React } from '@web3-react/core'
|
||||||
|
import { usePriceCakeBusd } from 'state/hooks'
|
||||||
|
import Balance from 'components/Balance'
|
||||||
|
import { TOKEN_SYMBOL } from 'config/index'
|
||||||
|
import useHarvestBoard from '../../hooks/useHarvestBoard'
|
||||||
|
|
||||||
|
interface FarmCardActionsProps {
|
||||||
|
earnings?: BigNumber
|
||||||
|
pid?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const HarvestAction: React.FC<FarmCardActionsProps> = ({ earnings, pid }) => {
|
||||||
|
const { account } = useWeb3React()
|
||||||
|
const { toastSuccess, toastError } = useToast()
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const [pendingTx, setPendingTx] = useState(false)
|
||||||
|
const { onReward } = useHarvestBoard(pid)
|
||||||
|
const cakePrice = usePriceCakeBusd()
|
||||||
|
const dispatch = useAppDispatch()
|
||||||
|
const rawEarningsBalance = account ? getBalanceAmount(earnings) : BIG_ZERO
|
||||||
|
const displayBalance = rawEarningsBalance.toFixed(3, BigNumber.ROUND_DOWN)
|
||||||
|
const earningsBusd = rawEarningsBalance ? rawEarningsBalance.multipliedBy(cakePrice).toNumber() : 0
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Flex width="100%" justifyContent="space-between" alignItems="center">
|
||||||
|
<Flex flexDirection="column" alignItems="flex-start">
|
||||||
|
<Heading color={rawEarningsBalance.eq(0) ? 'textDisabled' : 'text'}>{displayBalance}</Heading>
|
||||||
|
{earningsBusd > 0 && (
|
||||||
|
<Balance fontSize="12px" color="textSubtle" decimals={2} value={earningsBusd} unit=" USD" prefix="~" />
|
||||||
|
)}
|
||||||
|
</Flex>
|
||||||
|
<Button
|
||||||
|
disabled={rawEarningsBalance.eq(0) || pendingTx}
|
||||||
|
onClick={async () => {
|
||||||
|
setPendingTx(true)
|
||||||
|
try {
|
||||||
|
await onReward()
|
||||||
|
toastSuccess(
|
||||||
|
`${t('Harvested')}!`,
|
||||||
|
t('Your %symbol% earnings have been sent to your wallet!', { symbol: TOKEN_SYMBOL }),
|
||||||
|
)
|
||||||
|
} catch (e) {
|
||||||
|
toastError(
|
||||||
|
t('Error'),
|
||||||
|
t('Please try again. Confirm the transaction and make sure you are paying enough gas!'),
|
||||||
|
)
|
||||||
|
console.error(e)
|
||||||
|
} finally {
|
||||||
|
setPendingTx(false)
|
||||||
|
}
|
||||||
|
dispatch(fetchFarmUserDataAsync({ account, pids: [pid] }))
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('Harvest')}
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HarvestAction
|
||||||
|
|
@ -6,7 +6,7 @@ const useHarvestBoard = (boardPid: number) => {
|
||||||
const boardChefContract = useBoardchef(boardPid)
|
const boardChefContract = useBoardchef(boardPid)
|
||||||
|
|
||||||
const handleHarvest = useCallback(async () => {
|
const handleHarvest = useCallback(async () => {
|
||||||
await harvestBoard(boardChefContract, boardPid)
|
await harvestBoard(boardChefContract)
|
||||||
}, [boardPid, boardChefContract])
|
}, [boardPid, boardChefContract])
|
||||||
|
|
||||||
return { onReward: handleHarvest }
|
return { onReward: handleHarvest }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
import { Flex, Button, Modal, Image } from '@pancakeswap/uikit'
|
import { Flex, Button } from '@pancakeswap/uikit'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { useTranslation } from 'contexts/Localization'
|
import { useTranslation } from 'contexts/Localization'
|
||||||
import { useAccount } from 'state/userInfo/hooks'
|
import { useAccount } from 'state/userInfo/hooks'
|
||||||
|
|
@ -10,6 +10,7 @@ import useToast from 'hooks/useToast'
|
||||||
import { checkBuyResult } from 'services/referral'
|
import { checkBuyResult } from 'services/referral'
|
||||||
import useRefresh from 'hooks/useRefresh'
|
import useRefresh from 'hooks/useRefresh'
|
||||||
import tokens from 'config/constants/tokens'
|
import tokens from 'config/constants/tokens'
|
||||||
|
import { useReferralCommanderConfigInfo } from 'state/referral/hooks'
|
||||||
import { useCheckTokenBalance, useApproveReferral, useBuyTransaction } from '../hooks'
|
import { useCheckTokenBalance, useApproveReferral, useBuyTransaction } from '../hooks'
|
||||||
|
|
||||||
const Btn = styled(Button)`
|
const Btn = styled(Button)`
|
||||||
|
|
@ -22,6 +23,7 @@ const Btn = styled(Button)`
|
||||||
const BuyActions: React.FC = () => {
|
const BuyActions: React.FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const account = useAccount()
|
const account = useAccount()
|
||||||
|
const referralCommanderConfigInfo = useReferralCommanderConfigInfo()
|
||||||
const [allowanceList, setAllowanceList] = useState({ usdt: 0, hcc: 0 })
|
const [allowanceList, setAllowanceList] = useState({ usdt: 0, hcc: 0 })
|
||||||
const usdtContract = useERC20(getAddress(tokens.usdt.address))
|
const usdtContract = useERC20(getAddress(tokens.usdt.address))
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
@ -32,6 +34,7 @@ const BuyActions: React.FC = () => {
|
||||||
const { onApprove: onUsdtApprove } = useApproveReferral(usdtContract)
|
const { onApprove: onUsdtApprove } = useApproveReferral(usdtContract)
|
||||||
const { onApprove: onHccApprove } = useApproveReferral(hccContract)
|
const { onApprove: onHccApprove } = useApproveReferral(hccContract)
|
||||||
const buyTransaction = useBuyTransaction()
|
const buyTransaction = useBuyTransaction()
|
||||||
|
const [onCheckBalance] = useCheckTokenBalance()
|
||||||
const handleApprove = async (approve) => {
|
const handleApprove = async (approve) => {
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
@ -52,8 +55,16 @@ const BuyActions: React.FC = () => {
|
||||||
const handleBuy = async () => {
|
const handleBuy = async () => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
try {
|
try {
|
||||||
|
const enoughBalance = onCheckBalance(
|
||||||
|
referralCommanderConfigInfo.properties?.price?.HCC,
|
||||||
|
referralCommanderConfigInfo.properties?.price?.USDT,
|
||||||
|
)
|
||||||
|
if (enoughBalance) {
|
||||||
const res = await buyTransaction()
|
const res = await buyTransaction()
|
||||||
setTxId(res.hash)
|
setTxId(res.hash)
|
||||||
|
} else {
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
toastError(e?.error?.message || e.message)
|
toastError(e?.error?.message || e.message)
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,10 @@ const RegimentalCom: React.FC = () => {
|
||||||
<ContentDiv>
|
<ContentDiv>
|
||||||
<MainDiv>
|
<MainDiv>
|
||||||
<HeadingDiv scale="xl" mb="24px" textAlign="center">
|
<HeadingDiv scale="xl" mb="24px" textAlign="center">
|
||||||
{referralCommanderConfigInfo.properties.name}
|
{referralCommanderConfigInfo?.properties?.name}
|
||||||
</HeadingDiv>
|
</HeadingDiv>
|
||||||
<LogoImage>
|
<LogoImage>
|
||||||
<Image src={referralCommanderConfigInfo.properties.cover as string} width={249} height={249} />
|
<Image src={referralCommanderConfigInfo?.properties?.cover} width={249} height={249} />
|
||||||
{/* <Image src="/images/recommend/logo.svg" width={249} height={249} /> */}
|
{/* <Image src="/images/recommend/logo.svg" width={249} height={249} /> */}
|
||||||
</LogoImage>
|
</LogoImage>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,21 +9,20 @@ import { ethers, Contract } from 'ethers'
|
||||||
import { getBalanceNumber, getDecimalAmountNumber } from 'utils/formatBalance'
|
import { getBalanceNumber, getDecimalAmountNumber } from 'utils/formatBalance'
|
||||||
import { getWithdrawRewardParams, getBuyReferralParams } from 'services/referral'
|
import { getWithdrawRewardParams, getBuyReferralParams } from 'services/referral'
|
||||||
|
|
||||||
export const useCheckTokenBalance = ({ isBnb, isHcc, isUsdt }) => {
|
export const useCheckTokenBalance = () => {
|
||||||
const { balance: usdtTokenBalance } = useTokenBalance(getAddress(tokensList.usdt.address))
|
const { balance: usdtTokenBalance } = useTokenBalance(getAddress(tokensList.usdt.address))
|
||||||
const { balance: hccTokenBalance } = useTokenBalance(getAddress(tokensList.hcc.address))
|
const { balance: hccTokenBalance } = useTokenBalance(getAddress(tokensList.hcc.address))
|
||||||
const { toastWarning } = useToast()
|
const { toastWarning } = useToast()
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const onCheck = useCallback(
|
const onCheck = useCallback(
|
||||||
(hccAmount, usdtAmount) => {
|
(hccAmount, usdtAmount) => {
|
||||||
if (
|
if (getBalanceNumber(hccTokenBalance) <= hccAmount || getBalanceNumber(usdtTokenBalance) <= usdtAmount) {
|
||||||
(isHcc && getBalanceNumber(hccTokenBalance) === hccAmount) ||
|
|
||||||
(isUsdt && getBalanceNumber(usdtTokenBalance) === usdtAmount)
|
|
||||||
) {
|
|
||||||
toastWarning(t('Insufficient Balance'))
|
toastWarning(t('Insufficient Balance'))
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
},
|
},
|
||||||
[isBnb, isHcc, isUsdt],
|
[usdtTokenBalance, hccTokenBalance],
|
||||||
)
|
)
|
||||||
return [onCheck]
|
return [onCheck]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,6 @@ const Nft: React.FC = () => {
|
||||||
const account = useAccount()
|
const account = useAccount()
|
||||||
|
|
||||||
const referralIsCommander = useReferralIsCommander()
|
const referralIsCommander = useReferralIsCommander()
|
||||||
// const referralIsCommander = false
|
|
||||||
console.log('referralIsCommander:', referralIsCommander)
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(fetchReferralInfoAsync(account))
|
dispatch(fetchReferralInfoAsync(account))
|
||||||
}, [account])
|
}, [account])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue