Skip to content

Commit

Permalink
Merge pull request #1150 from rupak-nm/cover-earning-fix
Browse files Browse the repository at this point in the history
Fixed cover earnings chart
  • Loading branch information
flashburst committed Mar 6, 2024
2 parents 0a171c7 + 2bb20cb commit ab66526
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/hooks/useCoverEarningInsights.jsx
@@ -1,8 +1,13 @@
import {
useEffect,
useMemo,
useState
} from 'react'

import { getMonthsBetweenDates } from '@/lib/dates'
import { useAppConstants } from '@/src/context/AppConstants'
import { useProtocolMonthData } from '@/src/hooks/useProtocolMonthData'
import { convertFromUnits } from '@/utils/bn'
import { useEffect, useMemo, useState } from 'react'
import { toBN } from '@/utils/bn'

const getInitialDateRange = (from) => {
const currentDate = from
Expand Down Expand Up @@ -73,7 +78,7 @@ function useCoverEarningInsights () {

return '0'
}
).map(val => { return Number(convertFromUnits(val, liquidityTokenDecimals)) }))
).map(val => { return toBN(val || 0).toNumber() }))
}
}, [data, dateRange, liquidityTokenDecimals])

Expand Down
9 changes: 7 additions & 2 deletions src/services/aggregated-stats/protocol.js
Expand Up @@ -90,7 +90,12 @@ async function getIndividualProtocolMonthData (networkId) {
return
}

return data.protocolMonthDatas
return data.protocolMonthDatas.map(x => {
return {
networkId: networkId,
...x
}
})
}

export async function getGroupedProtocolMonthData (networkId) {
Expand All @@ -116,7 +121,7 @@ export async function getGroupedProtocolMonthData (networkId) {
if (!Array.isArray(arr)) { return }

arr.forEach(val => {
obj[val.id] = sumOf(val.nonCumulativeCoverFee, obj[val.id] || '0')
obj[val.id] = sumOf(convertFromUnits(val.nonCumulativeCoverFee, ChainConfig[val.networkId]?.stablecoin?.tokenDecimals || 6), obj[val.id] || '0')
})
})

Expand Down

0 comments on commit ab66526

Please sign in to comment.