diff --git a/src/config/abi/referral.json b/src/config/abi/referral.json index 558fea0..9faa686 100644 --- a/src/config/abi/referral.json +++ b/src/config/abi/referral.json @@ -2,9 +2,7 @@ { "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" } + { "internalType": "address", "name": "_otherPaymentAddress", "type": "address" } ], "stateMutability": "nonpayable", "type": "constructor" @@ -159,13 +157,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [], - "name": "hccPirce", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { "internalType": "address", "name": "owner", "type": "address" }, @@ -176,7 +167,20 @@ "stateMutability": "view", "type": "function" }, - { "inputs": [], "name": "mint", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "hccPirce", "type": "uint256" }, + { "internalType": "uint256", "name": "otherPaymentPirce", "type": "uint256" }, + { "internalType": "uint256", "name": "_timestamp", "type": "uint256" }, + { "internalType": "uint256", "name": "code", "type": "uint256" }, + { "internalType": "bytes", "name": "_signature", "type": "bytes" } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "name", @@ -191,13 +195,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [], - "name": "otherPaymentPirce", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, { "inputs": [], "name": "owner", @@ -274,13 +271,6 @@ "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", @@ -288,13 +278,6 @@ "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", @@ -302,6 +285,20 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "hccPirce", "type": "uint256" }, + { "internalType": "uint256", "name": "otherPaymentPirce", "type": "uint256" }, + { "internalType": "uint256", "name": "_timestamp", "type": "uint256" }, + { "internalType": "uint256", "name": "code", "type": "uint256" }, + { "internalType": "bytes", "name": "_signature", "type": "bytes" } + ], + "name": "signatureMint", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "pure", + "type": "function" + }, { "inputs": [ { "internalType": "address", "name": "wallet", "type": "address" }, diff --git a/src/config/constants/contracts.ts b/src/config/constants/contracts.ts index e211527..ded3014 100644 --- a/src/config/constants/contracts.ts +++ b/src/config/constants/contracts.ts @@ -8,19 +8,19 @@ export default { 56: '0x6ab8463a4185b80905e05a9ff80a2d6b714b9e95', }, boardChef: { - 97: '0x38bafe75a90bc310b8b5058be3ba6511c3bc215b', + 97: '0x7e64aac0806597cb2efddf7c001e59d6b4e9cb15', 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 节点董事会合约 }, holderChef: { - 97: '0x0584becc972bb2171502a2b54e9f52656b707d35', + 97: '0x4cbbb9e9569a208c9975574675ba24eccea342b3', 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 持币人 }, referralChef: { - 97: '0x2f2aec0ee0da9f81e28e78a072cfbea6f35b1e06', + 97: '0x86a510e82aceb27ed9e9880fb981d4b42ff16cb4', 56: '0x88F46EF2Ee08494D84942DCA3bd24cDEf7C88Ae2', // NEED CHANGE 邀请或则军团长 }, referralRewardChef: { - 97: '0xe031cf7053ea3b7605bb289efe2307356f6ace6d', + 97: '0x86a510e82aceb27ed9e9880fb981d4b42ff16cb4', 56: '0x88F46EF2Ee08494D84942DCA3bd24cDEf7C88Ae2', // NEED CHANGE 邀请或则军团长收益 }, lotteryV2: { diff --git a/src/services/referral.ts b/src/services/referral.ts index 1367736..b202817 100644 --- a/src/services/referral.ts +++ b/src/services/referral.ts @@ -13,6 +13,13 @@ export const withdrawReward = () => { method: 'get', }) } +export const checkWithdrawResult = (params) => { + return request.request({ + url: '/high_city/app/api/invite/commander/tx', + method: 'post', + params, + }) +} export const inviteReceive = () => { return request.request({ diff --git a/src/state/boards/fetchBoardsUser.ts b/src/state/boards/fetchBoardsUser.ts index d7a039b..ed2b299 100644 --- a/src/state/boards/fetchBoardsUser.ts +++ b/src/state/boards/fetchBoardsUser.ts @@ -8,8 +8,8 @@ import { getAddress, getBoardAddress } from 'utils/addressHelpers' export const fetchBoardUserAllowances = async (account: string) => { const calls = boardsConfig.map((board) => { const tokenAddresses = getAddress(board.tokenAddresses) - const boardChefAdress = getAddress(board.contractAddress) - return { address: tokenAddresses, name: 'allowance', params: [account, boardChefAdress] } + const boardChefAddress = getAddress(board.contractAddress) + return { address: tokenAddresses, name: 'allowance', params: [account, boardChefAddress] } }) const rawLpAllowances = await multicall(erc20ABI, calls) @@ -53,7 +53,6 @@ export const fetchBoardUserInfo = async (account: string) => { }, ] const [userInfo, estimatedProfit] = await multicall(board.abi, calls) - console.log(estimatedProfit) return { stakedBalance: new BigNumber(userInfo.amount._hex).toJSON(), unLockTime: userInfo.unLockTime ? new BigNumber(userInfo.unLockTime._hex).toNumber() : 0, diff --git a/src/state/referral/index.ts b/src/state/referral/index.ts index b2c1433..181d1c8 100644 --- a/src/state/referral/index.ts +++ b/src/state/referral/index.ts @@ -1,6 +1,11 @@ import { createSlice } from '@reduxjs/toolkit' import { getReferralInfo } from 'services/referral' import { ReferralInfo, ReferralConfigType } from 'types/referral' +import BigNumber from 'bignumber.js' +import erc20ABI from 'config/abi/erc20.json' +import multicall from 'utils/multicall' +import tokens from 'config/constants/tokens' +import { getAddress, getReferralAddress } from 'utils/addressHelpers' import { ReferralState } from '../types' const initialState: ReferralState = { @@ -9,6 +14,11 @@ const initialState: ReferralState = { isCommander: false, rewardInfo: {}, } +const payWayList = { + usdt: tokens.usdt, + // bnb: tokens.bnb, + hcc: tokens.hcc, +} export const referralSlice = createSlice({ name: 'Referral', initialState, @@ -41,4 +51,18 @@ export const fetchReferralInfoAsync = (account) => async (dispatch) => { ) } +export const fetchReferralUserAllowances = async (account: string) => { + const calls = Object.values(payWayList).map((payWayItem) => { + const tokenAddresses = getAddress(payWayItem.address) + const referralChefAddress = getReferralAddress() + return { address: tokenAddresses, name: 'allowance', params: [account, referralChefAddress] } + }) + + const rawLpAllowances = await multicall(erc20ABI, calls) + const parsedLpAllowances = rawLpAllowances.map((balance) => { + return new BigNumber(balance).toNumber() + }) + return parsedLpAllowances +} + export default referralSlice.reducer diff --git a/src/views/Referral/hooks/index.ts b/src/views/Referral/hooks/index.ts index 42e7d4d..d769b6d 100644 --- a/src/views/Referral/hooks/index.ts +++ b/src/views/Referral/hooks/index.ts @@ -30,10 +30,9 @@ export const useBuyTransaction = () => { const referralContract = useReferralchef() const transaction = async () => { const data = await withdrawReward() - const { to, amount, code, signature } = data - console.log(data) - const params = [to, amount, code, signature] - const price = getDecimalAmountNumber(amount) + const { address, receive, timestamp, sign } = data + const params = [address, receive, timestamp, sign] + const price = getDecimalAmountNumber(receive) const res = await referralContract.adminMint(...params, { value: price }) return res } @@ -44,10 +43,9 @@ export const useWithdraw = () => { const referralRewardContract = useReferralRewardchef() const transaction = async () => { const data = await withdrawReward() - const { to, amount, expiredTime, signature } = data - console.log(data) - const params = [to, amount, expiredTime, signature] - const price = getDecimalAmountNumber(amount) + const { address, receive, timestamp, sign } = data + const params = [address, receive, timestamp, sign] + const price = getDecimalAmountNumber(receive) const res = await referralRewardContract.withDrawReward(...params, { value: price }) return res }