Skip to content

VAIController

This is the implementation contract for the VAIUnitroller proxy

Initial index used in interest computations

uint256 INITIAL_VAI_MINT_INDEX

poolId for core Pool

uint96 CORE_POOL_ID

The mintVAI function mints and transfers VAI from the protocol to the user, and adds a borrow balance. The amount minted must be less than the user’s Account Liquidity and the mint vai limit.

function mintVAI(uint256 mintVAIAmount) external returns (uint256)
NameTypeDescription
mintVAIAmountuint256The amount of the VAI to be minted.
NameTypeDescription
[0]uint2560 on success, otherwise an error code

The repay function transfers VAI interest into the protocol and burns the rest, reducing the borrower’s borrow balance. Before repaying VAI, users must first approve VAIController to access their VAI balance.

function repayVAI(uint256 amount) external returns (uint256, uint256)
NameTypeDescription
amountuint256The amount of VAI to be repaid.
NameTypeDescription
[0]uint256Error code (0=success, otherwise a failure, see ErrorReporter.sol)
[1]uint256Actual repayment amount

The repay on behalf function transfers VAI interest into the protocol and burns the rest, reducing the borrower’s borrow balance. Borrowed VAIs are repaid by another user (possibly the borrower). Before repaying VAI, the payer must first approve VAIController to access their VAI balance.

function repayVAIBehalf(address borrower, uint256 amount) external returns (uint256, uint256)
NameTypeDescription
borroweraddressThe account to repay the debt for.
amountuint256The amount of VAI to be repaid.
NameTypeDescription
[0]uint256Error code (0=success, otherwise a failure, see ErrorReporter.sol)
[1]uint256Actual repayment amount

The sender liquidates the vai minters collateral. The collateral seized is transferred to the liquidator.

function liquidateVAI(address borrower, uint256 repayAmount, contract VTokenInterface vTokenCollateral) external returns (uint256, uint256)
NameTypeDescription
borroweraddressThe borrower of vai to be liquidated
repayAmountuint256The amount of the underlying borrowed asset to repay
vTokenCollateralcontract VTokenInterfaceThe market in which to seize collateral from the borrower
NameTypeDescription
[0]uint256Error code (0=success, otherwise a failure, see ErrorReporter.sol)
[1]uint256Actual repayment amount

Sets a new comptroller

function _setComptroller(contract ComptrollerInterface comptroller_) external returns (uint256)
NameTypeDescription
[0]uint256uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)

Set the prime token contract address

function setPrimeToken(address prime_) external
NameTypeDescription
prime_addressThe new address of the prime token contract

Set the VAI token contract address

function setVAIToken(address vai_) external
NameTypeDescription
vai_addressThe new address of the VAI token contract

Toggle mint only for prime holder

function toggleOnlyPrimeHolderMint() external returns (uint256)
NameTypeDescription
[0]uint256uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)

struct AccountAmountLocalVars {
uint256 oErr;
enum CarefulMath.MathError mErr;
uint256 sumSupply;
uint256 marketSupply;
uint256 sumBorrowPlusEffects;
uint256 vTokenBalance;
uint256 borrowBalance;
uint256 exchangeRateMantissa;
uint256 oraclePriceMantissa;
struct ExponentialNoError.Exp exchangeRate;
struct ExponentialNoError.Exp oraclePrice;
struct ExponentialNoError.Exp tokensToDenom;
}

Function that returns the amount of VAI a user can mint based on their account liquidy and the VAI mint rate If mintEnabledOnlyForPrimeHolder is true, only Prime holders are able to mint VAI

function getMintableVAI(address minter) public view returns (uint256, uint256)
NameTypeDescription
minteraddressThe account to check mintable VAI
NameTypeDescription
[0]uint256Error code (0=success, otherwise a failure, see ErrorReporter.sol for details)
[1]uint256Mintable amount (with 18 decimals)

Update treasury data

function _setTreasuryData(address newTreasuryGuardian, address newTreasuryAddress, uint256 newTreasuryPercent) external returns (uint256)
NameTypeDescription
newTreasuryGuardianaddressNew Treasury Guardian address
newTreasuryAddressaddressNew Treasury Address
newTreasuryPercentuint256New fee percentage for minting VAI that is sent to the treasury

Gets yearly VAI interest rate based on the VAI price

function getVAIRepayRate() public view returns (uint256)
NameTypeDescription
[0]uint256uint256 Yearly VAI interest rate

Get interest rate per block

function getVAIRepayRatePerBlock() public view returns (uint256)
NameTypeDescription
[0]uint256uint256 Interest rate per bock

Get the last updated interest index for a VAI Minter

function getVAIMinterInterestIndex(address minter) public view returns (uint256)
NameTypeDescription
minteraddressAddress of VAI minter
NameTypeDescription
[0]uint256uint256 Returns the interest rate index for a minter

Get the current total VAI a user needs to repay

function getVAIRepayAmount(address account) public view returns (uint256)
NameTypeDescription
accountaddressThe address of the VAI borrower
NameTypeDescription
[0]uint256(uint256) The total amount of VAI the user needs to repay

Calculate how much VAI the user needs to repay

function getVAICalculateRepayAmount(address borrower, uint256 repayAmount) public view returns (uint256, uint256, uint256)
NameTypeDescription
borroweraddressThe address of the VAI borrower
repayAmountuint256The amount of VAI being returned
NameTypeDescription
[0]uint256Amount of VAI to be burned
[1]uint256Amount of VAI the user needs to pay in current interest
[2]uint256Amount of VAI the user needs to pay in past interest

Accrue interest on outstanding minted VAI

function accrueVAIInterest() public

Sets the address of the access control of this contract

function setAccessControl(address newAccessControlAddress) external
NameTypeDescription
newAccessControlAddressaddressNew address for the access control

Set VAI borrow base rate

function setBaseRate(uint256 newBaseRateMantissa) external
NameTypeDescription
newBaseRateMantissauint256the base rate multiplied by 10**18

Set VAI borrow float rate

function setFloatRate(uint256 newFloatRateMantissa) external
NameTypeDescription
newFloatRateMantissauint256the VAI float rate multiplied by 10**18

Set VAI stability fee receiver address

function setReceiver(address newReceiver) external
NameTypeDescription
newReceiveraddressthe address of the VAI fee receiver

Set VAI mint cap

function setMintCap(uint256 _mintCap) external
NameTypeDescription
_mintCapuint256the amount of VAI that can be minted

Return the address of the VAI token

function getVAIAddress() public view virtual returns (address)
NameTypeDescription
[0]addressThe address of VAI