fix race cond in price & stats load
This commit is contained in:
parent
8c23e2f861
commit
0d8e3d604e
|
@ -5,8 +5,8 @@ import Link from './Link'
|
||||||
//import GradientText from './GradientText'
|
//import GradientText from './GradientText'
|
||||||
|
|
||||||
const LendSection = () => {
|
const LendSection = () => {
|
||||||
const [stats, setStats] = useState([])
|
const [stats, setStats] = useState(null)
|
||||||
const [prices, setPrices] = useState([])
|
const [prices, setPrices] = useState(null)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadStats = async () => {
|
const loadStats = async () => {
|
||||||
|
@ -30,17 +30,16 @@ const LendSection = () => {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const propsFor = (symbol) => {
|
const propsFor = (symbol) => {
|
||||||
const filtered = stats.filter((s) => s.symbol == symbol)
|
if (!stats || !prices)
|
||||||
if (filtered.length < 1)
|
|
||||||
return {
|
return {
|
||||||
name: symbol,
|
name: symbol,
|
||||||
icon: `../token/icon-${symbol.toLowerCase()}.svg`,
|
icon: `../token/icon-${symbol.toLowerCase()}.svg`,
|
||||||
interest: { deposit: 0, borrow: 0 },
|
interest: { deposit: 0, borrow: 0 },
|
||||||
liquidity: { native: 0, usd: 0 },
|
liquidity: { native: 0, usd: 0 },
|
||||||
}
|
}
|
||||||
|
const filtered = stats.filter((s) => s.symbol == symbol)
|
||||||
const lastStats = filtered[filtered.length - 1]
|
const lastStats = filtered[filtered.length - 1]
|
||||||
const lastPrice = symbol == 'USDC' ? 1 : prices[symbol][lastStats.hourly]
|
const lastPrice = symbol === 'USDC' ? 1 : prices[symbol][lastStats.hourly]
|
||||||
const native = lastStats.totalDeposits // - lastStats.totalBorrows
|
const native = lastStats.totalDeposits // - lastStats.totalBorrows
|
||||||
return {
|
return {
|
||||||
name: symbol,
|
name: symbol,
|
||||||
|
|
Loading…
Reference in New Issue