Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ON_HOLD: position can not be liquidated #7

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions contracts/protocol/libraries/logic/LiquidationLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ library LiquidationLogic {
using UserConfiguration for DataTypes.UserConfigurationMap;
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
using GPv2SafeERC20 for IERC20;
using WadRayMath for uint256;

// See `IPool` for descriptions
event ReserveUsedAsCollateralEnabled(
Expand Down Expand Up @@ -213,6 +214,15 @@ library LiquidationLogic {

// Transfer fee to treasury if it is non-zero
if (vars.liquidationProtocolFeeAmount != 0) {
uint256 index = collateralReserve.getNormalizedIncome();
uint256 pTokenAmount = vars.liquidationProtocolFeeAmount.rayDiv(
index
);
uint256 pTokenBalance = IPToken(vars.collateralXToken)
.scaledBalanceOf(params.user);
if (pTokenAmount > pTokenBalance) {
vars.liquidationProtocolFeeAmount = pTokenBalance.rayMul(index);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we are saying:


a.rayMul(x).rayDiv(x) > a

is possible right

Copy link
Contributor Author

@zhoujia6139 zhoujia6139 Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a.rayMul(x).rayDiv(x) == a if x > 1

IPToken(vars.collateralXToken).transferOnLiquidation(
params.user,
IPToken(vars.collateralXToken).RESERVE_TREASURY_ADDRESS(),
Expand Down