Skip to content

Commit

Permalink
query indexer & resolve conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
vuonghuuhung committed Sep 26, 2024
1 parent 78142f8 commit 3c79fc2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/pages/Pool-V3/components/CreatePositionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,16 @@ const CreatePositionForm: FC<CreatePoolFormProps> = ({
const [amountTo, setAmountTo] = useState<number | string>();
const [amountFrom, setAmountFrom] = useState<number | string>();

const fromUsd = (extendPrices?.[tokenFrom?.coinGeckoId] * Number(amountFrom || 0)).toFixed(6);
const toUsd = (extendPrices?.[tokenTo?.coinGeckoId] * Number(amountTo || 0)).toFixed(6);
const zapUsd = (extendPrices?.[tokenZap?.coinGeckoId] * Number(zapAmount || 0)).toFixed(6);
const fromUsd = extendPrices?.[tokenFrom?.coinGeckoId]
? (extendPrices[tokenFrom.coinGeckoId] * Number(amountFrom || 0)).toFixed(6)
: '0';
const toUsd = extendPrices?.[tokenTo?.coinGeckoId]
? (extendPrices[tokenTo.coinGeckoId] * Number(amountTo || 0)).toFixed(6)
: '0';
const zapUsd = extendPrices?.[tokenZap?.coinGeckoId]
? (extendPrices[tokenZap.coinGeckoId] * Number(zapAmount || 0)).toFixed(6)
: '0';

const xUsd =
zapInResponse &&
(extendPrices?.[tokenFrom?.coinGeckoId] * (Number(zapInResponse.amountX || 0) / 10 ** tokenFrom.decimals)).toFixed(
Expand Down Expand Up @@ -952,7 +959,7 @@ const CreatePositionForm: FC<CreatePoolFormProps> = ({
if (error instanceof RouteNotFoundError) {
setZapError('No route found, try other tokens or other amount');
} else if (error instanceof RouteNoLiquidity) {
setZapError("No liquidity found for the swap route. Cannot proceed with the swap.");
setZapError('No liquidity found for the swap route. Cannot proceed with the swap.');
} else if (error instanceof SpamTooManyRequestsError) {
setZapError('Too many requests, please try again later, after 1 minute');
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Pool-V3/components/ZapOutForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ const ZapOutForm: FC<ZapOutFormProps> = ({

if (incentives) {
Object.keys(incentives).forEach((key) => {
const token = oraichainTokens.find((e) => extractAddress(e ) === key);
const token = oraichainTokens.find((e) => extractAddress(e) === key);
receiveIncentiveTokens.push({
icon: getIcon({
isLightTheme,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Pool-V3/hooks/useGetPoolDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
import { CoinGeckoPrices } from 'hooks/useCoingecko';
import { PoolFeeAndLiquidityDaily } from 'libs/contractSingleton';
import { useEffect, useState } from 'react';
import { FeeDailyData, getFeeDailyData, getPoolDetail, getPoolDetailFromBackend, PoolDetail } from 'rest/graphClient';
import { FeeDailyData, getFeeDailyData, getPoolDetail, PoolDetail } from 'rest/graphClient';
import { toDisplay } from '@oraichain/oraidex-common';

export type LiquidityDistribution = {
Expand All @@ -24,7 +24,7 @@ export const useGetPoolDetail = (poolKey: string, prices: CoinGeckoPrices<string
total: 0,
allocation: {}
});
const { data, refetch: refetchPoolDetail } = useQuery<PoolDetail>(['pool-v3-detail'], () => getPoolDetailFromBackend(poolKey), {
const { data, refetch: refetchPoolDetail } = useQuery<PoolDetail>(['pool-v3-detail'], () => getPoolDetail(poolKey), {
refetchOnWindowFocus: false,
placeholderData: null,
// cacheTime: 5 * 60 * 1000
Expand Down

0 comments on commit 3c79fc2

Please sign in to comment.