Skip to content

Commit

Permalink
Adjust collateralValue to be correctly denominated in borrow asset units
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoopmann committed Sep 19, 2024
1 parent 9b47e6e commit 3f55f64
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contracts/adapters/MorphoLeverageStrategyExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ contract MorphoLeverageStrategyExtension is BaseExtension {
struct ActionInfo {
uint256 collateralBalance; // Balance of underlying held in Morpho in base units (e.g. USDC 10e6)
uint256 borrowBalance; // Balance of underlying borrowed from Morpho in base units
uint256 collateralValue; // Valuation relative to the borrow asset
uint256 collateralValue; // Valuation of collateral in borrow asset base units
uint256 collateralPrice; // Price of collateral relative to borrow asset as returned by morpho oracle
uint256 setTotalSupply; // Total supply of SetToken
uint256 lltv;
Expand Down Expand Up @@ -911,7 +911,7 @@ contract MorphoLeverageStrategyExtension is BaseExtension {
(uint256 collateralBalance, uint256 borrowBalance,) = strategy.leverageModule.getCollateralAndBorrowBalances(strategy.setToken);
rebalanceInfo.collateralBalance = collateralBalance;
rebalanceInfo.borrowBalance = borrowBalance;
rebalanceInfo.collateralValue = rebalanceInfo.collateralPrice.preciseMul(rebalanceInfo.collateralBalance);
rebalanceInfo.collateralValue = rebalanceInfo.collateralPrice.mul(rebalanceInfo.collateralBalance).div(MORPHO_ORACLE_PRICE_SCALE);
rebalanceInfo.setTotalSupply = strategy.setToken.totalSupply();
rebalanceInfo.lltv = marketParams.lltv;

Expand Down Expand Up @@ -1042,7 +1042,7 @@ contract MorphoLeverageStrategyExtension is BaseExtension {
pure
returns(uint256)
{
return _collateralValue.preciseDiv(_collateralValue.sub(_borrowBalance.mul(1e18)));
return _collateralValue.preciseDiv(_collateralValue.sub(_borrowBalance));
}

/**
Expand Down

0 comments on commit 3f55f64

Please sign in to comment.