🐛fix prices passed to HC and formatting (#473)
This commit is contained in:
parent
8a87329c90
commit
d7b91f4115
@ -14,6 +14,7 @@ import {
|
||||
HealthComputer,
|
||||
} from 'types/generated/mars-rover-health-computer/MarsRoverHealthComputer.types'
|
||||
import { convertAccountToPositions } from 'utils/accounts'
|
||||
import { getAssetByDenom } from 'utils/assets'
|
||||
import { LTV_BUFFER } from 'utils/constants'
|
||||
import {
|
||||
BorrowTarget,
|
||||
@ -70,7 +71,13 @@ export default function useHealthComputer(account?: Account) {
|
||||
const priceData = useMemo(() => {
|
||||
return prices.reduce(
|
||||
(prev, curr) => {
|
||||
prev[curr.denom] = curr.amount.shiftedBy(VALUE_SCALE_FACTOR).toString()
|
||||
const decimals = getAssetByDenom(curr.denom)?.decimals || 6
|
||||
|
||||
// The HealthComputer needs prices expressed per 1 amount. So we need to correct here for any additional decimals.
|
||||
prev[curr.denom] = curr.amount
|
||||
.shiftedBy(VALUE_SCALE_FACTOR)
|
||||
.shiftedBy(-decimals + 6)
|
||||
.toString()
|
||||
return prev
|
||||
},
|
||||
{} as { [key: string]: string },
|
||||
|
Loading…
Reference in New Issue
Block a user