Address Contract Verified
Address
0xeDc614E4e9A173Fb72e21b1814AC068A458C64e7
Balance
0 ETH
Nonce
1
Code Size
2704 bytes
Creator
0x868964fa...f479 at tx 0xdb856eba...997cba
Indexed Transactions
0
Contract Bytecode
2704 bytes
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806380031e371161008c578063a15f30ac11610066578063a15f30ac14610185578063b25895441461018e578063c72c4d1014610196578063f2fde38b146101a957600080fd5b806380031e371461014557806381c8c9721461014d5780638da5cb5b1461016057600080fd5b806317319873146100d45780633b458c01146100f057806365614f81146101055780636ee082ca1461010d578063715018a6146101355780637b832f581461013d575b600080fd5b6100dd60035481565b6040519081526020015b60405180910390f35b6101036100fe36600461091d565b6101bc565b005b6006546100dd565b61012061011b3660046108cd565b61021c565b604080519283526020830191909152016100e7565b610103610363565b6005546100dd565b6100dd610399565b61012061015b366004610879565b6103bd565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100e7565b6100dd60025481565b6004546100dd565b60015461016d906001600160a01b031681565b6101036101b736600461085f565b610473565b6000546001600160a01b031633146101ef5760405162461bcd60e51b81526004016101e6906109a1565b60405180910390fd5b600284905561020a846b033b2e3c9fd0803ce8000000610a2d565b60035560049290925560055560065550565b60008061024a6040518060800160405280600081526020016000815260200160008152602001600081525090565b8481526000602082018190526040820152841561027e5780516102799061027190886109d6565b82519061051e565b610281565b60005b6060820181905260025410156102e65760006102b160035460025484606001516102ab9190610a2d565b9061051e565b6006549091506102c19082610600565b6005546004546102d191906109d6565b6102db91906109d6565b602083015250610318565b6103056002546102ab600554846060015161060090919063ffffffff16565b60045461031291906109d6565b60208201525b61034961032785612710610a2d565b610343836060015161033d8986602001516106c3565b90610600565b90610705565b604082018190526020909101519097909650945050505050565b6000546001600160a01b0316331461038d5760405162461bcd60e51b81526004016101e6906109a1565b610397600061078f565b565b60006006546005546004546103ae91906109d6565b6103b891906109d6565b905090565b6040516370a0823160e01b81526001600160a01b03868116600483015260009182918291908a16906370a082319060240160206040518083038186803b15801561040657600080fd5b505afa15801561041a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043e9190610905565b90508561044b88836109d6565b6104559190610a2d565b90506104638982878761021c565b9250925050965096945050505050565b6000546001600160a01b0316331461049d5760405162461bcd60e51b81526004016101e6906109a1565b6001600160a01b0381166105025760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101e6565b61050b8161078f565b50565b6b033b2e3c9fd0803ce800000090565b60408051808201909152600381526219181960e91b6020820152600090826105595760405162461bcd60e51b81526004016101e6919061094e565b5060006105676002846109ee565b90506b033b2e3c9fd0803ce800000061058282600019610a2d565b61058c91906109ee565b8411156040518060400160405280600381526020016203230360ec1b815250906105c95760405162461bcd60e51b81526004016101e6919061094e565b5082816105e26b033b2e3c9fd0803ce800000087610a0e565b6105ec91906109d6565b6105f691906109ee565b9150505b92915050565b600082158061060d575081155b1561061a575060006105fa565b8161063260026b033b2e3c9fd0803ce80000006109ee565b61063e90600019610a2d565b61064891906109ee565b8311156040518060400160405280600381526020016203230360ec1b815250906106855760405162461bcd60e51b81526004016101e6919061094e565b506b033b2e3c9fd0803ce800000061069e6002826109ee565b6106a88486610a0e565b6106b291906109d6565b6106bc91906109ee565b9392505050565b600082806106d55760009150506105fa565b60006106e48461033d876107df565b905060006106fb6106f4846107df565b839061051e565b9695505050505050565b6000821580610712575081155b1561071f575060006105fa565b8161072d60026127106109ee565b61073990600019610a2d565b61074391906109ee565b8311156040518060400160405280600381526020016203230360ec1b815250906107805760405162461bcd60e51b81526004016101e6919061094e565b5061271061069e6002826109ee565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806107f0633b9aca0084610a0e565b905082610801633b9aca00836109ee565b146040518060400160405280600381526020016203230360ec1b8152509061083c5760405162461bcd60e51b81526004016101e6919061094e565b5092915050565b80356001600160a01b038116811461085a57600080fd5b919050565b600060208284031215610870578081fd5b6106bc82610843565b60008060008060008060c08789031215610891578182fd5b61089a87610843565b95506108a860208801610843565b95989597505050506040840135936060810135936080820135935060a0909101359150565b600080600080608085870312156108e2578384fd5b6108eb85610843565b966020860135965060408601359560600135945092505050565b600060208284031215610916578081fd5b5051919050565b60008060008060808587031215610932578384fd5b5050823594602084013594506040840135936060013592509050565b6000602080835283518082850152825b8181101561097a5785810183015185820160400152820161095e565b8181111561098b5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082198211156109e9576109e9610a44565b500190565b600082610a0957634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615610a2857610a28610a44565b500290565b600082821015610a3f57610a3f610a44565b500390565b634e487b7160e01b600052601160045260246000fdfea264697066735822122038385a3171da20e5f8ccca3992899921108a2da0359fbc6f9a2bef85ab9cf77464736f6c63430008040033
Verified Source Code Full Match
Compiler: v0.8.4+commit.c7e474f2
EVM: istanbul
Optimization: Yes (200 runs)
InterestRate.sol 192 lines
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;
import {IInterestRate} from "../interfaces/IInterestRate.sol";
import {ILendPoolAddressesProvider} from "../interfaces/ILendPoolAddressesProvider.sol";
import {WadRayMath} from "../libraries/math/WadRayMath.sol";
import {PercentageMath} from "../libraries/math/PercentageMath.sol";
import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title InterestRate contract
* @notice Implements the calculation of the interest rates depending on the reserve state
* @dev The model of interest rate is based on 2 slopes, one before the `OPTIMAL_UTILIZATION_RATE`
* point of utilization and another from that one to 100%
* @author Bend
**/
contract InterestRate is IInterestRate, Ownable {
using WadRayMath for uint256;
using PercentageMath for uint256;
ILendPoolAddressesProvider public addressesProvider;
/**
* @dev this constant represents the utilization rate at which the pool aims to obtain most competitive borrow rates.
* Expressed in ray
**/
uint256 public OPTIMAL_UTILIZATION_RATE;
/**
* @dev This constant represents the excess utilization rate above the optimal. It's always equal to
* 1-optimal utilization rate. Added as a constant here for gas optimizations.
* Expressed in ray
**/
uint256 public EXCESS_UTILIZATION_RATE;
// Base variable borrow rate when Utilization rate = 0. Expressed in ray
uint256 internal _baseVariableBorrowRate;
// Slope of the variable interest curve when utilization rate > 0 and <= OPTIMAL_UTILIZATION_RATE. Expressed in ray
uint256 internal _variableRateSlope1;
// Slope of the variable interest curve when utilization rate > OPTIMAL_UTILIZATION_RATE. Expressed in ray
uint256 internal _variableRateSlope2;
constructor(
ILendPoolAddressesProvider provider,
uint256 optimalUtilizationRate_,
uint256 baseVariableBorrowRate_,
uint256 variableRateSlope1_,
uint256 variableRateSlope2_
) Ownable() {
addressesProvider = provider;
OPTIMAL_UTILIZATION_RATE = optimalUtilizationRate_;
EXCESS_UTILIZATION_RATE = WadRayMath.ray() - (optimalUtilizationRate_);
_baseVariableBorrowRate = baseVariableBorrowRate_;
_variableRateSlope1 = variableRateSlope1_;
_variableRateSlope2 = variableRateSlope2_;
}
function setInterestRateParams(
uint256 optimalUtilizationRate_,
uint256 baseVariableBorrowRate_,
uint256 variableRateSlope1_,
uint256 variableRateSlope2_
) public onlyOwner {
OPTIMAL_UTILIZATION_RATE = optimalUtilizationRate_;
EXCESS_UTILIZATION_RATE = WadRayMath.ray() - (optimalUtilizationRate_);
_baseVariableBorrowRate = baseVariableBorrowRate_;
_variableRateSlope1 = variableRateSlope1_;
_variableRateSlope2 = variableRateSlope2_;
}
function variableRateSlope1() external view returns (uint256) {
return _variableRateSlope1;
}
function variableRateSlope2() external view returns (uint256) {
return _variableRateSlope2;
}
function baseVariableBorrowRate() external view override returns (uint256) {
return _baseVariableBorrowRate;
}
function getMaxVariableBorrowRate() external view override returns (uint256) {
return _baseVariableBorrowRate + (_variableRateSlope1) + (_variableRateSlope2);
}
/**
* @dev Calculates the interest rates depending on the reserve's state and configurations
* @param reserve The address of the reserve
* @param liquidityAdded The liquidity added during the operation
* @param liquidityTaken The liquidity taken during the operation
* @param totalVariableDebt The total borrowed from the reserve at a variable rate
* @param reserveFactor The reserve portion of the interest that goes to the treasury of the market
* @return The liquidity rate, the stable borrow rate and the variable borrow rate
**/
function calculateInterestRates(
address reserve,
address bToken,
uint256 liquidityAdded,
uint256 liquidityTaken,
uint256 totalVariableDebt,
uint256 reserveFactor
) external view override returns (uint256, uint256) {
uint256 availableLiquidity = IERC20Upgradeable(reserve).balanceOf(bToken);
//avoid stack too deep
availableLiquidity = availableLiquidity + (liquidityAdded) - (liquidityTaken);
return calculateInterestRates(reserve, availableLiquidity, totalVariableDebt, reserveFactor);
}
struct CalcInterestRatesLocalVars {
uint256 totalDebt;
uint256 currentVariableBorrowRate;
uint256 currentLiquidityRate;
uint256 utilizationRate;
}
/**
* @dev Calculates the interest rates depending on the reserve's state and configurations.
* NOTE This function is kept for compatibility with the previous DefaultInterestRateStrategy interface.
* New protocol implementation uses the new calculateInterestRates() interface
* @param reserve The address of the reserve
* @param availableLiquidity The liquidity available in the corresponding bToken
* @param totalVariableDebt The total borrowed from the reserve at a variable rate
* @param reserveFactor The reserve portion of the interest that goes to the treasury of the market
* @return The liquidity rate and the variable borrow rate
**/
function calculateInterestRates(
address reserve,
uint256 availableLiquidity,
uint256 totalVariableDebt,
uint256 reserveFactor
) public view override returns (uint256, uint256) {
reserve;
CalcInterestRatesLocalVars memory vars;
vars.totalDebt = totalVariableDebt;
vars.currentVariableBorrowRate = 0;
vars.currentLiquidityRate = 0;
vars.utilizationRate = vars.totalDebt == 0 ? 0 : vars.totalDebt.rayDiv(availableLiquidity + (vars.totalDebt));
if (vars.utilizationRate > OPTIMAL_UTILIZATION_RATE) {
uint256 excessUtilizationRateRatio = (vars.utilizationRate - (OPTIMAL_UTILIZATION_RATE)).rayDiv(
EXCESS_UTILIZATION_RATE
);
vars.currentVariableBorrowRate =
_baseVariableBorrowRate +
(_variableRateSlope1) +
(_variableRateSlope2.rayMul(excessUtilizationRateRatio));
} else {
vars.currentVariableBorrowRate =
_baseVariableBorrowRate +
(vars.utilizationRate.rayMul(_variableRateSlope1).rayDiv(OPTIMAL_UTILIZATION_RATE));
}
vars.currentLiquidityRate = _getOverallBorrowRate(totalVariableDebt, vars.currentVariableBorrowRate)
.rayMul(vars.utilizationRate)
.percentMul(PercentageMath.PERCENTAGE_FACTOR - (reserveFactor));
return (vars.currentLiquidityRate, vars.currentVariableBorrowRate);
}
/**
* @dev Calculates the overall borrow rate as the weighted average between the total variable debt and total stable debt
* @param totalVariableDebt The total borrowed from the reserve at a variable rate
* @param currentVariableBorrowRate The current variable borrow rate of the reserve
* @return The weighted averaged borrow rate
**/
function _getOverallBorrowRate(uint256 totalVariableDebt, uint256 currentVariableBorrowRate)
internal
pure
returns (uint256)
{
uint256 totalDebt = totalVariableDebt;
if (totalDebt == 0) return 0;
uint256 weightedVariableRate = totalVariableDebt.wadToRay().rayMul(currentVariableBorrowRate);
uint256 overallBorrowRate = weightedVariableRate.rayDiv(totalDebt.wadToRay());
return overallBorrowRate;
}
}
IInterestRate.sol 29 lines
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;
/**
* @title IInterestRate interface
* @dev Interface for the calculation of the interest rates
* @author Bend
*/
interface IInterestRate {
function baseVariableBorrowRate() external view returns (uint256);
function getMaxVariableBorrowRate() external view returns (uint256);
function calculateInterestRates(
address reserve,
uint256 availableLiquidity,
uint256 totalVariableDebt,
uint256 reserveFactor
) external view returns (uint256, uint256);
function calculateInterestRates(
address reserve,
address bToken,
uint256 liquidityAdded,
uint256 liquidityTaken,
uint256 totalVariableDebt,
uint256 reserveFactor
) external view returns (uint256 liquidityRate, uint256 variableBorrowRate);
}
ILendPoolAddressesProvider.sol 89 lines
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;
/**
* @title LendPoolAddressesProvider contract
* @dev Main registry of addresses part of or connected to the protocol, including permissioned roles
* - Acting also as factory of proxies and admin of those, so with right to change its implementations
* - Owned by the Bend Governance
* @author Bend
**/
interface ILendPoolAddressesProvider {
event MarketIdSet(string newMarketId);
event LendPoolUpdated(address indexed newAddress, bytes encodedCallData);
event ConfigurationAdminUpdated(address indexed newAddress);
event EmergencyAdminUpdated(address indexed newAddress);
event LendPoolConfiguratorUpdated(address indexed newAddress, bytes encodedCallData);
event ReserveOracleUpdated(address indexed newAddress);
event NftOracleUpdated(address indexed newAddress);
event LendPoolLoanUpdated(address indexed newAddress, bytes encodedCallData);
event ProxyCreated(bytes32 id, address indexed newAddress);
event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy, bytes encodedCallData);
event BNFTRegistryUpdated(address indexed newAddress);
event IncentivesControllerUpdated(address indexed newAddress);
event UIDataProviderUpdated(address indexed newAddress);
event BendDataProviderUpdated(address indexed newAddress);
event WalletBalanceProviderUpdated(address indexed newAddress);
function getMarketId() external view returns (string memory);
function setMarketId(string calldata marketId) external;
function setAddress(bytes32 id, address newAddress) external;
function setAddressAsProxy(
bytes32 id,
address impl,
bytes memory encodedCallData
) external;
function getAddress(bytes32 id) external view returns (address);
function getLendPool() external view returns (address);
function setLendPoolImpl(address pool, bytes memory encodedCallData) external;
function getLendPoolConfigurator() external view returns (address);
function setLendPoolConfiguratorImpl(address configurator, bytes memory encodedCallData) external;
function getPoolAdmin() external view returns (address);
function setPoolAdmin(address admin) external;
function getEmergencyAdmin() external view returns (address);
function setEmergencyAdmin(address admin) external;
function getReserveOracle() external view returns (address);
function setReserveOracle(address reserveOracle) external;
function getNFTOracle() external view returns (address);
function setNFTOracle(address nftOracle) external;
function getLendPoolLoan() external view returns (address);
function setLendPoolLoanImpl(address loan, bytes memory encodedCallData) external;
function getBNFTRegistry() external view returns (address);
function setBNFTRegistry(address factory) external;
function getIncentivesController() external view returns (address);
function setIncentivesController(address controller) external;
function getUIDataProvider() external view returns (address);
function setUIDataProvider(address provider) external;
function getBendDataProvider() external view returns (address);
function setBendDataProvider(address provider) external;
function getWalletBalanceProvider() external view returns (address);
function setWalletBalanceProvider(address provider) external;
}
WadRayMath.sol 135 lines
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;
import {Errors} from "../helpers/Errors.sol";
/**
* @title WadRayMath library
* @author Bend
* @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)
**/
library WadRayMath {
uint256 internal constant WAD = 1e18;
uint256 internal constant HALF_WAD = WAD / 2;
uint256 internal constant RAY = 1e27;
uint256 internal constant HALF_RAY = RAY / 2;
uint256 internal constant WAD_RAY_RATIO = 1e9;
/**
* @return One ray, 1e27
**/
function ray() internal pure returns (uint256) {
return RAY;
}
/**
* @return One wad, 1e18
**/
function wad() internal pure returns (uint256) {
return WAD;
}
/**
* @return Half ray, 1e27/2
**/
function halfRay() internal pure returns (uint256) {
return HALF_RAY;
}
/**
* @return Half ray, 1e18/2
**/
function halfWad() internal pure returns (uint256) {
return HALF_WAD;
}
/**
* @dev Multiplies two wad, rounding half up to the nearest wad
* @param a Wad
* @param b Wad
* @return The result of a*b, in wad
**/
function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0 || b == 0) {
return 0;
}
require(a <= (type(uint256).max - HALF_WAD) / b, Errors.MATH_MULTIPLICATION_OVERFLOW);
return (a * b + HALF_WAD) / WAD;
}
/**
* @dev Divides two wad, rounding half up to the nearest wad
* @param a Wad
* @param b Wad
* @return The result of a/b, in wad
**/
function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, Errors.MATH_DIVISION_BY_ZERO);
uint256 halfB = b / 2;
require(a <= (type(uint256).max - halfB) / WAD, Errors.MATH_MULTIPLICATION_OVERFLOW);
return (a * WAD + halfB) / b;
}
/**
* @dev Multiplies two ray, rounding half up to the nearest ray
* @param a Ray
* @param b Ray
* @return The result of a*b, in ray
**/
function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0 || b == 0) {
return 0;
}
require(a <= (type(uint256).max - HALF_RAY) / b, Errors.MATH_MULTIPLICATION_OVERFLOW);
return (a * b + HALF_RAY) / RAY;
}
/**
* @dev Divides two ray, rounding half up to the nearest ray
* @param a Ray
* @param b Ray
* @return The result of a/b, in ray
**/
function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, Errors.MATH_DIVISION_BY_ZERO);
uint256 halfB = b / 2;
require(a <= (type(uint256).max - halfB) / RAY, Errors.MATH_MULTIPLICATION_OVERFLOW);
return (a * RAY + halfB) / b;
}
/**
* @dev Casts ray down to wad
* @param a Ray
* @return a casted to wad, rounded half up to the nearest wad
**/
function rayToWad(uint256 a) internal pure returns (uint256) {
uint256 halfRatio = WAD_RAY_RATIO / 2;
uint256 result = halfRatio + a;
require(result >= halfRatio, Errors.MATH_ADDITION_OVERFLOW);
return result / WAD_RAY_RATIO;
}
/**
* @dev Converts wad up to ray
* @param a Wad
* @return a converted in ray
**/
function wadToRay(uint256 a) internal pure returns (uint256) {
uint256 result = a * WAD_RAY_RATIO;
require(result / WAD_RAY_RATIO == a, Errors.MATH_MULTIPLICATION_OVERFLOW);
return result;
}
}
PercentageMath.sol 52 lines
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;
import {Errors} from "../helpers/Errors.sol";
/**
* @title PercentageMath library
* @author Bend
* @notice Provides functions to perform percentage calculations
* @dev Percentages are defined by default with 2 decimals of precision (100.00). The precision is indicated by PERCENTAGE_FACTOR
* @dev Operations are rounded half up
**/
library PercentageMath {
uint256 constant PERCENTAGE_FACTOR = 1e4; //percentage plus two decimals
uint256 constant HALF_PERCENT = PERCENTAGE_FACTOR / 2;
uint256 constant ONE_PERCENT = 1e2; //100, 1%
uint256 constant TEN_PERCENT = 1e3; //1000, 10%
uint256 constant ONE_THOUSANDTH_PERCENT = 1e1; //10, 0.1%
uint256 constant ONE_TEN_THOUSANDTH_PERCENT = 1; //1, 0.01%
/**
* @dev Executes a percentage multiplication
* @param value The value of which the percentage needs to be calculated
* @param percentage The percentage of the value to be calculated
* @return The percentage of value
**/
function percentMul(uint256 value, uint256 percentage) internal pure returns (uint256) {
if (value == 0 || percentage == 0) {
return 0;
}
require(value <= (type(uint256).max - HALF_PERCENT) / percentage, Errors.MATH_MULTIPLICATION_OVERFLOW);
return (value * percentage + HALF_PERCENT) / PERCENTAGE_FACTOR;
}
/**
* @dev Executes a percentage division
* @param value The value of which the percentage needs to be calculated
* @param percentage The percentage of the value to be calculated
* @return The value divided the percentage
**/
function percentDiv(uint256 value, uint256 percentage) internal pure returns (uint256) {
require(percentage != 0, Errors.MATH_DIVISION_BY_ZERO);
uint256 halfPercentage = percentage / 2;
require(value <= (type(uint256).max - halfPercentage) / PERCENTAGE_FACTOR, Errors.MATH_MULTIPLICATION_OVERFLOW);
return (value * PERCENTAGE_FACTOR + halfPercentage) / percentage;
}
}
IERC20Upgradeable.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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 this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Errors.sol 130 lines
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;
/**
* @title Errors library
* @author Bend
* @notice Defines the error messages emitted by the different contracts of the Bend protocol
*/
library Errors {
enum ReturnCode {
SUCCESS,
FAILED
}
string public constant SUCCESS = "0";
//common errors
string public constant CALLER_NOT_POOL_ADMIN = "100"; // 'The caller must be the pool admin'
string public constant CALLER_NOT_ADDRESS_PROVIDER = "101";
string public constant INVALID_FROM_BALANCE_AFTER_TRANSFER = "102";
string public constant INVALID_TO_BALANCE_AFTER_TRANSFER = "103";
string public constant CALLER_NOT_ONBEHALFOF_OR_IN_WHITELIST = "104";
string public constant CALLER_NOT_RISK_ADMIN = "105";
string public constant CALLER_NOT_RISK_OR_POOL_ADMIN = "106";
//math library erros
string public constant MATH_MULTIPLICATION_OVERFLOW = "200";
string public constant MATH_ADDITION_OVERFLOW = "201";
string public constant MATH_DIVISION_BY_ZERO = "202";
string public constant MATH_NUMBER_OVERFLOW = "203";
//validation & check errors
string public constant VL_INVALID_AMOUNT = "301"; // 'Amount must be greater than 0'
string public constant VL_NO_ACTIVE_RESERVE = "302"; // 'Action requires an active reserve'
string public constant VL_RESERVE_FROZEN = "303"; // 'Action cannot be performed because the reserve is frozen'
string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = "304"; // 'User cannot withdraw more than the available balance'
string public constant VL_BORROWING_NOT_ENABLED = "305"; // 'Borrowing is not enabled'
string public constant VL_COLLATERAL_BALANCE_IS_0 = "306"; // 'The collateral balance is 0'
string public constant VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = "307"; // 'Health factor is lesser than the liquidation threshold'
string public constant VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = "308"; // 'There is not enough collateral to cover a new borrow'
string public constant VL_NO_DEBT_OF_SELECTED_TYPE = "309"; // 'There's no debt need to repay'
string public constant VL_NO_ACTIVE_NFT = "310";
string public constant VL_NFT_FROZEN = "311";
string public constant VL_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = "312"; // 'User did not borrow the specified currency'
string public constant VL_INVALID_HEALTH_FACTOR = "313";
string public constant VL_INVALID_ONBEHALFOF_ADDRESS = "314";
string public constant VL_INVALID_TARGET_ADDRESS = "315";
string public constant VL_INVALID_RESERVE_ADDRESS = "316";
string public constant VL_SPECIFIED_LOAN_NOT_BORROWED_BY_USER = "317";
string public constant VL_SPECIFIED_RESERVE_NOT_BORROWED_BY_USER = "318";
string public constant VL_HEALTH_FACTOR_HIGHER_THAN_LIQUIDATION_THRESHOLD = "319";
//lend pool errors
string public constant LP_CALLER_NOT_LEND_POOL_CONFIGURATOR = "400"; // 'The caller of the function is not the lending pool configurator'
string public constant LP_IS_PAUSED = "401"; // 'Pool is paused'
string public constant LP_NO_MORE_RESERVES_ALLOWED = "402";
string public constant LP_NOT_CONTRACT = "403";
string public constant LP_BORROW_NOT_EXCEED_LIQUIDATION_THRESHOLD = "404";
string public constant LP_BORROW_IS_EXCEED_LIQUIDATION_PRICE = "405";
string public constant LP_NO_MORE_NFTS_ALLOWED = "406";
string public constant LP_INVALIED_USER_NFT_AMOUNT = "407";
string public constant LP_INCONSISTENT_PARAMS = "408";
string public constant LP_NFT_IS_NOT_USED_AS_COLLATERAL = "409";
string public constant LP_CALLER_MUST_BE_AN_BTOKEN = "410";
string public constant LP_INVALIED_NFT_AMOUNT = "411";
string public constant LP_NFT_HAS_USED_AS_COLLATERAL = "412";
string public constant LP_DELEGATE_CALL_FAILED = "413";
string public constant LP_AMOUNT_LESS_THAN_EXTRA_DEBT = "414";
string public constant LP_AMOUNT_LESS_THAN_REDEEM_THRESHOLD = "415";
string public constant LP_AMOUNT_GREATER_THAN_MAX_REPAY = "416";
string public constant LP_NFT_TOKEN_ID_EXCEED_MAX_LIMIT = "417";
string public constant LP_NFT_SUPPLY_NUM_EXCEED_MAX_LIMIT = "418";
string public constant LP_CALLER_NOT_VALID_INTERCEPTOR = "419";
string public constant LP_CALLER_NOT_VALID_LOCKER = "420";
//lend pool loan errors
string public constant LPL_INVALID_LOAN_STATE = "480";
string public constant LPL_INVALID_LOAN_AMOUNT = "481";
string public constant LPL_INVALID_TAKEN_AMOUNT = "482";
string public constant LPL_AMOUNT_OVERFLOW = "483";
string public constant LPL_BID_PRICE_LESS_THAN_LIQUIDATION_PRICE = "484";
string public constant LPL_BID_PRICE_LESS_THAN_HIGHEST_PRICE = "485";
string public constant LPL_BID_REDEEM_DURATION_HAS_END = "486";
string public constant LPL_BID_USER_NOT_SAME = "487";
string public constant LPL_BID_REPAY_AMOUNT_NOT_ENOUGH = "488";
string public constant LPL_BID_AUCTION_DURATION_HAS_END = "489";
string public constant LPL_BID_AUCTION_DURATION_NOT_END = "490";
string public constant LPL_BID_PRICE_LESS_THAN_BORROW = "491";
string public constant LPL_INVALID_BIDDER_ADDRESS = "492";
string public constant LPL_AMOUNT_LESS_THAN_BID_FINE = "493";
string public constant LPL_INVALID_BID_FINE = "494";
//common token errors
string public constant CT_CALLER_MUST_BE_LEND_POOL = "500"; // 'The caller of this function must be a lending pool'
string public constant CT_INVALID_MINT_AMOUNT = "501"; //invalid amount to mint
string public constant CT_INVALID_BURN_AMOUNT = "502"; //invalid amount to burn
string public constant CT_BORROW_ALLOWANCE_NOT_ENOUGH = "503";
//reserve logic errors
string public constant RL_RESERVE_ALREADY_INITIALIZED = "601"; // 'Reserve has already been initialized'
string public constant RL_LIQUIDITY_INDEX_OVERFLOW = "602"; // Liquidity index overflows uint128
string public constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = "603"; // Variable borrow index overflows uint128
string public constant RL_LIQUIDITY_RATE_OVERFLOW = "604"; // Liquidity rate overflows uint128
string public constant RL_VARIABLE_BORROW_RATE_OVERFLOW = "605"; // Variable borrow rate overflows uint128
//configure errors
string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = "700"; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_CONFIGURATION = "701"; // 'Invalid risk parameters for the reserve'
string public constant LPC_CALLER_NOT_EMERGENCY_ADMIN = "702"; // 'The caller must be the emergency admin'
string public constant LPC_INVALIED_BNFT_ADDRESS = "703";
string public constant LPC_INVALIED_LOAN_ADDRESS = "704";
string public constant LPC_NFT_LIQUIDITY_NOT_0 = "705";
//reserve config errors
string public constant RC_INVALID_LTV = "730";
string public constant RC_INVALID_LIQ_THRESHOLD = "731";
string public constant RC_INVALID_LIQ_BONUS = "732";
string public constant RC_INVALID_DECIMALS = "733";
string public constant RC_INVALID_RESERVE_FACTOR = "734";
string public constant RC_INVALID_REDEEM_DURATION = "735";
string public constant RC_INVALID_AUCTION_DURATION = "736";
string public constant RC_INVALID_REDEEM_FINE = "737";
string public constant RC_INVALID_REDEEM_THRESHOLD = "738";
string public constant RC_INVALID_MIN_BID_FINE = "739";
string public constant RC_INVALID_MAX_BID_FINE = "740";
//address provider erros
string public constant LPAPR_PROVIDER_NOT_REGISTERED = "760"; // 'Provider is not registered'
string public constant LPAPR_INVALID_ADDRESSES_PROVIDER_ID = "761";
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Read Contract
EXCESS_UTILIZATION_RATE 0x17319873 → uint256
OPTIMAL_UTILIZATION_RATE 0xa15f30ac → uint256
addressesProvider 0xc72c4d10 → address
baseVariableBorrowRate 0xb2589544 → uint256
calculateInterestRates 0x6ee082ca → uint256, uint256
calculateInterestRates 0x81c8c972 → uint256, uint256
getMaxVariableBorrowRate 0x80031e37 → uint256
owner 0x8da5cb5b → address
variableRateSlope1 0x7b832f58 → uint256
variableRateSlope2 0x65614f81 → uint256
Write Contract 3 functions
These functions modify contract state and require a wallet transaction to execute.
renounceOwnership 0x715018a6
No parameters
setInterestRateParams 0x3b458c01
uint256 optimalUtilizationRate_
uint256 baseVariableBorrowRate_
uint256 variableRateSlope1_
uint256 variableRateSlope2_
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address