Skip to content

Commit

Permalink
feat: add hasPendingRewards property to the context
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermendes committed Nov 11, 2024
1 parent e193b89 commit b908cc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type StakingContextType = {
totalApr: number;
isPaused: boolean;
stakedPct: number;
hasPendingRewards: boolean;
syncConnectedAccount: () => void;
syncAllowance: () => void;
approveAndSync: () => void;
Expand Down
7 changes: 7 additions & 0 deletions src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'react';
import { BigNumber, ethers } from 'ethers';
import { useAccount, useChainId, useSwitchChain } from 'wagmi';
import { parseFixed } from '@ethersproject/bignumber';
import {
approveStaking,
calculateAprs,
Expand Down Expand Up @@ -480,6 +481,10 @@ export const StakingProvider = ({
await syncConnectedAccount();
}, [chainId, networkConfig, switchChain, syncConnectedAccount, web3Provider]);

const hasPendingRewards = streams.some(({ amount, decimals }) =>
amount?.gt(parseFixed('0.0001', decimals)),
);

const value = useMemo(
() => ({
accountSynced,
Expand All @@ -499,6 +504,7 @@ export const StakingProvider = ({
totalApr,
isPaused,
stakedPct,
hasPendingRewards,
syncConnectedAccount,
syncAllowance,
approveAndSync,
Expand Down Expand Up @@ -538,6 +544,7 @@ export const StakingProvider = ({
withdrawAllAndSync,
withdrawAndSync,
withdrawableVoteBalance,
hasPendingRewards,
],
);

Expand Down

0 comments on commit b908cc3

Please sign in to comment.