From 39b8acf4c31e4866bb45ff901c635ed4ac1f8ef3 Mon Sep 17 00:00:00 2001 From: piekczyk Date: Wed, 30 Oct 2024 10:51:04 +0100 Subject: [PATCH] Update Aave v3 liquidation price (#707) --- packages/dma-library/package.json | 2 +- packages/dma-library/src/views/aave/index.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/dma-library/package.json b/packages/dma-library/package.json index 48a3ac1f7..4d425afe0 100644 --- a/packages/dma-library/package.json +++ b/packages/dma-library/package.json @@ -1,6 +1,6 @@ { "name": "@oasisdex/dma-library", - "version": "0.6.72", + "version": "0.6.74", "typings": "lib/index.d.ts", "types": "lib/index.d.ts", "main": "lib/index.js", diff --git a/packages/dma-library/src/views/aave/index.ts b/packages/dma-library/src/views/aave/index.ts index e5112f007..538474e6c 100644 --- a/packages/dma-library/src/views/aave/index.ts +++ b/packages/dma-library/src/views/aave/index.ts @@ -347,6 +347,7 @@ export const getCurrentPositionAaveV3Omni: AaveV3GetCurrentPositionOmni = async let maxLoanToValue = new BigNumber(reserveDataForCollateral.ltv.toString()).div(BASE) if (eModeCategoryData !== undefined) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars liquidationThreshold = new BigNumber(eModeCategoryData.liquidationThreshold.toString()).div( BASE, ) @@ -359,10 +360,13 @@ export const getCurrentPositionAaveV3Omni: AaveV3GetCurrentPositionOmni = async ) const oracle = validatedCollateralPrice.div(validatedDebtPrice) + // W use liquidationThreshold in AaveLikePositionV2 class to calculate liquidationPrice (LP). + // Recently a new Aave version 3.2 was released and now maxLoanToValue should be used instead to calculate LP. + // Since Spark uses the same class but was not updated we make this custom overwrite here. const category = { dustLimit: new BigNumber(0), maxLoanToValue: maxLoanToValue, - liquidationThreshold: liquidationThreshold, + liquidationThreshold: maxLoanToValue, } const { collateral, debt } = calculateViewValuesForPosition({