B Erc 20

Compound

Compound's CErc20 Contract

CTokens which wrap an EIP-20 underlying

Methods

_acceptAdmin

function _acceptAdmin() external nonpayable returns (uint256)

Accepts transfer of admin rights. msg.sender must be pendingAdmin

Admin function for pending admin to accept role and update admin

Returns

NameTypeDescription

_0

uint256

uint 0=success, otherwise a failure (see ErrorReporter.sol for details)

_addReserves

function _addReserves(uint256 addAmount) external nonpayable returns (uint256)

The sender adds to reserves.

Parameters

NameTypeDescription

addAmount

uint256

The amount fo underlying token to add as reserves

Returns

NameTypeDescription

_0

uint256

uint 0=success, otherwise a failure (see ErrorReporter.sol for details)

_reduceReserves

function _reduceReserves(uint256 reduceAmount) external nonpayable returns (uint256)

Accrues interest and reduces reserves by transferring to admin

Parameters

NameTypeDescription

reduceAmount

uint256

Amount of reduction to reserves

Returns

NameTypeDescription

_0

uint256

uint 0=success, otherwise a failure (see ErrorReporter.sol for details)

_setBondtroller

function _setBondtroller(contract Bondtroller newBondtroller) external nonpayable returns (uint256)

Sets a new bondtroller for the market

Admin function to set a new bondtroller

Parameters

NameTypeDescription

newBondtroller

contract Bondtroller

undefined

Returns

NameTypeDescription

_0

uint256

uint 0=success, otherwise a failure (see ErrorReporter.sol for details)

_setInterestRateModel

function _setInterestRateModel(contract InterestRateModel newInterestRateModel) external nonpayable returns (uint256)

accrues interest and updates the interest rate model using _setInterestRateModelFresh

Admin function to accrue interest and update the interest rate model

Parameters

NameTypeDescription

newInterestRateModel

contract InterestRateModel

the new interest rate model to use

Returns

NameTypeDescription

_0

uint256

uint 0=success, otherwise a failure (see ErrorReporter.sol for details)

_setPendingAdmin

function _setPendingAdmin(address payable newPendingAdmin) external nonpayable returns (uint256)

Begins transfer of admin rights. The newPendingAdmin must call _acceptAdmin to finalize the transfer.

Admin function to begin change of admin. The newPendingAdmin must call _acceptAdmin to finalize the transfer.

Parameters

NameTypeDescription

newPendingAdmin

address payable

New pending admin.

Returns

NameTypeDescription

_0

uint256

uint 0=success, otherwise a failure (see ErrorReporter.sol for details)

_setReserveFactor

function _setReserveFactor(uint256 newReserveFactorMantissa) external nonpayable 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

Parameters

NameTypeDescription

newReserveFactorMantissa

uint256

undefined

Returns

NameTypeDescription

_0

uint256

uint 0=success, otherwise a failure (see ErrorReporter.sol for details)

accountTokens

function accountTokens(address) external view returns (uint256)

Official record of token balances for each account

Parameters

NameTypeDescription

_0

address

undefined

Returns

NameTypeDescription

_0

uint256

undefined

accrualBlockNumber

function accrualBlockNumber() external view returns (uint256)

Block number that interest was last accrued at

Returns

NameTypeDescription

_0

uint256

undefined

accrueInterest

function accrueInterest() external nonpayable 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.

Returns

NameTypeDescription

_0

uint256

undefined

admin

function admin() external view returns (address payable)

Administrator for this contract

Returns

NameTypeDescription

_0

address payable

undefined

allowance

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

Get the current allowance from owner for spender

Parameters

NameTypeDescription

owner

address

The address of the account which owns the tokens to be spent

spender

address

The address of the account which may transfer tokens

Returns

NameTypeDescription

_0

uint256

The number of tokens allowed to be spent (-1 means infinite)

approve

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

Approve spender to transfer up to amount from src

This will overwrite the approval amount for spender and is subject to issues noted here

Parameters

NameTypeDescription

spender

address

The address of the account which may transfer tokens

amount

uint256

The number of tokens that are approved (-1 means infinite)

Returns

NameTypeDescription

_0

bool

Whether or not the approval succeeded

balanceOf

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

Get the token balance of the owner

Parameters

NameTypeDescription

owner

address

The address of the account to query

Returns

NameTypeDescription

_0

uint256

The number of tokens owned by owner

balanceOfUnderlying

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

Get the underlying balance of the owner

This also accrues interest in a transaction

Parameters

NameTypeDescription

owner

address

The address of the account to query

Returns

NameTypeDescription

_0

uint256

The amount of underlying owned by owner

balanceOfUnderlyingView

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

Parameters

NameTypeDescription

owner

address

undefined

Returns

NameTypeDescription

_0

uint256

undefined

bondtroller

function bondtroller() external view returns (contract Bondtroller)

Contract which oversees inter-cToken operations

Returns

NameTypeDescription

_0

contract Bondtroller

undefined

borrowBalanceCurrent

function borrowBalanceCurrent(address account) external nonpayable returns (uint256)

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

Parameters

NameTypeDescription

account

address

The address whose balance should be calculated after updating borrowIndex

Returns

NameTypeDescription

_0

uint256

The calculated balance

borrowBalanceStored

function borrowBalanceStored(address account) external view returns (uint256)

Return the borrow balance of account based on stored data

Parameters

NameTypeDescription

account

address

The address whose balance should be calculated

Returns

NameTypeDescription

_0

uint256

The calculated balance

borrowIndex

function borrowIndex() external view returns (uint256)

Accumulator of the total earned interest rate since the opening of the market

Returns

NameTypeDescription

_0

uint256

undefined

borrowRatePerBlock

function borrowRatePerBlock() external view returns (uint256)

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

Returns

NameTypeDescription

_0

uint256

The borrow interest rate per block, scaled by 1e18

decimals

function decimals() external view returns (uint8)

EIP-20 token decimals for this token

Returns

NameTypeDescription

_0

uint8

undefined

exchangeRateCurrent

function exchangeRateCurrent() external nonpayable returns (uint256)

Accrue interest then return the up-to-date exchange rate

Returns

NameTypeDescription

_0

uint256

Calculated exchange rate scaled by 1e18

exchangeRateStored

function exchangeRateStored() external view returns (uint256)

Calculates the exchange rate from the underlying to the CToken

This function does not accrue interest before calculating the exchange rate

Returns

NameTypeDescription

_0

uint256

Calculated exchange rate scaled by 1e18

getAccountSnapshot

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

Get a snapshot of the account's balances, and the cached exchange rate

This is used by bondtroller to more efficiently perform liquidity checks.

Parameters

NameTypeDescription

account

address

Address of the account to snapshot

Returns

NameTypeDescription

_0

uint256

(possible error, token balance, borrow balance, exchange rate mantissa)

_1

uint256

undefined

_2

uint256

undefined

_3

uint256

undefined

getCash

function getCash() external view returns (uint256)

Get cash balance of this cToken in the underlying asset

Returns

NameTypeDescription

_0

uint256

The quantity of underlying asset owned by this contract

initialize

function initialize(address underlying_, contract Bondtroller comptroller_, contract InterestRateModel interestRateModel_, uint256 initialExchangeRateMantissa_, string name_, string symbol_, uint8 decimals_) external nonpayable

Initialize the new money market

Parameters

NameTypeDescription

underlying_

address

The address of the underlying asset

comptroller_

contract Bondtroller

The address of the Comptroller

interestRateModel_

contract InterestRateModel

The address of the interest rate model

initialExchangeRateMantissa_

uint256

The initial exchange rate, scaled by 1e18

name_

string

ERC-20 name of this token

symbol_

string

ERC-20 symbol of this token

decimals_

uint8

ERC-20 decimal precision of this token

initialize

function initialize(contract Bondtroller bondtroller_, contract InterestRateModel interestRateModel_, uint256 initialExchangeRateMantissa_, string name_, string symbol_, uint8 decimals_) external nonpayable

Initialize the money market

Parameters

NameTypeDescription

bondtroller_

contract Bondtroller

The address of the Bondtroller

interestRateModel_

contract InterestRateModel

The address of the interest rate model

initialExchangeRateMantissa_

uint256

The initial exchange rate, scaled by 1e18

name_

string

EIP-20 name of this token

symbol_

string

EIP-20 symbol of this token

decimals_

uint8

EIP-20 decimal precision of this token

interestRateModel

function interestRateModel() external view returns (contract InterestRateModel)

Model which tells what the current interest rate should be

Returns

NameTypeDescription

_0

contract InterestRateModel

undefined

isCToken

function isCToken() external view returns (bool)

Indicator that this is a CToken contract (for inspection)

Returns

NameTypeDescription

_0

bool

undefined

name

function name() external view returns (string)

EIP-20 token name for this token

Returns

NameTypeDescription

_0

string

undefined

pendingAdmin

function pendingAdmin() external view returns (address payable)

Pending administrator for this contract

Returns

NameTypeDescription

_0

address payable

undefined

protocolSeizeShareMantissa

function protocolSeizeShareMantissa() external view returns (uint256)

Share of seized collateral that is added to reserves

Returns

NameTypeDescription

_0

uint256

undefined

reserveFactorMantissa

function reserveFactorMantissa() external view returns (uint256)

Fraction of interest currently set aside for reserves

Returns

NameTypeDescription

_0

uint256

undefined

supplyRatePerBlock

function supplyRatePerBlock() external view returns (uint256)

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

Returns

NameTypeDescription

_0

uint256

The supply interest rate per block, scaled by 1e18

sweepToken

function sweepToken(contract EIP20NonStandardInterface token) external nonpayable

A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to admin (timelock)

Parameters

NameTypeDescription

token

contract EIP20NonStandardInterface

The address of the ERC-20 token to sweep

symbol

function symbol() external view returns (string)

EIP-20 token symbol for this token

Returns

NameTypeDescription

_0

string

undefined

totalBorrows

function totalBorrows() external view returns (uint256)

Total amount of outstanding borrows of the underlying in this market

Returns

NameTypeDescription

_0

uint256

undefined

totalBorrowsCurrent

function totalBorrowsCurrent() external nonpayable returns (uint256)

Returns the current total borrows plus accrued interest

Returns

NameTypeDescription

_0

uint256

The total borrows with interest

totalReserves

function totalReserves() external view returns (uint256)

Total amount of reserves of the underlying held in this market

Returns

NameTypeDescription

_0

uint256

undefined

totalSupply

function totalSupply() external view returns (uint256)

Total number of tokens in circulation

Returns

NameTypeDescription

_0

uint256

undefined

transfer

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

Transfer amount tokens from msg.sender to dst

Parameters

NameTypeDescription

dst

address

The address of the destination account

amount

uint256

The number of tokens to transfer

Returns

NameTypeDescription

_0

bool

Whether or not the transfer succeeded

transferFrom

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

Transfer amount tokens from src to dst

Parameters

NameTypeDescription

src

address

The address of the source account

dst

address

The address of the destination account

amount

uint256

The number of tokens to transfer

Returns

NameTypeDescription

_0

bool

Whether or not the transfer succeeded

underlying

function underlying() external view returns (address)

Underlying asset for this CToken

Returns

NameTypeDescription

_0

address

undefined

Events

AccrueInterest

event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows)

Event emitted when interest is accrued

Parameters

NameTypeDescription

cashPrior

uint256

undefined

interestAccumulated

uint256

undefined

borrowIndex

uint256

undefined

totalBorrows

uint256

undefined

Approval

event Approval(address indexed owner, address indexed spender, uint256 amount)

EIP20 Approval event

Parameters

NameTypeDescription

owner indexed

address

undefined

spender indexed

address

undefined

amount

uint256

undefined

Borrow

event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows)

Event emitted when underlying is borrowed

Parameters

NameTypeDescription

borrower

address

undefined

borrowAmount

uint256

undefined

accountBorrows

uint256

undefined

totalBorrows

uint256

undefined

Failure

event Failure(uint256 error, uint256 info, uint256 detail)

Parameters

NameTypeDescription

error

uint256

undefined

info

uint256

undefined

detail

uint256

undefined

LiquidateBorrow

event LiquidateBorrow(address liquidator, address borrower, uint256 repayAmount, address cTokenCollateral, uint256 seizeTokens)

Event emitted when a borrow is liquidated

Parameters

NameTypeDescription

liquidator

address

undefined

borrower

address

undefined

repayAmount

uint256

undefined

cTokenCollateral

address

undefined

seizeTokens

uint256

undefined

Mint

event Mint(address minter, uint256 mintAmount, uint256 mintTokens)

Event emitted when tokens are minted

Parameters

NameTypeDescription

minter

address

undefined

mintAmount

uint256

undefined

mintTokens

uint256

undefined

NewAdmin

event NewAdmin(address oldAdmin, address newAdmin)

Event emitted when pendingAdmin is accepted, which means admin is updated

Parameters

NameTypeDescription

oldAdmin

address

undefined

newAdmin

address

undefined

NewBondtroller

event NewBondtroller(contract Bondtroller oldBondtroller, contract Bondtroller newBondtroller)

Event emitted when bondtroller is changed

Parameters

NameTypeDescription

oldBondtroller

contract Bondtroller

undefined

newBondtroller

contract Bondtroller

undefined

NewMarketInterestRateModel

event NewMarketInterestRateModel(contract InterestRateModel oldInterestRateModel, contract InterestRateModel newInterestRateModel)

Event emitted when interestRateModel is changed

Parameters

NameTypeDescription

oldInterestRateModel

contract InterestRateModel

undefined

newInterestRateModel

contract InterestRateModel

undefined

NewPendingAdmin

event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin)

Event emitted when pendingAdmin is changed

Parameters

NameTypeDescription

oldPendingAdmin

address

undefined

newPendingAdmin

address

undefined

NewReserveFactor

event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa)

Event emitted when the reserve factor is changed

Parameters

NameTypeDescription

oldReserveFactorMantissa

uint256

undefined

newReserveFactorMantissa

uint256

undefined

Redeem

event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens)

Event emitted when tokens are redeemed

Parameters

NameTypeDescription

redeemer

address

undefined

redeemAmount

uint256

undefined

redeemTokens

uint256

undefined

RepayBorrow

event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows)

Event emitted when a borrow is repaid

Parameters

NameTypeDescription

payer

address

undefined

borrower

address

undefined

repayAmount

uint256

undefined

accountBorrows

uint256

undefined

totalBorrows

uint256

undefined

ReservesAdded

event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves)

Event emitted when the reserves are added

Parameters

NameTypeDescription

benefactor

address

undefined

addAmount

uint256

undefined

newTotalReserves

uint256

undefined

ReservesReduced

event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves)

Event emitted when the reserves are reduced

Parameters

NameTypeDescription

admin

address

undefined

reduceAmount

uint256

undefined

newTotalReserves

uint256

undefined

Transfer

event Transfer(address indexed from, address indexed to, uint256 amount)

EIP20 Transfer event

Parameters

NameTypeDescription

from indexed

address

undefined

to indexed

address

undefined

amount

uint256

undefined

Last updated