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