From 479cccf1dc77b9a491b5085a4ceee63dbd9df371 Mon Sep 17 00:00:00 2001 From: 0xhardrefresh <0xhardrefresh@protonmail.com> Date: Tue, 24 Oct 2023 14:08:54 +0300 Subject: [PATCH] fixed position info decimals --- src/components/borrow/AdditionalInfoBlock.vue | 4 +--- src/helpers/cauldron/getUserPositions.ts | 5 +++-- src/views/borrow/Repay.vue | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/borrow/AdditionalInfoBlock.vue b/src/components/borrow/AdditionalInfoBlock.vue index 4a8e204c9..03b904377 100644 --- a/src/components/borrow/AdditionalInfoBlock.vue +++ b/src/components/borrow/AdditionalInfoBlock.vue @@ -68,9 +68,7 @@ export default { userBorrowAmount() { return +utils.formatUnits( - this.cauldron.userPosition?.borrowInfo.userBorrowAmount, - this.cauldron.config.collateralInfo.decimals - ); + this.cauldron.userPosition?.borrowInfo.userBorrowAmount); }, collateralToMim() { diff --git a/src/helpers/cauldron/getUserPositions.ts b/src/helpers/cauldron/getUserPositions.ts index a32f10a45..9eef0defe 100644 --- a/src/helpers/cauldron/getUserPositions.ts +++ b/src/helpers/cauldron/getUserPositions.ts @@ -2,6 +2,7 @@ import { Contract, BigNumber, utils } from "ethers"; import lensAbi from "@/utils/abi/marketLens.js"; import type { providers } from "ethers"; import type { UserPositions } from "@/helpers/cauldron/types"; +import type { CauldronConfig } from "@/utils/cauldronsConfig/configTypes"; import { getLensAddress } from "@/helpers/cauldron/getLensAddress"; const emptyPosition = { @@ -18,7 +19,7 @@ const emptyPosition = { }; export const getUserPositions = async ( - configs: Array, + configs: Array, provider: providers.BaseProvider, account: string | undefined, cauldronContracts: Array, @@ -69,7 +70,7 @@ export const getUserPositions = async ( userBorrowAmount: position.borrowValue, userBorrowPart: userBorrowPart[idx], }, - liquidationPrice: utils.formatUnits(position.liquidationPrice), + liquidationPrice: utils.formatUnits(position.liquidationPrice, configs[idx]?.collateralInfo.decimals), oracleRate: oracleExchangeRate[idx], }; }); diff --git a/src/views/borrow/Repay.vue b/src/views/borrow/Repay.vue index d352be291..8395d52cf 100644 --- a/src/views/borrow/Repay.vue +++ b/src/views/borrow/Repay.vue @@ -246,12 +246,13 @@ export default { expectedCollateralAmount() { const { userCollateralAmount } = this.cauldron.userPosition.collateralInfo; + const { decimals } = this.activeToken; const expectedAmount = userCollateralAmount.sub( this.parseCollateralAmount ); - return +expectedAmount < 0 ? 0 : utils.formatUnits(expectedAmount); + return +expectedAmount < 0 ? 0 : utils.formatUnits(expectedAmount, decimals); }, expectedBorrowAmount() {