Skip to content

Commit ebd1f08

Browse files
author
omriss
committed
#431: ALMF: fix emitted ltv value
1 parent d6a8a31 commit ebd1f08

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/strategies/AaveLeverageMerklFarmStrategy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ contract AaveLeverageMerklFarmStrategy is
390390
override
391391
returns (uint[] memory amountsConsumed, uint value)
392392
{
393-
return ALMFLib.previewDepositValue(_getLeverageLendingBaseStorage(), amountsMax);
393+
(amountsConsumed, value) = ALMFLib.previewDepositValue(_getLeverageLendingBaseStorage(), amountsMax);
394394
}
395395

396396
//endregion ----------------------------------- Strategy base

src/strategies/libs/ALMFLib.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,18 @@ library ALMFLib {
205205
// ensure that all rewards are still exist on the balance
206206
require(tokenBalance0 == IERC20(token).balanceOf(address(this)), IControllable.IncorrectBalance());
207207

208-
(,,,, uint ltv,) = IPool(IAToken($.lendingVault).POOL()).getUserAccountData(address(this));
209-
emit ILeverageLendingStrategy.LeverageLendingHealth(ltv, ALMFCalcLib.ltvToLeverage(ltv));
208+
_emitLeverageLendingHealth($);
210209

211210
$.tempAction = ILeverageLendingStrategy.CurrentAction.None;
212211
}
213212

213+
function _emitLeverageLendingHealth(ILeverageLendingStrategy.LeverageLendingBaseStorage storage $) internal {
214+
(uint collateralAmountBase, uint debtAmountBase,,,,) =
215+
IPool(IAToken($.lendingVault).POOL()).getUserAccountData(address(this));
216+
uint ltv = ALMFCalcLib.getLtv(collateralAmountBase, debtAmountBase);
217+
emit ILeverageLendingStrategy.LeverageLendingHealth(ltv, ALMFCalcLib.ltvToLeverage(ltv));
218+
}
219+
214220
function receiveFlashLoanBalancerV2(
215221
address platform,
216222
ILeverageLendingStrategy.LeverageLendingBaseStorage storage $,

0 commit comments

Comments
 (0)