🐛fix prices passed to HC and formatting (#473)
This commit is contained in:
parent
8a87329c90
commit
d7b91f4115
@ -14,6 +14,7 @@ import {
|
|||||||
HealthComputer,
|
HealthComputer,
|
||||||
} from 'types/generated/mars-rover-health-computer/MarsRoverHealthComputer.types'
|
} from 'types/generated/mars-rover-health-computer/MarsRoverHealthComputer.types'
|
||||||
import { convertAccountToPositions } from 'utils/accounts'
|
import { convertAccountToPositions } from 'utils/accounts'
|
||||||
|
import { getAssetByDenom } from 'utils/assets'
|
||||||
import { LTV_BUFFER } from 'utils/constants'
|
import { LTV_BUFFER } from 'utils/constants'
|
||||||
import {
|
import {
|
||||||
BorrowTarget,
|
BorrowTarget,
|
||||||
@ -70,7 +71,13 @@ export default function useHealthComputer(account?: Account) {
|
|||||||
const priceData = useMemo(() => {
|
const priceData = useMemo(() => {
|
||||||
return prices.reduce(
|
return prices.reduce(
|
||||||
(prev, curr) => {
|
(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
|
return prev
|
||||||
},
|
},
|
||||||
{} as { [key: string]: string },
|
{} as { [key: string]: string },
|
||||||
|
Loading…
Reference in New Issue
Block a user