Skip to content

ComptrollerLens

The ComptrollerLens contract has functions to get the number of tokens that can be seized through liquidation, hypothetical account liquidity and shortfall of an account.

struct AccountLiquidityLocalVars {
uint256 sumCollateral;
uint256 sumBorrowPlusEffects;
uint256 vTokenBalance;
uint256 borrowBalance;
uint256 exchangeRateMantissa;
uint256 oraclePriceMantissa;
struct ExponentialNoError.Exp weightedFactor;
struct ExponentialNoError.Exp exchangeRate;
struct ExponentialNoError.Exp oraclePrice;
struct ExponentialNoError.Exp tokensToDenom;
}

Computes the number of collateral tokens to be seized in a liquidation event

function liquidateCalculateSeizeTokens(address comptroller, address vTokenBorrowed, address vTokenCollateral, uint256 actualRepayAmount) external view returns (uint256, uint256)
NameTypeDescription
comptrolleraddressAddress of comptroller
vTokenBorrowedaddressAddress of the borrowed vToken
vTokenCollateraladdressAddress of collateral for the borrow
actualRepayAmountuint256Repayment amount i.e amount to be repaid of total borrowed amount
NameTypeDescription
[0]uint256A tuple of error code, and tokens to seize
[1]uint256

Computes the number of collateral tokens to be seized in a liquidation event

function liquidateCalculateSeizeTokens(address borrower, address comptroller, address vTokenBorrowed, address vTokenCollateral, uint256 actualRepayAmount) external view returns (uint256, uint256)
NameTypeDescription
borroweraddressAddress of borrower whose collateral is being seized
comptrolleraddressAddress of comptroller
vTokenBorrowedaddressAddress of the borrowed vToken
vTokenCollateraladdressAddress of collateral for the borrow
actualRepayAmountuint256Repayment amount i.e amount to be repaid of total borrowed amount
NameTypeDescription
[0]uint256A tuple of error code, and tokens to seize
[1]uint256

Computes the number of VAI tokens to be seized in a liquidation event

function liquidateVAICalculateSeizeTokens(address comptroller, address vTokenCollateral, uint256 actualRepayAmount) external view returns (uint256, uint256)
NameTypeDescription
comptrolleraddressAddress of comptroller
vTokenCollateraladdressAddress of collateral for vToken
actualRepayAmountuint256Repayment amount i.e amount to be repaid of the total borrowed amount
NameTypeDescription
[0]uint256A tuple of error code, and tokens to seize
[1]uint256

Computes the hypothetical liquidity and shortfall of an account given a hypothetical borrow A snapshot of the account is taken and the total borrow amount of the account is calculated

function getHypotheticalAccountLiquidity(address comptroller, address account, contract VToken vTokenModify, uint256 redeemTokens, uint256 borrowAmount, enum WeightFunction weightingStrategy) external view returns (uint256, uint256, uint256)
NameTypeDescription
comptrolleraddressAddress of comptroller
accountaddressAddress of the borrowed vToken
vTokenModifycontract VTokenAddress of collateral for vToken
redeemTokensuint256Number of vTokens being redeemed
borrowAmountuint256Amount borrowed
weightingStrategyenum WeightFunctionThe weighting strategy to use: - WeightFunction.USE_COLLATERAL_FACTOR to use collateral factor - WeightFunction.USE_LIQUIDATION_THRESHOLD to use liquidation threshold
NameTypeDescription
[0]uint256Returns a tuple of error code, liquidity, and shortfall
[1]uint256
[2]uint256