PrimaryLendingPlatformLiquidationCore
Overview
License: MIT
Core contract for liquidating loans on the PrimaryLendingPlatform.
Abstract contract that allows users to liquidate loans.
Structs info
Ratio
MaxLAParams
Events info
Liquidate
Emitted when a liquidation occurs.
Parameters:
liquidator
address
The address of the account that initiates the liquidation.
borrower
address
The address of the borrower whose position is being liquidated.
lendingToken
address
The address of the token being used for lending.
prjAddress
address
The address of the project being liquidated.
amountPrjLiquidated
uint256
The amount of the project's tokens being liquidated.
SetPrimaryLendingPlatform
Emitted when the primary lending platform address is set.
Parameters:
newPrimaryLendingPlatform
address
The new primary lending platform address.
SetMinPartialLiquidationAmount
Emitted when the minimum amount for partial liquidation is set.
Parameters:
newAmount
uint256
The new minimum amount for partial liquidation.
SetMaxLRF
Emitted when the maximum Liquidation Reserve Factor (LRF) is set.
Parameters:
numeratorLRF
uint8
The numerator of the LRF fraction.
denominatorLRF
uint8
The denominator of the LRF fraction.
SetLiquidatorRewardCalculationFactor
Emitted when the liquidator reward calculation factor is set.
Parameters:
numeratorLRF
uint8
The numerator of the liquidator reward calculation factor.
denominatorLRF
uint8
The denominator of the liquidator reward calculation factor.
SetTargetHealthFactor
Emitted when the target health factor is set.
Parameters:
numeratorHF
uint8
The numerator of the target health factor.
denominatorHF
uint8
The denominator of the target health factor.
SetExchangeAggregator
Emitted when the exchange aggregator and registry aggregator addresses are set.
Parameters:
exchangeAggregator
address
The address of the exchange aggregator.
registryAggregator
address
The address of the registry aggregator.
Constants info
MODERATOR_ROLE (0x797669c9)
LIQUIDATOR_REWARD_FACTOR_DECIMAL (0x150f2191)
BUFFER_PERCENTAGE (0x952038c2)
State variables info
minPartialLiquidationAmount (0x802937ac)
targetHealthFactor (0x254cf439)
liquidatorRewardCalcFactor (0xc9fd7f25)
maxLRF (0x83958352)
primaryLendingPlatform (0x92641a7c)
exchangeAggregator (0x60df4f35)
registryAggregator (0xf38cb29a)
Modifiers info
onlyModerator
Modifier that only allows access to accounts with the MODERATOR_ROLE.
isProjectTokenListed
Modifier that only allows access to project tokens that are listed on the PrimaryLendingPlatform.
Parameters:
_projectToken
address
The address of the project token.
isLendingTokenListed
Modifier that only allows access to lending tokens that are listed on the PrimaryLendingPlatform.
Parameters:
_lendingToken
address
The address of the lending token.
onlyRelatedContracts
Modifier that only allows access to related contracts of the PrimaryLendingPlatform.
Functions info
initialize (0xc4d66de8)
Initializes the contract with the provided PIT address.
Sets up initial roles, initializes AccessControl, and sets the provided PIT address.
Parameters:
pit
address
The address of the PrimaryLendingPlatform contract.
setMinPartialLiquidationAmount (0x35f67981)
Sets the minimum partial liquidation amount. Can only be called by accounts with the MODERATOR_ROLE.
Parameters:
newAmount
uint256
The minimum partial liquidation amount.
setMaxLRF (0x1ed95f01)
Sets the maximum Liquidation Reserve Factor (LRF) that can be used for liquidation.
Requirements:
The denominator must not be zero.
Only the moderator can call this function.
Parameters:
numeratorLRF
uint8
The numerator of the LRF ratio.
denominatorLRF
uint8
The denominator of the LRF ratio.
setLiquidatorRewardCalculationFactor (0x3495b179)
Sets the liquidator reward calculation factor.
Requirements:
The caller must have the
MODERATOR_ROLE
role.The denominatorLRF cannot be zero.
Parameters:
numeratorLRF
uint8
The numerator of the liquidator reward calculation factor.
denominatorLRF
uint8
The denominator of the liquidator reward calculation factor.
setPrimaryLendingPlatformAddress (0xcec5a0b0)
Sets the address of the primary lending platform contract.
Requirements:
Only the moderator can call this function.
The new primary lending platform address must not be the zero address.
Parameters:
newPrimaryLendingPlatform
address
The address of the new primary lending platform contract.
setTargetHealthFactor (0xffac9b50)
Sets the target health factor.
Requirements:
Only the moderator can call this function.
The denominatorHF cannot be zero.
Parameters:
numeratorHF
uint8
The numerator for the target health factor.
denominatorHF
uint8
The denominator for the target health factor.
setExchangeAggregator (0x3c4841b4)
Updates the Exchange Aggregator contract and registry contract addresses.
Requirements:
The caller must be the moderator.
exchangeAggregatorAddress
must not be the zero address.registryAggregatorAddress
must be a valid Augustus contract if it is not the zero address.
Parameters:
exchangeAggregatorAddress
address
The new address of the Exchange Aggregator contract.
registryAggregatorAddress
address
The new address of the Aggregator registry contract.
getCurrentHealthFactor (0xb398f0e7)
Gets the current health factor of a specific account's position.
Parameters:
_account
address
The address of the account.
_projectToken
address
The address of the project token.
_lendingToken
address
The address of the lending token.
Return values:
healthFactorNumerator
uint256
The numerator of the health factor.
healthFactorDenominator
uint256
The denominator of the health factor.
getCurrentOutstanding (0x9bfeb5d5)
Gets the current outstanding amount of a specific account's position.
Parameters:
_account
address
The address of the account.
_projectToken
address
The address of the project token.
_lendingToken
address
The address of the lending token.
Return values:
[0]
uint256
currentOutstanding The current outstanding amount of the account's position.
getTokenPrice (0xc9f7153c)
Gets the price of a token in USD.
Parameters:
token
address
The address of the token.
amount
uint256
The amount of the token.
Return values:
collateralPrice
uint256
The price of the token in USD.
capitalPrice
uint256
The price of the token in USD.
liquidatorRewardFactor (0x894c4d5b)
Calculates the liquidator reward factor (LRF) for a given position.
Formula: LRF = (1 + (1 - HF) * k)
Parameters:
_account
address
The address of the borrower whose position is being considered.
_projectToken
address
The address of the project token.
_lendingToken
address
The address of the lending token.
Return values:
lrfNumerator
uint256
The numerator of the liquidator reward factor.
lrfDenominator
uint256
The denominator of the liquidator reward factor.
getMaxLiquidationAmount (0x7da157b9)
Calculates the maximum liquidation amount (MaxLA) for a given position.
Formula: MaxLA = (LVR * CVc - THF * LVc) / (LRF * LVR - THF)
Parameters:
account
address
The address of the borrower whose position is being considered.
projectToken
address
The address of the project token.
lendingToken
address
The address of the lending token.
Return values:
maxLA
uint256
The maximum liquidation amount in the lending token.
getLiquidationAmount (0x90edd058)
Returns the minimum and maximum liquidation amount for a given account, project token, and lending token.
Formula:
MinLA = min(MaxLA, MPA)
MaxLA = (LVR * CVc - THF * LVc) / (LRF * LVR - THF)
Parameters:
_account
address
The account for which to calculate the liquidation amount.
_projectToken
address
The project token address.
_lendingToken
address
The lending token address.
Return values:
maxLA
uint256
The maximum liquidation amount.
minLA
uint256
The minimum liquidation amount.
Last updated