Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
FixedInterestRateModel
Compiler Version
v0.6.12+commit.27d51765
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "../library/Ownable.sol"; interface IInterestRateModelClient { function updateInterest() external returns (bool); } /** * @title dForce's Fixed Interest Rate Model Contract * @author dForce */ contract FixedInterestRateModel is Ownable { // ratePerBlock must not exceed this value uint256 internal constant ratePerBlockMax = 0.001e18; /** * @notice The approximate number of Ethereum blocks produced each year * @dev This is not used internally, but is expected externally for an interest rate model */ uint256 public constant blocksPerYear = 2425846; /** * @notice Borrow interest rates per block */ mapping(address => uint256) public borrowRatesPerBlock; /** * @notice Supply interest rates per block */ mapping(address => uint256) public supplyRatesPerBlock; /** * @dev Emitted when borrow rate for `target` is set to `rate`. */ event BorrowRateSet(address target, uint256 rate); /** * @dev Emitted when supply rate for `target` is set to `rate`. */ event SupplyRateSet(address target, uint256 rate); constructor() public { __Ownable_init(); } /*********************************/ /******** Security Check *********/ /*********************************/ /** * @notice Ensure this is an interest rate model contract. */ function isInterestRateModel() external pure returns (bool) { return true; } /** * @notice Get the current borrow rate per block * @param cash Not used by this model. * @param borrows Not used by this model. * @param reserves Not used by this model. * @return Current borrow rate per block (as a percentage, and scaled by 1e18). */ function getBorrowRate( uint256 cash, uint256 borrows, uint256 reserves ) public view returns (uint256) { cash; borrows; reserves; return borrowRatesPerBlock[msg.sender]; } /** * @dev Get the current supply interest rate per block. * @param cash Not used by this model. * @param borrows Not used by this model. * @param reserves Not used by this model. * @param reserveRatio Not used by this model. * @return The supply rate per block (as a percentage, and scaled by 1e18). */ function getSupplyRate( uint256 cash, uint256 borrows, uint256 reserves, uint256 reserveRatio ) external view returns (uint256) { cash; borrows; reserves; reserveRatio; return supplyRatesPerBlock[msg.sender]; } /** * @notice Admin function to set the current borrow rate per block */ function _setBorrowRate(address _target, uint256 _rate) public onlyOwner { require(_rate <= ratePerBlockMax, "Borrow rate invalid"); // Settle interest before setting new one IInterestRateModelClient(_target).updateInterest(); borrowRatesPerBlock[_target] = _rate; emit BorrowRateSet(_target, _rate); } /** * @notice Admin function to set the current supply interest rate per block */ function _setSupplyRate(address _target, uint256 _rate) public onlyOwner { require(_rate <= ratePerBlockMax, "Supply rate invalid"); // Settle interest before setting new one IInterestRateModelClient(_target).updateInterest(); supplyRatesPerBlock[_target] = _rate; emit SupplyRateSet(_target, _rate); } /** * @notice Admin function to set the borrow interest rates per block for targets */ function _setBorrowRates( address[] calldata _targets, uint256[] calldata _rates ) external onlyOwner { require( _targets.length == _rates.length, "Targets and rates length mismatch!" ); uint256 _len = _targets.length; for (uint256 i = 0; i < _len; i++) { _setBorrowRate(_targets[i], _rates[i]); } } /** * @notice Admin function to set the supply interest rates per block for the targets */ function _setSupplyRates( address[] calldata _targets, uint256[] calldata _rates ) external onlyOwner { require( _targets.length == _rates.length, "Targets and rates length mismatch!" ); uint256 _len = _targets.length; for (uint256 i = 0; i < _len; i++) { _setSupplyRate(_targets[i], _rates[i]); } } }
//SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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 {_setPendingOwner} and {_acceptOwner}. */ contract Ownable { /** * @dev Returns the address of the current owner. */ address payable public owner; /** * @dev Returns the address of the current pending owner. */ address payable public pendingOwner; event NewOwner(address indexed previousOwner, address indexed newOwner); event NewPendingOwner( address indexed oldPendingOwner, address indexed newPendingOwner ); /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner == msg.sender, "onlyOwner: caller is not the owner"); _; } /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal { owner = msg.sender; emit NewOwner(address(0), msg.sender); } /** * @notice Base on the inputing parameter `newPendingOwner` to check the exact error reason. * @dev Transfer contract control to a new owner. The newPendingOwner must call `_acceptOwner` to finish the transfer. * @param newPendingOwner New pending owner. */ function _setPendingOwner(address payable newPendingOwner) external onlyOwner { require( newPendingOwner != address(0) && newPendingOwner != pendingOwner, "_setPendingOwner: New owenr can not be zero address and owner has been set!" ); // Gets current owner. address oldPendingOwner = pendingOwner; // Sets new pending owner. pendingOwner = newPendingOwner; emit NewPendingOwner(oldPendingOwner, newPendingOwner); } /** * @dev Accepts the admin rights, but only for pendingOwenr. */ function _acceptOwner() external { require( msg.sender == pendingOwner, "_acceptOwner: Only for pending owner!" ); // Gets current values for events. address oldOwner = owner; address oldPendingOwner = pendingOwner; // Set the new contract owner. owner = pendingOwner; // Clear the pendingOwner. pendingOwner = address(0); emit NewOwner(oldOwner, owner); emit NewPendingOwner(oldPendingOwner, pendingOwner); } uint256[50] private __gap; }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"}],"name":"BorrowRateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"NewOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldPendingOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newPendingOwner","type":"address"}],"name":"NewPendingOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"}],"name":"SupplyRateSet","type":"event"},{"inputs":[],"name":"_acceptOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint256","name":"_rate","type":"uint256"}],"name":"_setBorrowRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_targets","type":"address[]"},{"internalType":"uint256[]","name":"_rates","type":"uint256[]"}],"name":"_setBorrowRates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newPendingOwner","type":"address"}],"name":"_setPendingOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint256","name":"_rate","type":"uint256"}],"name":"_setSupplyRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_targets","type":"address[]"},{"internalType":"uint256[]","name":"_rates","type":"uint256[]"}],"name":"_setSupplyRates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"blocksPerYear","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowRatesPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cash","type":"uint256"},{"internalType":"uint256","name":"borrows","type":"uint256"},{"internalType":"uint256","name":"reserves","type":"uint256"}],"name":"getBorrowRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cash","type":"uint256"},{"internalType":"uint256","name":"borrows","type":"uint256"},{"internalType":"uint256","name":"reserves","type":"uint256"},{"internalType":"uint256","name":"reserveRatio","type":"uint256"}],"name":"getSupplyRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInterestRateModel","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supplyRatesPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5061001961001e565b61005f565b600080546001600160a01b0319163390811782556040519091907f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364908290a3565b610ba18061006e6000396000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c80639ce5e6301161008c578063b8b5745a11610066578063b8b5745a1461026d578063e30c39781461032b578063fc4d33f914610333578063fe8120991461033b576100ea565b80639ce5e6301461020a578063a385fb9614610236578063b81688161461023e576100ea565b80635325a819116100c85780635325a8191461016c5780636e96dfd71461019257806385052e57146101ba5780638da5cb5b146101e6576100ea565b806315f24053146100ef5780632191f92a1461012a57806337336b1f14610146575b600080fd5b6101186004803603606081101561010557600080fd5b50803590602081013590604001356103f9565b60408051918252519081900360200190f35b610132610410565b604080519115158252519081900360200190f35b6101186004803603602081101561015c57600080fd5b50356001600160a01b0316610415565b6101186004803603602081101561018257600080fd5b50356001600160a01b0316610427565b6101b8600480360360208110156101a857600080fd5b50356001600160a01b0316610439565b005b6101b8600480360360408110156101d057600080fd5b506001600160a01b038135169060200135610535565b6101ee610690565b604080516001600160a01b039092168252519081900360200190f35b6101b86004803603604081101561022057600080fd5b506001600160a01b03813516906020013561069f565b6101186107fa565b6101186004803603608081101561025457600080fd5b5080359060208101359060408101359060600135610801565b6101b86004803603604081101561028357600080fd5b810190602081018135600160201b81111561029d57600080fd5b8201836020820111156102af57600080fd5b803590602001918460208302840111600160201b831117156102d057600080fd5b919390929091602081019035600160201b8111156102ed57600080fd5b8201836020820111156102ff57600080fd5b803590602001918460208302840111600160201b8311171561032057600080fd5b509092509050610819565b6101ee6108f3565b6101b8610902565b6101b86004803603604081101561035157600080fd5b810190602081018135600160201b81111561036b57600080fd5b82018360208201111561037d57600080fd5b803590602001918460208302840111600160201b8311171561039e57600080fd5b919390929091602081019035600160201b8111156103bb57600080fd5b8201836020820111156103cd57600080fd5b803590602001918460208302840111600160201b831117156103ee57600080fd5b5090925090506109e5565b336000908152603460205260409020549392505050565b600190565b60346020526000908152604090205481565b60356020526000908152604090205481565b6000546001600160a01b031633146104825760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b6001600160a01b038116158015906104a857506001546001600160a01b03828116911614155b6104e35760405162461bcd60e51b815260040180806020018281038252604b815260200180610ab8604b913960600191505060405180910390fd5b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b90600090a35050565b6000546001600160a01b0316331461057e5760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b66038d7ea4c680008111156105d0576040805162461bcd60e51b8152602060048201526013602482015272109bdc9c9bddc81c985d19481a5b9d985b1a59606a1b604482015290519081900360640190fd5b816001600160a01b031663d14827916040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561060b57600080fd5b505af115801561061f573d6000803e3d6000fd5b505050506040513d602081101561063557600080fd5b50506001600160a01b0382166000818152603460209081526040918290208490558151928352820183905280517f2d47cc4bd70042c9fca65ef418127e93b16dc1317b8fdbaa435d06be6a540bd29281900390910190a15050565b6000546001600160a01b031681565b6000546001600160a01b031633146106e85760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b66038d7ea4c6800081111561073a576040805162461bcd60e51b815260206004820152601360248201527214dd5c1c1b1e481c985d19481a5b9d985b1a59606a1b604482015290519081900360640190fd5b816001600160a01b031663d14827916040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561077557600080fd5b505af1158015610789573d6000803e3d6000fd5b505050506040513d602081101561079f57600080fd5b50506001600160a01b0382166000818152603560209081526040918290208490558151928352820183905280517f232be9c39aca88e1188a369186dc31bcae0b30bfce17e809513487500c2ee84f9281900390910190a15050565b622503f681565b33600090815260356020526040902054949350505050565b6000546001600160a01b031633146108625760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b8281146108a05760405162461bcd60e51b8152600401808060200182810382526022815260200180610b036022913960400191505060405180910390fd5b8260005b818110156108eb576108e38686838181106108bb57fe5b905060200201356001600160a01b03168585848181106108d757fe5b9050602002013561069f565b6001016108a4565b505050505050565b6001546001600160a01b031681565b6001546001600160a01b0316331461094b5760405162461bcd60e51b8152600401808060200182810382526025815260200180610b476025913960400191505060405180910390fd5b60008054600180546001600160a01b038082166001600160a01b03198086168217808855931690935560405193811694929391169184917f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b23649190a36001546040516001600160a01b03918216918316907fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b90600090a35050565b6000546001600160a01b03163314610a2e5760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b828114610a6c5760405162461bcd60e51b8152600401808060200182810382526022815260200180610b036022913960400191505060405180910390fd5b8260005b818110156108eb57610aaf868683818110610a8757fe5b905060200201356001600160a01b0316858584818110610aa357fe5b90506020020135610535565b600101610a7056fe5f73657450656e64696e674f776e65723a204e6577206f77656e722063616e206e6f74206265207a65726f206164647265737320616e64206f776e657220686173206265656e20736574215461726765747320616e64207261746573206c656e677468206d69736d61746368216f6e6c794f776e65723a2063616c6c6572206973206e6f7420746865206f776e65725f6163636570744f776e65723a204f6e6c7920666f722070656e64696e67206f776e657221a264697066735822122039708b9ae8836516f52a2fab5cd27d34b488575713752eb4e935c04b333fa99b64736f6c634300060c0033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80639ce5e6301161008c578063b8b5745a11610066578063b8b5745a1461026d578063e30c39781461032b578063fc4d33f914610333578063fe8120991461033b576100ea565b80639ce5e6301461020a578063a385fb9614610236578063b81688161461023e576100ea565b80635325a819116100c85780635325a8191461016c5780636e96dfd71461019257806385052e57146101ba5780638da5cb5b146101e6576100ea565b806315f24053146100ef5780632191f92a1461012a57806337336b1f14610146575b600080fd5b6101186004803603606081101561010557600080fd5b50803590602081013590604001356103f9565b60408051918252519081900360200190f35b610132610410565b604080519115158252519081900360200190f35b6101186004803603602081101561015c57600080fd5b50356001600160a01b0316610415565b6101186004803603602081101561018257600080fd5b50356001600160a01b0316610427565b6101b8600480360360208110156101a857600080fd5b50356001600160a01b0316610439565b005b6101b8600480360360408110156101d057600080fd5b506001600160a01b038135169060200135610535565b6101ee610690565b604080516001600160a01b039092168252519081900360200190f35b6101b86004803603604081101561022057600080fd5b506001600160a01b03813516906020013561069f565b6101186107fa565b6101186004803603608081101561025457600080fd5b5080359060208101359060408101359060600135610801565b6101b86004803603604081101561028357600080fd5b810190602081018135600160201b81111561029d57600080fd5b8201836020820111156102af57600080fd5b803590602001918460208302840111600160201b831117156102d057600080fd5b919390929091602081019035600160201b8111156102ed57600080fd5b8201836020820111156102ff57600080fd5b803590602001918460208302840111600160201b8311171561032057600080fd5b509092509050610819565b6101ee6108f3565b6101b8610902565b6101b86004803603604081101561035157600080fd5b810190602081018135600160201b81111561036b57600080fd5b82018360208201111561037d57600080fd5b803590602001918460208302840111600160201b8311171561039e57600080fd5b919390929091602081019035600160201b8111156103bb57600080fd5b8201836020820111156103cd57600080fd5b803590602001918460208302840111600160201b831117156103ee57600080fd5b5090925090506109e5565b336000908152603460205260409020549392505050565b600190565b60346020526000908152604090205481565b60356020526000908152604090205481565b6000546001600160a01b031633146104825760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b6001600160a01b038116158015906104a857506001546001600160a01b03828116911614155b6104e35760405162461bcd60e51b815260040180806020018281038252604b815260200180610ab8604b913960600191505060405180910390fd5b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b90600090a35050565b6000546001600160a01b0316331461057e5760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b66038d7ea4c680008111156105d0576040805162461bcd60e51b8152602060048201526013602482015272109bdc9c9bddc81c985d19481a5b9d985b1a59606a1b604482015290519081900360640190fd5b816001600160a01b031663d14827916040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561060b57600080fd5b505af115801561061f573d6000803e3d6000fd5b505050506040513d602081101561063557600080fd5b50506001600160a01b0382166000818152603460209081526040918290208490558151928352820183905280517f2d47cc4bd70042c9fca65ef418127e93b16dc1317b8fdbaa435d06be6a540bd29281900390910190a15050565b6000546001600160a01b031681565b6000546001600160a01b031633146106e85760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b66038d7ea4c6800081111561073a576040805162461bcd60e51b815260206004820152601360248201527214dd5c1c1b1e481c985d19481a5b9d985b1a59606a1b604482015290519081900360640190fd5b816001600160a01b031663d14827916040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561077557600080fd5b505af1158015610789573d6000803e3d6000fd5b505050506040513d602081101561079f57600080fd5b50506001600160a01b0382166000818152603560209081526040918290208490558151928352820183905280517f232be9c39aca88e1188a369186dc31bcae0b30bfce17e809513487500c2ee84f9281900390910190a15050565b622503f681565b33600090815260356020526040902054949350505050565b6000546001600160a01b031633146108625760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b8281146108a05760405162461bcd60e51b8152600401808060200182810382526022815260200180610b036022913960400191505060405180910390fd5b8260005b818110156108eb576108e38686838181106108bb57fe5b905060200201356001600160a01b03168585848181106108d757fe5b9050602002013561069f565b6001016108a4565b505050505050565b6001546001600160a01b031681565b6001546001600160a01b0316331461094b5760405162461bcd60e51b8152600401808060200182810382526025815260200180610b476025913960400191505060405180910390fd5b60008054600180546001600160a01b038082166001600160a01b03198086168217808855931690935560405193811694929391169184917f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b23649190a36001546040516001600160a01b03918216918316907fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b90600090a35050565b6000546001600160a01b03163314610a2e5760405162461bcd60e51b8152600401808060200182810382526022815260200180610b256022913960400191505060405180910390fd5b828114610a6c5760405162461bcd60e51b8152600401808060200182810382526022815260200180610b036022913960400191505060405180910390fd5b8260005b818110156108eb57610aaf868683818110610a8757fe5b905060200201356001600160a01b0316858584818110610aa357fe5b90506020020135610535565b600101610a7056fe5f73657450656e64696e674f776e65723a204e6577206f77656e722063616e206e6f74206265207a65726f206164647265737320616e64206f776e657220686173206265656e20736574215461726765747320616e64207261746573206c656e677468206d69736d61746368216f6e6c794f776e65723a2063616c6c6572206973206e6f7420746865206f776e65725f6163636570744f776e65723a204f6e6c7920666f722070656e64696e67206f776e657221a264697066735822122039708b9ae8836516f52a2fab5cd27d34b488575713752eb4e935c04b333fa99b64736f6c634300060c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.