ETH Price: $2,185.92 (-0.08%)
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

Transaction Hash
Block
From
To

There are no matching entries

> 10 Internal Transactions found.

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
1075581342023-07-30 11:04:05988 days ago1690715045
0x40BE3709...71501C499
0 ETH
1075527842023-07-30 8:05:45988 days ago1690704345
0x40BE3709...71501C499
0 ETH
1075527662023-07-30 8:05:09988 days ago1690704309
0x40BE3709...71501C499
0 ETH
1075420902023-07-30 2:09:17988 days ago1690682957
0x40BE3709...71501C499
0 ETH
1075349162023-07-29 22:10:09988 days ago1690668609
0x40BE3709...71501C499
0 ETH
1075337572023-07-29 21:31:31988 days ago1690666291
0x40BE3709...71501C499
0 ETH
1075319492023-07-29 20:31:15988 days ago1690662675
0x40BE3709...71501C499
0 ETH
1075238222023-07-29 16:00:21988 days ago1690646421
0x40BE3709...71501C499
0 ETH
1075238202023-07-29 16:00:17988 days ago1690646417
0x40BE3709...71501C499
0 ETH
1075238172023-07-29 16:00:11988 days ago1690646411
0x40BE3709...71501C499
0 ETH
1075238152023-07-29 16:00:07988 days ago1690646407
0x40BE3709...71501C499
0 ETH
1075238132023-07-29 16:00:03988 days ago1690646403
0x40BE3709...71501C499
0 ETH
1075230882023-07-29 15:35:53988 days ago1690644953
0x40BE3709...71501C499
0 ETH
1075230642023-07-29 15:35:05988 days ago1690644905
0x40BE3709...71501C499
0 ETH
1075160292023-07-29 11:40:35989 days ago1690630835
0x40BE3709...71501C499
0 ETH
1075111482023-07-29 8:57:53989 days ago1690621073
0x40BE3709...71501C499
0 ETH
1075111482023-07-29 8:57:53989 days ago1690621073
0x40BE3709...71501C499
0 ETH
1075111482023-07-29 8:57:53989 days ago1690621073
0x40BE3709...71501C499
0 ETH
1075111482023-07-29 8:57:53989 days ago1690621073
0x40BE3709...71501C499
0 ETH
1075111482023-07-29 8:57:53989 days ago1690621073
0x40BE3709...71501C499
0 ETH
1075108962023-07-29 8:49:29989 days ago1690620569
0x40BE3709...71501C499
0 ETH
1075108962023-07-29 8:49:29989 days ago1690620569
0x40BE3709...71501C499
0 ETH
1075108962023-07-29 8:49:29989 days ago1690620569
0x40BE3709...71501C499
0 ETH
1075108962023-07-29 8:49:29989 days ago1690620569
0x40BE3709...71501C499
0 ETH
1075108962023-07-29 8:49:29989 days ago1690620569
0x40BE3709...71501C499
0 ETH
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StablePrimaryInterestModel

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "../library/SafeRatioMath.sol";

/**
 * @title dForce's lending InterestRateModelV2 Contract
 * @author dForce
 */
contract InterestRateModelV2 {
    using SafeMathUpgradeable for uint256;
    using SafeRatioMath for uint256;

    uint256 private constant ONE = 1e18;

    /**
     * @notice The approximate number of blocks produced each year for different blockchain.
     */
    uint256 public blocksPerYear;

    uint256 public base;
    uint256 public optimal;
    uint256 public slope_1;
    uint256 public slope_2;

    constructor(
        uint256 _base,
        uint256 _optimal,
        uint256 _slope_1,
        uint256 _slope_2,
        uint256 _blocksPerYear
    ) public {
        require(_base <= ONE, "interestRateModelV2: Base can not exceed 1!");
        require(_optimal > 0, "interestRateModelV2: Optimal can not be zero!");
        require(_optimal < ONE, "interestRateModelV2: Optimal should be less than 1!");
        require(_slope_1 <= ONE, "interestRateModelV2: Slope 1 can not exceed 1!");
        require(_blocksPerYear > 0, "interestRateModelV2: Blocks per year can not be zero!");
        base = _base;
        optimal = _optimal;
        slope_1 = _slope_1;
        slope_2 = _slope_2;
        blocksPerYear = _blocksPerYear;
    }

    /*********************************/
    /******** Security Check *********/
    /*********************************/

    /**
     * @notice Ensure this is an interest rate model contract.
     */
    function isInterestRateModel() external pure returns (bool) {
        return true;
    }

    /**
     * @notice Calculate the utilization rate: `_borrows / (_cash + _borrows - _reserves)`
     * @param _cash Asset balance
     * @param _borrows Asset borrows
     * @param _reserves Asset reserves
     * @return Asset utilization [0, 1e18]
     */
    function utilizationRate(
        uint256 _cash,
        uint256 _borrows,
        uint256 _reserves
    ) internal pure returns (uint256) {
        // Utilization rate is 0 when there are no borrows
        if (_borrows == 0) return 0;

        // Utilization rate is 100% when _grossSupply is less than or equal to borrows
        uint256 _grossSupply = _cash.add(_borrows);
        if (_grossSupply <= _reserves) return ONE;

        // Utilization rate is 100% when _borrows is greater than _supply
        uint256 _supply = _grossSupply.sub(_reserves);
        if (_borrows > _supply) return ONE;

        return _borrows.rdiv(_supply);
    }

    /**
     * @notice Get the current borrow rate per block, 18 decimal places
     * @param _balance Asset balance
     * @param _borrows Asset borrows
     * @param _reserves Asset reserves
     * @return _borrowRate Current borrow rate APR
     */
    function getBorrowRate(
        uint256 _balance,
        uint256 _borrows,
        uint256 _reserves
    ) external view returns (uint256 _borrowRate) {
        uint256 _util = utilizationRate(_balance, _borrows, _reserves);
        uint256 _annualBorrowRateScaled = 0;

        // Borrow rate is:
        // 1). when Ur < Uoptimal, Rate = R0 + R1 * Ur / Uoptimal
        // 2). when Ur >= Uoptimal, Rate = R0 + R1 + R2 * (Ur-Uoptimal)/(1-Uoptimal)
        // R0: Base, R1: Slope1, R2: Slope2
        if (_util < optimal) {
            _annualBorrowRateScaled = base.add(slope_1.mul(_util).div(optimal));
        } else {
            _annualBorrowRateScaled = base.add(slope_1).add(slope_2.mul(_util.sub(optimal)).div(ONE.sub(optimal)));
        }

        // And then divide down by blocks per year.
        _borrowRate = _annualBorrowRateScaled.div(blocksPerYear);
    }
}

contract StablePrimaryInterestModel is InterestRateModelV2 {
    constructor(uint256 _blocksPerYear) public InterestRateModelV2(0, 0.9e18, 0.05e18, 0.6e18, _blocksPerYear) {}
}

contract StableSecondaryInterestModel is InterestRateModelV2 {
    constructor(uint256 _blocksPerYear) public InterestRateModelV2(0, 0.8e18, 0.07e18, 1e18, _blocksPerYear) {}
}

contract BNBLikeInterestModel is InterestRateModelV2 {
    constructor(uint256 _blocksPerYear) public InterestRateModelV2(0, 0.9e18, 0.09e18, 1e18, _blocksPerYear) {}
}

contract MainPrimaryInterestModel is InterestRateModelV2 {
    constructor(uint256 _blocksPerYear) public InterestRateModelV2(0, 0.7e18, 0.05e18, 1e18, _blocksPerYear) {}
}

contract MainSecondaryInterestModel is InterestRateModelV2 {
    constructor(uint256 _blocksPerYear) public InterestRateModelV2(0, 0.65e18, 0.07e18, 0.8e18, _blocksPerYear) {}
}

contract CakeLikeInterestModel is InterestRateModelV2 {
    constructor(uint256 _blocksPerYear) public InterestRateModelV2(0, 0.65e18, 0.07e18, 1.2e18, _blocksPerYear) {}
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @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 SafeMathUpgradeable {
    /**
     * @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) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        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) {
        // 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 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) {
        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) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

//SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";

library SafeRatioMath {
    using SafeMathUpgradeable for uint256;

    uint256 private constant BASE = 10**18;
    uint256 private constant DOUBLE = 10**36;

    function divup(uint256 x, uint256 y) internal pure returns (uint256 z) {
        z = x.add(y.sub(1)).div(y);
    }

    function rmul(uint256 x, uint256 y) internal pure returns (uint256 z) {
        z = x.mul(y).div(BASE);
    }

    function rdiv(uint256 x, uint256 y) internal pure returns (uint256 z) {
        z = x.mul(BASE).div(y);
    }

    function rdivup(uint256 x, uint256 y) internal pure returns (uint256 z) {
        z = x.mul(BASE).add(y.sub(1)).div(y);
    }

    function tmul(
        uint256 x,
        uint256 y,
        uint256 z
    ) internal pure returns (uint256 result) {
        result = x.mul(y).mul(z).div(DOUBLE);
    }

    function rpow(
        uint256 x,
        uint256 n,
        uint256 base
    ) internal pure returns (uint256 z) {
        assembly {
            switch x
                case 0 {
                    switch n
                        case 0 {
                            z := base
                        }
                        default {
                            z := 0
                        }
                }
                default {
                    switch mod(n, 2)
                        case 0 {
                            z := base
                        }
                        default {
                            z := x
                        }
                    let half := div(base, 2) // for rounding.

                    for {
                        n := div(n, 2)
                    } n {
                        n := div(n, 2)
                    } {
                        let xx := mul(x, x)
                        if iszero(eq(div(xx, x), x)) {
                            revert(0, 0)
                        }
                        let xxRound := add(xx, half)
                        if lt(xxRound, xx) {
                            revert(0, 0)
                        }
                        x := div(xxRound, base)
                        if mod(n, 2) {
                            let zx := mul(z, x)
                            if and(
                                iszero(iszero(x)),
                                iszero(eq(div(zx, x), z))
                            ) {
                                revert(0, 0)
                            }
                            let zxRound := add(zx, half)
                            if lt(zxRound, zx) {
                                revert(0, 0)
                            }
                            z := div(zxRound, base)
                        }
                    }
                }
        }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"uint256","name":"_blocksPerYear","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"base","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"blocksPerYear","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balance","type":"uint256"},{"internalType":"uint256","name":"_borrows","type":"uint256"},{"internalType":"uint256","name":"_reserves","type":"uint256"}],"name":"getBorrowRate","outputs":[{"internalType":"uint256","name":"_borrowRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInterestRateModel","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"optimal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"slope_1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"slope_2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506040516105ec3803806105ec8339818101604052602081101561003357600080fd5b50516000670c7d713b49da000066b1a2bc2ec50000670853a0d2313c000084600081116100915760405162461bcd60e51b81526004018080602001828103825260358152602001806105b76035913960400191505060405180910390fd5b60019490945560029290925560035560045560005550610501806100b66000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80635001f3b51161005b5780635001f3b5146100e15780637dbefcb6146100e9578063a385fb96146100f1578063e7bed802146100f95761007d565b806315f24053146100825780632191f92a146100bd5780634d24044c146100d9575b600080fd5b6100ab6004803603606081101561009857600080fd5b5080359060208101359060400135610101565b60408051918252519081900360200190f35b6100c56101c5565b604080519115158252519081900360200190f35b6100ab6101ca565b6100ab6101d0565b6100ab6101d6565b6100ab6101dc565b6100ab6101e2565b60008061010f8585856101e8565b905060006002548210156101515761014a61014160025461013b8560035461025690919063ffffffff16565b906102b8565b600154906102fa565b90506101ad565b6101aa610195610174600254670de0b6b3a764000061035490919063ffffffff16565b61013b61018c6002548761035490919063ffffffff16565b60045490610256565b6003546001546101a4916102fa565b906102fa565b90505b6000546101bb9082906102b8565b9695505050505050565b600190565b60025481565b60015481565b60035481565b60005481565b60045481565b6000826101f75750600061024f565b600061020385856102fa565b905082811161021d57670de0b6b3a764000091505061024f565b60006102298285610354565b90508085111561024557670de0b6b3a76400009250505061024f565b6101bb8582610396565b9392505050565b600082610265575060006102b2565b8282028284828161027257fe5b04146102af5760405162461bcd60e51b81526004018080602001828103825260218152602001806104ab6021913960400191505060405180910390fd5b90505b92915050565b60006102af83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506103ae565b6000828201838110156102af576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60006102af83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610450565b60006102af8261013b85670de0b6b3a7640000610256565b6000818361043a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156103ff5781810151838201526020016103e7565b50505050905090810190601f16801561042c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161044657fe5b0495945050505050565b600081848411156104a25760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156103ff5781810151838201526020016103e7565b50505090039056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122095e1fede4795595642e4bdd6fd63e3b997124bd1eb2db97a92a88717aa69b29a64736f6c634300060c0033696e746572657374526174654d6f64656c56323a20426c6f636b732070657220796561722063616e206e6f74206265207a65726f2100000000000000000000000000000000000000000000000000000000002503f6

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80635001f3b51161005b5780635001f3b5146100e15780637dbefcb6146100e9578063a385fb96146100f1578063e7bed802146100f95761007d565b806315f24053146100825780632191f92a146100bd5780634d24044c146100d9575b600080fd5b6100ab6004803603606081101561009857600080fd5b5080359060208101359060400135610101565b60408051918252519081900360200190f35b6100c56101c5565b604080519115158252519081900360200190f35b6100ab6101ca565b6100ab6101d0565b6100ab6101d6565b6100ab6101dc565b6100ab6101e2565b60008061010f8585856101e8565b905060006002548210156101515761014a61014160025461013b8560035461025690919063ffffffff16565b906102b8565b600154906102fa565b90506101ad565b6101aa610195610174600254670de0b6b3a764000061035490919063ffffffff16565b61013b61018c6002548761035490919063ffffffff16565b60045490610256565b6003546001546101a4916102fa565b906102fa565b90505b6000546101bb9082906102b8565b9695505050505050565b600190565b60025481565b60015481565b60035481565b60005481565b60045481565b6000826101f75750600061024f565b600061020385856102fa565b905082811161021d57670de0b6b3a764000091505061024f565b60006102298285610354565b90508085111561024557670de0b6b3a76400009250505061024f565b6101bb8582610396565b9392505050565b600082610265575060006102b2565b8282028284828161027257fe5b04146102af5760405162461bcd60e51b81526004018080602001828103825260218152602001806104ab6021913960400191505060405180910390fd5b90505b92915050565b60006102af83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506103ae565b6000828201838110156102af576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60006102af83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610450565b60006102af8261013b85670de0b6b3a7640000610256565b6000818361043a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156103ff5781810151838201526020016103e7565b50505050905090810190601f16801561042c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161044657fe5b0495945050505050565b600081848411156104a25760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156103ff5781810151838201526020016103e7565b50505090039056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122095e1fede4795595642e4bdd6fd63e3b997124bd1eb2db97a92a88717aa69b29a64736f6c634300060c0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000000000000000000000000000000000000002503f6

-----Decoded View---------------
Arg [0] : _blocksPerYear (uint256): 2425846

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000002503f6


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
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.