Compare commits
No commits in common. "3113810d5c037f31041cb33d6aea9f6fd0c4535f" and "494df5f1398517d9af9b3f7d0a786b44c5f0cf86" have entirely different histories.
3113810d5c
...
494df5f139
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ghost-dao-interface",
|
||||
"private": true,
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@ -39,7 +39,6 @@ export const config = createConfig({
|
||||
]),
|
||||
[mordor.id]: fallback([
|
||||
http('https://rpc.mordor.etccooperative.org'),
|
||||
http('https://geth-mordor.etc-network.info'),
|
||||
])
|
||||
},
|
||||
})
|
||||
|
||||
@ -96,8 +96,5 @@ export const UNISWAP_V2_FACTORY = {
|
||||
};
|
||||
|
||||
export const CEX_TICKERS = {
|
||||
[NetworkId.TESTNET_MORDOR]: [
|
||||
"https://api.binance.com/api/v3/ticker/price?symbol=ETCUSDT",
|
||||
"https://api.coinbase.com/v2/prices/ETC-USDT/spot",
|
||||
],
|
||||
[NetworkId.TESTNET_MORDOR]: "ETCUSDT",
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { useEffect, useState, useMemo, useCallback } from "react";
|
||||
import ReactGA from "react-ga4";
|
||||
|
||||
import {
|
||||
Box,
|
||||
@ -155,10 +154,6 @@ 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)
|
||||
|
||||
@ -50,7 +50,7 @@ const WethWrapper = ({ chainId, address, config, connect }) => {
|
||||
const { symbol: faucetSymbol } = useTokenSymbol(chainId, "GDAI");
|
||||
|
||||
useEffect(() => {
|
||||
ReactGA.send({ hitType: "pageview", page: "/wrapper" });
|
||||
ReactGA.send({ hitType: "pageview", page: "/faucet" });
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -43,10 +43,10 @@ function callWithCacheTTL(fn, ttlMs = 5000) {
|
||||
|
||||
export const useDaiPrice = (chainId) => {
|
||||
const [daiPrice, setDaiPrice] = useState(new DecimalBigNumber(1000000000000000000n, 18));
|
||||
const cexApis = CEX_TICKERS[chainId];
|
||||
const cexTicker = CEX_TICKERS[chainId];
|
||||
|
||||
useEffect(() => {
|
||||
if (!cexApis) {
|
||||
if (!cexTicker) {
|
||||
setDaiPrice(new DecimalBigNumber(1000000000000000000n, 18));
|
||||
return;
|
||||
}
|
||||
@ -54,35 +54,25 @@ export const useDaiPrice = (chainId) => {
|
||||
let getCexPriceCached = cexPriceGetters.get(chainId);
|
||||
if (!getCexPriceCached) {
|
||||
getCexPriceCached = callWithCacheTTL(() => {
|
||||
const fetchPromises = cexApis.map(url => fetch(url)
|
||||
return fetch(`https://api.binance.com/api/v3/ticker/price?symbol=${cexTicker}`)
|
||||
.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(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);
|
||||
.then(price => {
|
||||
const coinPrice = Number(price?.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, cexApis])
|
||||
}, [chainId, cexTicker])
|
||||
|
||||
return daiPrice;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user