Compare commits

..

No commits in common. "3113810d5c037f31041cb33d6aea9f6fd0c4535f" and "494df5f1398517d9af9b3f7d0a786b44c5f0cf86" have entirely different histories.

6 changed files with 12 additions and 31 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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