Compare commits

..

3 Commits

Author SHA1 Message Date
3113810d5c
analytics fix; incorrect path registered
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
2025-11-03 13:42:33 +03:00
c41da3195d
concurrent price endpoint added
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
2025-11-03 13:41:15 +03:00
d666a6f559
additional rpc endpoint for mordor testnet
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
2025-11-03 13:37:27 +03:00
6 changed files with 31 additions and 12 deletions

View File

@ -1,7 +1,7 @@
{
"name": "ghost-dao-interface",
"private": true,
"version": "0.3.0",
"version": "0.3.3",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -39,6 +39,7 @@ export const config = createConfig({
]),
[mordor.id]: fallback([
http('https://rpc.mordor.etccooperative.org'),
http('https://geth-mordor.etc-network.info'),
])
},
})

View File

@ -96,5 +96,8 @@ export const UNISWAP_V2_FACTORY = {
};
export const CEX_TICKERS = {
[NetworkId.TESTNET_MORDOR]: "ETCUSDT",
[NetworkId.TESTNET_MORDOR]: [
"https://api.binance.com/api/v3/ticker/price?symbol=ETCUSDT",
"https://api.coinbase.com/v2/prices/ETC-USDT/spot",
],
}

View File

@ -1,4 +1,5 @@
import { useEffect, useState, useMemo, useCallback } from "react";
import ReactGA from "react-ga4";
import {
Box,
@ -154,6 +155,10 @@ const Bridge = ({ chainId, address, config, connect }) => {
refetch: ghstBalanceRefetch
} = useBalance(chainId, "GHST", address);
useEffect(() => {
ReactGA.send({ hitType: "pageview", page: "/bridge" });
}, []);
useEffect(() => {
const interval = setInterval(() => {
setRotation((prevRotation) => prevRotation > 0 ? 0 : 180)

View File

@ -50,7 +50,7 @@ const WethWrapper = ({ chainId, address, config, connect }) => {
const { symbol: faucetSymbol } = useTokenSymbol(chainId, "GDAI");
useEffect(() => {
ReactGA.send({ hitType: "pageview", page: "/faucet" });
ReactGA.send({ hitType: "pageview", page: "/wrapper" });
}, [])
useEffect(() => {

View File

@ -43,10 +43,10 @@ function callWithCacheTTL(fn, ttlMs = 5000) {
export const useDaiPrice = (chainId) => {
const [daiPrice, setDaiPrice] = useState(new DecimalBigNumber(1000000000000000000n, 18));
const cexTicker = CEX_TICKERS[chainId];
const cexApis = CEX_TICKERS[chainId];
useEffect(() => {
if (!cexTicker) {
if (!cexApis) {
setDaiPrice(new DecimalBigNumber(1000000000000000000n, 18));
return;
}
@ -54,25 +54,35 @@ export const useDaiPrice = (chainId) => {
let getCexPriceCached = cexPriceGetters.get(chainId);
if (!getCexPriceCached) {
getCexPriceCached = callWithCacheTTL(() => {
return fetch(`https://api.binance.com/api/v3/ticker/price?symbol=${cexTicker}`)
const fetchPromises = cexApis.map(url => fetch(url)
.then(res => {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
});
})
)
return Promise.any(fetchPromises);
}, 5000);
cexPriceGetters.set(chainId, getCexPriceCached);
}
getCexPriceCached()
.then(price => {
const coinPrice = Number(price?.price ?? 0.0);
.then(response => {
if ('data' in response) {
const coinPrice = Number(response?.data?.amount ?? 0.0);
const priceInWei = Math.floor(coinPrice * 1e18);
setDaiPrice(new DecimalBigNumber(BigInt(priceInWei), 18));
} else if ('price' in response) {
const coinPrice = Number(response?.price ?? 0.0);
const priceInWei = Math.floor(coinPrice * 1e18)
setDaiPrice(new DecimalBigNumber(BigInt(priceInWei), 18));
} else {
throw Error("Unexpected json in response.");
}
})
.catch(error => {
setDaiPrice(new DecimalBigNumber(0n, 18));
});
}, [chainId, cexTicker])
}, [chainId, cexApis])
return daiPrice;
};