BToken

Overview

License: MIT

abstract contract BToken is BTokenInterface, Exponential, TokenErrorReporter

Author: Compound Abstract base for CTokens

Structs info

MintLocalVars

struct MintLocalVars {
	TokenErrorReporter.Error err;
	CarefulMath.MathError mathErr;
	uint256 exchangeRateMantissa;
	uint256 mintTokens;
	uint256 totalSupplyNew;
	uint256 accountTokensNew;
	uint256 actualMintAmount;
}

RedeemLocalVars

struct RedeemLocalVars {
	TokenErrorReporter.Error err;
	CarefulMath.MathError mathErr;
	uint256 exchangeRateMantissa;
	uint256 redeemTokens;
	uint256 redeemAmount;
	uint256 totalSupplyNew;
	uint256 accountTokensNew;
}

BorrowLocalVars

struct BorrowLocalVars {
	CarefulMath.MathError mathErr;
	uint256 accountBorrows;
	uint256 accountBorrowsNew;
	uint256 totalBorrowsNew;
}

RepayBorrowLocalVars

struct RepayBorrowLocalVars {
	TokenErrorReporter.Error err;
	CarefulMath.MathError mathErr;
	uint256 repayAmount;
	uint256 borrowerIndex;
	uint256 accountBorrows;
	uint256 accountBorrowsNew;
	uint256 totalBorrowsNew;
	uint256 actualRepayAmount;
}

Modifiers info

nonReentrant

modifier nonReentrant()

Prevents a contract from calling itself, directly or indirectly.

Functions info

initialize (0x99d8c1b4)

function initialize(
    Bondtroller bondtroller_,
    InterestRateModel interestRateModel_,
    uint256 initialExchangeRateMantissa_,
    string memory name_,
    string memory symbol_,
    uint8 decimals_
) public

Initializes the money market.

Parameters:

transfer (0xa9059cbb)

function transfer(
    address dst,
    uint256 amount
) external override nonReentrant returns (bool)

Transfers amount tokens from msg.sender to dst.

Parameters:

Return values:

transferFrom (0x23b872dd)

function transferFrom(
    address src,
    address dst,
    uint256 amount
) external override nonReentrant returns (bool)

Transfers amount tokens from src to dst.

Parameters:

Return values:

approve (0x095ea7b3)

function approve(
    address spender,
    uint256 amount
) external override returns (bool)

Approves spender to transfer up to amount from src. This will overwrite the approval amount for spender and is subject to issues noted here.

Parameters:

Return values:

allowance (0xdd62ed3e)

function allowance(
    address owner,
    address spender
) external view override returns (uint256)

Gets the current allowance from owner for spender.

Parameters:

Return values:

balanceOf (0x70a08231)

function balanceOf(address owner) external view override returns (uint256)

Gets the token balance of the owner.

Parameters:

Return values:

balanceOfUnderlying (0x3af9e669)

function balanceOfUnderlying(address owner) external override returns (uint256)

Gets the underlying balance of the owner. This also accrues interest in a transaction.

Parameters:

Return values:

balanceOfUnderlyingView (0x439d3ee7)

function balanceOfUnderlyingView(address owner) external view returns (uint256)

Returns the balance of the underlying asset of this bToken for the given account. This is a view function, which means it will not modify the blockchain state.

Parameters:

Return values:

getAccountSnapshot (0xc37f68e2)

function getAccountSnapshot(
    address account
) external view override returns (uint256, uint256, uint256, uint256)

Gets a snapshot of the account's balances, and the cached exchange rate. This is used by bondtroller to more efficiently perform liquidity checks.

Parameters:

Return values:

borrowRatePerBlock (0xf8f9da28)

function borrowRatePerBlock() external view override returns (uint256)

Returns the current per-block borrow interest rate for this cToken.

Return values:

supplyRatePerBlock (0xae9d70b0)

function supplyRatePerBlock() external view override returns (uint256)

Returns the current per-block supply interest rate for this cToken.

Return values:

totalBorrowsCurrent (0x73acee98)

function totalBorrowsCurrent() external override nonReentrant returns (uint256)

Returns the current total borrows plus accrued interest.

Return values:

borrowBalanceCurrent (0x17bfdfbc)

function borrowBalanceCurrent(
    address account
) external override nonReentrant returns (uint256)

Accrues interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex.

Parameters:

Return values:

borrowBalanceStored (0x95dd9193)

function borrowBalanceStored(
    address account
) public view override returns (uint256)

Returns the borrow balance of account based on stored data.

Parameters:

Return values:

exchangeRateCurrent (0xbd6d894d)

function exchangeRateCurrent() public override nonReentrant returns (uint256)

Accrues interest then return the up-to-date exchange rate.

Return values:

exchangeRateStored (0x182df0f5)

function exchangeRateStored() public view override returns (uint256)

Calculates the exchange rate from the underlying to the CToken.

Return values:

getCash (0x3b1d21a2)

function getCash() external view override returns (uint256)

Gets cash balance of this cToken in the underlying asset.

Return values:

accrueInterest (0xa6afed95)

function accrueInterest() public override returns (uint256)

Applies accrued interest to total borrows and reserves. This calculates interest accrued from the last checkpointed block up to the current block and writes new checkpoint to storage.

_setBondtroller (0xb4ac7688)

function _setBondtroller(
    Bondtroller newBondtroller
) public override returns (uint256)

Sets a new bondtroller for the market. Admin function to set a new bondtroller.

Return values:

_setReserveFactor (0xfca7820b)

function _setReserveFactor(
    uint256 newReserveFactorMantissa
) external override nonReentrant returns (uint256)

Accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh. Admin function to accrue interest and set a new reserve factor.

Return values:

_reduceReserves (0x601a0bf1)

function _reduceReserves(
    uint256 reduceAmount
) external override nonReentrant returns (uint256)

Accrues interest and reduces reserves by transferring to moderator.

Parameters:

Return values:

_setInterestRateModel (0xf2b3abbd)

function _setInterestRateModel(
    InterestRateModel newInterestRateModel
) public override returns (uint256)

accrues interest and updates the interest rate model using _setInterestRateModelFresh. Admin function to accrue interest and update the interest rate model.

Parameters:

Return values:

hasRoleModerator (0xd6526889)

function hasRoleModerator(address account) public view virtual returns (bool)

Returns whether the specified account has the moderator role.

Parameters:

Return values:

Last updated