MintBUM

The mintBUM function mints and transfers BUM 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 bum limit.

BUMController

function mintBUM(uint mintBUMAmount) returns (uint)
  • msg.sender: The account to which minted bum shall be transferred.
  • mintBUMAmount: The amount of the BUM to be minted.
  • RETURN: on success, otherwise an Error code.

Solidity

BUMController bumController = BUMController(0xABCD...);
require(cToken.borrow(100) == 0, "got collateral and has bum mint rate?");

Web3 1.0

const bumController = BUMController.at(0xABCD...);
await bumController.methods.mintBUM(50).send({from: 0xMyAccount});

RepayBUM

The repay function transfers BUM into the protocol and burn, reducing the user's borrow balance.

BUMController

function repayBUM(uint repayBUMAmount) returns (uint)
  • msg.sender: The account which minted the BUM, and shall repay the BUM.
  • repayBUMAmount: The amount of the BUM to be repaid.
  • RETURN: on success, otherwise an Error code.

Before repaying an asset, users must first approve the BUM to access their BUM balance.

Solidity

BUMController bumController = BUMController(0xABCD...);
require(bumController.repayBUM.value(100)() == 0, "transfer approved?");

Web3 1.0

const bumController = BUMController.at(0xABCD...);
await bumController.methods.repayBUM(10000).send({from: 0xMyAccount});

LiquidateBUM

A user who has negative account liquidity is subject to liquidation by other users of the protocol to return his/her account liquidity back to positive (i.e. above the collateral requirement). When a liquidation occurs, a liquidator may repay some or all of an outstanding borrow on behalf of a borrower and in return receive a discounted amount of collateral held by the borrower; this discount is defined as the liquidation incentive.

A liquidator may close up to a certain fixed percentage (i.e. close factor) of any individual outstanding borrow of the underwater account. Liquidators must interact with BUMUnitroller contract in which they wish to repay BUM and seize another asset as collateral. When collateral is seized, the liquidator is transferred cTokens, which they may redeem the same as if they had supplied the asset themselves. Users must approve BUM contract before calling liquidateBUM, as they are transferring funds into the contract.

BUMController

function liquidateBUM(address borrower, uint amount, address collateral) returns (uint)
  • msg.sender: The account which shall liquidate the borrower by repaying their BUM and seizing their collateral.
  • borrower: The account with negative account liquidity that shall be liquidated.
  • amount: The amount of the minted BUM to be repaid and converted into collateral.
  • collateral: The address of the cToken currently held as collateral by a borrower, that the liquidator shall seize.
  • RETURN: on success, otherwise an Error code.

Before supplying BUM, users must first approve the BUMController to access their BUM balance.

Solidity

BUMController bumController = BUMController(0xABCD...);
VBep20 cTokenCollateral = VBep20(0xABCD...);
require(cToken.liquidateBUM(0xBorrower, 100, cTokenCollateral) == 0, "borrower underwater?");

Web3 1.0

const bumController = BUMController.at(0xABCD...);
const cTokenCollateral = CBep20.at(0xABCD...);
await bumController.methods.liquidateBUM(0xBorrower, 33, cTokenCollateral).send({from: 0xLiquidator});

Key Events

Event Description

MintBUM(address minter, uint mintBUMAmount)

Emitted upon a successful MintBUM.

RepayBUM(address payer, address borrower, uint repayAmount)

Emitted upon a successful RepayBUM.

LiquidateBUM(address liquidator, address borrower, uint repayAmount, address cTokenCollateral, uint seizeTokens)

Emitted upon a successful LiquidateBUM.

Error Codes

Code Name Description

0

NO_ERROR

Not a failure.

1

UNAUTHORIZED

The sender is not authorized to perform this action.

2

REJECTION

The action would violate the comptroller, bumController policy.

3

SNAPSHOT_ERROR

The comptroller could not get the account borrows and exchange rate from the market.

4

PRICE_ERROR

The comptroller could not obtain a required price of an asset.

5

MATH_ERROR

A math calculation error occurred.

6

INSUFFICIENT_BALANCE_FOR_BUM

Caller does not have sufficient balance to mint BUM.


                

Failure Info

Code Name

0

SET_PENDING_ADMIN_OWNER_CHECK

1

SET_PENDING_IMPLEMENTATION_OWNER_CHECK

2

SET_COMPTROLLER_OWNER_CHECK

3

ACCEPT_ADMIN_PENDING_ADMIN_CHECK

4

ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK

5

BUM_MINT_REJECTION

6

BUM_BURN_REJECTION

7

BUM_LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED

8

BUM_LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED

9

BUM_LIQUIDATE_COLLATERAL_FRESHNESS_CHECK

10

BUM_LIQUIDATE_COMPTROLLER_REJECTION

11

BUM_LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED

12

BUM_LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX

13

BUM_LIQUIDATE_CLOSE_AMOUNT_IS_ZERO

14

BUM_LIQUIDATE_FRESHNESS_CHECK

15

BUM_LIQUIDATE_LIQUIDATOR_IS_BORROWER

16

BUM_LIQUIDATE_REPAY_BORROW_FRESH_FAILED

17

BUM_LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED

18

BUM_LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED

19

BUM_LIQUIDATE_SEIZE_COMPTROLLER_REJECTION

20

BUM_LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER

21

BUM_LIQUIDATE_SEIZE_TOO_MUCH

22

MINT_FEE_CALCULATION_FAILED

23

SET_TREASURY_OWNER_CHECK