From 1bff22307b772bf20881701be5114daaebf5030f Mon Sep 17 00:00:00 2001
From: gary <1032230992@qq.com>
Date: Sat, 23 Apr 2022 17:21:47 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=91=A3=E4=BA=8B?=
=?UTF-8?q?=E4=BC=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env.development | 8 +-
package.json | 1 +
src/App.tsx | 1 +
src/components/Menu/config.ts | 5 +
src/config/abi/board.json | 851 ++++++++----------
src/config/abi/leaderNft.json | 405 +++++++++
src/config/constants/boards.ts | 12 +-
src/config/constants/contracts.ts | 6 +-
src/config/constants/index.ts | 1 +
src/config/constants/tokens.ts | 21 +-
src/config/constants/types.ts | 2 +
src/config/index.ts | 2 +-
src/hooks/useContract.ts | 4 +-
src/state/boards/fetchBoards.ts | 15 +-
src/state/boards/fetchBoardsUser.ts | 78 +-
src/state/boards/index.ts | 18 +-
src/state/hooks.ts | 2 +-
src/state/types.ts | 2 +-
src/utils/calls/boards.ts | 27 +
src/utils/calls/index.ts | 1 +
src/utils/contractHelpers.ts | 7 +-
.../Board/components/BoardCard/BoardCard.tsx | 7 +-
.../BoardCard/CardActionsContainer.tsx | 21 +-
.../components/BoardCard/CardHeading.tsx | 2 +-
.../components/BoardCard/DetailsSection.tsx | 2 +-
.../components/BoardCard/StakeAction.tsx | 23 +-
src/views/Board/hooks/useApproveBoard.ts | 4 +-
src/views/Board/hooks/useHarvestBoard.ts | 6 +-
src/views/Board/hooks/useStakeBoard.ts | 6 +-
src/views/Board/hooks/useUnstakeBoard.ts | 6 +-
yarn.lock | 5 +
31 files changed, 943 insertions(+), 608 deletions(-)
create mode 100644 src/config/abi/leaderNft.json
create mode 100644 src/utils/calls/boards.ts
diff --git a/.env.development b/.env.development
index eeb149f..d28e5f8 100644
--- a/.env.development
+++ b/.env.development
@@ -1,14 +1,14 @@
-REACT_APP_CHAIN_ID = "56"
+REACT_APP_CHAIN_ID = "97"
REACT_APP_GTAG = "GTM-PXLD3XW"
# 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
-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
-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_PREDICTION = "https://api.thegraph.com/subgraphs/name/pancakeswap/prediction"
diff --git a/package.json b/package.json
index 4c16ae5..4d9cf50 100644
--- a/package.json
+++ b/package.json
@@ -56,6 +56,7 @@
"canvas-confetti": "^1.3.3",
"cids": "^1.0.0",
"date-fns": "^2.21.3",
+ "dayjs": "^1.11.1",
"easymde": "^2.15.0",
"ethers": "^5.1.4",
"graphql": "^15.5.0",
diff --git a/src/App.tsx b/src/App.tsx
index 2d40467..f259898 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -93,6 +93,7 @@ const App: React.FC = () => {
+
diff --git a/src/components/Menu/config.ts b/src/components/Menu/config.ts
index cd902a2..3516e8d 100644
--- a/src/components/Menu/config.ts
+++ b/src/components/Menu/config.ts
@@ -45,6 +45,11 @@ const config: (t: ContextApi['t']) => MenuEntry[] = (t) => [
icon: 'TicketIcon',
href: '/nft',
},
+ {
+ label: t('Board'),
+ icon: 'TicketIcon',
+ href: '/board',
+ },
// {
// label: t('Prediction (BETA)'),
// icon: 'PredictionsIcon',
diff --git a/src/config/abi/board.json b/src/config/abi/board.json
index 1299954..37ce156 100644
--- a/src/config/abi/board.json
+++ b/src/config/abi/board.json
@@ -1,464 +1,387 @@
-[
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "_candy",
- "type": "address"
- },
- {
- "internalType": "address",
- "name": "_xCandy",
- "type": "address"
- },
- {
- "internalType": "bool",
- "name": "_turnOnCondition",
- "type": "bool"
- }
- ],
- "stateMutability": "nonpayable",
- "type": "constructor"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "address",
- "name": "user",
- "type": "address"
- },
- {
- "indexed": false,
- "internalType": "uint256",
- "name": "amount",
- "type": "uint256"
- }
- ],
- "name": "Deposit",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "address",
- "name": "user",
- "type": "address"
- },
- {
- "indexed": false,
- "internalType": "uint256",
- "name": "amount",
- "type": "uint256"
- }
- ],
- "name": "EmergencyWithdraw",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "address",
- "name": "to",
- "type": "address"
- },
- {
- "indexed": false,
- "internalType": "uint256",
- "name": "amount",
- "type": "uint256"
- }
- ],
- "name": "NodeReward",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "address",
- "name": "previousOwner",
- "type": "address"
- },
- {
- "indexed": true,
- "internalType": "address",
- "name": "newOwner",
- "type": "address"
- }
- ],
- "name": "OwnershipTransferred",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "address",
- "name": "user",
- "type": "address"
- },
- {
- "indexed": false,
- "internalType": "uint256",
- "name": "amount",
- "type": "uint256"
- }
- ],
- "name": "Withdraw",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "address",
- "name": "from",
- "type": "address"
- },
- {
- "indexed": false,
- "internalType": "uint256",
- "name": "amount",
- "type": "uint256"
- }
- ],
- "name": "WithdrawNodeReward",
- "type": "event"
- },
- {
- "inputs": [],
- "name": "Candy",
- "outputs": [
- {
- "internalType": "contract IHRC20",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "XCandy",
- "outputs": [
- {
- "internalType": "contract IHRC20",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "from",
- "type": "address"
- },
- {
- "internalType": "uint256",
- "name": "rewardNum",
- "type": "uint256"
- }
- ],
- "name": "addNodeReward",
- "outputs": [
- {
- "internalType": "bool",
- "name": "",
- "type": "bool"
- }
- ],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "account",
- "type": "address"
- }
- ],
- "name": "addWhitelisted",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "name": "canGetRewardMap",
- "outputs": [
- {
- "internalType": "uint256",
- "name": "",
- "type": "uint256"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "uint256",
- "name": "_thresholdDivider",
- "type": "uint256"
- }
- ],
- "name": "changeThresholdDivider",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "conditionTurnOn",
- "outputs": [
- {
- "internalType": "bool",
- "name": "",
- "type": "bool"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "uint256",
- "name": "_amount",
- "type": "uint256"
- }
- ],
- "name": "enterStake",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "firstStakeThreshold",
- "outputs": [
- {
- "internalType": "uint256",
- "name": "",
- "type": "uint256"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "_findAddress",
- "type": "address"
- }
- ],
- "name": "getIsNodeMembers",
- "outputs": [
- {
- "internalType": "bool",
- "name": "",
- "type": "bool"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "account",
- "type": "address"
- }
- ],
- "name": "isWhitelisted",
- "outputs": [
- {
- "internalType": "bool",
- "name": "",
- "type": "bool"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "leaveStake",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "leaveStakePrecheck",
- "outputs": [
- {
- "internalType": "bool",
- "name": "",
- "type": "bool"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "name": "nodeMembers",
- "outputs": [
- {
- "internalType": "bool",
- "name": "",
- "type": "bool"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "nodeToPeriod",
- "outputs": [
- {
- "internalType": "uint256",
- "name": "",
- "type": "uint256"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "owner",
- "outputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "account",
- "type": "address"
- }
- ],
- "name": "removeWhitelisted",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "renounceOwnership",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "bool",
- "name": "_turnOn",
- "type": "bool"
- }
- ],
- "name": "switchCondition",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "thresholdDivider",
- "outputs": [
- {
- "internalType": "uint256",
- "name": "",
- "type": "uint256"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "newOwner",
- "type": "address"
- }
- ],
- "name": "transferOwnership",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "name": "userInfo",
- "outputs": [
- {
- "internalType": "uint256",
- "name": "amount",
- "type": "uint256"
- },
- {
- "internalType": "uint256",
- "name": "stakeTs",
- "type": "uint256"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "withDrawReward",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- }
-]
+[
+ {
+ "inputs": [
+ {
+ "internalType": "contract IERC20",
+ "name": "_HCC",
+ "type": "address"
+ },
+ {
+ "internalType": "address",
+ "name": "_HCCBODReawardPool",
+ "type": "address"
+ },
+ {
+ "internalType": "uint256",
+ "name": "_minStakeAmount",
+ "type": "uint256"
+ }
+ ],
+ "stateMutability": "nonpayable",
+ "type": "constructor"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "internalType": "address",
+ "name": "user",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "internalType": "uint256",
+ "name": "value",
+ "type": "uint256"
+ }
+ ],
+ "name": "Deposit",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "internalType": "address",
+ "name": "user",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "internalType": "uint256",
+ "name": "amount",
+ "type": "uint256"
+ }
+ ],
+ "name": "EmergencyWithdraw",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "internalType": "address",
+ "name": "previousOwner",
+ "type": "address"
+ },
+ {
+ "indexed": true,
+ "internalType": "address",
+ "name": "newOwner",
+ "type": "address"
+ }
+ ],
+ "name": "OwnershipTransferred",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": false,
+ "internalType": "address",
+ "name": "newHCCBODReawardPool",
+ "type": "address"
+ }
+ ],
+ "name": "SetHCCBODReawardPoolEvent",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": false,
+ "internalType": "uint256",
+ "name": "newLockTime",
+ "type": "uint256"
+ }
+ ],
+ "name": "SetLockTimeEvent",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": false,
+ "internalType": "uint256",
+ "name": "newMinStakeAmount",
+ "type": "uint256"
+ }
+ ],
+ "name": "SetMinStakeAmontEvent",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "internalType": "address",
+ "name": "user",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "internalType": "uint256",
+ "name": "amount",
+ "type": "uint256"
+ }
+ ],
+ "name": "Withdraw",
+ "type": "event"
+ },
+ {
+ "inputs": [],
+ "name": "HCC",
+ "outputs": [
+ {
+ "internalType": "contract IERC20",
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "HCCBODReawardPool",
+ "outputs": [
+ {
+ "internalType": "address",
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "_poolInfo",
+ "outputs": [
+ {
+ "internalType": "uint256",
+ "name": "accHCCPerShare",
+ "type": "uint256"
+ },
+ {
+ "internalType": "uint256",
+ "name": "totalAmount",
+ "type": "uint256"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "uint256",
+ "name": "_amount",
+ "type": "uint256"
+ },
+ {
+ "internalType": "address",
+ "name": "_userAddress",
+ "type": "address"
+ }
+ ],
+ "name": "deposit",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "emergencyWithdrawHCC",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "lockTime",
+ "outputs": [
+ {
+ "internalType": "uint256",
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "minStakeAmount",
+ "outputs": [
+ {
+ "internalType": "uint256",
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "owner",
+ "outputs": [
+ {
+ "internalType": "address",
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "paused",
+ "outputs": [
+ {
+ "internalType": "bool",
+ "name": "",
+ "type": "bool"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "address",
+ "name": "_user",
+ "type": "address"
+ }
+ ],
+ "name": "pendingHCC",
+ "outputs": [
+ {
+ "internalType": "uint256",
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "renounceOwnership",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "address",
+ "name": "_HCCBODReawardPool",
+ "type": "address"
+ }
+ ],
+ "name": "setHCCBODReawardPool",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "uint256",
+ "name": "_lockTime",
+ "type": "uint256"
+ }
+ ],
+ "name": "setLockTime",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "uint256",
+ "name": "_minStakeAmount",
+ "type": "uint256"
+ }
+ ],
+ "name": "setMinStakeAmount",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "setPause",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "address",
+ "name": "newOwner",
+ "type": "address"
+ }
+ ],
+ "name": "transferOwnership",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "updatePool",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "address",
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "name": "userInfo",
+ "outputs": [
+ {
+ "internalType": "uint256",
+ "name": "amount",
+ "type": "uint256"
+ },
+ {
+ "internalType": "uint256",
+ "name": "rewardDebt",
+ "type": "uint256"
+ },
+ {
+ "internalType": "uint256",
+ "name": "unLockTime",
+ "type": "uint256"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "withdrawHCC",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ }
+]
\ No newline at end of file
diff --git a/src/config/abi/leaderNft.json b/src/config/abi/leaderNft.json
new file mode 100644
index 0000000..558fea0
--- /dev/null
+++ b/src/config/abi/leaderNft.json
@@ -0,0 +1,405 @@
+[
+ {
+ "inputs": [
+ { "internalType": "address", "name": "_hccAddress", "type": "address" },
+ { "internalType": "address", "name": "_otherPaymentAddress", "type": "address" },
+ { "internalType": "uint256", "name": "_hccPirce", "type": "uint256" },
+ { "internalType": "uint256", "name": "_otherPaymentPirce", "type": "uint256" }
+ ],
+ "stateMutability": "nonpayable",
+ "type": "constructor"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ { "indexed": true, "internalType": "address", "name": "owner", "type": "address" },
+ { "indexed": true, "internalType": "address", "name": "approved", "type": "address" },
+ { "indexed": true, "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+ ],
+ "name": "Approval",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ { "indexed": true, "internalType": "address", "name": "owner", "type": "address" },
+ { "indexed": true, "internalType": "address", "name": "operator", "type": "address" },
+ { "indexed": false, "internalType": "bool", "name": "approved", "type": "bool" }
+ ],
+ "name": "ApprovalForAll",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ { "indexed": true, "internalType": "address", "name": "owner", "type": "address" },
+ { "indexed": true, "internalType": "uint256", "name": "id", "type": "uint256" },
+ { "indexed": true, "internalType": "uint256", "name": "code", "type": "uint256" }
+ ],
+ "name": "CreateNft",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [{ "indexed": false, "internalType": "address", "name": "newHccAddress", "type": "address" }],
+ "name": "HccAddressChange",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [{ "indexed": false, "internalType": "uint256", "name": "newHccPrice", "type": "uint256" }],
+ "name": "HccPriceChange",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [{ "indexed": false, "internalType": "address", "name": "newOtherPaymentAddress", "type": "address" }],
+ "name": "OtherPaymentAddressChange",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [{ "indexed": false, "internalType": "uint256", "name": "newOtherPaymentPirce", "type": "uint256" }],
+ "name": "OtherPaymentPirceChange",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
+ { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
+ ],
+ "name": "OwnershipTransferred",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [{ "indexed": false, "internalType": "bool", "name": "pause", "type": "bool" }],
+ "name": "PauseEvent",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ { "indexed": true, "internalType": "address", "name": "from", "type": "address" },
+ { "indexed": true, "internalType": "address", "name": "to", "type": "address" },
+ { "indexed": true, "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+ ],
+ "name": "Transfer",
+ "type": "event"
+ },
+ {
+ "inputs": [],
+ "name": "START_AT",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "_lastTokenID",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "to", "type": "address" },
+ { "internalType": "uint256", "name": "_timestamp", "type": "uint256" },
+ { "internalType": "uint256", "name": "code", "type": "uint256" },
+ { "internalType": "bytes", "name": "_signature", "type": "bytes" }
+ ],
+ "name": "adminMint",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "to", "type": "address" },
+ { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+ ],
+ "name": "approve",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }],
+ "name": "balanceOf",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "baseTokenURI",
+ "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "executorAddress",
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }],
+ "name": "getApproved",
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "hccAddress",
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "hccPirce",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "owner", "type": "address" },
+ { "internalType": "address", "name": "operator", "type": "address" }
+ ],
+ "name": "isApprovedForAll",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ { "inputs": [], "name": "mint", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
+ {
+ "inputs": [],
+ "name": "name",
+ "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "otherPaymentAddress",
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "otherPaymentPirce",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "owner",
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }],
+ "name": "ownerOf",
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }],
+ "name": "rawOwnerOf",
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "from", "type": "address" },
+ { "internalType": "address", "name": "to", "type": "address" },
+ { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+ ],
+ "name": "safeTransferFrom",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "from", "type": "address" },
+ { "internalType": "address", "name": "to", "type": "address" },
+ { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
+ { "internalType": "bytes", "name": "_data", "type": "bytes" }
+ ],
+ "name": "safeTransferFrom",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "operator", "type": "address" },
+ { "internalType": "bool", "name": "approved", "type": "bool" }
+ ],
+ "name": "setApprovalForAll",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "string", "name": "baseURI", "type": "string" }],
+ "name": "setBaseURI",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "address", "name": "executor", "type": "address" }],
+ "name": "setExecutorAddress",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "address", "name": "newHccAddress", "type": "address" }],
+ "name": "setHccAddress",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "uint256", "name": "newHccPirce", "type": "uint256" }],
+ "name": "setHccPirce",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "address", "name": "newOtherPaymentAddress", "type": "address" }],
+ "name": "setOtherPaymentAddress",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "uint256", "name": "newOtherPaymentPirce", "type": "uint256" }],
+ "name": "setOtherPaymentPirce",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "bool", "name": "_pause", "type": "bool" }],
+ "name": "setPause",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "wallet", "type": "address" },
+ { "internalType": "uint256", "name": "code", "type": "uint256" },
+ { "internalType": "uint256", "name": "_timestamp", "type": "uint256" },
+ { "internalType": "bytes", "name": "_signature", "type": "bytes" }
+ ],
+ "name": "signatureWallet",
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+ "stateMutability": "pure",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }],
+ "name": "supportsInterface",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "symbol",
+ "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "uint256", "name": "index", "type": "uint256" }],
+ "name": "tokenByIndex",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "owner", "type": "address" },
+ { "internalType": "uint256", "name": "index", "type": "uint256" }
+ ],
+ "name": "tokenOfOwnerByIndex",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }],
+ "name": "tokenURI",
+ "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "totalSupply",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "totalToken",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "from", "type": "address" },
+ { "internalType": "address", "name": "to", "type": "address" },
+ { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+ ],
+ "name": "transferFrom",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
+ "name": "transferOwnership",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [{ "internalType": "address", "name": "_owner", "type": "address" }],
+ "name": "walletOfOwner",
+ "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "tokenAddress", "type": "address" },
+ { "internalType": "address", "name": "to", "type": "address" },
+ { "internalType": "uint256", "name": "value", "type": "uint256" }
+ ],
+ "name": "withDrawToken",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ }
+]
diff --git a/src/config/constants/boards.ts b/src/config/constants/boards.ts
index 0b545c2..c7d95a7 100644
--- a/src/config/constants/boards.ts
+++ b/src/config/constants/boards.ts
@@ -1,17 +1,19 @@
-import contracts from './contracts'
+import addresses from 'config/constants/contracts'
+import boardChef from 'config/abi/board.json'
import tokens from './tokens'
import { BoardConfig } from './types'
-const BoardList: BoardConfig[] = [
+const bordsList: BoardConfig[] = [
{
pid: 1,
- name: 'Nodes',
+ name: 'Board',
img: 'nodes',
- stringId: 100004,
tokenSymbol: tokens.hcc.symbol,
tokenAddresses: tokens.hcc.address,
tokenDecimals: 18,
+ contractAddress: addresses.boardChef,
+ abi: boardChef,
},
]
-export default BoardList
+export default bordsList
diff --git a/src/config/constants/contracts.ts b/src/config/constants/contracts.ts
index 96866a4..e053bf4 100644
--- a/src/config/constants/contracts.ts
+++ b/src/config/constants/contracts.ts
@@ -8,12 +8,12 @@ export default {
56: '0x6ab8463a4185b80905e05a9ff80a2d6b714b9e95',
},
boardChef: {
- 97: '0x4BC67bBC22a245035fDd1F00DCa7d4F2E1e8f636',
+ 97: '0x0dF74009bF2b85b2B19FC7aF67DD5AAF2cde4Ce0',
56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会合约
},
referralChef: {
- 97: '0x3Dcf2586519a25719658Afb2cDB4CEf0DD647Ea3',
- 56: '0x88F46EF2Ee08494D84942DCA3bd24cDEf7C88Ae2', // NEED CHANGE 邀请合约
+ 97: '0xE79D28722220fcC13833476E327DEA3a663f64DB',
+ 56: '0x88F46EF2Ee08494D84942DCA3bd24cDEf7C88Ae2', // NEED CHANGE 邀请或则军团长
},
lotteryV2: {
97: '0x5790c3534F30437641541a0FA04C992799602998',
diff --git a/src/config/constants/index.ts b/src/config/constants/index.ts
index ef5232e..c5f4b37 100644
--- a/src/config/constants/index.ts
+++ b/src/config/constants/index.ts
@@ -91,3 +91,4 @@ export const BLOCKED_ADDRESSES: string[] = [
export { default as farmsConfig } from './farms'
export { default as poolsConfig } from './pools'
export { default as ifosConfig } from './ifo'
+export { default as boardConfig } from './boards'
diff --git a/src/config/constants/tokens.ts b/src/config/constants/tokens.ts
index 7aafa54..3d95c65 100644
--- a/src/config/constants/tokens.ts
+++ b/src/config/constants/tokens.ts
@@ -60,11 +60,20 @@ export const USDC = new Token(
)
const tokens = {
+ usdt: {
+ symbol: 'USDT',
+ address: {
+ 56: '0x55d398326f99059fF775485246999027B3197955',
+ 97: '0xaC893B498E2005Af4cb8b03D710F187EC23a8f5f',
+ },
+ decimals: 18,
+ projectLink: 'https://tether.to/',
+ },
hcc: {
symbol: 'HCC',
address: {
56: '0x20de22029ab63cf9A7Cf5fEB2b737Ca1eE4c82A6',
- 97: '0x71D239B4564DC00d994AbF6E6cD7582dd873649E',
+ 97: '0xbdd6c43fb8e97a73e464fca5ab6f3d2f402be20c',
},
decimals: 18,
projectLink: 'https://tranchess.com/',
@@ -902,15 +911,7 @@ const tokens = {
decimals: 18,
projectLink: 'https://chain.link/',
},
- usdt: {
- symbol: 'USDT',
- address: {
- 56: '0x55d398326f99059fF775485246999027B3197955',
- 97: '0xE02dF9e3e622DeBdD69fb838bB799E3F168902c5',
- },
- decimals: 18,
- projectLink: 'https://tether.to/',
- },
+
btcb: {
symbol: 'BTCB',
address: {
diff --git a/src/config/constants/types.ts b/src/config/constants/types.ts
index 1eba84d..361c325 100644
--- a/src/config/constants/types.ts
+++ b/src/config/constants/types.ts
@@ -185,4 +185,6 @@ export interface BoardConfig {
tokenSymbol: string
tokenAddresses: Address
tokenDecimals: number
+ contractAddress: Address
+ abi: any
}
diff --git a/src/config/index.ts b/src/config/index.ts
index 169479d..9742734 100644
--- a/src/config/index.ts
+++ b/src/config/index.ts
@@ -27,7 +27,7 @@ export const CAKE_PER_YEAR = CAKE_PER_BLOCK.times(BLOCKS_PER_YEAR)
export const BASE_URL = 'https://pancakeswap.finance'
export const BASE_ADD_LIQUIDITY_URL = `${BASE_URL}/add`
export const BASE_LIQUIDITY_POOL_URL = `${BASE_URL}/pool`
-export const BASE_BSC_SCAN_URL = BASE_BSC_SCAN_URLS[ChainId.MAINNET]
+export const BASE_BSC_SCAN_URL = BASE_BSC_SCAN_URLS[ChainId.TESTNET]
export const LOTTERY_MAX_NUMBER_OF_TICKETS = 50
export const LOTTERY_TICKET_PRICE = 1
export const DEFAULT_TOKEN_DECIMAL = BIG_TEN.pow(18)
diff --git a/src/hooks/useContract.ts b/src/hooks/useContract.ts
index 89affe0..cc77f12 100644
--- a/src/hooks/useContract.ts
+++ b/src/hooks/useContract.ts
@@ -100,9 +100,9 @@ export const useMasterchef = () => {
const { library } = useActiveWeb3React()
return useMemo(() => getMasterchefContract(library.getSigner()), [library])
}
-export const useBoardchef = () => {
+export const useBoardchef = (id: number) => {
const { library } = useActiveWeb3React()
- return useMemo(() => getBoardchefContract(library.getSigner()), [library])
+ return useMemo(() => getBoardchefContract(id, library.getSigner()), [library])
}
export const useReferralchef = () => {
const { library } = useActiveWeb3React()
diff --git a/src/state/boards/fetchBoards.ts b/src/state/boards/fetchBoards.ts
index 4430903..342f48f 100644
--- a/src/state/boards/fetchBoards.ts
+++ b/src/state/boards/fetchBoards.ts
@@ -9,7 +9,7 @@ const fetchBoards = async () => {
const data = await Promise.all(
boardsConfig.map(async (boardConfig) => {
const tokenAddress = getAddress(boardConfig.tokenAddresses)
- const BoardChefAddress = getBoardAddress()
+ const BoardChefAddress = getAddress(boardConfig.contractAddress)
const calls = [
// 查节点的代币数量
{
@@ -26,18 +26,27 @@ const fetchBoards = async () => {
// eslint-disable-next-line prefer-const
let [tokenBalance, tokenDecimals] = await multicall(erc20, calls)
tokenBalance = new BigNumber(tokenBalance).div(new BigNumber(10).pow(tokenDecimals))
- let [minStakeAmount] = await multicall(boardchefABI, [
+ // eslint-disable-next-line prefer-const
+ let [minStakeAmount, lockTime] = await multicall(boardConfig.abi, [
// 最低质押额度
{
address: BoardChefAddress,
- name: 'firstStakeThreshold',
+ name: 'minStakeAmount',
+ },
+ // 最低质押额度
+ {
+ address: BoardChefAddress,
+ name: 'lockTime',
},
])
+ lockTime = new BigNumber(lockTime).toJSON()
+ console.log(lockTime)
minStakeAmount = new BigNumber(minStakeAmount).div(new BigNumber(10).pow(tokenDecimals)).toJSON()
return {
...boardConfig,
tokenBalance: tokenBalance.toJSON(),
minStakeAmount,
+ lockTime,
}
}),
)
diff --git a/src/state/boards/fetchBoardsUser.ts b/src/state/boards/fetchBoardsUser.ts
index ab9f202..932251c 100644
--- a/src/state/boards/fetchBoardsUser.ts
+++ b/src/state/boards/fetchBoardsUser.ts
@@ -4,13 +4,11 @@ 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 contracts from 'config/constants/contracts'
-import tokens from 'config/constants/tokens'
export const fetchBoardUserAllowances = async (account: string) => {
const calls = boardsConfig.map((board) => {
const tokenAddresses = getAddress(board.tokenAddresses)
- const boardChefAdress = getBoardAddress()
+ const boardChefAdress = getAddress(board.contractAddress)
return { address: tokenAddresses, name: 'allowance', params: [account, boardChefAdress] }
})
@@ -38,54 +36,30 @@ export const fetchBoardUserTokenBalances = async (account: string) => {
return parsedTokenBalances
}
-export const fetchBoardUserStakedBalances = async (account: string) => {
- const calls = boardsConfig.map((board) => {
- const boardChefAdress = getBoardAddress()
- return {
- address: boardChefAdress,
- name: 'userInfo',
- params: [account],
- }
- })
+export const fetchBoardUserInfo = async (account: string) => {
+ const data = await Promise.all(
+ boardsConfig.map(async (board) => {
+ const boardChefAdress = getAddress(board.contractAddress)
+ const calls = [
+ {
+ address: boardChefAdress,
+ name: 'userInfo',
+ params: [account],
+ },
+ {
+ address: boardChefAdress,
+ name: 'pendingHCC',
+ params: [account],
+ },
+ ]
+ const [userInfo, estimatedProfit] = await multicall(boardABI, calls)
+ return {
+ stakedBalance: new BigNumber(userInfo.amount._hex).toJSON(),
+ unLockTime: new BigNumber(userInfo.unLockTime._hex).toNumber(),
+ estimatedProfit: new BigNumber(estimatedProfit).toJSON(),
+ }
+ }),
+ )
- const rawStakedBalances = await multicall(boardABI, calls)
- const parsedStakedBalances = rawStakedBalances.map((stakedBalance) => {
- return {
- stakedBalance: new BigNumber(stakedBalance[0]._hex).toJSON(),
- stakedTime: new BigNumber(stakedBalance[1]._hex).toNumber(),
- }
- })
- return parsedStakedBalances
-}
-
-export const fetchBoardUserUnlockTime = async (account: string) => {
- const calls = boardsConfig.map((board) => {
- const boardChefAdress = getBoardAddress()
- return {
- address: boardChefAdress,
- name: 'boardToPeriod',
- }
- })
-
- const rawUnlockTime = await multicall(boardABI, calls)
- const parsedUnlockTime = rawUnlockTime.map((time) => {
- return new BigNumber(time[0]._hex).toNumber()
- })
- return parsedUnlockTime
-}
-
-export const fetchUserXCandyBalance = async (account: string) => {
- const calls = boardsConfig.map((board) => {
- return {
- address: getAddress(tokens.hcc.address),
- name: 'balanceOf',
- params: [account],
- }
- })
-
- const rawXTokenBalance = await multicall(erc20ABI, calls)
- const parsedXTokenBalance = rawXTokenBalance.map((item) => {
- return new BigNumber(item[0]._hex).toJSON()
- })
- return parsedXTokenBalance
+ return data
}
diff --git a/src/state/boards/index.ts b/src/state/boards/index.ts
index e2404b9..a0e9936 100644
--- a/src/state/boards/index.ts
+++ b/src/state/boards/index.ts
@@ -3,13 +3,7 @@ import { createSlice } from '@reduxjs/toolkit'
import BigNumber from 'bignumber.js'
import boardsConfig from 'config/constants/boards'
import fetchBoards from './fetchBoards'
-import {
- fetchBoardUserAllowances,
- fetchBoardUserTokenBalances,
- fetchBoardUserStakedBalances,
- fetchBoardUserUnlockTime,
- fetchUserXCandyBalance,
-} from './fetchBoardsUser'
+import { fetchBoardUserAllowances, fetchBoardUserTokenBalances, fetchBoardUserInfo } from './fetchBoardsUser'
import { BoardsState, Boards } from '../types'
const initialState: BoardsState = { data: [...boardsConfig] }
@@ -46,17 +40,15 @@ export const fetchBoardsPublicDataAsync = () => async (dispatch) => {
export const fetchBoardUserDataAsync = (account) => async (dispatch) => {
const userBoardAllowances = await fetchBoardUserAllowances(account)
const userBoardTokenBalances = await fetchBoardUserTokenBalances(account)
- const userStakedBalances = await fetchBoardUserStakedBalances(account)
- const userUnlockTimes = await fetchBoardUserUnlockTime(account)
- const userXCandyBalances = await fetchUserXCandyBalance(account)
+ const userInfo = await fetchBoardUserInfo(account)
const arrayOfUserDataObjects = userBoardAllowances.map((nodeAllowance, index) => {
return {
index,
allowance: userBoardAllowances[index],
tokenBalance: userBoardTokenBalances[index],
- stakedBalance: userStakedBalances[index].stakedBalance,
- xCandyBalance: userXCandyBalances[index],
- unlockTime: userUnlockTimes[index] + userStakedBalances[index].stakedTime,
+ stakedBalance: userInfo[index].stakedBalance,
+ unlockTime: userInfo[index].unLockTime,
+ estimatedProfit: userInfo[index].estimatedProfit,
}
})
diff --git a/src/state/hooks.ts b/src/state/hooks.ts
index fdb8c23..7a34d04 100644
--- a/src/state/hooks.ts
+++ b/src/state/hooks.ts
@@ -217,7 +217,7 @@ export const useBoardUser = (pid) => {
tokenBalance: board.userData ? new BigNumber(board.userData.tokenBalance) : new BigNumber(0),
stakedBalance: board.userData ? new BigNumber(board.userData.stakedBalance) : new BigNumber(0),
unlockTime: board.userData ? board.userData.unlockTime : 0,
- xCandyBalance: board.userData ? board.userData.xCandyBalance : 0,
+ estimatedProfit: board.userData ? board.userData.estimatedProfit : 0,
}
}
// cake
diff --git a/src/state/types.ts b/src/state/types.ts
index 0a870a6..5127c32 100644
--- a/src/state/types.ts
+++ b/src/state/types.ts
@@ -516,7 +516,7 @@ export interface Boards extends BoardConfig {
tokenBalance: BigNumber
stakedBalance: BigNumber
unlockTime: number
- xCandyBalance: number
+ estimatedProfit: number
}
}
export interface BoardsState {
diff --git a/src/utils/calls/boards.ts b/src/utils/calls/boards.ts
new file mode 100644
index 0000000..6f67bdc
--- /dev/null
+++ b/src/utils/calls/boards.ts
@@ -0,0 +1,27 @@
+import BigNumber from 'bignumber.js'
+import { DEFAULT_GAS_LIMIT, DEFAULT_TOKEN_DECIMAL } from 'config'
+
+const options = {
+ gasLimit: DEFAULT_GAS_LIMIT,
+}
+
+export const stakeBoard = async (masterChefContract, pid, amount) => {
+ const value = new BigNumber(amount).times(DEFAULT_TOKEN_DECIMAL).toString()
+
+ const tx = await masterChefContract.deposit(pid, value, options)
+ const receipt = await tx.wait()
+ return receipt.status
+}
+
+export const unstakeBoard = async (masterChefContract, pid, amount) => {
+ const value = new BigNumber(amount).times(DEFAULT_TOKEN_DECIMAL).toString()
+ const tx = await masterChefContract.withdrawHCC(pid, value, options)
+ const receipt = await tx.wait()
+ return receipt.status
+}
+
+export const harvestBoard = async (masterChefContract, pid) => {
+ const tx = await masterChefContract.harvest(pid, '0', options)
+ const receipt = await tx.wait()
+ return receipt.status
+}
diff --git a/src/utils/calls/index.ts b/src/utils/calls/index.ts
index 080309c..598cc10 100644
--- a/src/utils/calls/index.ts
+++ b/src/utils/calls/index.ts
@@ -1,3 +1,4 @@
export * from './estimateGas'
export * from './farms'
export * from './pools'
+export * from './boards'
diff --git a/src/utils/contractHelpers.ts b/src/utils/contractHelpers.ts
index da53ff5..3610ce1 100644
--- a/src/utils/contractHelpers.ts
+++ b/src/utils/contractHelpers.ts
@@ -1,6 +1,6 @@
import { ethers } from 'ethers'
import { simpleRpcProvider } from 'utils/providers'
-import { poolsConfig } from 'config/constants'
+import { poolsConfig, boardConfig } from 'config/constants'
import { PoolCategory } from 'config/constants/types'
// Addresses
@@ -115,8 +115,9 @@ export const getLotteryV2Contract = (signer?: ethers.Signer | ethers.providers.P
export const getMasterchefContract = (signer?: ethers.Signer | ethers.providers.Provider) => {
return getContract(masterChef, getMasterChefAddress(), signer)
}
-export const getBoardchefContract = (signer?: ethers.Signer | ethers.providers.Provider) => {
- return getContract(boardChef, getBoardAddress(), signer)
+export const getBoardchefContract = (id: number, signer?: ethers.Signer | ethers.providers.Provider) => {
+ const config = boardConfig.find((board) => board.pid === id)
+ return getContract(config.abi, getAddress(config.contractAddress), signer)
}
export const getReferralchefContract = (signer?: ethers.Signer | ethers.providers.Provider) => {
return getContract(referralChef, getReferralAddress(), signer)
diff --git a/src/views/Board/components/BoardCard/BoardCard.tsx b/src/views/Board/components/BoardCard/BoardCard.tsx
index ee5949f..ff2e6ed 100644
--- a/src/views/Board/components/BoardCard/BoardCard.tsx
+++ b/src/views/Board/components/BoardCard/BoardCard.tsx
@@ -88,10 +88,9 @@ const NodeCard: React.FC = ({ board, account }) => {
return (
- {/* {true && } */}
-
-
+
+ {/*
setShowExpandableSection(!showExpandableSection)}
expanded={showExpandableSection}
@@ -101,7 +100,7 @@ const NodeCard: React.FC = ({ board, account }) => {
bscScanAddress={`${process.env.REACT_APP_NETWORK_URL}/address/${getBoardAddress()}`}
totalValueFormated={board.tokenBalance || '-'}
/>
-
+ */}
)
}
diff --git a/src/views/Board/components/BoardCard/CardActionsContainer.tsx b/src/views/Board/components/BoardCard/CardActionsContainer.tsx
index eb4a0b4..f81bc7d 100644
--- a/src/views/Board/components/BoardCard/CardActionsContainer.tsx
+++ b/src/views/Board/components/BoardCard/CardActionsContainer.tsx
@@ -19,20 +19,20 @@ const Action = styled.div`
`
interface NodeCardActionsProps {
- node: Boards
+ board: Boards
provider?: ProviderType
account?: string
}
-const CardActions: React.FC = ({ node, account }) => {
+const CardActions: React.FC = ({ board, account }) => {
const { t } = useTranslation()
const [requestedApproval, setRequestedApproval] = useState(false)
- const pid = node.pid
- const { allowance, tokenBalance, stakedBalance, xCandyBalance } = useBoardUser(pid)
+ const pid = board.pid
+ const { allowance, tokenBalance, stakedBalance, estimatedProfit } = useBoardUser(pid)
const isApproved = account && allowance && allowance.isGreaterThan(0)
- const tokenContract = useERC20(getAddress(node.tokenAddresses))
+ const tokenContract = useERC20(getAddress(board.tokenAddresses))
- const { onApprove } = useApproveBoard(tokenContract)
+ const { onApprove } = useApproveBoard(tokenContract, pid)
const handleApprove = useCallback(async () => {
try {
@@ -50,15 +50,12 @@ const CardActions: React.FC = ({ node, account }) => {
-
- {TOKEN_SYMBOL}
-
- {t('Amount')}
+ {t('TotalProfit')}
- {getBalanceNumber(new BigNumber(xCandyBalance))}
+ {getBalanceNumber(new BigNumber(estimatedProfit))}
>
@@ -73,7 +70,7 @@ const CardActions: React.FC = ({ node, account }) => {
- {node.tokenSymbol}
+ {board.tokenSymbol}
{t('Staked')}
diff --git a/src/views/Board/components/BoardCard/CardHeading.tsx b/src/views/Board/components/BoardCard/CardHeading.tsx
index 3494372..a09d1eb 100644
--- a/src/views/Board/components/BoardCard/CardHeading.tsx
+++ b/src/views/Board/components/BoardCard/CardHeading.tsx
@@ -24,7 +24,7 @@ const CardHeading: React.FC = ({ name, img, tokenSymbol
{name}
-
+ {/* */}
)
diff --git a/src/views/Board/components/BoardCard/DetailsSection.tsx b/src/views/Board/components/BoardCard/DetailsSection.tsx
index 808848f..a908098 100644
--- a/src/views/Board/components/BoardCard/DetailsSection.tsx
+++ b/src/views/Board/components/BoardCard/DetailsSection.tsx
@@ -40,7 +40,7 @@ const DetailsSection: React.FC = ({ bscScanAddress, remo
{/* )} */}
- {t( 'View on BscScan')}
+ {t('View on BscScan')}
diff --git a/src/views/Board/components/BoardCard/StakeAction.tsx b/src/views/Board/components/BoardCard/StakeAction.tsx
index 4558aa6..82f1e6a 100644
--- a/src/views/Board/components/BoardCard/StakeAction.tsx
+++ b/src/views/Board/components/BoardCard/StakeAction.tsx
@@ -1,10 +1,8 @@
import React, { useMemo } from 'react'
-// import dayjs from 'dayjs'
+import dayjs from 'dayjs'
import styled from 'styled-components'
import BigNumber from 'bignumber.js'
import { Button, Flex, Heading, IconButton, AddIcon, MinusIcon, useModal } from '@pancakeswap/uikit'
-
-// import { NODE_UNLOCK_TIME } from 'config/index'
import { getBalanceNumber } from 'utils/formatBalance'
import { useBoardsFromPid } from 'state/hooks'
import { useTranslation } from 'contexts/Localization'
@@ -52,20 +50,11 @@ const StakeAction: React.FC = ({ stakedBalance, tokenBalan
,
)
const handleUnstake = () => {
- // const unstakeDay = new Date().getDay()
- // const unlockTime = userData.unlockTime * 1000
- // // 只能周五解锁 NEED CHANGE
- // if (unstakeDay !== NODE_UNLOCK_TIME || unlockTime > new Date().getTime()) {
- // toastWarning(
- // TranslateString(101012, 'Unlock time'),
- // `${dayjs(unlockTime).format('YYYY-MM-DD HH:mm')} Next Friday`, // NEED CHANGE
- // )
- // return
- // }
- // if (new BigNumber(userData.stakedBalance).toJSON() !== new BigNumber(userData.xCandyBalance).toJSON()) {
- // toastWarning(TranslateString(100103, 'Hint'), TranslateString(101019, 'Unlocking conditions are not met'))
- // return
- // }
+ const unlockTime = userData.unlockTime * 1000
+ if (unlockTime > new Date().getTime()) {
+ toastWarning(t('Unlock time %unlockTime%', { unlockTime: dayjs(unlockTime).format('YYYY-MM-DD HH:mm') }))
+ // return
+ }
// onUnstake()
}
const renderStakingButtons = () => {
diff --git a/src/views/Board/hooks/useApproveBoard.ts b/src/views/Board/hooks/useApproveBoard.ts
index d5f5a8e..ea143d4 100644
--- a/src/views/Board/hooks/useApproveBoard.ts
+++ b/src/views/Board/hooks/useApproveBoard.ts
@@ -2,8 +2,8 @@ import { useCallback } from 'react'
import { ethers, Contract } from 'ethers'
import { useBoardchef } from 'hooks/useContract'
-const useApproveBoard = (lpContract: Contract) => {
- const boardChefContract = useBoardchef()
+const useApproveBoard = (lpContract: Contract, pid) => {
+ const boardChefContract = useBoardchef(pid)
const handleApprove = useCallback(async () => {
try {
const tx = await lpContract.approve(boardChefContract.address, ethers.constants.MaxUint256)
diff --git a/src/views/Board/hooks/useHarvestBoard.ts b/src/views/Board/hooks/useHarvestBoard.ts
index f0908ff..5c003fe 100644
--- a/src/views/Board/hooks/useHarvestBoard.ts
+++ b/src/views/Board/hooks/useHarvestBoard.ts
@@ -1,12 +1,12 @@
import { useCallback } from 'react'
-import { harvestFarm } from 'utils/calls'
+import { harvestBoard } from 'utils/calls'
import { useBoardchef } from 'hooks/useContract'
const useHarvestBoard = (boardPid: number) => {
- const boardChefContract = useBoardchef()
+ const boardChefContract = useBoardchef(boardPid)
const handleHarvest = useCallback(async () => {
- await harvestFarm(boardChefContract, boardPid)
+ await harvestBoard(boardChefContract, boardPid)
}, [boardPid, boardChefContract])
return { onReward: handleHarvest }
diff --git a/src/views/Board/hooks/useStakeBoard.ts b/src/views/Board/hooks/useStakeBoard.ts
index 58e3ed5..ad5cd81 100644
--- a/src/views/Board/hooks/useStakeBoard.ts
+++ b/src/views/Board/hooks/useStakeBoard.ts
@@ -1,13 +1,13 @@
import { useCallback } from 'react'
-import { stakeFarm } from 'utils/calls'
+import { stakeBoard } from 'utils/calls'
import { useBoardchef } from 'hooks/useContract'
const useStakeBoard = (pid: number) => {
- const boardChefContract = useBoardchef()
+ const boardChefContract = useBoardchef(pid)
const handleStake = useCallback(
async (amount: string) => {
- const txHash = await stakeFarm(boardChefContract, pid, amount)
+ const txHash = await stakeBoard(boardChefContract, pid, amount)
console.info(txHash)
},
[boardChefContract, pid],
diff --git a/src/views/Board/hooks/useUnstakeBoard.ts b/src/views/Board/hooks/useUnstakeBoard.ts
index 6e2f2b2..bdcd099 100644
--- a/src/views/Board/hooks/useUnstakeBoard.ts
+++ b/src/views/Board/hooks/useUnstakeBoard.ts
@@ -1,13 +1,13 @@
import { useCallback } from 'react'
-import { unstakeFarm } from 'utils/calls'
+import { unstakeBoard } from 'utils/calls'
import { useBoardchef } from 'hooks/useContract'
const useUnstakeBoard = (pid: number) => {
- const boardChefContract = useBoardchef()
+ const boardChefContract = useBoardchef(pid)
const handleUnstake = useCallback(
async (amount: string) => {
- await unstakeFarm(boardChefContract, pid, amount)
+ await unstakeBoard(boardChefContract, pid, amount)
},
[boardChefContract, pid],
)
diff --git a/yarn.lock b/yarn.lock
index e6d4d22..6f0cca4 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7638,6 +7638,11 @@ date-fns@^2.0.1, date-fns@^2.21.3:
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.22.1.tgz#1e5af959831ebb1d82992bf67b765052d8f0efc4"
integrity sha512-yUFPQjrxEmIsMqlHhAhmxkuH769baF21Kk+nZwZGyrMoyLA+LugaQtC0+Tqf9CBUUULWwUJt6Q5ySI3LJDDCGg==
+dayjs@^1.11.1:
+ version "1.11.1"
+ resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.11.1.tgz#90b33a3dda3417258d48ad2771b415def6545eb0"
+ integrity sha512-ER7EjqVAMkRRsxNCC5YqJ9d9VQYuWdGt7aiH2qA5R5wt8ZmWaP2dLUSIK6y/kVzLMlmh1Tvu5xUf4M/wdGJ5KA==
+
debug-fabulous@0.0.X:
version "0.0.4"
resolved "https://registry.yarnpkg.com/debug-fabulous/-/debug-fabulous-0.0.4.tgz#fa071c5d87484685424807421ca4b16b0b1a0763"