source_idx
stringlengths
1
5
contract_name
stringlengths
1
48
func_name
stringlengths
0
52
masked_contract
stringlengths
105
184k
func_body
stringlengths
0
324k
func_requirement
stringlengths
1
28.3k
352
CarefulMath
divUInt
contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uin...
if (b == 0) { return (MathError.DIVISION_BY_ZERO, 0); } return (MathError.NO_ERROR, a / b);
* * @dev Integer division of two numbers, truncating the quotient.
352
CarefulMath
subUInt
contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uin...
if (b <= a) { return (MathError.NO_ERROR, a - b); } else { return (MathError.INTEGER_UNDERFLOW, 0); }
* * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).
352
CarefulMath
addUInt
contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uin...
uint c = a + b; if (c >= a) { return (MathError.NO_ERROR, c); } else { return (MathError.INTEGER_OVERFLOW, 0); }
* * @dev Adds two numbers, returns an error on overflow.
352
CarefulMath
addThenSubUInt
contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uin...
(MathError err0, uint sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c);
* * @dev add a and b and then subtract c
352
Exponential
getExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError err0, uint scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint rational) = divUInt(scaledNumerator, denom); if (err1 != MathError.NO_ERROR) { return (err1, Exp...
* * @dev Creates an exponential from numerator and denominator values. * Note: Returns an error if (`num` * 10e18) > MAX_INT, * or if `denom` is zero.
352
Exponential
addExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError error, uint result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result}));
* * @dev Adds two exponentials, returning a new exponential.
352
Exponential
subExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError error, uint result) = subUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result}));
* * @dev Subtracts two exponentials, returning a new exponential.
352
Exponential
mulScalar
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa}));
* * @dev Multiply an Exp by a scalar, returning a new Exp.
352
Exponential
mulScalarTruncate
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(product));
* * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.
352
Exponential
mulScalarTruncateAddUInt
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return addUInt(truncate(product), addend);
* * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.
352
Exponential
divScalar
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: descaledMantissa}));
* * @dev Divide an Exp by a scalar, returning a new Exp.
352
Exponential
divScalarByExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
/* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ (MathError err0, uint numerator) = mu...
* * @dev Divide a scalar by an Exp, returning a new Exp.
352
Exponential
divScalarByExpTruncate
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(fraction));
* * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.
352
Exponential
mulExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } // We add half the scale before dividing so that we get rounding instead of truncation. // See "Listing 6" and text...
* * @dev Multiplies two exponentials, returning a new exponential.
352
Exponential
mulExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
return mulExp(Exp({mantissa: a}), Exp({mantissa: b}));
* * @dev Multiplies two exponentials given their mantissas, returning a new exponential.
352
Exponential
mulExp3
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
(MathError err, Exp memory ab) = mulExp(a, b); if (err != MathError.NO_ERROR) { return (err, ab); } return mulExp(ab, c);
* * @dev Multiplies three exponentials, returning a new exponential.
352
Exponential
divExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
return getExp(a.mantissa, b.mantissa);
* * @dev Divides two exponentials, returning a new exponential. * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)
352
Exponential
truncate
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
// Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale;
* * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15
352
Exponential
lessThanExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
return left.mantissa < right.mantissa;
* * @dev Checks if first Exp is less than second Exp.
352
Exponential
lessThanOrEqualExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
return left.mantissa <= right.mantissa;
* * @dev Checks if left Exp <= right Exp.
352
Exponential
greaterThanExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
return left.mantissa > right.mantissa;
* * @dev Checks if left Exp > right Exp.
352
Exponential
isZeroExp
contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Crea...
return value.mantissa == 0;
* * @dev returns true if Exp is exactly zero
352
BToken
initialize
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
require(msg.sender == admin, "only admin may initialize the market"); require(accrualBlockNumber == 0 && borrowIndex == 0, "market may only be initialized once"); // Set initial exchange rate initialExchangeRateMantissa = initialExchangeRateMantissa_; require(initialExchangeRat...
* * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ EIP-20 name of this token * @param ...
352
BToken
transferTokens
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
/* Fail if transfer not allowed */ uint allowed = bController.transferAllowed(address(this), src, dst, tokens); if (allowed != 0) { return failOpaque(Error.BCONTROLLER_REJECTION, FailureInfo.TRANSFER_BCONTROLLER_REJECTION, allowed); } /* Do not allow self-transfers ...
* * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally * @param spender The address of the account performing the transfer * @param src The address of the source account * @param dst The address of the destination acc...
352
BToken
transfer
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR);
* * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded
352
BToken
transferFrom
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR);
* * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded
352
BToken
approve
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
address src = msg.sender; transferAllowances[src][spender] = amount; emit Approval(src, spender, amount); return true;
* * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param...
352
BToken
allowance
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
return transferAllowances[owner][spender];
* * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite)
352
BToken
balanceOf
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
return accountTokens[owner];
* * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner`
352
BToken
balanceOfUnderlying
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()}); (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]); require(mErr == MathError.NO_ERROR, "balance could not be calculated"); return balance;
* * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner`
352
BToken
getAccountSnapshot
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint bTokenBalance = accountTokens[account]; uint borrowBalance; uint exchangeRateMantissa; MathError mErr; (mErr, borrowBalance) = borrowBalanceStoredInternal(account); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } ...
* * @notice Get a snapshot of the account's balances, and the cached exchange rate * @dev This is used by bController to more efficiently perform liquidity checks. * @param account Address of the account to snapshot * @return (possible error, token balance, borrow balance, exchange rate mantissa)
352
BToken
getBlockNumber
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
return block.number;
* * @dev Function to simply retrieve block number * This exists mainly for inheriting test contracts to stub this result.
352
BToken
borrowRatePerBlock
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves);
* * @notice Returns the current per-block borrow interest rate for this bToken * @return The borrow interest rate per block, scaled by 1e18
352
BToken
supplyRatePerBlock
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa);
* * @notice Returns the current per-block supply interest rate for this bToken * @return The supply interest rate per block, scaled by 1e18
352
BToken
totalBorrowsCurrent
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return totalBorrows;
* * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest
352
BToken
borrowBalanceCurrent
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return borrowBalanceStored(account);
* * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex * @param account The address whose balance should be calculated after updating borrowIndex * @return The calculated balance
352
BToken
borrowBalanceStored
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
(MathError err, uint result) = borrowBalanceStoredInternal(account); require(err == MathError.NO_ERROR, "borrowBalanceStored: borrowBalanceStoredInternal failed"); return result;
* * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return The calculated balance
352
BToken
borrowBalanceStoredInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
/* Note: we do not assert that the market is up to date */ MathError mathErr; uint principalTimesIndex; uint result; /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowInde...
* * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return (error code, the calculated balance or 0 if error code is non-zero)
352
BToken
exchangeRateCurrent
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return exchangeRateStored();
* * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18
352
BToken
exchangeRateStored
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
(MathError err, uint result) = exchangeRateStoredInternal(); require(err == MathError.NO_ERROR, "exchangeRateStored: exchangeRateStoredInternal failed"); return result;
* * @notice Calculates the exchange rate from the underlying to the BToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18
352
BToken
exchangeRateStoredInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint _totalSupply = totalSupply; if (_totalSupply == 0) { /* * If there are no tokens minted: * exchangeRate = initialExchangeRate */ return (MathError.NO_ERROR, initialExchangeRateMantissa); } else { /* * ...
* * @notice Calculates the exchange rate from the underlying to the BToken * @dev This function does not accrue interest before calculating the exchange rate * @return (error code, calculated exchange rate scaled by 1e18)
352
BToken
getCash
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
return getCashPrior();
* * @notice Get cash balance of this bToken in the underlying asset * @return The quantity of underlying asset owned by this contract
352
BToken
accrueInterest
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
/* Remember the initial block number */ uint currentBlockNumber = getBlockNumber(); uint accrualBlockNumberPrior = accrualBlockNumber; /* Short-circuit accumulating 0 interest */ if (accrualBlockNumberPrior == currentBlockNumber) { return uint(Error.NO_ERROR); ...
* * @notice Applies accrued interest to total borrows and reserves * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage.
352
BToken
mintInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0); } // mintFresh e...
* * @notice Sender supplies assets into the market and receives bTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, se...
352
BToken
mintFresh
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
/* Fail if mint not allowed */ uint allowed = bController.mintAllowed(address(this), minter, mintAmount); if (allowed != 0) { return (failOpaque(Error.BCONTROLLER_REJECTION, FailureInfo.MINT_BCONTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equ...
* * @notice User supplies assets into the market and receives bTokens in exchange * @dev Assumes interest has already been accrued up to the current block * @param minter The address of the account which is supplying the assets * @param mintAmount The amount of the underlying asset to supply * ...
352
BToken
redeemInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh em...
* * @notice Sender redeems bTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of bTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for detail...
352
BToken
redeemUnderlyingInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh em...
* * @notice Sender redeems bTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to receive from redeeming bTokens * @return uint 0=success, otherwise a failure (see...
352
BToken
redeemFresh
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
require(redeemTokensIn == 0 || redeemAmountIn == 0, "one of redeemTokensIn or redeemAmountIn must be zero"); RedeemLocalVars memory vars; /* exchangeRate = invoke Exchange Rate Stored() */ (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal(); if (vars.mathE...
* * @notice User redeems bTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block * @param redeemer The address of the account which is redeeming the tokens * @param redeemTokensIn The number of bTokens to redeem into underlying (only one ...
352
BToken
borrowInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED); } // borrowFresh em...
* * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BToken
borrowFresh
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
/* Fail if borrow not allowed */ uint allowed = bController.borrowAllowed(address(this), borrower, borrowAmount); if (allowed != 0) { return failOpaque(Error.BCONTROLLER_REJECTION, FailureInfo.BORROW_BCONTROLLER_REJECTION, allowed); } /* Verify market's block number...
* * @notice Users borrow assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BToken
repayBorrowInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0); } // rep...
* * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.
352
BToken
repayBorrowBehalfInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0); } // rep...
* * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.
352
BToken
repayBorrowFresh
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
/* Fail if repayBorrow not allowed */ uint allowed = bController.repayBorrowAllowed(address(this), payer, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.BCONTROLLER_REJECTION, FailureInfo.REPAY_BORROW_BCONTROLLER_REJECTION, allowed), 0); } /* V...
* * @notice Borrows are repaid by another user (possibly the borrower). * @param payer the account paying off the borrow * @param borrower the account with the debt being payed off * @param repayAmount the amount of undelrying tokens being returned * @return (uint, uint) An error code (0=succes...
352
BToken
liquidateBorrowInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0); } ...
* * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this bToken to be liquidated * @param bTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amou...
352
BToken
liquidateBorrowFresh
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
/* Fail if liquidate not allowed */ uint allowed = bController.liquidateBorrowAllowed(address(this), address(bTokenCollateral), liquidator, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.BCONTROLLER_REJECTION, FailureInfo.LIQUIDATE_BCONTROLLER_REJECTION, allowe...
* * @notice The liquidator liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this bToken to be liquidated * @param liquidator The address repaying the borrow and seizing collateral * @param bTokenCollateral The mark...
352
BToken
seize
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);
* * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Will fail unless called by another bToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed bToken and not a parameter. * @param liquidator The account receiving seized colla...
352
BToken
seizeInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
/* Fail if seize not allowed */ uint allowed = bController.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens); if (allowed != 0) { return failOpaque(Error.BCONTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_BCONTROLLER_REJECTION, allowed); } ...
* * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another BToken. * Its absolutely critical to use msg.sender as the seizer bToken and not a parameter. * @param seizerToken The c...
352
BToken
_setPendingAdmin
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
// Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value new...
** Admin Functions ** * * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. ...
352
BToken
_acceptAdmin
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
// Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin ...
* * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BToken
_setBController
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
// Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_BCONTROLLER_OWNER_CHECK); } BControllerInterface oldBController = bController; // Ensure invoke bController.isBController() returns true require(newBControlle...
* * @notice Sets a new bController for the market * @dev Admin function to set a new bController * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BToken
_setReserveFactor
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED)...
* * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh * @dev Admin function to accrue interest and set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BToken
_setReserveFactorFresh
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
// Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK); } // Verify market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error...
* * @notice Sets a new reserve factor for the protocol (*requires fresh interest accrual) * @dev Admin function to set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BToken
_addReservesInternal
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED); } ...
* * @notice Accrues interest and reduces reserves by transferring from msg.sender * @param addAmount Amount of addition to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BToken
_addReservesFresh
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
// totalReserves + actualAddAmount uint totalReservesNew; uint actualAddAmount; // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES...
* * @notice Add reserves by transferring from caller * @dev Requires fresh interest accrual * @param addAmount Amount of addition to reserves * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees
352
BToken
_reduceReserves
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED); ...
* * @notice Accrues interest and reduces reserves by transferring to admin * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BToken
_reduceReservesFresh
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
// totalReserves - reduceAmount uint totalReservesNew; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK); } // We fail gracefully unless market's block number equals current block nu...
* * @notice Reduces reserves by transferring to admin * @dev Requires fresh interest accrual * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BToken
_setInterestRateModel
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTE...
* * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh * @dev Admin function to accrue interest and update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorRepor...
352
BToken
_setInterestRateModelFresh
contract BToken is BTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate...
// Used to store old model for use in the event that is emitted on success InterestRateModel oldInterestRateModel; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK); } // We...
* * @notice updates the interest rate model (*requires fresh interest accrual) * @dev Admin function to update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BErc20
initialize
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
// BToken initialize does the bulk of the work super.initialize(bController_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_); // Set underlying and sanity check it underlying = underlying_; EIP20Interface(underlying).totalSupply();
* * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by...
352
BErc20
mint
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
(uint err,) = mintInternal(mintAmount); return err;
** User Interface ** * * @notice Sender supplies assets into the market and receives bTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return uint 0=success, otherwise a failure (see ...
352
BErc20
redeem
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
return redeemInternal(redeemTokens);
* * @notice Sender redeems bTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of bTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for detail...
352
BErc20
redeemUnderlying
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
return redeemUnderlyingInternal(redeemAmount);
* * @notice Sender redeems bTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to redeem * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for d...
352
BErc20
borrow
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
return borrowInternal(borrowAmount);
* * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BErc20
repayBorrow
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
(uint err,) = repayBorrowInternal(repayAmount); return err;
* * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BErc20
repayBorrowBehalf
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
(uint err,) = repayBorrowBehalfInternal(borrower, repayAmount); return err;
* * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BErc20
liquidateBorrow
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
(uint err,) = liquidateBorrowInternal(borrower, repayAmount, bTokenCollateral); return err;
* * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this bToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param bTokenCollateral The market in...
352
BErc20
_addReserves
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
return _addReservesInternal(addAmount);
* * @notice The sender adds to reserves. * @param addAmount The amount fo underlying token to add as reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
352
BErc20
getCashPrior
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
EIP20Interface token = EIP20Interface(underlying); return token.balanceOf(address(this));
** Safe Token ** * * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying tokens owned by this contract
352
BErc20
doTransferIn
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this)); token.transferFrom(from, address(this), amount); bool success; assembly { switch returndatasize() case ...
* * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case. * This will revert due to insufficient balance or insufficient allowance. * This function returns the actual amount received, * which may be less than `amount` if there i...
352
BErc20
doTransferOut
contract BErc20 is BToken, BErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param bController_ The address of the BController * @param interestRateModel_ The address of the interest rate model * @param initialExchang...
EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); token.transfer(to, amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) ...
* * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to * insufficient cash held in this contract. If caller has checked proto...
352
SimplePriceOracle
assetPrices
contract SimplePriceOracle is PriceOracle { address public admin; address public pendingAdmin; mapping(string => address) birdTokens; mapping(address => uint256) prices; event PricePosted( string symbol, address asset, uint256 previousPriceMantissa, uint256 requestedP...
return prices[asset];
v1 price oracle interface for use as backing of proxy
361
Pausable
freezeAccount
contract Pausable is Ownable{ event Pause(); event Unpause(); bool public paused = false; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); // freeze, unfreeze function freezeAccount(address target, bool freeze) onlyController public {<FIL...
frozenAccount[target] = freeze; emit FrozenFunds(target, freeze);
freeze, unfreeze
361
Pausable
isFrozenAccount
contract Pausable is Ownable{ event Pause(); event Unpause(); bool public paused = false; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); // freeze, unfreeze function freezeAccount(address target, bool freeze) onlyController public { ...
return frozenAccount[target];
need deploy
361
Pausable
pause
contract Pausable is Ownable{ event Pause(); event Unpause(); bool public paused = false; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); // freeze, unfreeze function freezeAccount(address target, bool freeze) onlyController public { ...
paused = true; emit Pause();
* * @dev called by the owner to pause, triggers stopped state
361
Pausable
unpause
contract Pausable is Ownable{ event Pause(); event Unpause(); bool public paused = false; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); // freeze, unfreeze function freezeAccount(address target, bool freeze) onlyController public { ...
paused = false; emit Unpause();
* * @dev called by the owner to unpause, returns to normal state
361
ERC20
totalSupply
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
return _totalSupply;
* * @dev Total number of tokens in existence
361
ERC20
balanceOf
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
return _balances[owner];
* * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address.
361
ERC20
allowance
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
require(!frozenAccount[msg.sender]); return _allowed[owner][spender];
* * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender.
361
ERC20
transfer
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
require(!frozenAccount[msg.sender]); _transfer(msg.sender, to, value); return true;
* * @dev Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred.
361
ERC20
approve
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
require(spender != address(0)); require(!frozenAccount[msg.sender]); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true;
* * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate thi...
361
ERC20
transferFrom
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
require(!frozenAccount[msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true;
* * @dev Transfer tokens from one address to another * @param from address The address which you want to send tokens from * @param to address The address which you want to transfer to * @param value uint256 the amount of tokens to be transferred
361
ERC20
increaseAllowance
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
require(spender != address(0)); require(!frozenAccount[msg.sender]); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true;
* * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol ...
361
ERC20
decreaseAllowance
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
require(spender != address(0)); require(!frozenAccount[msg.sender]); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true;
* * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol ...
361
ERC20
_transfer
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value);
* * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred.
361
ERC20
_mint
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value);
* * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param value The amount that will be c...
361
ERC20
_burn
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
require(account != address(0)); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value);
* * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param value The amount that will be burnt.
361
ERC20
_burnFrom
contract ERC20 is IERC20, Pausable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function ...
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( value); _burn(account, value);
* * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param value The amount that will be burnt.
361
ERC20Burnable
burn
contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function burn(uint256 value) public {<FILL_FUNCTION_BODY>} /** * @dev Burns a specific amount of tokens from the target address and decrements allo...
_burn(msg.sender, value);
* * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned.
361
ERC20Burnable
burnFrom
contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function burn(uint256 value) public { _burn(msg.sender, value); } /** * @dev Burns a specific amount of tokens from the target addres...
_burnFrom(from, value);
* * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned
361
ERC20Mintable
mint
contract ERC20Mintable is ERC20 { /** * @dev Function to mint tokens * @param to The address that will receive the minted tokens. * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address to, uint256 ...
_mint(to, value); return true;
* * @dev Function to mint tokens * @param to The address that will receive the minted tokens. * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful.