ETH Price: $1,987.49 (+1.41%)

Contract

0x0D184ADF34065598311233A1d37765f76fbC5a72

Overview

ETH Balance

0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Transfer Ownersh...2547689392024-09-18 10:30:25512 days ago1726655425IN
0x0D184ADF...76fbC5a72
0 ETH0.000000850.01
Transfer Ownersh...2540993742024-09-16 11:31:20514 days ago1726486280IN
0x0D184ADF...76fbC5a72
0 ETH0.000000630.01

Parent Transaction Hash Block From To
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
WethVariableUtilisationRatesCalculator

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: BUSL-1.1
// Last deployed from commit: b75e073cf23a3eb181f55a89a800ef040b7ba456;
pragma solidity 0.8.17;

import "@openzeppelin/contracts/access/Ownable.sol";
import "../../interfaces/IRatesCalculator.sol";

/**
 * @title WethVariableUtilisationRatesCalculator
 * @dev Contract which calculates the interest rates based on pool utilisation.
 * Utilisation is computed as the ratio between funds borrowed and funds deposited to the pool.
 * Borrowing rates are calculated using a piecewise linear function. The first piece is defined by SLOPE_1
 * and OFFSET (shift). Second piece is defined by SLOPE_2 (calculated off-chain), BREAKPOINT (threshold value above
 * which second piece is considered) and MAX_RATE (value at pool utilisation of 1).
 **/
contract WethVariableUtilisationRatesCalculator is IRatesCalculator, Ownable {
    uint256 public constant SLOPE_1 = 0.05e18;
    uint256 public constant OFFSET_1 = 0;

    uint256 public constant BREAKPOINT_1 = 0.6e18;

    uint256 public constant SLOPE_2 = 0.2e18;
    //negative, hence minus in calculations
    uint256 public constant OFFSET_2 = 0.09e18;

    uint256 public constant BREAKPOINT_2 = 0.8e18;

    uint256 public constant SLOPE_3 = 0.5e18;
    //negative, hence minus in calculations
    uint256 public constant OFFSET_3 = 0.33e18;

    // BREAKPOINT must be lower than 1e18

    uint256 public constant BREAKPOINT_3 = 0.9e18;

    uint256 public constant SLOPE_4= 29.8e18;
    //negative, hence minus in calculations
    uint256 public constant OFFSET_4 = 26.7e18;

    uint256 public constant MAX_RATE = 3.1e18;




    //residual spread to account for arithmetic inaccuracies in calculation of deposit rate. Does not result in any meaningful
    //profit generation
    uint256 public spread = 1e12;

    /* ========== VIEW FUNCTIONS ========== */

    /**
     * Returns the pool utilisation, which is a ratio between loans and deposits
     * utilisation = value_of_loans / value_of_deposits
     * @dev _totalLoans total value of loans
     * @dev _totalDeposits total value of deposits
     **/
    function getPoolUtilisation(uint256 _totalLoans, uint256 _totalDeposits) public pure returns (uint256) {
        if (_totalDeposits == 0) return 0;

        return (_totalLoans * 1e18) / _totalDeposits;
    }

    /**
     * Returns the current deposit rate
     * The value is based on the current borrowing rate and satisfies the invariant:
     * value_of_loans * borrowing_rate = value_of_deposits * deposit_rate
     * @dev _totalLoans total value of loans
     * @dev _totalDeposits total value of deposits
     **/
    function calculateDepositRate(uint256 _totalLoans, uint256 _totalDeposits) external view override returns (uint256) {
        if (_totalDeposits == 0) return 0;

        if (_totalLoans >= _totalDeposits) {
            return MAX_RATE * (1e18 - spread) / 1e18;
        } else {
            uint256 rate = this.calculateBorrowingRate(_totalLoans, _totalDeposits) * (1e18 - spread) * _totalLoans / (_totalDeposits * 1e18);
            return rate;
        }
    }

    /**
     * Returns the current borrowing rate
     * The value is based on the pool utilisation according to the piecewise linear formula:
     * 1) for pool utilisation lower than or equal to breakpoint:
     * borrowing_rate = SLOPE_1 * utilisation + OFFSET
     * 2) for pool utilisation greater than breakpoint:
     * borrowing_rate = SLOPE_2 * utilisation + MAX_RATE - SLOPE_2
     * @dev _totalLoans total value of loans
     * @dev _totalDeposits total value of deposits
     **/
    function calculateBorrowingRate(uint256 totalLoans, uint256 totalDeposits) external pure override returns (uint256) {
        if (totalDeposits == 0) return OFFSET_1;

        uint256 poolUtilisation = getPoolUtilisation(totalLoans, totalDeposits);

        if (poolUtilisation >= 1e18) {
            return MAX_RATE;
        } else if (poolUtilisation <= BREAKPOINT_1) {
            return (poolUtilisation * SLOPE_1) / 1e18 + OFFSET_1;
        } else if (poolUtilisation <= BREAKPOINT_2) {
            return (poolUtilisation * SLOPE_2) / 1e18 - OFFSET_2;
        } else if (poolUtilisation <= BREAKPOINT_3) {
            return (poolUtilisation * SLOPE_3) / 1e18 - OFFSET_3;
        } else {
            // full formula derived from piecewise linear function calculation except for SLOPE_2/3/4 subtraction (separated for
            // unsigned integer safety check)
            return (poolUtilisation * SLOPE_4) / 1e18 - OFFSET_4;
        }
    }

    /* ========== SETTERS ========== */
    /**
     * Sets the spread between deposit and borrow rate, number between 0 and 1e18
     * @param _spread spread defined by user
     **/
    function setSpread(uint256 _spread) external onlyOwner {
        require(_spread < 1e18, "Spread must be smaller than 1e18");
        spread = _spread;
        emit SpreadChanged(msg.sender, _spread, block.timestamp);
    }

    /* ========== OVERRIDDEN FUNCTIONS ========== */

    function renounceOwnership() public virtual override {}

    /* ========== EVENTS ========== */

    /**
     * @dev emitted after changing the spread
     * @param performer an address of wallet setting a new spread
     * @param newSpread new spread
     * @param timestamp time of a spread change
     **/
    event SpreadChanged(address indexed performer, uint256 newSpread, uint256 timestamp);
}

// 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);
    }
}

// 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;
    }
}

// SPDX-License-Identifier: BUSL-1.1
// Last deployed from commit: ;
pragma solidity 0.8.17;

/**
 * @title IRatesCalculator
 * @dev Interface defining base method for contracts implementing interest rates calculation.
 * The calculated value could be based on the relation between funds borrowed and deposited.
 */
interface IRatesCalculator {
    function calculateBorrowingRate(uint256 totalLoans, uint256 totalDeposits) external view returns (uint256);

    function calculateDepositRate(uint256 totalLoans, uint256 totalDeposits) external view returns (uint256);
}

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

Contract Security Audit

Contract ABI

API
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"performer","type":"address"},{"indexed":false,"internalType":"uint256","name":"newSpread","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"SpreadChanged","type":"event"},{"inputs":[],"name":"BREAKPOINT_1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BREAKPOINT_2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BREAKPOINT_3","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OFFSET_1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OFFSET_2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OFFSET_3","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OFFSET_4","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"},{"inputs":[],"name":"SLOPE_3","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLOPE_4","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"totalLoans","type":"uint256"},{"internalType":"uint256","name":"totalDeposits","type":"uint256"}],"name":"calculateBorrowingRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_totalLoans","type":"uint256"},{"internalType":"uint256","name":"_totalDeposits","type":"uint256"}],"name":"calculateDepositRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_totalLoans","type":"uint256"},{"internalType":"uint256","name":"_totalDeposits","type":"uint256"}],"name":"getPoolUtilisation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_spread","type":"uint256"}],"name":"setSpread","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"spread","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405264e8d4a5100060015534801561001957600080fd5b5061002333610028565b610078565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610829806100876000396000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c80637cd08331116100ad578063b66a261c11610071578063b66a261c14610220578063bfe7cfd214610233578063c24dbebd14610242578063df841eec14610251578063f2fde38b1461026457600080fd5b80637cd08331146101c05780638da5cb5b146101d35780639a6fc9dc146101ee5780639ceca965146101fe578063b5f78b051461021157600080fd5b806356f21639116100f457806356f21639146101885780635c25c76c146101975780636e28a05d146101a057806370935a50146101af578063715018a6146101be57600080fd5b806301a5e5a01461013157806318c544b114610153578063321105fb1461015b5780633bf42d4b1461016957806349d94fee14610178575b600080fd5b610140670853a0d2313c000081565b6040519081526020015b60405180910390f35b610140600081565b61014066b1a2bc2ec5000081565b6101406702c68af0bb14000081565b6101406801728974898eee000081565b610140670494654067e1000081565b61014060015481565b61014067013fbe85edc9000081565b610140670b1a2bc2ec50000081565b005b6101406101ce366004610701565b610277565b6000546040516001600160a01b03909116815260200161014a565b61014068019d8ede1ce2a4000081565b61014061020c366004610701565b610391565b610140670c7d713b49da000081565b6101be61022e366004610723565b6103c7565b6101406706f05b59d3b2000081565b610140672b05699353b6000081565b61014061025f366004610701565b6104bf565b6101be61027236600461073c565b6105e6565b6000816000036102895750600061038b565b8183106102d257670de0b6b3a7640000600154670de0b6b3a76400006102af919061077b565b6102c190672b05699353b6000061078e565b6102cb91906107a5565b905061038b565b60006102e683670de0b6b3a764000061078e565b84600154670de0b6b3a76400006102fd919061077b565b6040516337e107bb60e21b81526004810188905260248101879052309063df841eec90604401602060405180830381865afa158015610340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036491906107c7565b61036e919061078e565b610378919061078e565b61038291906107a5565b915061038b9050565b92915050565b6000816000036103a35750600061038b565b816103b684670de0b6b3a764000061078e565b6103c091906107a5565b9392505050565b6000546001600160a01b031633146104265760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b670de0b6b3a7640000811061047d5760405162461bcd60e51b815260206004820181905260248201527f537072656164206d75737420626520736d616c6c6572207468616e2031653138604482015260640161041d565b60018190556040805182815242602082015233917f9e606dc778840dd5372c982cb6a54acae1e2f85905de7f64d37c63a0c5830e22910160405180910390a250565b6000816000036104d15750600061038b565b60006104dd8484610391565b9050670de0b6b3a764000081106104ff57672b05699353b6000091505061038b565b670853a0d2313c00008111610546576000670de0b6b3a764000061052a66b1a2bc2ec500008461078e565b61053491906107a5565b61053e91906107e0565b91505061038b565b670b1a2bc2ec500000811161058d5767013fbe85edc90000670de0b6b3a76400006105796702c68af0bb1400008461078e565b61058391906107a5565b61053e919061077b565b670c7d713b49da000081116105c057670494654067e10000670de0b6b3a76400006105796706f05b59d3b200008461078e565b6801728974898eee0000670de0b6b3a764000061057968019d8ede1ce2a400008461078e565b6000546001600160a01b031633146106405760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161041d565b6001600160a01b0381166106a55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161041d565b6106ae816106b1565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806040838503121561071457600080fd5b50508035926020909101359150565b60006020828403121561073557600080fd5b5035919050565b60006020828403121561074e57600080fd5b81356001600160a01b03811681146103c057600080fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561038b5761038b610765565b808202811582820484141761038b5761038b610765565b6000826107c257634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156107d957600080fd5b5051919050565b8082018082111561038b5761038b61076556fea2646970667358221220904727912ceeff40b2e3f8f269a7bbdcfbd4fb80f5c9d8638433522938d3622864736f6c63430008110033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061012c5760003560e01c80637cd08331116100ad578063b66a261c11610071578063b66a261c14610220578063bfe7cfd214610233578063c24dbebd14610242578063df841eec14610251578063f2fde38b1461026457600080fd5b80637cd08331146101c05780638da5cb5b146101d35780639a6fc9dc146101ee5780639ceca965146101fe578063b5f78b051461021157600080fd5b806356f21639116100f457806356f21639146101885780635c25c76c146101975780636e28a05d146101a057806370935a50146101af578063715018a6146101be57600080fd5b806301a5e5a01461013157806318c544b114610153578063321105fb1461015b5780633bf42d4b1461016957806349d94fee14610178575b600080fd5b610140670853a0d2313c000081565b6040519081526020015b60405180910390f35b610140600081565b61014066b1a2bc2ec5000081565b6101406702c68af0bb14000081565b6101406801728974898eee000081565b610140670494654067e1000081565b61014060015481565b61014067013fbe85edc9000081565b610140670b1a2bc2ec50000081565b005b6101406101ce366004610701565b610277565b6000546040516001600160a01b03909116815260200161014a565b61014068019d8ede1ce2a4000081565b61014061020c366004610701565b610391565b610140670c7d713b49da000081565b6101be61022e366004610723565b6103c7565b6101406706f05b59d3b2000081565b610140672b05699353b6000081565b61014061025f366004610701565b6104bf565b6101be61027236600461073c565b6105e6565b6000816000036102895750600061038b565b8183106102d257670de0b6b3a7640000600154670de0b6b3a76400006102af919061077b565b6102c190672b05699353b6000061078e565b6102cb91906107a5565b905061038b565b60006102e683670de0b6b3a764000061078e565b84600154670de0b6b3a76400006102fd919061077b565b6040516337e107bb60e21b81526004810188905260248101879052309063df841eec90604401602060405180830381865afa158015610340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036491906107c7565b61036e919061078e565b610378919061078e565b61038291906107a5565b915061038b9050565b92915050565b6000816000036103a35750600061038b565b816103b684670de0b6b3a764000061078e565b6103c091906107a5565b9392505050565b6000546001600160a01b031633146104265760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b670de0b6b3a7640000811061047d5760405162461bcd60e51b815260206004820181905260248201527f537072656164206d75737420626520736d616c6c6572207468616e2031653138604482015260640161041d565b60018190556040805182815242602082015233917f9e606dc778840dd5372c982cb6a54acae1e2f85905de7f64d37c63a0c5830e22910160405180910390a250565b6000816000036104d15750600061038b565b60006104dd8484610391565b9050670de0b6b3a764000081106104ff57672b05699353b6000091505061038b565b670853a0d2313c00008111610546576000670de0b6b3a764000061052a66b1a2bc2ec500008461078e565b61053491906107a5565b61053e91906107e0565b91505061038b565b670b1a2bc2ec500000811161058d5767013fbe85edc90000670de0b6b3a76400006105796702c68af0bb1400008461078e565b61058391906107a5565b61053e919061077b565b670c7d713b49da000081116105c057670494654067e10000670de0b6b3a76400006105796706f05b59d3b200008461078e565b6801728974898eee0000670de0b6b3a764000061057968019d8ede1ce2a400008461078e565b6000546001600160a01b031633146106405760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161041d565b6001600160a01b0381166106a55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161041d565b6106ae816106b1565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806040838503121561071457600080fd5b50508035926020909101359150565b60006020828403121561073557600080fd5b5035919050565b60006020828403121561074e57600080fd5b81356001600160a01b03811681146103c057600080fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561038b5761038b610765565b808202811582820484141761038b5761038b610765565b6000826107c257634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156107d957600080fd5b5051919050565b8082018082111561038b5761038b61076556fea2646970667358221220904727912ceeff40b2e3f8f269a7bbdcfbd4fb80f5c9d8638433522938d3622864736f6c63430008110033

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.