diff --git a/src/test/v2/__snapshots__/computation-and-formatting.test.ts.snap b/src/test/v2/__snapshots__/computation-and-formatting.test.ts.snap index 668d8a10..40b69a01 100644 --- a/src/test/v2/__snapshots__/computation-and-formatting.test.ts.snap +++ b/src/test/v2/__snapshots__/computation-and-formatting.test.ts.snap @@ -18,7 +18,7 @@ Object { "decimals": 18, "id": "0xff795577d9ac8bd7d90ee22b6c1703490b6512fd0x88757f2f99175387ab4c6a4b3067c77a695b0349", "lastUpdateTimestamp": 1607000068, - "liquidityRate": "0.02707021029693311716", + "liquidityRate": "0.02743993708230048129", "name": "", "reserveLiquidationBonus": "0.05", "symbol": "DAI", diff --git a/src/v2/computations-and-formatting.ts b/src/v2/computations-and-formatting.ts index 2c18c032..c061cec7 100644 --- a/src/v2/computations-and-formatting.ts +++ b/src/v2/computations-and-formatting.ts @@ -411,6 +411,19 @@ export function formatUserSummaryData( const userReservesData = userData.reservesData.map( ({ reserve, ...userReserve }): ComputedUserReserve => { const reserveDecimals = reserve.decimals; + const exactLiquidityRate = rayPow( + valueToZDBigNumber(reserve.liquidityRate) + .dividedBy(SECONDS_PER_YEAR) + .plus(RAY), + SECONDS_PER_YEAR + ).minus(RAY); + + const exactStableBorrowRate = rayPow( + valueToZDBigNumber(userReserve.stableBorrowRate) + .dividedBy(SECONDS_PER_YEAR) + .plus(RAY), + SECONDS_PER_YEAR + ).minus(RAY); return { ...userReserve, reserve: { @@ -421,13 +434,13 @@ export function formatUserSummaryData( ), 4 ), - liquidityRate: normalize(reserve.liquidityRate, RAY_DECIMALS), + liquidityRate: normalize(exactLiquidityRate, RAY_DECIMALS), }, scaledATokenBalance: normalize( userReserve.scaledATokenBalance, reserveDecimals ), - stableBorrowRate: normalize(userReserve.stableBorrowRate, RAY_DECIMALS), + stableBorrowRate: normalize(exactStableBorrowRate, RAY_DECIMALS), variableBorrowIndex: normalize( userReserve.variableBorrowIndex, RAY_DECIMALS