From 21ffb8b5b508c60121554dc7327de4c40c27d646 Mon Sep 17 00:00:00 2001 From: sharad-s Date: Tue, 15 Mar 2022 22:00:48 -0500 Subject: [PATCH] Convex Pool shows up in rewarded pools --- src/components/pages/Fuse/FuseTabBar.tsx | 7 -- .../pages/Fuse/Modals/PluginModal/index.ts | 2 +- src/constants/convex.ts | 4 +- src/hooks/convex/useConvexRewards.ts | 21 +----- src/hooks/fuse/useFusePools.ts | 66 ++++++++++--------- 5 files changed, 41 insertions(+), 59 deletions(-) diff --git a/src/components/pages/Fuse/FuseTabBar.tsx b/src/components/pages/Fuse/FuseTabBar.tsx index 2c1c11ac..2195b760 100644 --- a/src/components/pages/Fuse/FuseTabBar.tsx +++ b/src/components/pages/Fuse/FuseTabBar.tsx @@ -30,13 +30,6 @@ const FuseTabBar = () => { const [val, setVal] = useState(""); const { isAuthed, chainId } = useRari(); - useEffect(() => { - if (router.pathname === "/fuse") { - const route = val ? `/fuse?filter=${val}` : "/fuse"; - router.push(route, undefined, { shallow: true }); - } - }, [val]); - return ( { const cTokens: string[] | undefined = useConvexPoolSuppliedCTokens(POOL_156_COMPTROLLER) diff --git a/src/hooks/fuse/useFusePools.ts b/src/hooks/fuse/useFusePools.ts index a6da1b36..9b19c7e3 100644 --- a/src/hooks/fuse/useFusePools.ts +++ b/src/hooks/fuse/useFusePools.ts @@ -18,6 +18,8 @@ import { ChainID } from "esm/utils/networks"; import { BigNumber } from "ethers"; import { providers } from "@0xsequence/multicall"; +import { POOL_156_COMPTROLLER } from "constants/convex"; +import { flywheels } from "hooks/convex/useConvexRewards"; // Ethers export interface FusePool { @@ -121,7 +123,7 @@ export const fetchPoolsManual = async ({ const multicallProvider = new providers.MulticallProvider(fuse.provider) const multicallFuse = new Fuse(multicallProvider, chainId) - const poolRewardTokens = await Promise.all(fusePools.map( (pool) => { + const poolRewardTokens = await Promise.all(fusePools.map((pool) => { return multicallFuse.contracts.FusePoolLensSecondary.callStatic.getRewardSpeedsByPool( pool.comptroller ).then((rewards) => { @@ -174,30 +176,30 @@ export const fetchPools = async ({ const req = isMyPools ? fuse.contracts.FusePoolLens.callStatic.getPoolsBySupplierWithData(address) : isCreatedPools - ? fuse.contracts.FusePoolLens.callStatic.getPoolsByAccountWithData(address) - : isNonWhitelistedPools - ? fuse.contracts.FusePoolLens.callStatic.getPublicPoolsByVerificationWithData( - false - ) - : isRewardedPools - ? Promise.all([ - fuse.contracts.FusePoolLens.callStatic.getPublicPoolsByVerificationWithData( - true - ), - fuse.contracts.FusePoolLens.callStatic.getPublicPoolsByVerificationWithData( - false - )] - ).then(([verifiedPools, unverifiedPools]) => { - return [ - [...verifiedPools[0], ...unverifiedPools[0]], - [...verifiedPools[1], ...unverifiedPools[1]], - [...verifiedPools[2], ...unverifiedPools[2]], - [...verifiedPools[3], ...unverifiedPools[3]], - ] - }) - : fuse.contracts.FusePoolLens.callStatic.getPublicPoolsByVerificationWithData( - true - ); + ? fuse.contracts.FusePoolLens.callStatic.getPoolsByAccountWithData(address) + : isNonWhitelistedPools + ? fuse.contracts.FusePoolLens.callStatic.getPublicPoolsByVerificationWithData( + false + ) + : isRewardedPools + ? Promise.all([ + fuse.contracts.FusePoolLens.callStatic.getPublicPoolsByVerificationWithData( + true + ), + fuse.contracts.FusePoolLens.callStatic.getPublicPoolsByVerificationWithData( + false + )] + ).then(([verifiedPools, unverifiedPools]) => { + return [ + [...verifiedPools[0], ...unverifiedPools[0]], + [...verifiedPools[1], ...unverifiedPools[1]], + [...verifiedPools[2], ...unverifiedPools[2]], + [...verifiedPools[3], ...unverifiedPools[3]], + ] + }) + : fuse.contracts.FusePoolLens.callStatic.getPublicPoolsByVerificationWithData( + true + ); const { 0: ids, @@ -206,8 +208,8 @@ export const fetchPools = async ({ 3: errors, }: LensPoolsWithData = await req; - - const poolRewardTokens = await Promise.all(fusePools.map( (pool, index) => { + + const poolRewardTokens: string[][] = await Promise.all(fusePools.map((pool, index) => { return multicallFuse.contracts.FusePoolLensSecondary.callStatic.getRewardSpeedsByPool( pool.comptroller ).then((rewards) => { @@ -233,7 +235,7 @@ const createMergedPools = async ( const id = parseFloat(ids[i]); const fusePool = fusePools[i]; const fusePoolData = fusePoolsData[i]; - const poolTokenRewards = rewardTokens[i]; + const poolTokenRewards = id === 156 ? Object.values(flywheels).map(f => f.rewardToken) : rewardTokens[i]; const mergedPool = { id, @@ -272,7 +274,7 @@ export const useFusePools = (filter: string | null): MergedPool[] | null => { chainId, }); } - return await fetchPools({ fuse, address, filter, chainId}); + return await fetchPools({ fuse, address, filter, chainId }); } ); @@ -281,6 +283,8 @@ export const useFusePools = (filter: string | null): MergedPool[] | null => { return null; } + console.log({ pools }) + if (!pools.length) { return []; } @@ -293,9 +297,9 @@ export const useFusePools = (filter: string | null): MergedPool[] | null => { return poolSort(pools); } - if(isRewardedPools){ + if (isRewardedPools) { return poolSort(pools.filter((pool) => { - return pool.rewardTokens.length > 0 + return (pool.rewardTokens.length > 0 || pool.comptroller == POOL_156_COMPTROLLER) })) }