Cauldron V1

The first version of the cauldron, not used in production anymore.

This is the first version of the Cauldron Contracts. It is deployed directly and then used as a masterContract to deploy each market, as clones, following the minimal proxy pattern.

You can find the full contract here.

constructor nonpayable (address)

This will create the masterContract that will be used by all the clones (markets).

Write Functions

accrue

function accrue() public

Accrues the interest on the borrowed tokens and handles the accumulation of fees.

updateExchangeRate

function updateExchangeRate() public returns (bool updated, uint256 rate)

Gets the exchange rate, ie how much collateral to buy 1e18 asset. Invoked if needed since Oracle queries can be expensive.

Returns

addCollateral

function addCollateral(
        address to,
        bool skim,
        uint256 share
    ) public

Adds share amount of collateral from msg.sender to the account to.

Parameters

removeCollateral

function removeCollateral(address to, uint256 share) public solvent

Calls _removeCollateral, which removes the amount share of collateral and transfers it to the account to.

Parameters

borrow

function borrow(address to, uint256 amount) public solvent returns (uint256 part, uint256 share)

Calls _borrow, which allows the sender to borrow amount and transfer to to.

Parameters

Returns

repay

function repay(
        address to,
        bool skim,
        uint256 part
    ) public returns (uint256 amount)

Calls _repay, which repays a loan.

Parameters

Returns

cook

function cook(
        uint8[] calldata actions,
        uint256[] calldata values,
        bytes[] calldata datas
    ) external payable returns (uint256 value1, uint256 value2)

Executes a set of actions and allows composability (contract calls) to other contracts.

The cook function allows to bundle functionality within one contract call while passing return values from one call to the next one. Actions are defined by a numeric identifier and can return two values, value1 and value2 to the next function. The input arrays actions, values and datas define the sequential actions. In the Value array the ether value of a call may be defined.

Whereas calling functions like borrow that have the solvent modifier requires solvency at the end of the function, solvency only needs to be guaranteed at the end of the cook function, thereby allowing more complicated operations such as leveraging within one call.

For certain parameters either an external value can be passed in or the identifier USEVALUE1 (-1) or USE_VALUE2 (-2) to access either of the local variables. The following variables are marked in bold italic in the table below. If an action returns one value it is saved as value1, if two are returned they are saved as value1 and value2 respectively. Any action can access these values during the whole duration of the cook call.

The call data for the actions is ABI encoded as listed below.

// Functions that need accrue to be called
uint8 internal constant ACTION_REPAY = 2;
uint8 internal constant ACTION_REMOVE_COLLATERAL = 4;
uint8 internal constant ACTION_BORROW = 5;
uint8 internal constant ACTION_GET_REPAY_SHARE = 6;
uint8 internal constant ACTION_GET_REPAY_PART = 7;
uint8 internal constant ACTION_ACCRUE = 8;

// Functions that don't need accrue to be called
uint8 internal constant ACTION_ADD_COLLATERAL = 10;
uint8 internal constant ACTION_UPDATE_EXCHANGE_RATE = 11;

// Function on BentoBox
uint8 internal constant ACTION_BENTO_DEPOSIT = 20;
uint8 internal constant ACTION_BENTO_WITHDRAW = 21;
uint8 internal constant ACTION_BENTO_TRANSFER = 22;
uint8 internal constant ACTION_BENTO_TRANSFER_MULTIPLE = 23;
uint8 internal constant ACTION_BENTO_SETAPPROVAL = 24;

// Any external call (except to BentoBox)
uint8 internal constant ACTION_CALL = 30;

int256 internal constant USE_VALUE1 = -1;
int256 internal constant USE_VALUE2 = -2;

Parameters

Returns

liquidate

function liquidate(
        address[] calldata users,
        uint256[] calldata maxBorrowParts,
        address to,
        ISwapper swapper,
    ) public

Handles the liquidation of users' balances once the users' amount of collateral is too low.

Parameters

withdrawFees

function withdrawFees() public

Withdraw the fees accumulated to the feeTo address.

setFeeTo

function setFeeTo(address newFeeTo) public onlyOwner

Sets the beneficiary of fees accrued in liquidations. Can only be called by the owner of the contract.

Parameters

reduceSupply

function reduceSupply(uint256 amount) public 

Reduces the supply of MIM

Parameters

View Functions

accrueInfo

Return values

bentoBox

Return values

collateral

Return values

exchangeRate

Return values

feeTo

Return values

magicInternetMoney

Return values

masterContract

Return values

oracle

Return values

oracleData

Return values

owner

Return values

pendingOwner

When transferring ownership, the future owner is pending until they claims ownership.

Return values

totalBorrow

Returns the total amounts borrowed from the cauldron.

Return values

totalCollateralShare

Returns the amount (in shares) of the token collateral used as collateral in this cauldron.

Return values

userBorrowPart

Returns the amount of borrowParts held by a user. To convert that amount into a numerical MIM debt amount, you must do totalBorrow.elastic / totalBorrow.base * borrowParts.

Parameters

Return values

userCollateralShare

Amount (in shares) of the token collateral used as collateral by the user.

Parameters

Return values

Last updated