diff --git a/src/components/Aggregator/index.tsx b/src/components/Aggregator/index.tsx index e31b8f4ed..8a63e9254 100644 --- a/src/components/Aggregator/index.tsx +++ b/src/components/Aggregator/index.tsx @@ -181,7 +181,7 @@ const Routes = styled.div<{ visible: boolean }>` text-align: left; overflow-y: scroll; width: 100%; - min-height: 100%; + height: 100%; overflow-x: hidden; align-self: stretch; max-width: 30rem; @@ -611,7 +611,7 @@ export function AggregatorContainer() { !Number.isNaN(Number(balance.data.formatted)) && balance.data.value && selectedRoute?.fromAmount - ? +selectedRoute.fromAmount > Number(balance.data.value) + ? +Number(selectedRoute.fromAmount) > Number(balance.data.value) : false; const slippageIsWorng = Number.isNaN(Number(slippage)) || slippage === ''; diff --git a/src/components/Icons/index.tsx b/src/components/Icons/index.tsx index 283cdae01..63b495bc2 100644 --- a/src/components/Icons/index.tsx +++ b/src/components/Icons/index.tsx @@ -657,4 +657,31 @@ const SmolCheck = ( ); -export { GasIcon, CrossIcon, ArrowIcon, AggIcons, LlamaIcon, SmolCheck }; +const UpDownArrow = (props) => ( +
+ + +
+); + +export { GasIcon, CrossIcon, ArrowIcon, AggIcons, LlamaIcon, SmolCheck, UpDownArrow }; diff --git a/src/components/Lending/index.tsx b/src/components/Lending/index.tsx index 3af6c63d0..4deff5c4f 100644 --- a/src/components/Lending/index.tsx +++ b/src/components/Lending/index.tsx @@ -16,6 +16,7 @@ import { last } from 'lodash'; import { ArrowDownIcon, ArrowUpIcon, ExternalLinkIcon, QuestionIcon } from '@chakra-ui/icons'; import { IPool } from '~/types'; import { useLendingProps } from '~/queries/useLendingProps'; +import NextLink from 'next/link'; const ChainIcon = styled.img` width: 24px; @@ -31,45 +32,47 @@ const YieldsRow = ({ data, index, style, amountsProvided }) => { } = row; return ( - (url ? window.open(url, '_blank') : null)}> - - + + + + + + + + + + + {row.symbol} ➞ {row.borrowPool?.symbol} + + + + - - - - - - {row.symbol} ➞ {row.borrowPool?.symbol} - - - - - - {name} - - 0 ? 'rgba(0, 255, 0, 0.6)' : 'rgba(255, 0, 0, 0.6)') : undefined - }} - > - {amountsProvided ? ( - row.totalApy?.toFixed(2) + '%' - ) : ( - - - - )} - - {'$' + formatAmountString(row.borrowPool?.totalAvailableUsd)} - {formatAmountString(row?.ltv * 100)}% + {name} + + 0 ? 'rgba(0, 255, 0, 0.6)' : 'rgba(255, 0, 0, 0.6)') : undefined + }} + > + {amountsProvided ? ( + row.totalApy?.toFixed(2) + '%' + ) : ( + + + + )} + + {'$' + formatAmountString(row.borrowPool?.totalAvailableUsd)} + {formatAmountString(row?.ltv * 100)}% + ); }; diff --git a/src/components/Yields/index.tsx b/src/components/Yields/index.tsx index 703725821..94f9e3114 100644 --- a/src/components/Yields/index.tsx +++ b/src/components/Yields/index.tsx @@ -14,6 +14,8 @@ import { Filter } from 'react-feather'; import { ArrowBackIcon, ArrowDownIcon, ArrowUpIcon } from '@chakra-ui/icons'; import { useYieldProps } from '~/queries/useYieldProps'; import { useGetTokenList } from '~/queries/useGetTokenList'; +import Link from 'next/link'; +import { UpDownArrow } from '../Icons'; const ChainIcon = styled.img` width: 24px; @@ -23,30 +25,29 @@ const ChainIcon = styled.img` `; const YieldsRow = ({ data, index, style }) => ( - window?.open(`https://defillama.com/yields/pool/${data[index].pool}`, '_blank')} - > - - - {data[index].symbol} - - - - - - - - - {data[index].apyMean30d.toFixed(2)}% - {'$' + formatAmountString(data[index].tvlUsd)} - + + + + + {data[index].symbol} + + + + + + + + + {data[index].apyMean30d.toFixed(2)}% + {'$' + formatAmountString(data[index].tvlUsd)} + + ); const Yields = ({ tokens, isLoading, data: { data: initialData, config } }) => { @@ -133,32 +134,37 @@ const Yields = ({ tokens, isLoading, data: { data: initialData, config } }) => { /> ) : (
- { - setIsSearch(true); - router?.push({ query: { ...router.query, tab: 'earn', search: '' } }, undefined, { shallow: true }); - }} - /> - - - Earn with{' '} - - {search} +
+ { + setIsSearch(true); + router?.push({ query: { ...router.query, tab: 'earn', search: '' } }, undefined, { + shallow: true + }); + }} + /> + + + Earn with{' '} + + {search} + - - } - bgColor={'rgb(20, 22, 25)'} - onClick={() => setShowFilters(true)} - /> - + } + bgColor={'inherit'} + onClick={() => setShowFilters(true)} + /> + +
+ Symbol @@ -166,6 +172,9 @@ const Yields = ({ tokens, isLoading, data: { data: initialData, config } }) => { Chain { ) : ( ) - ) : null} + ) : ( + + )} handleSort('tvlUsd')} - style={{ color: sortBy === 'tvlUsd' ? 'white' : 'inherit', cursor: 'pointer' }} + style={{ + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + color: sortBy === 'tvlUsd' ? 'white' : 'inherit', + cursor: 'pointer' + }} > TVL{' '} {sortBy === 'tvlUsd' ? ( @@ -194,7 +211,9 @@ const Yields = ({ tokens, isLoading, data: { data: initialData, config } }) => { ) : ( ) - ) : null} + ) : ( + + )} {data?.length ? ( diff --git a/src/queries/useGetRoutes.tsx b/src/queries/useGetRoutes.tsx index e2b552297..6b382d414 100644 --- a/src/queries/useGetRoutes.tsx +++ b/src/queries/useGetRoutes.tsx @@ -81,9 +81,11 @@ export async function getAdapterRoutes({ adapter, chain, from, to, amount, extra : adapter.getQuote; if (adapter.isOutputAvailable) { price = await quouteFunc(chain, from, to, amount, extra); - if (price) { - amountIn = price.amountIn; + if (!price.amountIn) { + console.error(`${adapter.name} returned price without amountIn for output trade`); + return defaultRouteResponse({ adapter, amount }); } + amountIn = price.amountIn; } else if (isOutputDefined && !adapter.isOutputAvailable) { return defaultRouteResponse({ adapter, amount }); } else { @@ -94,7 +96,7 @@ export async function getAdapterRoutes({ adapter, chain, from, to, amount, extra return defaultRouteResponse({ adapter, amount }); } - if (!amountIn) throw Error('amountIn is not defined'); + if (!amountIn || amountIn === '0') throw Error('amountIn is not defined'); const txData = adapter?.getTxData?.(price) ?? ''; let l1Gas: number | 'Unknown' = 0; @@ -171,7 +173,7 @@ export function useGetRoutes({ lastFetched: res .filter((d) => d.isSuccess && !d.isFetching && d.dataUpdatedAt > 0) - .sort((a, b) => a.dataUpdatedAt - b.dataUpdatedAt)?.[0]?.dataUpdatedAt ?? Date.now(), + .sort((a, b) => b.dataUpdatedAt - a.dataUpdatedAt)?.[0]?.dataUpdatedAt ?? Date.now(), loadingRoutes, data, isLoading: res.length > 0 && data.length === 0