Merge branch 'dev' into myf-dev

This commit is contained in:
myf 2022-04-28 14:28:51 +08:00
commit 8e13aa91ac
14 changed files with 327 additions and 4494 deletions

View File

@ -1,8 +1,2 @@
# 🥞 Pancake Frontend
[![Netlify Status](https://api.netlify.com/api/v1/badges/7bebf1a3-be7b-4165-afd1-446256acd5e3/deploy-status)](https://app.netlify.com/sites/pancake-prod/deploys)
This project contains the main features of the pancake application.
If you want to contribute, please refer to the [contributing guidelines](./CONTRIBUTING.md) of this project.
test2
#
1. https://pancake.kiemtienonline360.com/#/add/BNB pancake测试服

View File

@ -6,7 +6,7 @@ import { useTranslation } from 'contexts/Localization'
import useTheme from 'hooks/useTheme'
import useAuth from 'hooks/useAuth'
import { useDispatch } from 'react-redux'
import { usePriceCakeBusd, useProfile } from 'state/hooks'
import { usePriceHccUsdt, useProfile } from 'state/hooks'
import { useUnactiveAccount, useSignLogin, useAccount, useUserInfo } from 'state/userInfo/hooks'
import useWeb3Provider from 'hooks/useActiveWeb3React'
import { clearUserInfo } from 'state/actions'
@ -17,7 +17,7 @@ const Menu = (props) => {
const { login, logout } = useAuth()
const [hasWalletLogin, setHasWalletLogin] = useState(false)
const { isDark, toggleTheme } = useTheme()
const cakePriceUsd = usePriceCakeBusd()
const hccPriceUsdt = usePriceHccUsdt()
const { library } = useWeb3Provider()
const unActiveAccount = useUnactiveAccount()
const dispatch = useDispatch()
@ -54,7 +54,7 @@ const Menu = (props) => {
currentLang={currentLanguage.code}
langs={languageList}
setLang={setLanguage}
cakePriceUsd={cakePriceUsd.toNumber()}
cakePriceUsd={hccPriceUsdt.toNumber()}
links={config(t)}
{...props}
/>

View File

@ -16,7 +16,7 @@ export default {
56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 持币人
},
referralChef: {
97: '0x86a510e82aceb27ed9e9880fb981d4b42ff16cb4',
97: '0x8a5dc1e8262d6a3de664624fdc13a533ba64e60d',
56: '0x88F46EF2Ee08494D84942DCA3bd24cDEf7C88Ae2', // NEED CHANGE 邀请或则军团长
},
referralRewardChef: {

File diff suppressed because it is too large Load Diff

View File

@ -2,240 +2,240 @@ import tokens from './tokens'
import farms from './farms'
import { Ifo, Token } from './types'
const cakeBnbLpToken: Token = {
symbol: farms[1].lpSymbol,
address: farms[1].lpAddresses,
decimals: 18,
}
// const cakeBnbLpToken: Token = {
// symbol: farms[1].lpSymbol,
// address: farms[1].lpAddresses,
// decimals: 18,
// }
const ifos: Ifo[] = [
{
id: 'kalmar',
address: '0x1aFB32b76696CdF05593Ca3f3957AEFB23a220FB',
isActive: true,
name: 'Kalmar (KALM)',
poolBasic: {
saleAmount: '375,000 KALM',
raiseAmount: '$750,000',
cakeToBurn: '$375,000',
distributionRatio: 0.3,
},
poolUnlimited: {
saleAmount: '875,000 KALM',
raiseAmount: '$2,500,000',
cakeToBurn: '$1,250,000',
distributionRatio: 0.7,
},
currency: cakeBnbLpToken,
token: tokens.kalm,
releaseBlockNumber: 7707736,
campaignId: '511110000',
articleUrl: 'https://pancakeswap.medium.com/kalmar-kalm-ifo-to-be-hosted-on-pancakeswap-4540059753e4',
tokenOfferingPrice: 2.0,
version: 2,
},
{
id: 'hotcross',
address: '0xb664cdbe385656F8c54031c0CB12Cea55b584b63',
isActive: false,
name: 'Hot Cross (HOTCROSS)',
poolBasic: {
saleAmount: '15,000,000 HOTCROSS',
raiseAmount: '$750,000',
cakeToBurn: '$375,000',
distributionRatio: 0.3,
},
poolUnlimited: {
saleAmount: '35,000,000 HOTCROSS',
raiseAmount: '$1,750,000',
cakeToBurn: '$875,000',
distributionRatio: 0.7,
},
currency: cakeBnbLpToken,
token: tokens.hotcross,
releaseBlockNumber: 7477900,
campaignId: '511100000',
articleUrl: 'https://pancakeswap.medium.com/hot-cross-hotcross-ifo-to-be-hosted-on-pancakeswap-10e70f1f6841',
tokenOfferingPrice: 0.05,
version: 2,
},
{
id: 'horizon',
address: '0x6137B571f7F1E44839ae10310a08be86D1A4D03B',
isActive: false,
name: 'Horizon Protocol (HZN)',
poolBasic: {
saleAmount: '3,000,000 HZN',
raiseAmount: '$750,000',
cakeToBurn: '$375,000',
distributionRatio: 0.3,
},
poolUnlimited: {
saleAmount: '7,000,000 HZN',
raiseAmount: '$1,750,000',
cakeToBurn: '$875,000',
distributionRatio: 0.7,
},
currency: cakeBnbLpToken,
token: tokens.hzn,
releaseBlockNumber: 6581111,
campaignId: '511090000',
articleUrl: 'https://pancakeswap.medium.com/horizon-protocol-hzn-ifo-to-be-hosted-on-pancakeswap-51f79601c9d8',
tokenOfferingPrice: 0.25,
version: 2,
},
{
id: 'belt',
address: '0xc9FBedC033a1c479a6AD451ffE463025E92a1d38',
isActive: false,
name: 'Belt (BELT)',
poolUnlimited: {
saleAmount: '150,000 BELT',
raiseAmount: '$3,000,000',
cakeToBurn: '$1,500,000',
distributionRatio: 1,
},
currency: cakeBnbLpToken,
token: tokens.belt,
releaseBlockNumber: 5493919,
campaignId: '511080000',
articleUrl: 'https://pancakeswap.medium.com/belt-fi-belt-ifo-to-be-hosted-on-pancakeswap-353585117e32',
tokenOfferingPrice: null,
version: 1,
},
{
id: 'watch',
address: '0x55344b55C71Ad8834C397E6e08dF5195cF84fe6d',
isActive: false,
name: 'Yieldwatch (WATCH)',
poolUnlimited: {
saleAmount: '8,000,000 WATCH',
raiseAmount: '$800,000',
cakeToBurn: '$400,000',
distributionRatio: 1,
},
currency: cakeBnbLpToken,
token: tokens.watch,
releaseBlockNumber: 5294924,
campaignId: '511070000',
articleUrl: 'https://pancakeswap.medium.com/yieldwatch-watch-ifo-to-be-hosted-on-pancakeswap-d24301f17241',
tokenOfferingPrice: null,
version: 1,
},
{
id: 'berry',
address: '0x5d028cE3435B2bB9AceBfaC599EEbA1ccD63d7dd',
isActive: false,
name: 'Berry (BRY)',
poolUnlimited: {
saleAmount: '2,000,000 BRY',
raiseAmount: '$1,000,000',
cakeToBurn: '$500,000',
distributionRatio: 1,
},
currency: cakeBnbLpToken,
token: tokens.bry,
releaseBlockNumber: 4750968,
campaignId: '511060000',
articleUrl: 'https://pancakeswap.medium.com/berry-bry-ifo-to-be-hosted-on-pancakeswap-b4f9095e9cdb',
tokenOfferingPrice: null,
version: 1,
},
{
id: 'soteria',
address: '0x9C21123D94b93361a29B2C2EFB3d5CD8B17e0A9e',
isActive: false,
name: 'Soteria (wSOTE)',
poolUnlimited: {
saleAmount: '1,500,000 wSOTE',
raiseAmount: '$525,000',
cakeToBurn: '$262,500',
distributionRatio: 1,
},
currency: cakeBnbLpToken,
token: tokens.wsote,
releaseBlockNumber: 4086064,
campaignId: '511050000',
articleUrl: 'https://pancakeswap.medium.com/soteria-sota-ifo-to-be-hosted-on-pancakeswap-64b727c272ae',
tokenOfferingPrice: null,
version: 1,
},
{
id: 'helmet',
address: '0xa32509d760ee47Eb2Be96D338b5d69B5FBa4eFEB',
isActive: false,
name: 'Helmet.insure (Helmet)',
poolUnlimited: {
saleAmount: '10,000,000 Helmet',
raiseAmount: '$1,000,000',
cakeToBurn: '$500,000',
distributionRatio: 1,
},
currency: cakeBnbLpToken,
token: tokens.helmet,
releaseBlockNumber: 3771926,
campaignId: '511040000',
articleUrl: 'https://pancakeswap.medium.com/1-000-000-helmet-helmet-ifo-to-be-hosted-on-pancakeswap-3379a2a89a67',
tokenOfferingPrice: null,
version: 1,
},
{
id: 'tenet',
address: '0xB922aA19A2603A07C6C9ED6c236618C9bac51f06',
isActive: false,
name: 'Tenet (TEN)',
poolUnlimited: {
saleAmount: '1,000,000 TEN',
raiseAmount: '$1,000,000',
cakeToBurn: '$500,000',
distributionRatio: 1,
},
currency: cakeBnbLpToken,
token: tokens.ten,
releaseBlockNumber: 3483883,
campaignId: '511030000',
articleUrl: 'https://pancakeswap.medium.com/tenet-ten-ifo-to-be-hosted-on-pancakeswap-b7e1eb4cb272',
tokenOfferingPrice: null,
version: 1,
},
{
id: 'ditto',
address: '0x570c9eB19553526Fb35895a531928E19C7D20788',
isActive: false,
name: 'Ditto (DITTO)',
poolUnlimited: {
saleAmount: '700,000 DITTO',
raiseAmount: '$630,000',
cakeToBurn: '$315,000',
distributionRatio: 1,
},
currency: cakeBnbLpToken,
token: tokens.ditto,
releaseBlockNumber: 3279767,
campaignId: '511020000',
articleUrl: 'https://pancakeswap.medium.com/ditto-money-ditto-ifo-to-be-hosted-on-pancakeswap-342da3059a66',
tokenOfferingPrice: null,
version: 1,
},
{
id: 'blink',
address: '0x44a9Cc8463EC00937242b660BF65B10365d99baD',
isActive: false,
name: 'BLINk (BLK)',
poolUnlimited: {
saleAmount: '100,000,000 BLINK',
raiseAmount: '$1,000,000',
cakeToBurn: '$500,000',
distributionRatio: 1,
},
currency: cakeBnbLpToken,
token: tokens.blink,
releaseBlockNumber: 3279767,
campaignId: '511010000',
articleUrl: 'https://medium.com/pancakeswap/1-000-000-ifo-blink-joins-pancakeswap-15841800bdd8',
tokenOfferingPrice: null,
version: 1,
},
// {
// id: 'kalmar',
// address: '0x1aFB32b76696CdF05593Ca3f3957AEFB23a220FB',
// isActive: true,
// name: 'Kalmar (KALM)',
// poolBasic: {
// saleAmount: '375,000 KALM',
// raiseAmount: '$750,000',
// cakeToBurn: '$375,000',
// distributionRatio: 0.3,
// },
// poolUnlimited: {
// saleAmount: '875,000 KALM',
// raiseAmount: '$2,500,000',
// cakeToBurn: '$1,250,000',
// distributionRatio: 0.7,
// },
// currency: cakeBnbLpToken,
// token: tokens.kalm,
// releaseBlockNumber: 7707736,
// campaignId: '511110000',
// articleUrl: 'https://pancakeswap.medium.com/kalmar-kalm-ifo-to-be-hosted-on-pancakeswap-4540059753e4',
// tokenOfferingPrice: 2.0,
// version: 2,
// },
// {
// id: 'hotcross',
// address: '0xb664cdbe385656F8c54031c0CB12Cea55b584b63',
// isActive: false,
// name: 'Hot Cross (HOTCROSS)',
// poolBasic: {
// saleAmount: '15,000,000 HOTCROSS',
// raiseAmount: '$750,000',
// cakeToBurn: '$375,000',
// distributionRatio: 0.3,
// },
// poolUnlimited: {
// saleAmount: '35,000,000 HOTCROSS',
// raiseAmount: '$1,750,000',
// cakeToBurn: '$875,000',
// distributionRatio: 0.7,
// },
// currency: cakeBnbLpToken,
// token: tokens.hotcross,
// releaseBlockNumber: 7477900,
// campaignId: '511100000',
// articleUrl: 'https://pancakeswap.medium.com/hot-cross-hotcross-ifo-to-be-hosted-on-pancakeswap-10e70f1f6841',
// tokenOfferingPrice: 0.05,
// version: 2,
// },
// {
// id: 'horizon',
// address: '0x6137B571f7F1E44839ae10310a08be86D1A4D03B',
// isActive: false,
// name: 'Horizon Protocol (HZN)',
// poolBasic: {
// saleAmount: '3,000,000 HZN',
// raiseAmount: '$750,000',
// cakeToBurn: '$375,000',
// distributionRatio: 0.3,
// },
// poolUnlimited: {
// saleAmount: '7,000,000 HZN',
// raiseAmount: '$1,750,000',
// cakeToBurn: '$875,000',
// distributionRatio: 0.7,
// },
// currency: cakeBnbLpToken,
// token: tokens.hzn,
// releaseBlockNumber: 6581111,
// campaignId: '511090000',
// articleUrl: 'https://pancakeswap.medium.com/horizon-protocol-hzn-ifo-to-be-hosted-on-pancakeswap-51f79601c9d8',
// tokenOfferingPrice: 0.25,
// version: 2,
// },
// {
// id: 'belt',
// address: '0xc9FBedC033a1c479a6AD451ffE463025E92a1d38',
// isActive: false,
// name: 'Belt (BELT)',
// poolUnlimited: {
// saleAmount: '150,000 BELT',
// raiseAmount: '$3,000,000',
// cakeToBurn: '$1,500,000',
// distributionRatio: 1,
// },
// currency: cakeBnbLpToken,
// token: tokens.belt,
// releaseBlockNumber: 5493919,
// campaignId: '511080000',
// articleUrl: 'https://pancakeswap.medium.com/belt-fi-belt-ifo-to-be-hosted-on-pancakeswap-353585117e32',
// tokenOfferingPrice: null,
// version: 1,
// },
// {
// id: 'watch',
// address: '0x55344b55C71Ad8834C397E6e08dF5195cF84fe6d',
// isActive: false,
// name: 'Yieldwatch (WATCH)',
// poolUnlimited: {
// saleAmount: '8,000,000 WATCH',
// raiseAmount: '$800,000',
// cakeToBurn: '$400,000',
// distributionRatio: 1,
// },
// currency: cakeBnbLpToken,
// token: tokens.watch,
// releaseBlockNumber: 5294924,
// campaignId: '511070000',
// articleUrl: 'https://pancakeswap.medium.com/yieldwatch-watch-ifo-to-be-hosted-on-pancakeswap-d24301f17241',
// tokenOfferingPrice: null,
// version: 1,
// },
// {
// id: 'berry',
// address: '0x5d028cE3435B2bB9AceBfaC599EEbA1ccD63d7dd',
// isActive: false,
// name: 'Berry (BRY)',
// poolUnlimited: {
// saleAmount: '2,000,000 BRY',
// raiseAmount: '$1,000,000',
// cakeToBurn: '$500,000',
// distributionRatio: 1,
// },
// currency: cakeBnbLpToken,
// token: tokens.bry,
// releaseBlockNumber: 4750968,
// campaignId: '511060000',
// articleUrl: 'https://pancakeswap.medium.com/berry-bry-ifo-to-be-hosted-on-pancakeswap-b4f9095e9cdb',
// tokenOfferingPrice: null,
// version: 1,
// },
// {
// id: 'soteria',
// address: '0x9C21123D94b93361a29B2C2EFB3d5CD8B17e0A9e',
// isActive: false,
// name: 'Soteria (wSOTE)',
// poolUnlimited: {
// saleAmount: '1,500,000 wSOTE',
// raiseAmount: '$525,000',
// cakeToBurn: '$262,500',
// distributionRatio: 1,
// },
// currency: cakeBnbLpToken,
// token: tokens.wsote,
// releaseBlockNumber: 4086064,
// campaignId: '511050000',
// articleUrl: 'https://pancakeswap.medium.com/soteria-sota-ifo-to-be-hosted-on-pancakeswap-64b727c272ae',
// tokenOfferingPrice: null,
// version: 1,
// },
// {
// id: 'helmet',
// address: '0xa32509d760ee47Eb2Be96D338b5d69B5FBa4eFEB',
// isActive: false,
// name: 'Helmet.insure (Helmet)',
// poolUnlimited: {
// saleAmount: '10,000,000 Helmet',
// raiseAmount: '$1,000,000',
// cakeToBurn: '$500,000',
// distributionRatio: 1,
// },
// currency: cakeBnbLpToken,
// token: tokens.helmet,
// releaseBlockNumber: 3771926,
// campaignId: '511040000',
// articleUrl: 'https://pancakeswap.medium.com/1-000-000-helmet-helmet-ifo-to-be-hosted-on-pancakeswap-3379a2a89a67',
// tokenOfferingPrice: null,
// version: 1,
// },
// {
// id: 'tenet',
// address: '0xB922aA19A2603A07C6C9ED6c236618C9bac51f06',
// isActive: false,
// name: 'Tenet (TEN)',
// poolUnlimited: {
// saleAmount: '1,000,000 TEN',
// raiseAmount: '$1,000,000',
// cakeToBurn: '$500,000',
// distributionRatio: 1,
// },
// currency: cakeBnbLpToken,
// token: tokens.ten,
// releaseBlockNumber: 3483883,
// campaignId: '511030000',
// articleUrl: 'https://pancakeswap.medium.com/tenet-ten-ifo-to-be-hosted-on-pancakeswap-b7e1eb4cb272',
// tokenOfferingPrice: null,
// version: 1,
// },
// {
// id: 'ditto',
// address: '0x570c9eB19553526Fb35895a531928E19C7D20788',
// isActive: false,
// name: 'Ditto (DITTO)',
// poolUnlimited: {
// saleAmount: '700,000 DITTO',
// raiseAmount: '$630,000',
// cakeToBurn: '$315,000',
// distributionRatio: 1,
// },
// currency: cakeBnbLpToken,
// token: tokens.ditto,
// releaseBlockNumber: 3279767,
// campaignId: '511020000',
// articleUrl: 'https://pancakeswap.medium.com/ditto-money-ditto-ifo-to-be-hosted-on-pancakeswap-342da3059a66',
// tokenOfferingPrice: null,
// version: 1,
// },
// {
// id: 'blink',
// address: '0x44a9Cc8463EC00937242b660BF65B10365d99baD',
// isActive: false,
// name: 'BLINk (BLK)',
// poolUnlimited: {
// saleAmount: '100,000,000 BLINK',
// raiseAmount: '$1,000,000',
// cakeToBurn: '$500,000',
// distributionRatio: 1,
// },
// currency: cakeBnbLpToken,
// token: tokens.blink,
// releaseBlockNumber: 3279767,
// campaignId: '511010000',
// articleUrl: 'https://medium.com/pancakeswap/1-000-000-ifo-blink-joins-pancakeswap-15841800bdd8',
// tokenOfferingPrice: null,
// version: 1,
// },
]
export default ifos

View File

@ -9,16 +9,16 @@ const priceHelperLps: FarmConfig[] = [
* Prices are then fetched for all farms (masterchef + priceHelperLps).
* Before storing to redux, farms without a PID are filtered out.
*/
{
pid: null,
lpSymbol: 'QSD-BNB LP',
lpAddresses: {
97: '',
56: '0x7b3ae32eE8C532016f3E31C8941D937c59e055B9',
},
token: tokens.qsd,
quoteToken: tokens.wbnb,
},
// {
// pid: null,
// lpSymbol: 'QSD-BNB LP',
// lpAddresses: {
// 97: '',
// 56: '0x7b3ae32eE8C532016f3E31C8941D937c59e055B9',
// },
// token: tokens.qsd,
// quoteToken: tokens.wbnb,
// },
]
export default priceHelperLps

View File

@ -1,9 +1,8 @@
import BigNumber from 'bignumber.js'
import erc20ABI from 'config/abi/erc20.json'
import boardABI from 'config/abi/board.json'
import multicall from 'utils/multicall'
import boardsConfig from 'config/constants/boards'
import { getAddress, getBoardAddress } from 'utils/addressHelpers'
import { getAddress } from 'utils/addressHelpers'
export const fetchBoardUserAllowances = async (account: string) => {
const calls = boardsConfig.map((board) => {
@ -39,15 +38,15 @@ export const fetchBoardUserTokenBalances = async (account: string) => {
export const fetchBoardUserInfo = async (account: string) => {
const data = await Promise.all(
boardsConfig.map(async (board) => {
const boardChefAdress = getAddress(board.contractAddress)
const boardChefAddress = getAddress(board.contractAddress)
const calls = [
{
address: boardChefAdress,
address: boardChefAddress,
name: 'userInfo',
params: [account],
},
{
address: boardChefAdress,
address: boardChefAddress,
name: 'pendingHCC',
params: [account],
},

View File

@ -12,7 +12,7 @@ const getFarmFromTokenSymbol = (farms: Farm[], tokenSymbol: string, preferredQuo
const getFarmBaseTokenPrice = (farm: Farm, quoteTokenFarm: Farm, bnbPriceBusd: BigNumber): BigNumber => {
const hasTokenPriceVsQuote = Boolean(farm.tokenPriceVsQuote)
if (farm.quoteToken.symbol === 'BUSD') {
if (farm.quoteToken.symbol === 'BUSD' || farm.quoteToken.symbol === 'USDT') {
return hasTokenPriceVsQuote ? new BigNumber(farm.tokenPriceVsQuote) : BIG_ZERO
}
@ -37,7 +37,7 @@ const getFarmBaseTokenPrice = (farm: Farm, quoteTokenFarm: Farm, bnbPriceBusd: B
: BIG_ZERO
}
if (quoteTokenFarm.quoteToken.symbol === 'BUSD') {
if (quoteTokenFarm.quoteToken.symbol === 'BUSD' || farm.quoteToken.symbol === 'USDT') {
const quoteTokenInBusd = quoteTokenFarm.tokenPriceVsQuote
return hasTokenPriceVsQuote && quoteTokenInBusd
? new BigNumber(farm.tokenPriceVsQuote).times(quoteTokenInBusd)
@ -49,7 +49,7 @@ const getFarmBaseTokenPrice = (farm: Farm, quoteTokenFarm: Farm, bnbPriceBusd: B
}
const getFarmQuoteTokenPrice = (farm: Farm, quoteTokenFarm: Farm, bnbPriceBusd: BigNumber): BigNumber => {
if (farm.quoteToken.symbol === 'BUSD') {
if (farm.quoteToken.symbol === 'BUSD' || farm.quoteToken.symbol === 'USDT') {
return BIG_ONE
}
@ -65,7 +65,7 @@ const getFarmQuoteTokenPrice = (farm: Farm, quoteTokenFarm: Farm, bnbPriceBusd:
return quoteTokenFarm.tokenPriceVsQuote ? bnbPriceBusd.times(quoteTokenFarm.tokenPriceVsQuote) : BIG_ZERO
}
if (quoteTokenFarm.quoteToken.symbol === 'BUSD') {
if (quoteTokenFarm.quoteToken.symbol === 'BUSD' || farm.quoteToken.symbol === 'USDT') {
return quoteTokenFarm.tokenPriceVsQuote ? new BigNumber(quoteTokenFarm.tokenPriceVsQuote) : BIG_ZERO
}
@ -73,8 +73,8 @@ const getFarmQuoteTokenPrice = (farm: Farm, quoteTokenFarm: Farm, bnbPriceBusd:
}
const fetchFarmsPrices = async (farms) => {
const bnbBusdFarm = farms.find((farm: Farm) => farm.pid === 252)
const bnbPriceBusd = bnbBusdFarm.tokenPriceVsQuote ? BIG_ONE.div(bnbBusdFarm.tokenPriceVsQuote) : BIG_ZERO
const bnbBusdFarm = farms.find((farm: Farm) => farm.pid === 252) // NEED CHANGE
const bnbPriceBusd = bnbBusdFarm?.tokenPriceVsQuote ? BIG_ONE.div(bnbBusdFarm.tokenPriceVsQuote) : BIG_ZERO
const farmsWithPrices = farms.map((farm) => {
const quoteTokenFarm = getFarmFromTokenSymbol(farms, farm.quoteToken.symbol)

View File

@ -56,7 +56,6 @@ const fetchFarm = async (farm: Farm): Promise<PublicFarmData> => {
name: 'decimals',
},
]
const [tokenBalanceLP, quoteTokenBalanceLP, lpTokenBalanceMC, lpTotalSupply, tokenDecimals, quoteTokenDecimals] =
await multicall(erc20, calls)
@ -75,24 +74,23 @@ const fetchFarm = async (farm: Farm): Promise<PublicFarmData> => {
const lpTotalInQuoteToken = quoteTokenAmountMc.times(new BigNumber(2))
// Only make masterchef calls if farm has pid
const [info, totalAllocPoint] =
pid || pid === 0
? await multicall(masterchefABI, [
{
address: getMasterChefAddress(),
name: 'poolInfo',
params: [pid],
},
{
address: getMasterChefAddress(),
name: 'totalAllocPoint',
},
])
: [null, null]
const [info, totalAllocPoint] = [null, null]
// (pid || pid === 0) // NEED CHANGE
// ? await multicall(masterchefABI, [
// {
// address: getMasterChefAddress(),
// name: 'poolInfo',
// params: [pid],
// },
// {
// address: getMasterChefAddress(),
// name: 'totalAllocPoint',
// },
// ])
// : [null, null]
const allocPoint = info ? new BigNumber(info.allocPoint?._hex) : BIG_ZERO
const poolWeight = totalAllocPoint ? allocPoint.div(new BigNumber(totalAllocPoint)) : BIG_ZERO
return {
tokenAmountMc: tokenAmountMc.toJSON(),
quoteTokenAmountMc: quoteTokenAmountMc.toJSON(),

View File

@ -79,7 +79,7 @@ export const usePollCoreFarmData = () => {
const { fastRefresh } = useRefresh()
useEffect(() => {
dispatch(fetchFarmsPublicDataAsync([251, 252]))
dispatch(fetchFarmsPublicDataAsync([251, 252, 1000])) // NEED CHANGE
}, [dispatch, fastRefresh])
}
@ -373,6 +373,10 @@ export const usePriceCakeBusd = (): BigNumber => {
const cakeBnbFarm = useFarmFromPid(251)
return new BigNumber(cakeBnbFarm.token.busdPrice)
}
export const usePriceHccUsdt = (): BigNumber => {
const hccUsdtFarm = useFarmFromPid(1000) // NEED CHANGE
return new BigNumber(hccUsdtFarm.token.busdPrice)
}
// Block
export const useBlock = () => {

View File

@ -43,8 +43,8 @@ export const fetchReferralInfoAsync = (account) => async (dispatch) => {
const configInfo: ReferralConfigInfo[] = await getReferralConfigInfo()
dispatch(
setReferralInfo({
commanderConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.COMMANDER),
normalConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.NORMAL),
commanderConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.COMMANDER) || {},
normalConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.NORMAL) || {},
isCommander: data.isCommander,
rewardInfo: data.reward || {},
}),

View File

@ -12,10 +12,6 @@ import useRefresh from 'hooks/useRefresh'
import tokens from 'config/constants/tokens'
import { useCheckTokenBalance, useApproveReferral, useBuyTransaction } from '../hooks'
// interface BuyActionsProps {
// }
const Btn = styled(Button)`
width: 50%;
margin: 20px auto 0px auto;
@ -30,7 +26,7 @@ const BuyActions: React.FC = () => {
const usdtContract = useERC20(getAddress(tokens.usdt.address))
const [loading, setLoading] = useState(false)
const [txId, setTxId] = useState()
const { toastSuccess } = useToast()
const { toastSuccess, toastError } = useToast()
const { fastRefresh } = useRefresh()
const hccContract = useERC20(getAddress(tokens.hcc.address))
const { onApprove: onUsdtApprove } = useApproveReferral(usdtContract)
@ -54,7 +50,14 @@ const BuyActions: React.FC = () => {
})
}
const handleBuy = async () => {
await buyTransaction()
setLoading(true)
try {
const res = await buyTransaction()
setTxId(res.hash)
} catch (e: any) {
setLoading(false)
toastError(e?.error?.message || e.message)
}
}
const getTransactionResult = async () => {
const res = await checkBuyResult({ tx: txId })
@ -101,7 +104,11 @@ const BuyActions: React.FC = () => {
{t('Approve %coin% Contract', { coin: 'hcc' })}
</Btn>
)}
{allowanceList?.usdt && allowanceList.hcc ? <Btn onClick={handleBuy}>{t('Buy It Now')}</Btn> : null}
{allowanceList?.usdt && allowanceList.hcc ? (
<Btn disabled={loading} onClick={handleBuy}>
{t('Buy It Now')}
</Btn>
) : null}
</Flex>
)
}

View File

@ -42,14 +42,15 @@ const ImageDiv = styled(Image)`
height: 300px;
}
`
const BuyNftModal: React.FC = () => {
interface BuyNftModalProps {
onDismiss?: () => void
}
const BuyNftModal: React.FC<BuyNftModalProps> = ({ onDismiss }) => {
const { t } = useTranslation()
const referralCommanderConfigInfo = useReferralCommanderConfigInfo()
const referralRewardInfo = useReferralNormalConfigInfo()
// const onDismiss = () => {}
return (
<ModalDiv title={`${t('purchase')}${referralCommanderConfigInfo.properties.name}`}>
<ModalDiv title={`${t('purchase')}${referralCommanderConfigInfo.properties.name}`} onDismiss={onDismiss}>
<Flex alignItems="center" flexWrap="wrap" justifyContent="center">
<ImageDiv
src={referralCommanderConfigInfo.properties.cover as string}

View File

@ -32,9 +32,8 @@ export const useBuyTransaction = () => {
const referralContract = useReferralchef()
const transaction = async () => {
const data = await getBuyReferralParams()
const { address, hccPrice, otherPaymentPirce, code, timestamp, sign } = data
const params = [address, hccPrice, otherPaymentPirce, code, timestamp, sign]
// const price = getDecimalAmountNumber(receive)
const { to, hccPrice, otherPaymentPrice, timestamp, code, sign } = data
const params = [to, hccPrice, otherPaymentPrice, timestamp, code, sign]
const res = await referralContract.mint(...params)
return res
}