Skip to content

Commit

Permalink
fix: solution to fix liquidation failed case.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoujia6139 committed Aug 26, 2022
1 parent 45f47b4 commit 623730b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contracts/protocol/libraries/logic/LiquidationLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ library LiquidationLogic {

// Transfer fee to treasury if it is non-zero
if (vars.liquidationProtocolFeeAmount != 0) {
uint256 index = collateralReserve.getNormalizedIncome();
uint256 aTokenAmount = vars.liquidationProtocolFeeAmount.rayDiv(index);
uint256 aTokenBalance = vars.collateralAToken.scaledBalanceOf(params.user);
if (aTokenAmount > aTokenBalance) {
vars.liquidationProtocolFeeAmount = aTokenBalance.rayMul(index);
}
vars.collateralAToken.transferOnLiquidation(
params.user,
vars.collateralAToken.RESERVE_TREASURY_ADDRESS(),
Expand Down

0 comments on commit 623730b

Please sign in to comment.