Overview
POL Balance
0 POL
POL Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
JumpRateModel
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 400 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./interfaces/IInterestRateModel.sol"; import "../libraries/SafeMath.sol"; /** * @title 0VIX's JumpRateModel Contract * @author 0VIX */ contract JumpRateModel is IInterestRateModel { using SafeMath for uint; event NewInterestParams(uint baseRatePerTimestamp, uint multiplierPerTimestamp, uint jumpMultiplierPerTimestamp, uint kink); bool public constant override isInterestRateModel = true; /** * @notice The approximate number of timestamps per year that is assumed by the interest rate model */ uint public constant timestampsPerYear = 31536000; /** * @notice The multiplier of utilization rate that gives the slope of the interest rate */ uint public multiplierPerTimestamp; /** * @notice The base interest rate which is the y-intercept when utilization rate is 0 */ uint public baseRatePerTimestamp; /** * @notice The multiplierPerTimestamp after hitting a specified utilization point */ uint public jumpMultiplierPerTimestamp; /** * @notice The utilization point at which the jump multiplier is applied */ uint public kink; /** * @notice Construct an interest rate model * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18) * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18) * @param jumpMultiplierPerYear The multiplierPerTimestamp after hitting a specified utilization point * @param kink_ The utilization point at which the jump multiplier is applied */ constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) { baseRatePerTimestamp = baseRatePerYear.mul(1e18).div(timestampsPerYear).div(1e18); multiplierPerTimestamp = multiplierPerYear.mul(1e18).div(timestampsPerYear).div(1e18); jumpMultiplierPerTimestamp = jumpMultiplierPerYear.mul(1e18).div(timestampsPerYear).div(1e18); kink = kink_; emit NewInterestParams(baseRatePerTimestamp, multiplierPerTimestamp, jumpMultiplierPerTimestamp, kink); } /** * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)` * @param cash The amount of cash in the market * @param borrows The amount of borrows in the market * @param reserves The amount of reserves in the market (currently unused) * @return The utilization rate as a mantissa between [0, 1e18] */ function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) { // Utilization rate is 0 when there are no borrows if (borrows == 0) { return 0; } return borrows.mul(1e18).div(cash.add(borrows).sub(reserves)); } /** * @notice Calculates the current borrow rate per timestmp, with the error code expected by the market * @param cash The amount of cash in the market * @param borrows The amount of borrows in the market * @param reserves The amount of reserves in the market * @return The borrow rate percentage per timestmp as a mantissa (scaled by 1e18) */ function getBorrowRate(uint cash, uint borrows, uint reserves) public view override returns (uint) { uint util = utilizationRate(cash, borrows, reserves); if (util <= kink) { return util.mul(multiplierPerTimestamp).div(1e18).add(baseRatePerTimestamp); } else { uint normalRate = kink.mul(multiplierPerTimestamp).div(1e18).add(baseRatePerTimestamp); uint excessUtil = util.sub(kink); return excessUtil.mul(jumpMultiplierPerTimestamp).div(1e18).add(normalRate); } } /** * @notice Calculates the current supply rate per timestmp * @param cash The amount of cash in the market * @param borrows The amount of borrows in the market * @param reserves The amount of reserves in the market * @param reserveFactorMantissa The current reserve factor for the market * @return The supply rate percentage per timestmp as a mantissa (scaled by 1e18) */ function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) public view override returns (uint) { uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa); uint borrowRate = getBorrowRate(cash, borrows, reserves); uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18); return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title 0VIX's IInterestRateModel Interface * @author 0VIX */ interface IInterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) function isInterestRateModel() external view returns(bool); /** * @notice Calculates the current borrow interest rate per timestmp * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @return The borrow rate per timestmp (as a percentage, and scaled by 1e18) */ function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint); /** * @notice Calculates the current supply interest rate per timestmp * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @param reserveFactorMantissa The current reserve factor the market has * @return The supply rate per timestmp (as a percentage, and scaled by 1e18) */ function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external view returns (uint); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; // From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol // Subject to the MIT license. /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } } /** * @dev Returns the addition of two unsigned integers, reverting with custom message on overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { uint256 c = a + b; require(c >= a, errorMessage); return c; } } /** * @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot underflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction underflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot underflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); uint256 c = a - b; return c; } } /** * @dev Returns the multiplication of two unsigned integers, reverting on overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } } /** * @dev Returns the multiplication of two unsigned integers, reverting on overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, errorMessage); return c; } } /** * @dev Returns the integer division of two unsigned integers. * Reverts on division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. * Reverts with custom message on division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b != 0, errorMessage); return a % b; } } }
{ "optimizer": { "enabled": true, "runs": 400 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"uint256","name":"baseRatePerYear","type":"uint256"},{"internalType":"uint256","name":"multiplierPerYear","type":"uint256"},{"internalType":"uint256","name":"jumpMultiplierPerYear","type":"uint256"},{"internalType":"uint256","name":"kink_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"baseRatePerTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"multiplierPerTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"jumpMultiplierPerTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"kink","type":"uint256"}],"name":"NewInterestParams","type":"event"},{"inputs":[],"name":"baseRatePerTimestamp","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":"reserveFactorMantissa","type":"uint256"}],"name":"getSupplyRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInterestRateModel","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"jumpMultiplierPerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"kink","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"multiplierPerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timestampsPerYear","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":"utilizationRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5060405161085938038061085983398101604081905261002f91610253565b610074670de0b6b3a76400006100626301e13380610062670de0b6b3a76400008961012a60201b6102a41790919060201c565b6101c060201b61033a1790919060201c565b60015561009e670de0b6b3a76400006100626301e1338081878461012a602090811b6102a417901c565b6000556100c8670de0b6b3a76400006100626301e1338081868461012a602090811b6102a417901c565b60028190556003829055600154600054604080519283526020830191909152810191909152606081018290527f6960ab234c7ef4b0c9197100f5393cfcde7c453ac910a27bd2000aa1dd4c068d9060800160405180910390a1505050506102db565b600082610139575060006101ba565b8282028284828161015a57634e487b7160e01b600052601260045260246000fd5b04146101b75760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084015b60405180910390fd5b90505b92915050565b60006101b783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061020860201b60201c565b600081836102295760405162461bcd60e51b81526004016101ae9190610288565b50600083858161024957634e487b7160e01b600052601260045260246000fd5b0495945050505050565b60008060008060808587031215610268578384fd5b505082516020840151604085015160609095015191969095509092509050565b6000602080835283518082850152825b818110156102b457858101830151858201604001528201610298565b818111156102c55783604083870101525b50601f01601f1916929092016040019392505050565b61056f806102ea6000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c806340bc0af41161006657806340bc0af4146100ea5780636c2df6a7146100f35780636e71e2d8146100fc578063b81688161461010f578063fd2da3391461012257600080fd5b80630c5748611461009857806315f24053146100b65780632191f92a146100c957806326c394f7146100e1575b600080fd5b6100a36301e1338081565b6040519081526020015b60405180910390f35b6100a36100c436600461048a565b61012b565b6100d1600181565b60405190151581526020016100ad565b6100a360025481565b6100a360015481565b6100a360005481565b6100a361010a36600461048a565b6101f7565b6100a361011d3660046104b5565b610237565b6100a360035481565b6000806101398585856101f7565b9050600354811161017f57610177600154610171670de0b6b3a764000061016b600054866102a490919063ffffffff16565b9061033a565b9061037c565b9150506101f0565b60006101aa600154610171670de0b6b3a764000061016b6000546003546102a490919063ffffffff16565b905060006101c3600354846103d190919063ffffffff16565b90506101ea82610171670de0b6b3a764000061016b600254866102a490919063ffffffff16565b93505050505b9392505050565b600082610206575060006101f0565b61022f61021d83610217878761037c565b906103d1565b61016b85670de0b6b3a76400006102a4565b949350505050565b60008061024c670de0b6b3a7640000846103d1565b9050600061025b87878761012b565b90506000610275670de0b6b3a764000061016b84866102a4565b9050610298670de0b6b3a764000061016b836102928c8c8c6101f7565b906102a4565b98975050505050505050565b6000826102b357506000610334565b828202828482816102d457634e487b7160e01b600052601260045260246000fd5b04146103315760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084015b60405180910390fd5b90505b92915050565b600061033183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610413565b6000828201838110156103315760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610328565b600061033183836040518060400160405280601f81526020017f536166654d6174683a207375627472616374696f6e20756e646572666c6f770081525061045e565b600081836104345760405162461bcd60e51b815260040161032891906104e6565b50600083858161045457634e487b7160e01b600052601260045260246000fd5b0495945050505050565b600081848411156104825760405162461bcd60e51b815260040161032891906104e6565b505050900390565b60008060006060848603121561049e578283fd5b505081359360208301359350604090920135919050565b600080600080608085870312156104ca578081fd5b5050823594602084013594506040840135936060013592509050565b6000602080835283518082850152825b81811015610512578581018301518582016040015282016104f6565b818111156105235783604083870101525b50601f01601f191692909201604001939250505056fea2646970667358221220871b374ba87d15d2498218887f0f0876697a12c954687b13a94dd00e41a7ff2a64736f6c6343000804003300000000000000000000000000000000000000000000000000470de4df820000000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000f207539952d00000000000000000000000000000000000000000000000000000b1a2bc2ec500000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100935760003560e01c806340bc0af41161006657806340bc0af4146100ea5780636c2df6a7146100f35780636e71e2d8146100fc578063b81688161461010f578063fd2da3391461012257600080fd5b80630c5748611461009857806315f24053146100b65780632191f92a146100c957806326c394f7146100e1575b600080fd5b6100a36301e1338081565b6040519081526020015b60405180910390f35b6100a36100c436600461048a565b61012b565b6100d1600181565b60405190151581526020016100ad565b6100a360025481565b6100a360015481565b6100a360005481565b6100a361010a36600461048a565b6101f7565b6100a361011d3660046104b5565b610237565b6100a360035481565b6000806101398585856101f7565b9050600354811161017f57610177600154610171670de0b6b3a764000061016b600054866102a490919063ffffffff16565b9061033a565b9061037c565b9150506101f0565b60006101aa600154610171670de0b6b3a764000061016b6000546003546102a490919063ffffffff16565b905060006101c3600354846103d190919063ffffffff16565b90506101ea82610171670de0b6b3a764000061016b600254866102a490919063ffffffff16565b93505050505b9392505050565b600082610206575060006101f0565b61022f61021d83610217878761037c565b906103d1565b61016b85670de0b6b3a76400006102a4565b949350505050565b60008061024c670de0b6b3a7640000846103d1565b9050600061025b87878761012b565b90506000610275670de0b6b3a764000061016b84866102a4565b9050610298670de0b6b3a764000061016b836102928c8c8c6101f7565b906102a4565b98975050505050505050565b6000826102b357506000610334565b828202828482816102d457634e487b7160e01b600052601260045260246000fd5b04146103315760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084015b60405180910390fd5b90505b92915050565b600061033183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610413565b6000828201838110156103315760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610328565b600061033183836040518060400160405280601f81526020017f536166654d6174683a207375627472616374696f6e20756e646572666c6f770081525061045e565b600081836104345760405162461bcd60e51b815260040161032891906104e6565b50600083858161045457634e487b7160e01b600052601260045260246000fd5b0495945050505050565b600081848411156104825760405162461bcd60e51b815260040161032891906104e6565b505050900390565b60008060006060848603121561049e578283fd5b505081359360208301359350604090920135919050565b600080600080608085870312156104ca578081fd5b5050823594602084013594506040840135936060013592509050565b6000602080835283518082850152825b81811015610512578581018301518582016040015282016104f6565b818111156105235783604083870101525b50601f01601f191692909201604001939250505056fea2646970667358221220871b374ba87d15d2498218887f0f0876697a12c954687b13a94dd00e41a7ff2a64736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000470de4df820000000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000f207539952d00000000000000000000000000000000000000000000000000000b1a2bc2ec500000
-----Decoded View---------------
Arg [0] : baseRatePerYear (uint256): 20000000000000000
Arg [1] : multiplierPerYear (uint256): 100000000000000000
Arg [2] : jumpMultiplierPerYear (uint256): 1090000000000000000
Arg [3] : kink_ (uint256): 800000000000000000
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000470de4df820000
Arg [1] : 000000000000000000000000000000000000000000000000016345785d8a0000
Arg [2] : 0000000000000000000000000000000000000000000000000f207539952d0000
Arg [3] : 0000000000000000000000000000000000000000000000000b1a2bc2ec500000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.