Skip to content

Commit

Permalink
Updated Mowable Grown Stalk calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
uncoolzero committed Oct 3, 2023
1 parent fadb478 commit 8be1fa2
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions projects/ui/src/components/Silo/Actions/Deposits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ const Deposits: FC<
const account = useWagmiAccount();
const newToken = sdk.tokens.findBySymbol(token.symbol) as ERC20Token;

const seeds = transform(newToken.rewards?.seeds.toBlockchain() || "0", 'ethers', sdk.tokens.SEEDS);
const stemTip = useStemTipForToken(newToken);
const lastStem = stemTip ? stemTip.sub(siloBalance?.mowStatus.lastStem || Number(0)) : Number(0);
const mowableStalk = transform(((stemTip?.sub(lastStem) || BigNumber.from(0)).mul(seeds)), 'bnjs', sdk.tokens.STALK);
const stemTip = useStemTipForToken(newToken) || BigNumber.from(0);
const lastStem = siloBalance?.mowStatus.lastStem || BigNumber.from(0);
const deltaStem = stemTip?.sub(lastStem) || BigNumber.from(0);

const rows: (LegacyDepositCrate & { id: string })[] = useMemo(
() =>
Expand Down Expand Up @@ -139,25 +138,18 @@ const Deposits: FC<
placement="bottom"
title={
<Stack gap={0.5}>
<StatHorizontal label="Mowable Grown Stalk">
{displayFullBN(mowableStalk, 2, 2)}
</StatHorizontal>
<StatHorizontal label="Mowed Grown Stalk">
{displayFullBN(params.row.stalk.grown.minus(mowableStalk), 2, 2)}
{displayBN(params.row.stalk.grown.minus(transform(sdk.tokens.STALK.fromBlockchain(transform(params.row.bdv, 'tokenValue', sdk.tokens.BEAN).toBigNumber().mul(deltaStem)), 'bnjs')))}
</StatHorizontal>
</Stack>
}
>
<span>
<Typography display={{ xs: 'none', md: 'block' }}>
{displayFullBN(
params.row.stalk.grown,
STALK.displayDecimals,
STALK.displayDecimals
)}
{displayBN(transform(sdk.tokens.STALK.fromBlockchain(transform(params.row.bdv, 'tokenValue', sdk.tokens.BEAN).toBigNumber().mul(deltaStem)), 'bnjs'))}
</Typography>
<Typography display={{ xs: 'block', md: 'none' }}>
{displayBN(params.row.stalk.grown)}
{displayBN(transform(sdk.tokens.STALK.fromBlockchain(transform(params.row.bdv, 'tokenValue', sdk.tokens.BEAN).toBigNumber().mul(deltaStem)), 'bnjs'))}
</Typography>
</span>
</Tooltip>
Expand All @@ -166,7 +158,7 @@ const Deposits: FC<
},
COLUMNS.seeds,
] as GridColumns,
[mowableStalk, token]
[deltaStem, sdk.tokens.BEAN, sdk.tokens.STALK, token]
);

const amount = siloBalance?.deposited.amount;
Expand Down

0 comments on commit 8be1fa2

Please sign in to comment.