From 818ba3ac39398bff31d57cd9ac8295c2588d2224 Mon Sep 17 00:00:00 2001 From: Joaquin Battilana Date: Sat, 27 Jul 2024 17:25:37 +0100 Subject: [PATCH] feat: overwrite virtgual acc --- .../v3-UiPoolDataProvider-contract/index.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/contract-helpers/src/v3-UiPoolDataProvider-contract/index.ts b/packages/contract-helpers/src/v3-UiPoolDataProvider-contract/index.ts index 2f670c8d..10535ad7 100644 --- a/packages/contract-helpers/src/v3-UiPoolDataProvider-contract/index.ts +++ b/packages/contract-helpers/src/v3-UiPoolDataProvider-contract/index.ts @@ -125,8 +125,11 @@ export class UiPoolDataProvider implements UiPoolDataProviderInterface { const { 0: reservesRaw, 1: poolBaseCurrencyRaw }: ReservesData = await this.getReservesData({ lendingPoolAddressProvider }); - const reservesData: ReserveDataHumanized[] = reservesRaw.map( - reserveRaw => ({ + const reservesData: ReserveDataHumanized[] = reservesRaw.map(reserveRaw => { + const virtualUnderlyingBalance = + reserveRaw.virtualUnderlyingBalance.toString(); + const { virtualAccActive } = reserveRaw; + return { id: `${this.chainId}-${reserveRaw.underlyingAsset}-${lendingPoolAddressProvider}`.toLowerCase(), underlyingAsset: reserveRaw.underlyingAsset.toLowerCase(), name: reserveRaw.name, @@ -156,7 +159,9 @@ export class UiPoolDataProvider implements UiPoolDataProviderInterface { reserveRaw.variableDebtTokenAddress.toString(), interestRateStrategyAddress: reserveRaw.interestRateStrategyAddress.toString(), - availableLiquidity: reserveRaw.availableLiquidity.toString(), + availableLiquidity: virtualAccActive + ? virtualUnderlyingBalance + : reserveRaw.availableLiquidity.toString(), totalPrincipalStableDebt: reserveRaw.totalPrincipalStableDebt.toString(), averageStableRate: reserveRaw.averageStableRate.toString(), @@ -191,11 +196,10 @@ export class UiPoolDataProvider implements UiPoolDataProviderInterface { debtCeilingDecimals: reserveRaw.debtCeilingDecimals.toNumber(), isSiloedBorrowing: reserveRaw.isSiloedBorrowing, flashLoanEnabled: reserveRaw.flashLoanEnabled, - virtualAccActive: reserveRaw.virtualAccActive, - virtualUnderlyingBalance: - reserveRaw.virtualUnderlyingBalance.toString(), - }), - ); + virtualAccActive, + virtualUnderlyingBalance, + }; + }); const baseCurrencyData: PoolBaseCurrencyHumanized = { // this is to get the decimals from the unit so 1e18 = string length of 19 - 1 to get the number of 0