Kashi Lending Pair (Market)

constructor nonpayable (address)

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

Parameter

Description

address bentoBox_

The address of the BentoBox

Events

Approval (address,address,uint256)

  • Parameters

  • address _owner

  • address _spender

  • uint256 _value

LogAccrue (uint256,uint256,uint64,uint256)

  • Parameters

  • uint256 accruedAmount

  • uint256 feeFraction

  • uint64 rate

  • uint256 utilization

LogAddAsset (address,address,uint256,uint256)

  • Parameters

  • address from

  • address to

  • uint256 share

  • uint256 fraction

LogAddCollateral (address,address,uint256)

  • Parameters

  • address from

  • address to

  • uint256 share

LogBorrow (address,address,uint256,uint256,uint256)

  • Parameters

  • address from

  • address to

  • uint256 amount

  • uint256 feeAmount

  • uint256 part

LogExchangeRate (uint256)

  • Parameters

  • uint256 rate

LogFeeTo (address)

  • Parameters

  • address newFeeTo

LogRemoveAsset (address,address,uint256,uint256)

  • Parameters

  • address from

  • address to

  • uint256 share

  • uint256 fraction

LogRemoveCollateral (address,address,uint256)

  • Parameters

  • address from

  • address to

  • uint256 share

LogRepay (address,address,uint256,uint256)

  • Parameters

  • address from

  • address to

  • uint256 amount

  • uint256 part

LogWithdrawFees (address,uint256)

  • Parameters

  • address feeTo

  • uint256 feesEarnedFraction

OwnershipTransferred (address,address)

  • Parameters

  • address previousOwner

  • address newOwner

Transfer (address,address,uint256)

  • Parameters

  • address _from

  • address _to

  • uint256 _value

Methods

accrue nonpayable ()

Accrues interest on call and updates the interest rate if the utilization falls out of the target window.

accrueInfo view ()

  • Return Values

  • uint64 interestPerSecond

  • uint64 lastAccrued

  • uint128 feesEarnedFraction

View function that returns the current interestPerSecond, the time at which accrue was last called and the feesEarnedFraction, the amount earned by the 10% cut in fees for xSUSHI holders that have not been claimed.

addAsset nonpayable (address,bool,uint256)

  • Parameters

  • address to

  • bool skim

  • uint256 share

  • Return Values

  • uint256 fraction

Allows a user to add funds from BentoBox or by transferring them to the contract and skimming. The user must have approved the master contract.

addCollateral nonpayable (address,bool,uint256)

  • Parameters

  • address to

  • bool skim

  • uint256 share

Allows a user to add collateral from BentoBox or by transferring them to the contract and skimming. The user must have approved the master contract.

asset view ()

  • Return Values

  • address _0

Returns the address of the asset.

bentoBox view ()

  • Return Values

  • address _0

Returns the address of BentoBox.

borrow nonpayable (address,uint256)

  • Parameters

  • address to

  • uint256 amount

  • Return Values

  • uint256 part Total part of the debt held by borrowers.

  • uint256 share Total amount in shares borrowed.

Allows to borrow a given amount if the user stays solvent. Sender borrows amount and transfers it to to.

collateral view ()

  • Return Values

  • address _0

Returns the address of the asset.

cook payable (uint8[],uint256[],bytes[])

  • Parameters

  • uint8[] actions

  • uint256[] values

  • bytes[] datas

  • Return Values

  • uint256 value1

  • uint256 value2

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.

Action Name

ID

parameter names

ABI encoding

returnValues

ACTION_ADD_ASSET

1

share, to, skim

int256, address, bool

fraction

ACTION_REPAY

2

share, to, skim

int256, address, bool

ACTION_REMOVE_ASSET

3

fraction, to

int256, address

share

ACTION_REMOVE_COLLATERAL

4

fraction, to

int256, address

ACTION_BORROW

5

amount, to

int256, address

part, share

ACTION_GET_REPAY_SHARE

6

part

int256

ACTION_GET_REPAY_PART

7

amount

int256

ACTION_ACCRUE

8

ACTION_ADD_COLLATERAL

10

share, to, skim

int256, address, bool

ACTION_UPDATE_EXCHANGE_RATE

11

must_update, minRate, maxRate

bool, uint256, uint256

ACTION_BENTO_DEPOSIT

20

token, to, amount, share

IERC20, address, int256, int256

amountOut, shareOut

ACTION_BENTO_WITHDRAW

21

token, to, amount, share

IERC20, address, int256, int256

amountOut, shareOut

ACTION_BENTO_TRANSFER

22

token, to, share

IERC20, address, int256

ACTION_BENTO_TRANSFER_MULTIPLE

23

token, tos, shares

IERC20, address[], uint256[]

ACTION_BENTO_SETAPPROVAL

24

user, _masterContract, approved, v, r, s

address, address, bool, uint8, bytes32, bytes32

ACTION_CALL

30

callee, callData, useValue1, useValue2, returnValues

address, bytes, bool, bool, uint8

The ACTION_CALL is a special action that allows an arbitrary contract call against any contract except itself and the BentoBox. The parameters useValue1 and useValue2 determine whether the internal values value1 and value2 are converted to a uint256 are appended to the callData byte string. The action call can also return can return up to two values that are saved as value1 and value2 if returnValues==2 or one value that is saved as value1 if returnValues==1.

exchangeRate view ()

  • Return Values

  • uint256 _0

Returns the exchangeRate currently saved for this pair.

feeTo view ()

  • Return Values

  • address _0

Returns the address of the fee recipient.

init payable (bytes)

  • Parameters

  • bytes data

Allows the initialization of a lending pair clone, this function is called upon clone creation by the BentoBox Factory. The data is ABI encoded as (IERC20, IERC20, IOracle, bytes) and consists of collateral, asset, oracle and oracleData.

liquidate nonpayable (address[],uint256[],address,address,bool)

  • Parameters

  • address[] users An array of user addresses.

  • uint256[] maxBorrowParts A one-to-one mapping to users, contains maximum (partial) borrow amounts (to liquidate) of the respective user.

  • address to Address of the receiver in open liquidations if swapper is zero.

  • address swapper Contract address of the ISwapper implementation. Swappers are restricted for closed liquidations. See setSwapper.

  • bool open True to perform a open liquidation else False.

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

In a closed liquidation, the SushiSwap swapper is called and proceeds go to xSushi holders. In the case of open liquidations, either a swapper of the users choice can be called that conforms to the ISwapper interface, or a flash liquidation can be possible in which the caller provides the borrowed asset and receives the collateral.

masterContract view ()

  • Return Values

  • address _0

oracle view ()

  • Return Values

  • address _0

oracleData view ()

  • Return Values

  • bytes _0

removeAsset nonpayable (address,uint256)

  • Parameters

  • address to

  • uint256 fraction

  • Return Values

  • uint256 share

removeCollateral nonpayable (address,uint256)

  • Parameters

  • address to

  • uint256 share

repay nonpayable (address,bool,uint256)

  • Parameters

  • address to Address of the user this payment should go.

  • bool skim True if the amount should be skimmed from the deposit balance of msg.sender. False if tokens from msg.sender in bentoBox should be transferred.

  • uint256 part The amount to repay. See userBorrowPart.

  • Return Values

  • uint256 amount The total amount repayed.

Repays a loan.

setFeeTo nonpayable (address)

  • Parameters

  • address newFeeTo The address of the receiver.

Sets the beneficiary of fees accrued in liquidations.

setSwapper nonpayable (address,bool)

  • Parameters

  • address swapper The address of the swapper contract that conforms to ISwapper.

  • bool enable True to enable the swapper. To disable use False.

Used to register and enable or disable swapper contracts used in closed liquidations.

swappers view (address)

  • Parameters

  • address _0

  • Return Values

  • bool _0

View function to get approved swappers.

totalAsset view ()

  • Return Values

  • uint128 elastic

  • uint128 base

elastic = BentoBox shares held by the KashiPair, base = Total fractions held by asset suppliers

totalBorrow view ()

  • Return Values

  • uint128 elastic

  • uint128 base

elastic = Total token amount to be repayed by borrowers, base = Total parts of the debt held by borrowers

totalCollateralShare view ()

  • Return Values

  • uint256 _0

updateExchangeRate nonpayable ()

  • Return Values

  • bool updated True if exchangeRate was updated.

  • uint256 rate The new exchange rate.

Gets the exchange rate. I.e how much collateral to buy 1e18 asset. This function is supposed to be invoked if needed because Oracle queries can be expensive.

userBorrowPart view (address)

  • Parameters

  • address _0

  • Return Values

  • uint256 _0

userCollateralShare view (address)

  • Parameters

  • address _0

  • Return Values

  • uint256 _0

withdrawFees nonpayable ()

Withdraws the fees accumulated.

ERC20 Functionality

allowance view (address,address)

  • Parameters

  • address _0

  • address _1

  • Return Values

  • uint256 _0

approve nonpayable (address,uint256)

  • Parameters

  • address spender

  • uint256 amount

  • Return Values

  • bool _0

balanceOf view (address)

  • Parameters

  • address _0

  • Return Values

  • uint256 _0

Returns the amount of fractions hold for an address. userAssetFraction is called balanceOf for ERC20 compatibility

decimals view ()

  • Return Values

  • uint8 _0

DOMAIN_SEPARATOR view ()

  • Return Values

  • bytes32 _0

name view ()

  • Return Values

  • string _0

nonces view (address)

  • Parameters

  • address _0

  • Return Values

  • uint256 _0

permit nonpayable (address,address,uint256,uint256,uint8,bytes32,bytes32)

  • Parameters

  • address owner_

  • address spender

  • uint256 value

  • uint256 deadline

  • uint8 v

  • bytes32 r

  • bytes32 s

symbol view ()

  • Return Values

  • string _0

Returns the symbol, composed from the symbols of asset, collateral and Oracle.

totalSupply view ()

  • Return Values

  • uint256 _0

Returns the total amount of asset fractions.

transfer nonpayable (address,uint256)

  • Parameters

  • address to

  • uint256 amount

  • Return Values

  • bool _0

transferFrom nonpayable (address,address,uint256)

  • Parameters

  • address from

  • address to

  • uint256 amount

  • Return Values

  • bool _0

BoringOwnable

claimOwnership nonpayable ()

Allows a new owner to accept ownership over the vault.

owner view ()

  • Return Values

  • address _0

Returns the owner of the contract.

transferOwnership nonpayable (address,bool,bool)

  • Parameters

  • address newOwner

  • bool direct

  • bool renounce

pendingOwner view ()

  • Return Values

  • address _0