From c06cc91f5c6529143b80214b77a553814240a245 Mon Sep 17 00:00:00 2001 From: 0xoscario <33234035+0xoscario@users.noreply.github.com> Date: Mon, 24 Feb 2025 09:47:54 -0800 Subject: [PATCH] Remove defiedge api --- src/hooks/v3/useV3Farms.ts | 34 +++--- src/state/mint/v3/hooks.ts | 208 ++++++++++++++++++------------------- 2 files changed, 121 insertions(+), 121 deletions(-) diff --git a/src/hooks/v3/useV3Farms.ts b/src/hooks/v3/useV3Farms.ts index 307c540f1..47f355616 100644 --- a/src/hooks/v3/useV3Farms.ts +++ b/src/hooks/v3/useV3Farms.ts @@ -36,7 +36,7 @@ import { useGammaData, useGammaRewards } from './useGammaData'; import { useActiveWeb3React } from 'hooks'; import { useSteerVaults } from './useSteerData'; import { useICHIVaultAPRs, useICHIVaults } from 'hooks/useICHIData'; -import { useDefiEdgeStrategiesAPR } from 'state/mint/v3/hooks'; +// import { useDefiEdgeStrategiesAPR } from 'state/mint/v3/hooks'; import { useEternalFarmAprs, useEternalFarmPoolAPRs, @@ -471,10 +471,10 @@ export const useMerklFarms = () => { ) .map((e) => e.id); }, [chainId, merklFarms]); - const { - isLoading: loadingDefiEdgeAPRs, - data: defiedgeAprs, - } = useDefiEdgeStrategiesAPR(defiEdgeIdsFiltered); + // const { + // isLoading: loadingDefiEdgeAPRs, + // data: defiedgeAprs, + // } = useDefiEdgeStrategiesAPR(defiEdgeIdsFiltered); const { data: eternalFarmPoolAprs, isLoading: eternalFarmPoolAprsLoading, @@ -562,12 +562,12 @@ export const useMerklFarms = () => { ); allowToken0 = ichiVault?.allowToken0; } else if (alm.label.includes('DefiEdge')) { - poolAPR = - defiedgeAprs?.find( - (e: any) => - e.strategy.address.toLowerCase() === - alm.almAddress.toLowerCase(), - )?.strategy?.fees_apr ?? 0; + poolAPR = 0; + // defiedgeAprs?.find( + // (e: any) => + // e.strategy.address.toLowerCase() === + // alm.almAddress.toLowerCase(), + // )?.strategy?.fees_apr ?? 0; } else if ( alm.label.toLowerCase().includes('quickswap') && eternalFarmPoolAprs @@ -587,7 +587,7 @@ export const useMerklFarms = () => { }); }, [ chainId, - defiedgeAprs, + // defiedgeAprs, eternalFarmPoolAprs, gammaData, ichiAPRs, @@ -598,7 +598,7 @@ export const useMerklFarms = () => { return { loading: loadingMerkl, loadingPoolAPRs: - loadingDefiEdgeAPRs || + // loadingDefiEdgeAPRs || loadingICHIAPRs || loadingUSDPrices || eternalFarmPoolAprsLoading || @@ -651,10 +651,10 @@ export const useGetMerklRewards = ( ...reasons, [breakdown.reason]: { unclaimed: ((reasons as any)[breakdown.reason] as any) - ? ((reasons as any)[breakdown.reason] as any).unclaimed + - BigInt(breakdown.amount) - - BigInt(breakdown.claimed) - : BigInt(breakdown.amount) - BigInt(breakdown.claimed), + ? ((reasons as any)[breakdown.reason] as any).unclaimed + + BigInt(breakdown.amount) - + BigInt(breakdown.claimed) + : BigInt(breakdown.amount) - BigInt(breakdown.claimed), }, }; }, diff --git a/src/state/mint/v3/hooks.ts b/src/state/mint/v3/hooks.ts index 59e379297..804231546 100644 --- a/src/state/mint/v3/hooks.ts +++ b/src/state/mint/v3/hooks.ts @@ -839,43 +839,43 @@ export function useV3DerivedMintInfo( return CurrencyAmount.fromRawAmount(dependentCurrency, dependentDeposit); } - if ( - liquidityRangeType === GlobalConst.v3LiquidityRangeType.DEFIEDGE_RANGE - ) { - if (!independentAmount || !dependentCurrency || !defiedgeStrategy) return; - - const tokenType = - defiedgeStrategy.token0 && - dependentCurrency.wrapped.address.toLowerCase() === - defiedgeStrategy.token0.toLowerCase() - ? 0 - : 1; - - let dependentDeposit; - - if (tokenType === 0) { - dependentDeposit = - (1 / defiedgeStrategy.ratio) * Number(independentAmount.toExact()); - } else { - dependentDeposit = - defiedgeStrategy.ratio * Number(independentAmount.toExact()); - } - - return CurrencyAmount.fromRawAmount( - dependentCurrency.isNative - ? dependentCurrency.wrapped - : dependentCurrency, - JSBI.BigInt( - parseUnits( - getFixedValue( - dependentDeposit.toString(), - dependentCurrency.decimals, - ), - dependentCurrency.decimals, - ), - ), - ); - } + // if ( + // liquidityRangeType === GlobalConst.v3LiquidityRangeType.DEFIEDGE_RANGE + // ) { + // if (!independentAmount || !dependentCurrency || !defiedgeStrategy) return; + + // const tokenType = + // defiedgeStrategy.token0 && + // dependentCurrency.wrapped.address.toLowerCase() === + // defiedgeStrategy.token0.toLowerCase() + // ? 0 + // : 1; + + // let dependentDeposit; + + // if (tokenType === 0) { + // dependentDeposit = + // (1 / defiedgeStrategy.ratio) * Number(independentAmount.toExact()); + // } else { + // dependentDeposit = + // defiedgeStrategy.ratio * Number(independentAmount.toExact()); + // } + + // return CurrencyAmount.fromRawAmount( + // dependentCurrency.isNative + // ? dependentCurrency.wrapped + // : dependentCurrency, + // JSBI.BigInt( + // parseUnits( + // getFixedValue( + // dependentDeposit.toString(), + // dependentCurrency.decimals, + // ), + // dependentCurrency.decimals, + // ), + // ), + // ); + // } if (liquidityRangeType === GlobalConst.v3LiquidityRangeType.STEER_RANGE) { if (!independentAmount || !dependentCurrency || !steerVault) return; @@ -966,7 +966,7 @@ export function useV3DerivedMintInfo( vaultToken0, uniPilotVaultReserve?.token1, uniPilotVaultReserve?.token0, - defiedgeStrategy, + // defiedgeStrategy, steerVault, outOfRange, invalidRange, @@ -1449,36 +1449,36 @@ export function useGetUnipilotVaults() { }); } -export const useDefiEdgeStrategiesAPR = (strategies: string[]) => { - const defiedgeAPIURL = process.env.REACT_APP_DEFIEDGE_API_URL; - const fetchDefiedgeStrategiesWithApr = async () => { - if (!defiedgeAPIURL) return []; - - try { - const res = await fetch( - `${defiedgeAPIURL}/polygon/details?strategies=${strategies.join()}`, - ); - const data = await res.json(); - if (data && data.length > 0) { - return data; - } - return []; - } catch { - return []; - } - }; - - return useQuery({ - queryKey: ['fetchDefiedgeStrategiesWithApr', strategies.join()], - queryFn: fetchDefiedgeStrategiesWithApr, - }); -}; +// export const useDefiEdgeStrategiesAPR = (strategies: string[]) => { +// const defiedgeAPIURL = process.env.REACT_APP_DEFIEDGE_API_URL; +// const fetchDefiedgeStrategiesWithApr = async () => { +// if (!defiedgeAPIURL) return []; + +// try { +// const res = await fetch( +// `${defiedgeAPIURL}/polygon/details?strategies=${strategies.join()}`, +// ); +// const data = await res.json(); +// if (data && data.length > 0) { +// return data; +// } +// return []; +// } catch { +// return []; +// } +// }; + +// return useQuery({ +// queryKey: ['fetchDefiedgeStrategiesWithApr', strategies.join()], +// queryFn: fetchDefiedgeStrategiesWithApr, +// }); +// }; export function useGetDefiedgeStrategies() { const { chainId } = useActiveWeb3React(); const strategies = getAllDefiedgeStrategies(chainId); const strategyIds = strategies.map((s) => s.id); - const defiedgeAPIURL = process.env.REACT_APP_DEFIEDGE_API_URL; + // const defiedgeAPIURL = process.env.REACT_APP_DEFIEDGE_API_URL; const strategyTickResult = useMultipleContractSingleData( strategyIds, @@ -1487,40 +1487,40 @@ export function useGetDefiedgeStrategies() { [0], ); - const fetchLiquidityRatio = useCallback( - async (strategy: string) => { - if (!defiedgeAPIURL) return 0; - - const res = await fetch( - `${defiedgeAPIURL}/polygon/${strategy.toLowerCase()}/deposit/ratio`, - ); - const data = await res.json(); - return data?.ratio ?? 0; - }, - [defiedgeAPIURL], - ); - - const fetchStrategiesLiquidityRatio = useCallback(async () => { - try { - const responses = await Promise.all( - strategies.map((s) => fetchLiquidityRatio(s.id)), - ); - return responses; - } catch (error) { - console.error('Error fetching liquidity ratios:', error); - return null; - } - }, [fetchLiquidityRatio, strategies]); - - const { - isLoading, - data: defiedgeStrategiesWithApr, - } = useDefiEdgeStrategiesAPR(strategyIds); - - const { data: liquidityRatios } = useQuery({ - queryKey: ['fetchStrategiesLiquidityRatio', strategies], - queryFn: fetchStrategiesLiquidityRatio, - }); + // const fetchLiquidityRatio = useCallback( + // async (strategy: string) => { + // if (!defiedgeAPIURL) return 0; + + // const res = await fetch( + // `${defiedgeAPIURL}/polygon/${strategy.toLowerCase()}/deposit/ratio`, + // ); + // const data = await res.json(); + // return data?.ratio ?? 0; + // }, + // [defiedgeAPIURL], + // ); + + // const fetchStrategiesLiquidityRatio = useCallback(async () => { + // try { + // const responses = await Promise.all( + // strategies.map((s) => fetchLiquidityRatio(s.id)), + // ); + // return responses; + // } catch (error) { + // console.error('Error fetching liquidity ratios:', error); + // return null; + // } + // }, [fetchLiquidityRatio, strategies]); + + // const { + // isLoading, + // data: defiedgeStrategiesWithApr, + // } = useDefiEdgeStrategiesAPR(strategyIds); + + // const { data: liquidityRatios } = useQuery({ + // queryKey: ['fetchStrategiesLiquidityRatio', strategies], + // queryFn: fetchStrategiesLiquidityRatio, + // }); const defiedgeStrategies = strategies.map((strategy, index) => { const strategyTickCallData = strategyTickResult[index]; @@ -1535,10 +1535,10 @@ export function useGetDefiedgeStrategies() { const tickLower = strategyTicksResult ? strategyTicksResult[0] : undefined; const tickUpper = strategyTicksResult ? strategyTicksResult[1] : undefined; - const strategyItem = defiedgeStrategiesWithApr?.find( - (e: any) => - e.strategy.address.toLowerCase() === strategy.id.toLowerCase(), - ); + // const strategyItem = defiedgeStrategiesWithApr?.find( + // (e: any) => + // e.strategy.address.toLowerCase() === strategy.id.toLowerCase(), + // ); return { id: strategy.id, @@ -1548,10 +1548,10 @@ export function useGetDefiedgeStrategies() { tickLower, tickUpper, onHold: !tickLower && !tickUpper, - apr: strategyItem?.strategy?.fees_apr, - ratio: liquidityRatios && liquidityRatios[index], + // apr: strategyItem?.strategy?.fees_apr, + // ratio: liquidityRatios && liquidityRatios[index], }; }); - return { isLoading, defiedgeStrategies }; + return { defiedgeStrategies }; }