Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 72082109 | 1041 days ago | 0 ETH | ||||
| 72077506 | 1041 days ago | 0 ETH | ||||
| 72077246 | 1041 days ago | 0 ETH | ||||
| 72077178 | 1041 days ago | 0 ETH | ||||
| 72074521 | 1041 days ago | 0 ETH | ||||
| 72069793 | 1041 days ago | 0 ETH | ||||
| 72067274 | 1041 days ago | 0 ETH | ||||
| 72067274 | 1041 days ago | 0 ETH | ||||
| 72066455 | 1041 days ago | 0 ETH | ||||
| 72065142 | 1041 days ago | 0 ETH | ||||
| 72065113 | 1041 days ago | 0 ETH | ||||
| 72057086 | 1041 days ago | 0 ETH | ||||
| 72046229 | 1041 days ago | 0 ETH | ||||
| 72038825 | 1041 days ago | 0 ETH | ||||
| 72038644 | 1041 days ago | 0 ETH | ||||
| 72038200 | 1041 days ago | 0 ETH | ||||
| 72033787 | 1041 days ago | 0 ETH | ||||
| 72033787 | 1041 days ago | 0 ETH | ||||
| 72033308 | 1041 days ago | 0 ETH | ||||
| 72032390 | 1041 days ago | 0 ETH | ||||
| 72028248 | 1041 days ago | 0 ETH | ||||
| 72017549 | 1041 days ago | 0 ETH | ||||
| 72017117 | 1041 days ago | 0 ETH | ||||
| 72017059 | 1041 days ago | 0 ETH | ||||
| 72015956 | 1041 days ago | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x91Cd729f...3deE1C7ad The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
LinearRateModel
Compiler Version
v0.8.17+commit.8df45f5f
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.8.17;
import {FixedPointMathLib} from "solmate/utils/FixedPointMathLib.sol";
import {IRateModel} from "../interface/core/IRateModel.sol";
/**
@title Linear Rate Model
@notice Rate model contract used by Lending pools to calculate borrow rate
per sec
Forked from aave https://github.com/aave/aave-v3-core/blob/master/contracts/protocol/pool/DefaultReserveInterestRateStrategy.sol
*/
contract LinearRateModel is IRateModel {
using FixedPointMathLib for uint;
/// @notice Base rate
uint public immutable baseRate;
/// @notice Slope of the variable interest curve when usage ratio > 0 and <= OPTIMAL_USAGE_RATIO
uint public immutable slope1;
/// @notice Slope of the variable interest curve when usage ratio > OPTIMAL_USAGE_RATIO
uint public immutable slope2;
/// @notice This constant represents the usage ratio at which the pool aims to obtain most competitive borrow rates
uint public immutable OPTIMAL_USAGE_RATIO;
/// @notice This constant represents the excess usage ratio above the optimal. It's always equal to 1-optimal usage ratio.
uint public immutable MAX_EXCESS_USAGE_RATIO;
/// @notice Number of seconds per year
uint immutable secsPerYear;
/**
@notice Contract constructor
@param _baseRate default value = 0
@param _slope1 default value = 40000000000000000
@param _slope2 default value = 750000000000000000
@param _optimalUsageRatio default value = 850000000000000000
@param _maxExcessUsageRatio default value = 150000000000000000
@param _secsPerYear secs in a year, default value = 31556952 * 1e18
*/
constructor(
uint _baseRate,
uint _slope1,
uint _slope2,
uint _optimalUsageRatio,
uint _maxExcessUsageRatio,
uint _secsPerYear
)
{
baseRate = _baseRate;
slope1 = _slope1;
slope2 = _slope2;
OPTIMAL_USAGE_RATIO = _optimalUsageRatio;
MAX_EXCESS_USAGE_RATIO = _maxExcessUsageRatio;
secsPerYear = _secsPerYear;
}
/**
@notice Calculates Borrow rate per second
@param liquidity total balance of the underlying asset in the pool
@param totalDebt balance of underlying assets borrowed from the pool
@return uint borrow rate per sec
*/
function getBorrowRatePerSecond(
uint liquidity,
uint totalDebt
)
external
view
returns (uint)
{
uint utilization = _utilization(liquidity, totalDebt);
if (utilization > OPTIMAL_USAGE_RATIO) {
return (
baseRate + slope1 + slope2.mulWadDown(
getExcessBorrowUsage(utilization)
)
).divWadDown(secsPerYear);
} else {
return (
baseRate + slope1.mulDivDown(utilization, OPTIMAL_USAGE_RATIO)
).divWadDown(secsPerYear);
}
}
function getExcessBorrowUsage(uint utilization)
internal
view
returns (uint)
{
return (utilization - OPTIMAL_USAGE_RATIO).divWadDown(
MAX_EXCESS_USAGE_RATIO
);
}
function _utilization(uint liquidity, uint borrows)
internal
pure
returns (uint)
{
uint totalAssets = liquidity + borrows;
return (totalAssets == 0) ? 0 : borrows.divWadDown(totalAssets);
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
library FixedPointMathLib {
/*//////////////////////////////////////////////////////////////
SIMPLIFIED FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.
function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
}
function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
}
function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
}
function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
}
/*//////////////////////////////////////////////////////////////
LOW LEVEL FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
function mulDivDown(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
assembly {
// Store x * y in z for now.
z := mul(x, y)
// Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
revert(0, 0)
}
// Divide z by the denominator.
z := div(z, denominator)
}
}
function mulDivUp(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
assembly {
// Store x * y in z for now.
z := mul(x, y)
// Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
revert(0, 0)
}
// First, divide z - 1 by the denominator and add 1.
// We allow z - 1 to underflow if z is 0, because we multiply the
// end result by 0 if z is zero, ensuring we return 0 if z is zero.
z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))
}
}
function rpow(
uint256 x,
uint256 n,
uint256 scalar
) internal pure returns (uint256 z) {
assembly {
switch x
case 0 {
switch n
case 0 {
// 0 ** 0 = 1
z := scalar
}
default {
// 0 ** n = 0
z := 0
}
}
default {
switch mod(n, 2)
case 0 {
// If n is even, store scalar in z for now.
z := scalar
}
default {
// If n is odd, store x in z for now.
z := x
}
// Shifting right by 1 is like dividing by 2.
let half := shr(1, scalar)
for {
// Shift n right by 1 before looping to halve it.
n := shr(1, n)
} n {
// Shift n right by 1 each iteration to halve it.
n := shr(1, n)
} {
// Revert immediately if x ** 2 would overflow.
// Equivalent to iszero(eq(div(xx, x), x)) here.
if shr(128, x) {
revert(0, 0)
}
// Store x squared.
let xx := mul(x, x)
// Round to the nearest number.
let xxRound := add(xx, half)
// Revert if xx + half overflowed.
if lt(xxRound, xx) {
revert(0, 0)
}
// Set x to scaled xxRound.
x := div(xxRound, scalar)
// If n is even:
if mod(n, 2) {
// Compute z * x.
let zx := mul(z, x)
// If z * x overflowed:
if iszero(eq(div(zx, x), z)) {
// Revert if x is non-zero.
if iszero(iszero(x)) {
revert(0, 0)
}
}
// Round to the nearest number.
let zxRound := add(zx, half)
// Revert if zx + half overflowed.
if lt(zxRound, zx) {
revert(0, 0)
}
// Return properly scaled zxRound.
z := div(zxRound, scalar)
}
}
}
}
}
/*//////////////////////////////////////////////////////////////
GENERAL NUMBER UTILITIES
//////////////////////////////////////////////////////////////*/
function sqrt(uint256 x) internal pure returns (uint256 z) {
assembly {
// Start off with z at 1.
z := 1
// Used below to help find a nearby power of 2.
let y := x
// Find the lowest power of 2 that is at least sqrt(x).
if iszero(lt(y, 0x100000000000000000000000000000000)) {
y := shr(128, y) // Like dividing by 2 ** 128.
z := shl(64, z) // Like multiplying by 2 ** 64.
}
if iszero(lt(y, 0x10000000000000000)) {
y := shr(64, y) // Like dividing by 2 ** 64.
z := shl(32, z) // Like multiplying by 2 ** 32.
}
if iszero(lt(y, 0x100000000)) {
y := shr(32, y) // Like dividing by 2 ** 32.
z := shl(16, z) // Like multiplying by 2 ** 16.
}
if iszero(lt(y, 0x10000)) {
y := shr(16, y) // Like dividing by 2 ** 16.
z := shl(8, z) // Like multiplying by 2 ** 8.
}
if iszero(lt(y, 0x100)) {
y := shr(8, y) // Like dividing by 2 ** 8.
z := shl(4, z) // Like multiplying by 2 ** 4.
}
if iszero(lt(y, 0x10)) {
y := shr(4, y) // Like dividing by 2 ** 4.
z := shl(2, z) // Like multiplying by 2 ** 2.
}
if iszero(lt(y, 0x8)) {
// Equivalent to 2 ** z.
z := shl(1, z)
}
// Shifting right by 1 is like dividing by 2.
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
// Compute a rounded down version of z.
let zRoundDown := div(x, z)
// If zRoundDown is smaller, use it.
if lt(zRoundDown, z) {
z := zRoundDown
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface IRateModel {
function getBorrowRatePerSecond(
uint liquidity,
uint borrows
) external view returns (uint);
}{
"remappings": [
"controller/=lib/controller/src/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"oracle/=lib/oracle/src/",
"solidity-bytes-utils/=lib/controller/lib/solidity-bytes-utils/contracts/",
"solmate/=lib/solmate/src/",
"v3-core/=lib/oracle/lib/v3-core/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"uint256","name":"_baseRate","type":"uint256"},{"internalType":"uint256","name":"_slope1","type":"uint256"},{"internalType":"uint256","name":"_slope2","type":"uint256"},{"internalType":"uint256","name":"_optimalUsageRatio","type":"uint256"},{"internalType":"uint256","name":"_maxExcessUsageRatio","type":"uint256"},{"internalType":"uint256","name":"_secsPerYear","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"MAX_EXCESS_USAGE_RATIO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPTIMAL_USAGE_RATIO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"}],"name":"getBorrowRatePerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"slope1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"slope2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
0x61014060405234801561001157600080fd5b5060405161056b38038061056b83398101604081905261003091610052565b60809590955260a09390935260c09190915260e052610100526101205261009c565b60008060008060008060c0878903121561006b57600080fd5b865195506020870151945060408701519350606087015192506080870151915060a087015190509295509295509295565b60805160a05160c05160e051610100516101205161043d61012e6000396000818161018b0152610244015260008181610106015261031401526000818160a5015281816101600152818161028a015261033801526000818161012d01526101b801526000818160df015281816101e20152610268015260008181606c0152818161020301526102b4015261043d6000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80631f68f20a1461006757806354c365c6146100a05780635592f328146100c7578063a62b75a8146100da578063a9c622f814610101578063d0134cb714610128575b600080fd5b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b60405190815260200160405180910390f35b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b61008e6100d53660046103a9565b61014f565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b60008061015c84846102de565b90507f000000000000000000000000000000000000000000000000000000000000000081111561023f576102377f00000000000000000000000000000000000000000000000000000000000000006101dd6101b68461030d565b7f00000000000000000000000000000000000000000000000000000000000000009061035d565b6102277f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006103e1565b61023191906103e1565b90610379565b9150506102d8565b6102377f00000000000000000000000000000000000000000000000000000000000000006102ae7f0000000000000000000000000000000000000000000000000000000000000000847f000000000000000000000000000000000000000000000000000000000000000061038a565b610231907f00000000000000000000000000000000000000000000000000000000000000006103e1565b92915050565b6000806102eb83856103e1565b90508015610302576102fd8382610379565b610305565b60005b949350505050565b60006102d87f00000000000000000000000000000000000000000000000000000000000000006102317f0000000000000000000000000000000000000000000000000000000000000000856103f4565b60006103728383670de0b6b3a764000061038a565b9392505050565b600061037283670de0b6b3a7640000845b8282028115158415858304851417166103a257600080fd5b0492915050565b600080604083850312156103bc57600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b808201808211156102d8576102d86103cb565b818103818111156102d8576102d86103cb56fea264697066735822122074b99e87a22531da264f421cc65bfbf7ed84a85f841148cacfb96e203214875b64736f6c634300081100330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008e1bc9bf0400000000000000000000000000000000000000000000000000000f43fc2c04ee00000000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000000002c68af0bb1400000000000000000000000000000000000000000000001a1a71cbb7a69c7e600000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100625760003560e01c80631f68f20a1461006757806354c365c6146100a05780635592f328146100c7578063a62b75a8146100da578063a9c622f814610101578063d0134cb714610128575b600080fd5b61008e7f000000000000000000000000000000000000000000000000000000000000000081565b60405190815260200160405180910390f35b61008e7f0000000000000000000000000000000000000000000000000b1a2bc2ec50000081565b61008e6100d53660046103a9565b61014f565b61008e7f000000000000000000000000000000000000000000000000008e1bc9bf04000081565b61008e7f00000000000000000000000000000000000000000000000002c68af0bb14000081565b61008e7f0000000000000000000000000000000000000000000000000f43fc2c04ee000081565b60008061015c84846102de565b90507f0000000000000000000000000000000000000000000000000b1a2bc2ec50000081111561023f576102377f0000000000000000000000000000000000000000001a1a71cbb7a69c7e6000006101dd6101b68461030d565b7f0000000000000000000000000000000000000000000000000f43fc2c04ee00009061035d565b6102277f000000000000000000000000000000000000000000000000008e1bc9bf0400007f00000000000000000000000000000000000000000000000000000000000000006103e1565b61023191906103e1565b90610379565b9150506102d8565b6102377f0000000000000000000000000000000000000000001a1a71cbb7a69c7e6000006102ae7f000000000000000000000000000000000000000000000000008e1bc9bf040000847f0000000000000000000000000000000000000000000000000b1a2bc2ec50000061038a565b610231907f00000000000000000000000000000000000000000000000000000000000000006103e1565b92915050565b6000806102eb83856103e1565b90508015610302576102fd8382610379565b610305565b60005b949350505050565b60006102d87f00000000000000000000000000000000000000000000000002c68af0bb1400006102317f0000000000000000000000000000000000000000000000000b1a2bc2ec500000856103f4565b60006103728383670de0b6b3a764000061038a565b9392505050565b600061037283670de0b6b3a7640000845b8282028115158415858304851417166103a257600080fd5b0492915050565b600080604083850312156103bc57600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b808201808211156102d8576102d86103cb565b818103818111156102d8576102d86103cb56fea264697066735822122074b99e87a22531da264f421cc65bfbf7ed84a85f841148cacfb96e203214875b64736f6c63430008110033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
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.