Skip to content

Commit

Permalink
Add Total Stalk Grown display
Browse files Browse the repository at this point in the history
  • Loading branch information
uncoolzero committed Nov 15, 2023
1 parent 1e37993 commit 63e6e4c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions projects/ui/src/components/Silo/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
displayPercentage,
displayStalk,
displayUSD,
STALK_PER_SEED_PER_SEASON,
} from '~/util';
import { ChipLabel, StyledTab } from '~/components/Common/Tabs';
import { ZERO_BN } from '~/constants';
Expand All @@ -27,6 +26,7 @@ import useMigrationNeeded from '~/hooks/farmer/useMigrationNeeded';
import stalkIconWinter from '~/img/beanstalk/stalk-icon-green.svg';
import seedIconWinter from '~/img/beanstalk/seed-icon-green.svg';
import { MigrateTab } from '~/components/Silo/MigrateTab';
import useFarmerSiloBalances from '~/hooks/farmer/useFarmerSiloBalances';

const depositStats = (s: BigNumber, v: BigNumber[], d: string) => (
<Stat
Expand Down Expand Up @@ -76,6 +76,7 @@ const Overview: FC<{
const account = useAccount();
const { data, loading } = useFarmerSiloHistory(account, false, true);
const migrationNeeded = useMigrationNeeded();
const siloBalance = useFarmerSiloBalances();
//
const [tab, handleChange] = useTabs(migrationNeeded ? SLUGS : altSLUGS, 'view');

Expand All @@ -85,6 +86,14 @@ const Overview: FC<{
? farmerSilo.stalk.active.div(beanstalkSilo.stalk.total)
: ZERO_BN;

const deposits = Object.values(siloBalance).map(token => token.deposited.crates).flat(Infinity)

let totalStalkGrown = farmerSilo.stalk.grown;

deposits.forEach((deposit: any) => {
totalStalkGrown = totalStalkGrown.plus(deposit.stalk.grown)
})

const stalkStats = useCallback(
(s: BigNumber, v: BigNumber[], d: string) => (
<>
Expand All @@ -107,18 +116,18 @@ const Overview: FC<{
sx={{ minWidth: 200, ml: 0 }}
/>
<Stat
title="Grown Stalk per Day"
title="Total Stalk Grown"
titleTooltip="The number of Stalk your Seeds will grow every 24 Seasons based on your current Seed balance."
amount={displayStalk(
farmerSilo.seeds.active.times(STALK_PER_SEED_PER_SEASON).times(24)
totalStalkGrown
)}
color="text.primary"
gap={0.25}
sx={{ minWidth: 120, ml: 0 }}
/>
</>
),
[farmerSilo, ownership]
[ownership, totalStalkGrown]
);

return (
Expand Down

0 comments on commit 63e6e4c

Please sign in to comment.