🐛fix prices passed to HC and formatting (#473)

This commit is contained in:
Bob van der Helm 2023-09-14 15:00:56 +02:00 committed by GitHub
parent 8a87329c90
commit d7b91f4115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 8 deletions

View File

@ -9,4 +9,4 @@ export default async function getAssetParams(): Promise<AssetParamsBaseForAddr[]
} catch (ex) { } catch (ex) {
throw ex throw ex
} }
} }

View File

@ -140,4 +140,4 @@ export default function LendingMarketsTable(props: Props) {
) )
return <AssetListTable title={title} rowRenderer={rowRenderer} columns={columns} data={data} /> return <AssetListTable title={title} rowRenderer={rowRenderer} columns={columns} data={data} />
} }

View File

@ -269,4 +269,4 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi {
unsubscribeBars(listenerGuid: string): void { unsubscribeBars(listenerGuid: string): void {
// TheGraph doesn't support websockets yet // TheGraph doesn't support websockets yet
} }
} }

View File

@ -229,4 +229,4 @@ export const ASSETS: Asset[] = [
hasOraclePrice: !IS_TESTNET, hasOraclePrice: !IS_TESTNET,
forceFetchPrice: !IS_TESTNET, forceFetchPrice: !IS_TESTNET,
}, },
] ]

View File

@ -102,4 +102,4 @@ export default function useDepositVault(props: Props): {
actions, actions,
totalValue, totalValue,
} }
} }

View File

@ -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 },

View File

@ -56,4 +56,4 @@ function useLendingMarketAssetsTableData(): {
}, [markets, marketDeposits, marketLiquidities, accountLentAmounts, convertAmount]) }, [markets, marketDeposits, marketLiquidities, accountLentAmounts, convertAmount])
} }
export default useLendingMarketAssetsTableData export default useLendingMarketAssetsTableData

View File

@ -96,4 +96,4 @@ interface MarketTableData {
marketLiquidityRate: number marketLiquidityRate: number
marketLiquidityAmount: BigNumber marketLiquidityAmount: BigNumber
marketLiquidationThreshold: number marketLiquidationThreshold: number
} }