fix LP dex link
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
86291f933b
commit
7be03aaa9f
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ghost-dao-interface",
|
||||
"private": true,
|
||||
"version": "0.6.3",
|
||||
"version": "0.6.4",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
||||
import { ChangeEvent, useState, useEffect } from "react";
|
||||
import { ChangeEvent, useState, useMemo, useEffect } from "react";
|
||||
import { useNavigate, createSearchParams } from "react-router-dom";
|
||||
import { useQuery } from "react-query";
|
||||
import { formatCurrency, formatNumber } from "../../../helpers";
|
||||
@ -30,6 +30,8 @@ import {
|
||||
useGhstPrice
|
||||
} from "../../../hooks/prices";
|
||||
import { useLpValuation } from "../../../hooks/treasury";
|
||||
import { useUniswapV2PairReserves } from "../../../hooks/uniswapv2";
|
||||
import { getTokenIcons } from "../../../hooks/helpers";
|
||||
import { useAccount, useBalance as useNativeBalance, useConfig } from "wagmi";
|
||||
|
||||
const addTokenToWallet = async (token, userAddress) => {
|
||||
@ -71,6 +73,7 @@ export const Token = (props) => {
|
||||
const {
|
||||
isNative,
|
||||
symbol,
|
||||
faucetPath,
|
||||
icons,
|
||||
address,
|
||||
price = 0,
|
||||
@ -86,8 +89,8 @@ export const Token = (props) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const useLink = (symbol, fromAddress, toAddress, isPool) => {
|
||||
if (symbol.toUpperCase() === "RESERVE") {
|
||||
navigate({ pathname: "/faucet" })
|
||||
if (faucetPath) {
|
||||
navigate({ pathname: faucetPath })
|
||||
} else {
|
||||
navigate({
|
||||
pathname: "/dex/uniswap",
|
||||
@ -146,7 +149,7 @@ export const Token = (props) => {
|
||||
onClick={() => useLink(symbol, reserveAddress, address, isPool)}
|
||||
fullWidth
|
||||
>
|
||||
<Typography>Get on {symbol?.toUpperCase() === "RESERVE" ? "Faucet" : "Uniswap"}</Typography>
|
||||
<Typography>Get {faucetPath ? "for Free" : "on DEX"}</Typography>
|
||||
</SecondaryButton>
|
||||
</Box>
|
||||
</Box>
|
||||
@ -189,6 +192,9 @@ export const useWallet = (chainId, userAddress) => {
|
||||
refetch: lpReserveFtsoRefetch,
|
||||
contractAddress: lpReserveFtsoBalanceAddress,
|
||||
} = useBalance(chainId, "RESERVE_FTSO", userAddress);
|
||||
const {
|
||||
tokens: lpReserveFtsoTokens,
|
||||
} = useUniswapV2PairReserves(chainId, "RESERVE_FTSO");
|
||||
|
||||
const nativePrice = useNativePrice(chainId);
|
||||
const reservePrice = useReservePrice(chainId);
|
||||
@ -206,13 +212,29 @@ export const useWallet = (chainId, userAddress) => {
|
||||
const { symbol: ghstSymbol } = useTokenSymbol(chainId, "GHST");
|
||||
const { symbol: lpReserveFtsoSymbol } = useTokenSymbol(chainId, "RESERVE_FTSO");
|
||||
|
||||
const lpReserveFtsoTokenNames = useMemo(() => {
|
||||
const token0 = getTokenIcons(chainId, lpReserveFtsoTokens?.token0 ?? []);
|
||||
const token1 = getTokenIcons(chainId, lpReserveFtsoTokens?.token1 ?? []);
|
||||
|
||||
let tokenAddresses = [lpReserveFtsoTokens?.token1, lpReserveFtsoTokens?.token0];
|
||||
let tokenNames = [...token1, ...token0];
|
||||
|
||||
if (token0?.at(0) === reserveSymbol) {
|
||||
tokenAddresses = [lpReserveFtsoTokens?.token0, lpReserveFtsoTokens?.token1];
|
||||
let tokenNames = [...token0, ...token1];
|
||||
}
|
||||
|
||||
return { tokenAddresses, tokenNames }
|
||||
}, [chainId, reserveSymbol, lpReserveFtsoTokens]);
|
||||
|
||||
const tokens = {
|
||||
native: {
|
||||
symbol: nativeSymbol,
|
||||
icons: [nativeSymbol],
|
||||
balance: nativeBalance,
|
||||
price: nativePrice,
|
||||
refetch: nativeBalanceRefetch
|
||||
refetch: nativeBalanceRefetch,
|
||||
faucetPath: isNetworkLegacy(chainId) ? "/faucet" : "/wrapper",
|
||||
},
|
||||
reserve: {
|
||||
symbol: reserveSymbol,
|
||||
@ -224,6 +246,7 @@ export const useWallet = (chainId, userAddress) => {
|
||||
? "https://ghostchain.io/wp-content/uploads/2025/03/gDAI.svg"
|
||||
: "https://ghostchain.io/wp-content/uploads/2025/11/6A-Classic-ETC-Token.svg",
|
||||
refetch: reserveRefetch,
|
||||
faucetPath: isNetworkLegacy(chainId) ? "/faucet" : "/wrapper",
|
||||
},
|
||||
ftso: {
|
||||
symbol: ftsoSymbol,
|
||||
@ -255,10 +278,10 @@ export const useWallet = (chainId, userAddress) => {
|
||||
reserveFtso: {
|
||||
isPool: true,
|
||||
symbol: lpReserveFtsoSymbol,
|
||||
address: lpReserveFtsoBalanceAddress,
|
||||
address: lpReserveFtsoTokenNames?.tokenAddresses.at(1) ?? "",
|
||||
balance: lpReserveFtsoBalance,
|
||||
price: lpReserveFtsoPrice,
|
||||
icons: ["FTSO", isNetworkLegacy(chainId) ? "GDAI" : tokenNameConverter(chainId, reserveSymbol)],
|
||||
icons: lpReserveFtsoTokenNames?.tokenNames,
|
||||
externalUrl: "https://ghostchain.io/wp-content/uploads/2025/03/uni-v2.svg",
|
||||
refetch: lpReserveFtsoRefetch,
|
||||
}
|
||||
|
||||
@ -164,6 +164,8 @@ export const getTokenIcons = (chainId, address) => {
|
||||
case FTSO_DAI_LP_ADDRESSES[chainId]:
|
||||
icons = ["FTSO", "WETH"];
|
||||
break;
|
||||
default:
|
||||
icons = [""]
|
||||
}
|
||||
return icons;
|
||||
}
|
||||
|
||||
@ -6,7 +6,9 @@ import { abi as Erc20Abi } from "../../abi/ERC20.json";
|
||||
|
||||
import { getTokenAddress } from "../helpers";
|
||||
|
||||
export const useUniswapV2PairReserves = (chainId, contractAddress) => {
|
||||
export const useUniswapV2PairReserves = (chainId, rawContractAddress) => {
|
||||
const contractAddress = getTokenAddress(chainId, rawContractAddress);
|
||||
|
||||
const { data: pairReserves, refetch: pairReservesRefetch } = useReadContract({
|
||||
abi: UniswapV2Pair,
|
||||
address: contractAddress,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user