diff --git a/.env b/.env index 27bc1169..ebfafabd 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -NEXT_PUBLIC_ALCHEMY_API_URL=https://mainnet.infura.io/v3/ +NEXT_PUBLIC_ALCHEMY_API_URL=https://mainnet.infura.io/v3/267d7afc40074cb393caa41e83578f9d diff --git a/src/hooks/distribution/useDistributionInfo.ts b/src/hooks/distribution/useDistributionInfo.ts index d9c33b42..718bde8f 100644 --- a/src/hooks/distribution/useDistributionInfo.ts +++ b/src/hooks/distribution/useDistributionInfo.ts @@ -13,11 +13,10 @@ type DistributionInfo = { dateEnded: BigNumber lastClaim: BigNumber amountOwedTotal: BigNumber - claimable: BigNumber curve: BigNumber } -const useDistribtuionInfo = (): DistributionInfo => { +const useDistributionInfo = (): DistributionInfo => { const { library, account, chainId } = useWeb3React() const distribution = useContract('BaoDistribution') @@ -26,9 +25,8 @@ const useDistribtuionInfo = (): DistributionInfo => { ['@/hooks/vebao/useAccountDistribution', providerKey(library, account, chainId)], async () => { const { dateStarted, dateEnded, lastClaim, amountOwedTotal } = await distribution.distributions(account) - const claimable = await distribution.claimable(account, 0) - const block = await library.getBlock() const timeStarted = dateStarted.mul(1000).toNumber() + const block = await library.getBlock() const timeNow = block.timestamp * 1000 const daysDiff = Math.floor((timeNow - timeStarted) / 86400000) const curve = await distribution.distCurve(amountOwedTotal, exponentiate(BigNumber.from(daysDiff))) @@ -38,7 +36,6 @@ const useDistribtuionInfo = (): DistributionInfo => { dateEnded, lastClaim, amountOwedTotal, - claimable, curve, } }, @@ -49,7 +46,6 @@ const useDistribtuionInfo = (): DistributionInfo => { dateEnded: BigNumber.from(0), lastClaim: BigNumber.from(0), amountOwedTotal: BigNumber.from(0), - claimable: BigNumber.from(0), curve: BigNumber.from(0), }, }, @@ -64,4 +60,4 @@ const useDistribtuionInfo = (): DistributionInfo => { return distributionInfo } -export default useDistribtuionInfo +export default useDistributionInfo diff --git a/src/pages/distribution/components/Claim.tsx b/src/pages/distribution/components/Claim.tsx index 2e7e03be..15a05c2f 100644 --- a/src/pages/distribution/components/Claim.tsx +++ b/src/pages/distribution/components/Claim.tsx @@ -6,6 +6,7 @@ import useTransactionHandler from '@/hooks/base/useTransactionHandler' import { BaoDistribution } from '@/typechain/BaoDistribution' //import { useWeb3React } from '@web3-react/core' import useDistributionInfo from '@/hooks/distribution/useDistributionInfo' +import useClaimable from '@/hooks/distribution/useClaimable' import { getDisplayBalance } from '@/utils/numberFormat' import { BigNumber } from 'ethers' import { formatUnits } from 'ethers/lib/utils' @@ -18,6 +19,7 @@ const Migration: React.FC = () => { const { handleTx } = useTransactionHandler() const distribution = useContract('BaoDistribution') const distributionInfo = useDistributionInfo() + const claimable = useClaimable() let lastClaim = 'Never' if (distributionInfo && !distributionInfo.dateStarted.eq(distributionInfo.lastClaim)) { @@ -78,7 +80,7 @@ const Migration: React.FC = () => {
BAO - {getDisplayBalance(distributionInfo.claimable || BigNumber.from(0))} + {getDisplayBalance(BigNumber.isBigNumber(claimable) ? claimable : BigNumber.from(0))}
@@ -98,11 +100,11 @@ const Migration: React.FC = () => {
) : (