Skip to content

Commit

Permalink
Convex Pool shows up in rewarded pools
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbacoa committed Mar 16, 2022
1 parent 4b927d5 commit 21ffb8b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 59 deletions.
7 changes: 0 additions & 7 deletions src/components/pages/Fuse/FuseTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<DashboardBox width="100%" mt={4} height={isMobile ? "auto" : "65px"}>
<RowOrColumn
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/Fuse/Modals/PluginModal/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import PluginModal from './PluginModal'
import PluginModal from './PluginRewardsModal'
export default PluginModal
4 changes: 3 additions & 1 deletion src/constants/convex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ type PluginCTokenInfoType = {
convexPoolName: string,
curvePoolLink: string,
}
}
}

export const POOL_156_COMPTROLLER = "0x07cd53380FE9B2a5E64099591b498c73F0EfaA66"
21 changes: 2 additions & 19 deletions src/hooks/convex/useConvexRewards.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { useRari } from "context/RariContext";
import { BigNumber, constants, Contract } from "ethers";
import { BigNumber, Contract } from "ethers";

import FlywheelLensABI from "contracts/abi/FlywheelRouter.json";
import { useQuery } from "react-query";
// import { formatEther } from "ethers/lib/utils";
import { useCallback } from "react";
import { Web3Provider } from "@ethersproject/providers";
import { filterOnlyObjectProperties } from "utils/fetchFusePoolData";
// import { getEthUsdPriceBN } from "esm/utils/getUSDPriceBN";
// import { FusePoolData } from "utils/fetchFusePoolData";
// import { getPriceFromOracles } from "hooks/rewards/useRewardAPY";
import { useConvexPoolSuppliedCTokens } from "hooks/convex/useConvexPoolSuppliedCTokens";
// import { pools } from "constants/pools";
// import useCTokensWithRewardsPlugin from "./useMarketsWithPlugins";

import { POOL_156_COMPTROLLER } from "constants/convex";

const FLYWHEEL_LENS_ROUTER = "0xe7813367804d5a8bc19c27a143c8b837d373e3b7";

Expand Down Expand Up @@ -214,17 +208,6 @@ export const useFlywheelsTotalUSD = (
*/


const POOL_156_MARKETS_WITH_PLUGINS = [
"0xEee0de9187B8B1Ba554E406d0b36a807A00B0ea5",
"0x03C2d837e625E0f5CC8f50084b7986863c82102C",
"0x5E479875Ed69d4F09f7bCAaF71E9879b12d9e326",
"0x3c37CdA5C30952E48aFcc40443A9296e59DAAcA9",
"0x97b8c935e130cBa777579Ea2460c4C3e78a48a61",
"0x2ec70d3Ff3FD7ac5c2a72AAA64A398b6CA7428A5",
"0xe71b4Cb8A99839042C45CC4cAca31C85C994E79f"
]

export const POOL_156_COMPTROLLER = "0x07cd53380fe9b2a5e64099591b498c73f0efaa66"

export const useConvexMaxClaimable = () => {
const cTokens: string[] | undefined = useConvexPoolSuppliedCTokens(POOL_156_COMPTROLLER)
Expand Down
66 changes: 35 additions & 31 deletions src/hooks/fuse/useFusePools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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,
Expand All @@ -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) => {
Expand All @@ -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,
Expand Down Expand Up @@ -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 });
}
);

Expand All @@ -281,6 +283,8 @@ export const useFusePools = (filter: string | null): MergedPool[] | null => {
return null;
}

console.log({ pools })

if (!pools.length) {
return [];
}
Expand All @@ -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)
}))
}

Expand Down

1 comment on commit 21ffb8b

@vercel
Copy link

@vercel vercel bot commented on 21ffb8b Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.