Skip to content

Commit

Permalink
Merge pull request #1653 from QuickSwap/hotfix/ui-issues-farms
Browse files Browse the repository at this point in the history
Hotfix/UI issues farms
  • Loading branch information
sameepsi authored Jan 17, 2025
2 parents 0bb8ea5 + 6c6fb94 commit 0302a00
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
32 changes: 25 additions & 7 deletions src/hooks/v3/useV3Farms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,13 @@ export const useGetMerklFarms = () => {
item.mainParameter.toLowerCase() ===
address.toLocaleLowerCase(),
) && amms.includes(item.ammName.toLocaleLowerCase()),
) as any[];
)
.map((item: any) => {
return {
...item,
symbolRewardToken: item['campaignParameters']['symbolRewardToken'],
};
}) as any[];
if (distributions.length < 1) {
return;
}
Expand Down Expand Up @@ -481,16 +487,28 @@ export const useMerklFarms = () => {
}
return false;
});
let almTVL =
(item.tvl ?? 0) -
filteredALMs.reduce((total: number, alm: any) => total + alm.almTVL, 0);

// if almTVL is less than 0, it means some tokens are not invested.
// In this case, it should be recalculated by positions.
if (almTVL < 0) {
almTVL =
(item.tvl ?? 0) -
filteredALMs.reduce((total: number, alm: any) => {
const investedBalance = alm.positions.reduce(
(acc, p) => (acc += p.tvl),
0,
);
return (total += investedBalance);
}, 0);
}
const alms = filteredALMs
.concat([
{
almAddress: item.pool,
almTVL:
(item.tvl ?? 0) -
filteredALMs.reduce(
(total: number, alm: any) => total + alm.almTVL,
0,
),
almTVL: almTVL,
almAPR: item?.meanAPR ?? 0,
label: item?.ammName,
},
Expand Down
1 change: 0 additions & 1 deletion src/pages/FarmPage/V3/MerklFarmCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const MerklFarmCard: React.FC<Props> = ({ farm }) => {
return {
...item,
dailyAmount,
symbolRewardToken: farm.symbolRewardToken,
};
})
.reduce((memo: any[], item: any) => {
Expand Down

0 comments on commit 0302a00

Please sign in to comment.