-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ gOHM
+
+
+
+
+
+
+
+ Balance: 0.00 gOHM
+
+
+
+
- |
-
+
+
+
+ Connect Wallet
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/Stake/components/ExternalStakePools/ExternalStakePools.tsx b/src/views/Stake/components/ExternalStakePools/ExternalStakePools.tsx
index 7c29d96398..77665a0f0b 100644
--- a/src/views/Stake/components/ExternalStakePools/ExternalStakePools.tsx
+++ b/src/views/Stake/components/ExternalStakePools/ExternalStakePools.tsx
@@ -14,35 +14,18 @@ import {
Tooltip,
} from "@olympusdao/component-library";
import { formatCurrency, formatNumber } from "src/helpers";
-import {
- balancerPools,
- beetsPools,
- convexPools,
- curvePools,
- fraxPools,
- joePools,
- jonesPools,
- sushiPools,
-} from "src/helpers/AllExternalPools";
+import { balancerPools, convexPools, curvePools, fraxPools } from "src/helpers/AllExternalPools";
import { ExternalPool } from "src/lib/ExternalPool";
import { NetworkId } from "src/networkDetails";
import {
BalancerPoolAPY,
BalancerSwapFees,
- BeetsPoolAPY,
ConvexPoolAPY,
CurvePoolAPY,
FraxPoolAPY,
- JoePoolAPY,
- JonesPoolAPY,
- SushiPoolAPY,
} from "src/views/Stake/components/ExternalStakePools/hooks/useStakePoolAPY";
import { useStakePoolBalance } from "src/views/Stake/components/ExternalStakePools/hooks/useStakePoolBalance";
-import {
- BalancerPoolTVL,
- CurvePoolTVL,
- useStakePoolTVL,
-} from "src/views/Stake/components/ExternalStakePools/hooks/useStakePoolTVL";
+import { CurvePoolTVL } from "src/views/Stake/components/ExternalStakePools/hooks/useStakePoolTVL";
import { useAccount } from "wagmi";
const PREFIX = "ExternalStakePools";
@@ -105,18 +88,6 @@ export const ExternalStakePools = () => {
const AllPools = (props: { isSmallScreen: boolean }) => (
- {sushiPools.map(pool => (
-
- ))}
- {joePools.map(pool => (
-
- ))}
- {beetsPools.map(pool => (
-
- ))}
- {jonesPools.map(pool => (
-
- ))}
{balancerPools.map(pool => (
))}
@@ -242,44 +213,6 @@ const MobileStakePool: React.FC<{ pool: ExternalPool; tvl?: number; apy?: number
);
};
-const SushiPools: React.FC<{ pool: ExternalPool; isSmallScreen: boolean }> = props => {
- const { data: totalValueLocked } = useStakePoolTVL(props.pool);
- const { apy } = SushiPoolAPY(props.pool);
- return props.isSmallScreen ? (
-
- ) : (
-
- );
-};
-
-const JoePools: React.FC<{ pool: ExternalPool; isSmallScreen: boolean }> = props => {
- const { data: totalValueLocked } = useStakePoolTVL(props.pool);
- const { apy } = JoePoolAPY(props.pool);
- return props.isSmallScreen ? (
-
- ) : (
-
- );
-};
-
-const BeetsPools: React.FC<{ pool: ExternalPool; isSmallScreen: boolean }> = props => {
- const { data: totalValueLocked } = BalancerPoolTVL(props.pool);
- const { apy } = BeetsPoolAPY(props.pool);
- return props.isSmallScreen ? (
-
- ) : (
-
- );
-};
-
-const JonesPools: React.FC<{ pool: ExternalPool; isSmallScreen: boolean }> = props => {
- const { apy, tvl } = JonesPoolAPY(props.pool);
- return props.isSmallScreen ? (
-
- ) : (
-
- );
-};
const BalancerPools: React.FC<{ pool: ExternalPool; isSmallScreen: boolean }> = props => {
const { data } = BalancerSwapFees(props.pool.address);
const { apy } = BalancerPoolAPY(props.pool);
diff --git a/src/views/Stake/components/ExternalStakePools/hooks/useStakePoolAPY.ts b/src/views/Stake/components/ExternalStakePools/hooks/useStakePoolAPY.ts
index 58df6dd3b5..6471f5891c 100644
--- a/src/views/Stake/components/ExternalStakePools/hooks/useStakePoolAPY.ts
+++ b/src/views/Stake/components/ExternalStakePools/hooks/useStakePoolAPY.ts
@@ -2,79 +2,18 @@ import { useQuery } from "@tanstack/react-query";
import axios from "axios";
import { gql, request } from "graphql-request";
import { getTokenPrice, parseBigNumber } from "src/helpers";
-import { createDependentQuery } from "src/helpers/react-query/createDependentQuery";
-import { queryAssertion } from "src/helpers/react-query/queryAssertion";
import { nonNullable } from "src/helpers/types/nonNullable";
import {
useStaticBalancerV2PoolContract,
- useStaticBeethovenChefContract,
- useStaticChefContract,
- useStaticChefRewarderContract,
useStaticCurveGaugeControllerContract,
useStaticCurveGaugeDepositContract,
useStaticCurvePoolContract,
- useStaticJoeChefContract,
- useStaticJoeRewarderContract,
} from "src/hooks/useContract";
-import { useGohmPrice } from "src/hooks/usePrices";
import { ExternalPool } from "src/lib/ExternalPool";
-import { BalancerPoolTVL, useStakePoolTVL } from "src/views/Stake/components/ExternalStakePools/hooks/useStakePoolTVL";
import { useProvider } from "wagmi";
export const stakePoolAPYQueryKey = (pool: ExternalPool) => ["StakePoolAPY", pool].filter(nonNullable);
-export const SushiPoolAPY = (pool: ExternalPool) => {
- const { data: tvl = 0 } = useStakePoolTVL(pool);
- const masterchef = useStaticChefContract(pool.masterchef, pool.networkID);
- const rewarder = useStaticChefRewarderContract(pool.rewarder, pool.networkID);
-
- const { data, isFetched, isLoading } = useQuery(["StakePoolAPY", pool], async () => {
- const rewardsPerWeek = parseBigNumber(await masterchef.sushiPerSecond(), 18) * 604800;
- const rewarderRewardsPerSecond = parseBigNumber(await rewarder.rewardPerSecond(), 18);
- const poolInfo = await masterchef.poolInfo(pool.poolId);
- const totalAllocPoint = parseBigNumber(await masterchef.totalAllocPoint(), 18);
- const poolRewardsPerWeek = (parseBigNumber(poolInfo.allocPoint, 18) / totalAllocPoint) * rewardsPerWeek;
- return { poolRewardsPerWeek, rewarderRewardsPerSecond };
- });
- const { data: apy = 0 } = APY(pool, tvl, data);
- return { apy, isFetched, isLoading };
-};
-
-export const JoePoolAPY = (pool: ExternalPool) => {
- const { data: tvl = 0 } = useStakePoolTVL(pool);
- const joechef = useStaticJoeChefContract(pool.masterchef, pool.networkID);
- const rewarder = useStaticJoeRewarderContract(pool.rewarder, pool.networkID);
-
- const { data, isFetched, isLoading } = useQuery(["StakePoolAPY", pool], async () => {
- const rewardsPerWeek = parseBigNumber(await joechef.joePerSec(), 18) * 604800;
- const rewarderRewardsPerSecond = parseBigNumber(await rewarder.tokenPerSec(), 18);
-
- const poolInfo = await joechef.poolInfo(pool.poolId);
- const totalAllocPoint = parseBigNumber(await joechef.totalAllocPoint(), 18);
- const poolRewardsPerWeek = (parseBigNumber(poolInfo.allocPoint, 18) / totalAllocPoint) * rewardsPerWeek;
-
- return { poolRewardsPerWeek, rewarderRewardsPerSecond };
- });
- const { data: apy = 0 } = APY(pool, tvl, data);
- return { apy, isFetched, isLoading };
-};
-
-export const BeetsPoolAPY = (pool: ExternalPool) => {
- const { data: tvl = 0 } = BalancerPoolTVL(pool);
- const beethovenChef = useStaticBeethovenChefContract(pool.masterchef, pool.networkID);
- const beetsrewarder = useStaticChefRewarderContract(pool.rewarder, pool.networkID);
- const { data, isFetched, isLoading } = useQuery(["StakePoolAPY", pool], async () => {
- const rewardsPerWeek = parseBigNumber(await beethovenChef.beetsPerBlock(), 18) * 604800;
- const rewarderRewardsPerSecond = parseBigNumber(await beetsrewarder.rewardPerSecond(), 18);
- const poolInfo = await beethovenChef.poolInfo(pool.poolId);
- const totalAllocPoint = parseBigNumber(await beethovenChef.totalAllocPoint(), 18);
- const poolRewardsPerWeek = (parseBigNumber(poolInfo.allocPoint, 18) / totalAllocPoint) * rewardsPerWeek;
- return { poolRewardsPerWeek, rewarderRewardsPerSecond };
- });
- const { data: apy = 0 } = APY(pool, tvl, data);
- return { apy, isFetched, isLoading };
-};
-
//TODO: Add support for Rewarder/Gauge if pool becomes incentivized.
//Currently this only calculates APR based on swap fees since there is no concept of staking.
export const BalancerPoolAPY = (pool: ExternalPool) => {
@@ -172,23 +111,6 @@ export const CurvePoolRewardAPY = (pool: ExternalPool) => {
return { data, isFetched, isLoading };
};
-//Returns Jones Pool APY and TVL. Response also returns TVL for the pool, unlike other queries.
-export const JonesPoolAPY = (pool: ExternalPool) => {
- const jonesAPI = "https://data.jonesdao.io/api/v1/jones/farms/general";
- const {
- data = { apy: 0, liquidity_locked: 0 },
- isFetched,
- isLoading,
- } = useQuery(["JonesPoolAPY", pool.address], async () => {
- const results = await axios.get(jonesAPI).then(res => {
- const poolData = res.data.farms.find((lp: { lpToken: string }) => lp.lpToken == pool.address);
- return poolData;
- });
- return results;
- });
- return { apy: data.apr / 100, tvl: data.totalStakedValue, isFetched, isLoading };
-};
-
//Returns Convex Pool APY and TVL. Response also returns TVL for the pool, unlike other queries.
export const ConvexPoolAPY = (pool: ExternalPool) => {
const convexAPI = "https://api.thegraph.com/subgraphs/name/convex-community/curve-pools";
@@ -235,28 +157,3 @@ export const FraxPoolAPY = (pool: ExternalPool) => {
});
return { apy: data.apy / 100, tvl: data.liquidity_locked, isFetched, isLoading };
};
-
-const APY = (
- pool: ExternalPool,
- tvl: number,
- data?: { poolRewardsPerWeek: number; rewarderRewardsPerSecond: number },
- nongOHMBonus?: string,
-) => {
- const useDependentQuery = createDependentQuery(stakePoolAPYQueryKey(pool));
- const { data: gohmPrice } = useGohmPrice();
-
- const bonusGecko = useDependentQuery("bonus", () => getTokenPrice(nongOHMBonus));
- const rewardPrice = useDependentQuery("rewardPrice", () => getTokenPrice(pool.rewardGecko));
- const bonusTokenPrice = nongOHMBonus ? bonusGecko : gohmPrice;
- return useQuery(
- ["APY", pool],
- () => {
- queryAssertion(bonusTokenPrice && rewardPrice && tvl && data);
- const rewarderRewardsPerWeek = data.rewarderRewardsPerSecond * 604800;
- const baseRewardAPY = ((data.poolRewardsPerWeek * rewardPrice) / tvl) * 52;
- const bonusRewardsAPY = ((rewarderRewardsPerWeek * bonusTokenPrice) / tvl) * 52;
- return baseRewardAPY + bonusRewardsAPY;
- },
- { enabled: !!tvl && !!gohmPrice && !!rewardPrice && !!data },
- );
-};
diff --git a/src/views/Stake/components/ExternalStakePools/hooks/useStakePoolTVL.ts b/src/views/Stake/components/ExternalStakePools/hooks/useStakePoolTVL.ts
index 267f3bb1a9..6a3cdc4d2c 100644
--- a/src/views/Stake/components/ExternalStakePools/hooks/useStakePoolTVL.ts
+++ b/src/views/Stake/components/ExternalStakePools/hooks/useStakePoolTVL.ts
@@ -1,94 +1,7 @@
import { useQuery } from "@tanstack/react-query";
import axios from "axios";
-import { GOHM_ADDRESSES } from "src/constants/addresses";
-import { getTokenPrice, parseBigNumber } from "src/helpers";
-import { createDependentQuery } from "src/helpers/react-query/createDependentQuery";
-import { queryAssertion } from "src/helpers/react-query/queryAssertion";
-import { nonNullable } from "src/helpers/types/nonNullable";
-import {
- useStaticBalancerV2PoolContract,
- useStaticBalancerVaultContract,
- useStaticPairContract,
-} from "src/hooks/useContract";
-import { useGohmPrice } from "src/hooks/usePrices";
import { ExternalPool } from "src/lib/ExternalPool";
-export const stakePoolTVLQueryKey = (poolAddress: string) => ["useStakePoolTVL", poolAddress].filter(nonNullable);
-
-export const useStakePoolTVL = (pool: ExternalPool) => {
- const contract = useStaticPairContract(pool.address, pool.networkID);
-
- // Get dependent data in parallel
- const key = stakePoolTVLQueryKey(pool.address);
- const useDependentQuery = createDependentQuery(key);
- const { data: gohmPrice } = useGohmPrice();
- const reserves = useDependentQuery("reserves", () => contract.getReserves());
- const firstTokenAddress = useDependentQuery("firstTokenAddress", () => contract.token0());
- const poolTokenSupply = useDependentQuery("poolTokenSupply", () => contract.totalSupply());
- const stakedBalance = useDependentQuery("stakedBalance", () => contract.balanceOf(pool.masterchef));
- const nonGohmTokenPrice = useDependentQuery("nonGohmTokenPrice", () => getTokenPrice(pool.pairGecko));
-
- return useQuery(
- [key],
- async () => {
- queryAssertion(
- gohmPrice && stakedBalance && poolTokenSupply && reserves && nonGohmTokenPrice && firstTokenAddress,
- key,
- );
-
- const isFirstTokenGohm =
- firstTokenAddress.toLowerCase() ===
- GOHM_ADDRESSES[pool.networkID as keyof typeof GOHM_ADDRESSES]?.toLowerCase();
-
- const firstTokenPrice = isFirstTokenGohm ? gohmPrice : nonGohmTokenPrice;
- const secondTokenPrice = isFirstTokenGohm ? nonGohmTokenPrice : gohmPrice;
-
- const totalLpAsUSD =
- parseBigNumber(reserves[0], 18) * firstTokenPrice + parseBigNumber(reserves[1], 18) * secondTokenPrice;
-
- const totalValueLocked = (totalLpAsUSD * parseBigNumber(stakedBalance, 18)) / parseBigNumber(poolTokenSupply, 18);
-
- return totalValueLocked;
- },
- {
- enabled:
- !!gohmPrice && !!stakedBalance && !!poolTokenSupply && !!reserves && !!nonGohmTokenPrice && !!firstTokenAddress,
- },
- );
-};
-
-export const BalancerPoolTVLQueryKey = (poolAddress: string) => ["useBalancerPoolTVL", poolAddress].filter(nonNullable);
-
-export const BalancerPoolTVL = (pool: ExternalPool) => {
- const vault = pool.vault ? pool.vault : "";
- const useDependentQuery = createDependentQuery(BalancerPoolTVLQueryKey(pool.address));
- const poolContract = useStaticBalancerV2PoolContract(pool.address, pool.networkID);
- const vaultContract = useStaticBalancerVaultContract(vault, pool.networkID);
- const { data: gohmPrice } = useGohmPrice();
- const nonGohmTokenPrice = useDependentQuery("nonGohmTokenPrice", () => getTokenPrice("fantom"));
- const { data, isFetched, isLoading } = useQuery(
- ["BalancerPoolTVL", pool],
- async () => {
- queryAssertion(gohmPrice && nonGohmTokenPrice);
- const poolId = await poolContract.getPoolId();
- const stakedBalance = await poolContract.balanceOf(pool.masterchef);
- const vaultBalances = await vaultContract.getPoolTokens(poolId);
- const poolTokenSupply = await poolContract.totalSupply();
- const isFirstTokenGohm =
- vaultBalances.tokens[0] === GOHM_ADDRESSES[pool.networkID as keyof typeof GOHM_ADDRESSES]?.toLowerCase();
- const firstTokenPrice = isFirstTokenGohm ? gohmPrice : nonGohmTokenPrice;
- const secondTokenPrice = isFirstTokenGohm ? nonGohmTokenPrice : gohmPrice;
- const totalLpAsUSD =
- parseBigNumber(vaultBalances.balances[0], 18) * firstTokenPrice +
- parseBigNumber(vaultBalances.balances[1], 18) * secondTokenPrice;
- const totalValueLocked = (totalLpAsUSD * parseBigNumber(stakedBalance, 18)) / parseBigNumber(poolTokenSupply, 18);
- return totalValueLocked;
- },
- { enabled: !!gohmPrice && !!nonGohmTokenPrice },
- );
- return { data, isFetched, isLoading };
-};
-
export const CurvePoolTVL = (pool: ExternalPool) => {
const curveAPI = "https://api.curve.fi/api/getFactoryCryptoPools";
const {
diff --git a/src/views/V1-Stake/__tests__/__snapshots__/V1-Stake.unit.test.tsx.snap b/src/views/V1-Stake/__tests__/__snapshots__/V1-Stake.unit.test.tsx.snap
index 7d46118360..3e456722c6 100644
--- a/src/views/V1-Stake/__tests__/__snapshots__/V1-Stake.unit.test.tsx.snap
+++ b/src/views/V1-Stake/__tests__/__snapshots__/V1-Stake.unit.test.tsx.snap
@@ -282,46 +282,33 @@ exports[` > should render component. not connected 1`] = `
style="z-index: 1; font-size: 24px;"
viewBox="0 0 32 32"
>
-
-
-
-
-
-
-
+
+
+
> should render component. not connected 1`] = `
- gOHM-wETH
+ OHM-DAI-wETH
> should render component. not connected 1`] = `
style="font-size: 15px;"
viewBox="0 0 32 32"
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -712,7 +437,10 @@ exports[` > should render component. not connected 1`] = `
class="MuiTypography-root MuiTypography-body1 css-pi8uen-MuiTypography-root"
style="line-height: 1.4;"
>
- 0.00%
+
| > should render component. not connected 1`] = `
>
Stake on
- Sushi
+ Balancer
@@ -767,47 +495,16 @@ exports[` > should render component. not connected 1`] = `
style="z-index: 1; font-size: 24px;"
viewBox="0 0 32 32"
>
-
-
-
-
-
-
-
-
> should render component. not connected 1`] = `
- gOHM-wETH
+ OHM-ETH
> should render component. not connected 1`] = `
style="font-size: 15px;"
viewBox="0 0 32 32"
>
+
+
+
+
+
+
+
+
@@ -910,14 +641,14 @@ exports[` > should render component. not connected 1`] = `
>
Stake on
- Sushi
+ Curve
@@ -956,47 +687,16 @@ exports[` > should render component. not connected 1`] = `
style="z-index: 1; font-size: 24px;"
viewBox="0 0 32 32"
>
-
-
-
-
-
-
-
-
> should render component. not connected 1`] = `
style="margin-left: -6px; z-index: 1; font-size: 24px;"
viewBox="0 0 32 32"
>
+
-
-
-
+
+
+
+
+
+
+
+
+
> should render component. not connected 1`] = `
style="font-size: 15px;"
viewBox="0 0 32 32"
>
+
+
+
+
+
+
+
@@ -1073,14 +833,14 @@ exports[` > should render component. not connected 1`] = `
>
Stake on
- Trader Joe
+ Convex
@@ -1119,47 +879,16 @@ exports[` > should render component. not connected 1`] = `
style="z-index: 1; font-size: 24px;"
viewBox="0 0 32 32"
>
-
-
-
-
-
-
-
-
> should render component. not connected 1`] = `
style="margin-left: -6px; z-index: 1; font-size: 24px;"
viewBox="0 0 32 32"
>
-
-
-
-
-
-
-
-
-
-
-
-
+
+
> should render component. not connected 1`] = `
- gOHM-wFTM
+ OHM-FRAX
+
+
+
+ Mint and Sync
+
+
+
+
+
+
> should render component. not connected 1`] = `
style="font-size: 15px;"
viewBox="0 0 32 32"
>
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -1300,14 +1024,14 @@ exports[` > should render component. not connected 1`] = `
>
Stake on
- Beethoven
+ Fraxswap
@@ -1325,563 +1049,257 @@ exports[` > should render component. not connected 1`] = `
-
+
+
+
+
+
+
+`;
+
+exports[` > should render the stake input Area when connected 1`] = `
+ |
-