fix perp funding rate
This commit is contained in:
parent
46b32d01ce
commit
6ad10826ca
|
@ -27,7 +27,7 @@ const PerpMarketsTable = () => {
|
|||
const showTableView = width ? width > breakpoints.md : false
|
||||
// const bids = mangoStore((s) => s.selectedMarket.bidsAccount)
|
||||
// const asks = mangoStore((s) => s.selectedMarket.asksAccount)
|
||||
const rate = usePerpFundingRate()
|
||||
const rates = usePerpFundingRate()
|
||||
|
||||
return (
|
||||
<ContentBox hideBorder hidePadding>
|
||||
|
@ -63,12 +63,8 @@ const PerpMarketsTable = () => {
|
|||
const chartData = coingeckoData ? coingeckoData.prices : undefined
|
||||
|
||||
let fundingRate
|
||||
if (
|
||||
rate.isSuccess
|
||||
// && bids instanceof BookSide &&
|
||||
// asks instanceof BookSide
|
||||
) {
|
||||
const marketRate = rate.data.find(
|
||||
if (rates.isSuccess && rates.data) {
|
||||
const marketRate = rates.data.find(
|
||||
(r) => r.market_index === market.perpMarketIndex
|
||||
)
|
||||
fundingRate = `${marketRate?.funding_apr.toFixed(2)}%`
|
||||
|
|
|
@ -27,23 +27,24 @@ export const usePerpFundingRate = () => {
|
|||
}
|
||||
)
|
||||
|
||||
return res
|
||||
return Array.isArray(res?.data) ? res : { isSuccess: false, data: null }
|
||||
}
|
||||
|
||||
const PerpFundingRate = () => {
|
||||
const { selectedMarket } = useSelectedMarket()
|
||||
const rate = usePerpFundingRate()
|
||||
|
||||
// const bids = mangoStore((s) => s.selectedMarket.bidsAccount)
|
||||
// const asks = mangoStore((s) => s.selectedMarket.asksAccount)
|
||||
|
||||
const fundingRate = useMemo(() => {
|
||||
if (rate.isSuccess && selectedMarket instanceof PerpMarket) {
|
||||
const marketRate = rate?.data.find(
|
||||
const marketRate = rate?.data?.find(
|
||||
(r) => r.market_index === selectedMarket.perpMarketIndex
|
||||
)
|
||||
return marketRate?.funding_rate_hourly
|
||||
}
|
||||
}, [rate])
|
||||
}, [rate, selectedMarket])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
Loading…
Reference in New Issue