Cauldron V3
Last updated
Last updated
Third version of the cauldrons, implementing the following changes:
Dynamic Interest Rate
Borrow Limit (per user & global)
Liquidations emit an event
exchangeRate is automatically updated before solvency checks.
Functions starting with '✨' are new in V3.
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.
This will create the masterContract that will be used by all the clones (markets).
Parameter | Description |
---|---|
Accrues the interest on the borrowed tokens and handles the accumulation of fees.
Gets the exchange rate, ie how much collateral to buy 1e18 asset. Invoked if needed since Oracle queries can be expensive.
Returns
Adds share
amount of collateral from msg.sender
to the account to
.
Parameters
Calls _removeCollateral
, which removes the amount share
of collateral and transfers it to the account to
.
Parameters
Calls _borrow
, which allows the sender to borrow amount
and transfer to to
.
Parameters
Returns
Calls _repay
, which repays a loan.
Parameters
Returns
Allows MasterContractOwner to change the borrow limits of the cauldron, both globally and per user.
Parameters
Allows MasterContractOwner to change the interest rate of the Cauldron. The rate can only be change every 3 days The newInterestRate can't be bigger than 175% of the old rate (the rate can't increase by more than 75% at the time) If rate was 0%, the rate can be increased to 1%, the previous rule then applies.
Parameters
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 USE_VALUE1 (-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.
Available actions and their ID:
Parameters
Returns
Handles the liquidation of users' balances once the users' amount of collateral is too low.
Parameters
Withdraw the fees accumulated to the feeTo address.
Sets the beneficiary of fees accrued in liquidations. Can only be called by the owner of the contract.
Parameters
Reduces the supply of MIM
Parameters
Returns the opening fee (charged instantly, added to user debt upon borrowing) in Basis Points.
Returns the Collateralization Rate (maximum % borrowable with this collateral) in Basis Points. eg: 75000 = 75%
Returns the liquidation fee in Basis Points. eg: 112000 would add 12% (it's a multiplier, so the value is 112%)
Return values
Return values
Returns the current borrowLimit, expressed in borrowParts at the cauldron level and at the address level.
Return values
Return values
Return values
Return values
Return values
Return values
Return values
Return values
Return values
When transferring ownership, the future owner is pending until they claims ownership.
Return values
Returns the total amounts borrowed from the cauldron.
Return values
Returns the amount (in shares) of the token collateral
used as collateral in this cauldron.
Return values
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
Amount (in shares) of the token collateral
used as collateral by the user.
Parameters
Return values
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type |
---|---|
Name | Type | Description |
---|---|---|
Action Name | ID | parameter names | ABI encoding | returnValues |
---|---|---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|