HYPE Price: $22.66 (+2.35%)
 

Overview

HYPE Balance

HyperEVM LogoHyperEVM LogoHyperEVM Logo0 HYPE

HYPE Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Cross-Chain Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x64a63d0e...5613EE483
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
VariableInterestRate

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: ISC
pragma solidity ^0.8.19;

// ====================================================================
// |     ______                   _______                             |
// |    / _____________ __  __   / ____(_____  ____ _____  ________   |
// |   / /_  / ___/ __ `| |/_/  / /_  / / __ \/ __ `/ __ \/ ___/ _ \  |
// |  / __/ / /  / /_/ _>  <   / __/ / / / / / /_/ / / / / /__/  __/  |
// | /_/   /_/   \__,_/_/|_|  /_/   /_/_/ /_/\__,_/_/ /_/\___/\___/   |
// |                                                                  |
// ====================================================================
// ====================== VariableInterestRate ========================
// ====================================================================
// Frax Finance: https://github.com/FraxFinance

// Primary Author
// Drake Evans: https://github.com/DrakeEvans

// Reviewers
// Dennis: https://github.com/denett

// ====================================================================

import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {IRateCalculatorV2} from "./interfaces/IRateCalculatorV2.sol";

/// @title A formula for calculating interest rates as a function of utilization and time
/// @author Drake Evans github.com/drakeevans
/// @notice A Contract for calculating interest rates as a function of utilization and time
contract VariableInterestRate is IRateCalculatorV2 {
    using Strings for uint256;

    /// @notice The name suffix for the interest rate calculator
    string public suffix;

    // Utilization Settings
    /// @notice The minimum utilization wherein no adjustment to full utilization and vertex rates occurs
    uint256 public immutable MIN_TARGET_UTIL;
    /// @notice The maximum utilization wherein no adjustment to full utilization and vertex rates occurs
    uint256 public immutable MAX_TARGET_UTIL;
    /// @notice The utilization at which the slope increases
    uint256 public immutable VERTEX_UTILIZATION;
    /// @notice precision of utilization calculations
    uint256 public constant UTIL_PREC = 1e5; // 5 decimals

    // Interest Rate Settings (all rates are per second), 365.24 days per year
    /// @notice The minimum interest rate (per second) when utilization is 100%
    uint256 public immutable MIN_FULL_UTIL_RATE; // 18 decimals
    /// @notice The maximum interest rate (per second) when utilization is 100%
    uint256 public immutable MAX_FULL_UTIL_RATE; // 18 decimals
    /// @notice The interest rate (per second) when utilization is 0%
    uint256 public immutable ZERO_UTIL_RATE; // 18 decimals
    /// @notice The interest rate half life in seconds, determines rate of adjustments to rate curve
    uint256 public immutable RATE_HALF_LIFE; // 1 decimals
    /// @notice The percent of the delta between max and min
    uint256 public immutable VERTEX_RATE_PERCENT; // 18 decimals
    /// @notice The precision of interest rate calculations
    uint256 public constant RATE_PREC = 1e18; // 18 decimals

    /// @notice The ```constructor``` function
    /// @param _suffix The suffix of the contract name
    /// @param _vertexUtilization The utilization at which the slope increases
    /// @param _vertexRatePercentOfDelta The percent of the delta between max and min, defines vertex rate
    /// @param _minUtil The minimum utilization wherein no adjustment to full utilization and vertex rates occurs
    /// @param _maxUtil The maximum utilization wherein no adjustment to full utilization and vertex rates occurs
    /// @param _zeroUtilizationRate The interest rate (per second) when utilization is 0%
    /// @param _minFullUtilizationRate The minimum interest rate at 100% utilization
    /// @param _maxFullUtilizationRate The maximum interest rate at 100% utilization
    /// @param _rateHalfLife The half life parameter for interest rate adjustments
    constructor(
        string memory _suffix,
        uint256 _vertexUtilization,
        uint256 _vertexRatePercentOfDelta,
        uint256 _minUtil,
        uint256 _maxUtil,
        uint256 _zeroUtilizationRate,
        uint256 _minFullUtilizationRate,
        uint256 _maxFullUtilizationRate,
        uint256 _rateHalfLife
    ) {
        suffix = _suffix;
        MIN_TARGET_UTIL = _minUtil;
        MAX_TARGET_UTIL = _maxUtil;
        VERTEX_UTILIZATION = _vertexUtilization;
        ZERO_UTIL_RATE = _zeroUtilizationRate;
        MIN_FULL_UTIL_RATE = _minFullUtilizationRate;
        MAX_FULL_UTIL_RATE = _maxFullUtilizationRate;
        RATE_HALF_LIFE = _rateHalfLife;
        VERTEX_RATE_PERCENT = _vertexRatePercentOfDelta;
    }

    /// @notice The ```name``` function returns the name of the rate contract
    /// @return memory name of contract
    function name() external view returns (string memory) {
        return string(abi.encodePacked("Variable Rate V2 ", suffix));
    }

    /// @notice The ```version``` function returns the semantic version of the rate contract
    /// @dev Follows semantic versioning
    /// @return _major Major version
    /// @return _minor Minor version
    /// @return _patch Patch version
    function version() external pure returns (uint256 _major, uint256 _minor, uint256 _patch) {
        _major = 2;
        _minor = 0;
        _patch = 0;
    }

    /// @notice The ```getFullUtilizationInterest``` function calculate the new maximum interest rate, i.e. rate when utilization is 100%
    /// @dev Given in interest per second
    /// @param _deltaTime The elapsed time since last update given in seconds
    /// @param _utilization The utilization %, given with 5 decimals of precision
    /// @param _fullUtilizationInterest The interest value when utilization is 100%, given with 18 decimals of precision
    /// @return _newFullUtilizationInterest The new maximum interest rate
    function getFullUtilizationInterest(uint256 _deltaTime, uint256 _utilization, uint64 _fullUtilizationInterest)
        internal
        view
        returns (uint64 _newFullUtilizationInterest)
    {
        if (_utilization < MIN_TARGET_UTIL) {
            // 18 decimals
            uint256 _deltaUtilization = ((MIN_TARGET_UTIL - _utilization) * 1e18) / MIN_TARGET_UTIL;
            // 36 decimals
            uint256 _decayGrowth = (RATE_HALF_LIFE * 1e36) + (_deltaUtilization * _deltaUtilization * _deltaTime);
            // 18 decimals
            _newFullUtilizationInterest = uint64((_fullUtilizationInterest * (RATE_HALF_LIFE * 1e36)) / _decayGrowth);
        } else if (_utilization > MAX_TARGET_UTIL) {
            // 18 decimals
            uint256 _deltaUtilization = ((_utilization - MAX_TARGET_UTIL) * 1e18) / (UTIL_PREC - MAX_TARGET_UTIL);
            // 36 decimals
            uint256 _decayGrowth = (RATE_HALF_LIFE * 1e36) + (_deltaUtilization * _deltaUtilization * _deltaTime);
            // 18 decimals
            _newFullUtilizationInterest = uint64((_fullUtilizationInterest * _decayGrowth) / (RATE_HALF_LIFE * 1e36));
        } else {
            _newFullUtilizationInterest = _fullUtilizationInterest;
        }
        if (_newFullUtilizationInterest > MAX_FULL_UTIL_RATE) {
            _newFullUtilizationInterest = uint64(MAX_FULL_UTIL_RATE);
        } else if (_newFullUtilizationInterest < MIN_FULL_UTIL_RATE) {
            _newFullUtilizationInterest = uint64(MIN_FULL_UTIL_RATE);
        }
    }

    /// @notice The ```getNewRate``` function calculates interest rates using two linear functions f(utilization)
    /// @param _deltaTime The elapsed time since last update, given in seconds
    /// @param _utilization The utilization %, given with 5 decimals of precision
    /// @param _oldFullUtilizationInterest The interest value when utilization is 100%, given with 18 decimals of precision
    /// @return _newRatePerSec The new interest rate, 18 decimals of precision
    /// @return _newFullUtilizationInterest The new max interest rate, 18 decimals of precision
    function getNewRate(uint256 _deltaTime, uint256 _utilization, uint64 _oldFullUtilizationInterest)
        external
        view
        returns (uint64 _newRatePerSec, uint64 _newFullUtilizationInterest)
    {
        _newFullUtilizationInterest = getFullUtilizationInterest(_deltaTime, _utilization, _oldFullUtilizationInterest);

        // _vertexInterest is calculated as the percentage of the delta between min and max interest
        uint256 _vertexInterest =
            (((_newFullUtilizationInterest - ZERO_UTIL_RATE) * VERTEX_RATE_PERCENT) / RATE_PREC) + ZERO_UTIL_RATE;
        if (_utilization < VERTEX_UTILIZATION) {
            // For readability, the following formula is equivalent to:
            // uint256 _slope = ((_vertexInterest - ZERO_UTIL_RATE) * UTIL_PREC) / VERTEX_UTILIZATION;
            // _newRatePerSec = uint64(ZERO_UTIL_RATE + ((_utilization * _slope) / UTIL_PREC));

            // 18 decimals
            _newRatePerSec =
                uint64(ZERO_UTIL_RATE + (_utilization * (_vertexInterest - ZERO_UTIL_RATE)) / VERTEX_UTILIZATION);
        } else {
            // For readability, the following formula is equivalent to:
            // uint256 _slope = (((_newFullUtilizationInterest - _vertexInterest) * UTIL_PREC) / (UTIL_PREC - VERTEX_UTILIZATION));
            // _newRatePerSec = uint64(_vertexInterest + (((_utilization - VERTEX_UTILIZATION) * _slope) / UTIL_PREC));

            // 18 decimals
            _newRatePerSec = uint64(
                _vertexInterest
                    + ((_utilization - VERTEX_UTILIZATION) * (_newFullUtilizationInterest - _vertexInterest))
                        / (UTIL_PREC - VERTEX_UTILIZATION)
            );
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

// SPDX-License-Identifier: ISC
pragma solidity ^0.8.19;

interface IRateCalculatorV2 {
    function name() external view returns (string memory);

    function version() external view returns (uint256, uint256, uint256);

    function getNewRate(
        uint256 _deltaTime,
        uint256 _utilization,
        uint64 _maxInterest
    ) external view returns (uint64 _newRatePerSec, uint64 _newMaxInterest);
}

Settings
{
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "remappings": [
    "@chainlink/=node_modules/@chainlink/",
    "@ensdomains/=node_modules/@ensdomains/",
    "@eth-optimism/=node_modules/@eth-optimism/",
    "@mean-finance/=node_modules/@mean-finance/",
    "@openzeppelin/=node_modules/@openzeppelin/",
    "@rari-capital/=node_modules/@rari-capital/",
    "@uniswap/=node_modules/@uniswap/",
    "base64-sol/=node_modules/base64-sol/",
    "ds-test/=lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "eth-gas-reporter/=node_modules/eth-gas-reporter/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "hardhat/=node_modules/hardhat/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solidity-bytes-utils/=node_modules/solidity-bytes-utils/",
    "gluex-router/=lib/gluex_router_contract/router_v1/",
    "@pythnetwork/=lib/pyth-adapters/node_modules/@pythnetwork/",
    "gluex_router_contract/=lib/gluex_router_contract/",
    "pyth-adapters/=lib/pyth-adapters/",
    "v3-core/=lib/v3-core/",
    "v3-periphery/=lib/v3-periphery/contracts/"
  ],
  "viaIR": true
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"string","name":"_suffix","type":"string"},{"internalType":"uint256","name":"_vertexUtilization","type":"uint256"},{"internalType":"uint256","name":"_vertexRatePercentOfDelta","type":"uint256"},{"internalType":"uint256","name":"_minUtil","type":"uint256"},{"internalType":"uint256","name":"_maxUtil","type":"uint256"},{"internalType":"uint256","name":"_zeroUtilizationRate","type":"uint256"},{"internalType":"uint256","name":"_minFullUtilizationRate","type":"uint256"},{"internalType":"uint256","name":"_maxFullUtilizationRate","type":"uint256"},{"internalType":"uint256","name":"_rateHalfLife","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"MAX_FULL_UTIL_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TARGET_UTIL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_FULL_UTIL_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_TARGET_UTIL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RATE_HALF_LIFE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RATE_PREC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UTIL_PREC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERTEX_RATE_PERCENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERTEX_UTILIZATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ZERO_UTIL_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_deltaTime","type":"uint256"},{"internalType":"uint256","name":"_utilization","type":"uint256"},{"internalType":"uint64","name":"_oldFullUtilizationInterest","type":"uint64"}],"name":"getNewRate","outputs":[{"internalType":"uint64","name":"_newRatePerSec","type":"uint64"},{"internalType":"uint64","name":"_newFullUtilizationInterest","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"suffix","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"_major","type":"uint256"},{"internalType":"uint256","name":"_minor","type":"uint256"},{"internalType":"uint256","name":"_patch","type":"uint256"}],"stateMutability":"pure","type":"function"}]

0x61018060405234620002e85762000cd9803803806200001e81620002ed565b9283398101610120908183820312620002e85782516001600160401b039190828111620002e857840191601f90828285011215620002e857835190808211620002bd57602091601f19956200007984888785011601620002ed565b95828752848383010111620002e857839060005b838110620002d35750506000918601015281870151604088015195606089015160808a01519160a08b01519460c08c01519660e08d015198610100809e01519a8051938411620002bd57600054926001938481811c91168015620002b2575b828210146200029c5783811162000251575b5080928511600114620001e7575083945090839291600094620001db575b50501b916000199060031b1c1916176000555b60805260a05260c052855260e0528452610140908152610160918252604051926109c594856200031486396080518581816101d50152610590015260a05185818161045301526106a9015260c0518581816103470152610555015260e05185818161040401526106e40152518481816102a8015261084e0152518381816102db015261062901525182818161023e015281816104ce015261071f01525181818161031901526105cb0152f35b0151925038806200011c565b9294849081166000805284600020946000905b888383106200023657505050106200021c575b505050811b016000556200012f565b015160001960f88460031b161c191690553880806200020d565b858701518855909601959485019487935090810190620001fa565b60008052816000208480880160051c82019284891062000292575b0160051c019085905b82811062000285575050620000fe565b6000815501859062000275565b925081926200026c565b634e487b7160e01b600052602260045260246000fd5b90607f1690620000ec565b634e487b7160e01b600052604160045260246000fd5b8181018301518882018401528592016200008d565b600080fd5b6040519190601f01601f191682016001600160401b03811183821017620002bd5760405256fe608060408181526004918236101561001657600080fd5b600092833560e01c9182624c98af146108375750816306fdde031461074257816317784ca41461070757816331bf879d146106cc57816340797eda1461069157816354fd4d501461066a5781636cd3cc771461064c5781638e75618c1461061157816391474c49146105ee57816395da99fc146105b35781639c07327014610578578163c41681251461053d578163cd3181d51461019f575063f7073c3a146100be57600080fd5b3461019b578160031936011261019b578051908280546100dd816108ba565b808552916001918083169081156101735750600114610117575b505050610109826101139403836108f4565b5191829182610871565b0390f35b80809650527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b82861061015b5750505061010982602061011395820101946100f7565b8054602087870181019190915290950194810161013e565b61011397508693506020925061010994915060ff191682840152151560051b820101946100f7565b5080fd5b8391503461019b57606036600319011261019b57803591602490813560443567ffffffffffffffff9586821691828103610539577f0000000000000000000000000000000000000000000000000000000000000000908185101561044e5750610208848261092c565b670de0b6b3a76400009081810291818304149015171561043c579061022c91610962565b6ec097ce7bc90715b34b9f10000000007f0000000000000000000000000000000000000000000000000000000000000000818102939291811591850414171561043c57889695949361029f8894610299610293879661028e876102a49861094f565b61094f565b82610982565b9261094f565b610962565b165b7f000000000000000000000000000000000000000000000000000000000000000090828116828111156103fd57505016925b847f000000000000000000000000000000000000000000000000000000000000000094169561034485670de0b6b3a764000061033e610317838c61092c565b7f00000000000000000000000000000000000000000000000000000000000000009061094f565b04610982565b917f0000000000000000000000000000000000000000000000000000000000000000948585106000146103a6575050509161029f6103909261038a86610396979661092c565b9061094f565b90610982565b16915b8351921682526020820152f35b92965092846103c5929596506103bb9161092c565b61038a878961092c565b92620186a09485039485116103ed57505050916103906103e6928694610962565b1691610399565b634e487b7160e01b825260119052fd5b90959291507f0000000000000000000000000000000000000000000000000000000000000000809110610432575b50506102d8565b169350848961042b565b634e487b7160e01b8652601188528686fd5b9192917f0000000000000000000000000000000000000000000000000000000000000000915088908286111561052a57505061048a818561092c565b670de0b6b3a76400009081810291818304149015171561043c57620186a091820391821161043c57906104bc91610962565b6ec097ce7bc90715b34b9f10000000007f0000000000000000000000000000000000000000000000000000000000000000818102949291811591860414171561043c57889695949361029f889461038a61051e879661028e876105249861094f565b84610982565b166102a6565b915095949392508591506102a6565b8480fd5b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50503461019b578160031936011261019b5760209051670de0b6b3a76400008152f35b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50503461019b578160031936011261019b5760209051620186a08152f35b50503461019b578160031936011261019b5760609181519160028352816020840152820152f35b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50503461019b578160031936011261019b578051906020927002b30b934b0b13632902930ba32902b191607d1b848401528093815491610781836108ba565b9260019081811690811561080d57506001146107b0575b6101138686610109828b03601f1981018452836108f4565b90808093949750527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8683106107f95750505050610109826031610113958201019438610798565b8054868401603101529183019181016107da565b905061011397508693506031925061010994915060ff191682840152801515028201019438610798565b84903461019b578160031936011261019b576020907f00000000000000000000000000000000000000000000000000000000000000008152f35b6020808252825181830181905290939260005b8281106108a657505060409293506000838284010152601f8019910116010190565b818101860151848201604001528501610884565b90600182811c921680156108ea575b60208310146108d457565b634e487b7160e01b600052602260045260246000fd5b91607f16916108c9565b90601f8019910116810190811067ffffffffffffffff82111761091657604052565b634e487b7160e01b600052604160045260246000fd5b9190820391821161093957565b634e487b7160e01b600052601160045260246000fd5b8181029291811591840414171561093957565b811561096c570490565b634e487b7160e01b600052601260045260246000fd5b919082018092116109395756fea2646970667358221220557623f64ab430858f29113c8b96dac24a2b0615adf8e378d5663111148cd7d064736f6c634300081300330000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000001117000000000000000000000000000000000000000000000000000071afd498d00000000000000000000000000000000000000000000000000000000000000009c4000000000000000000000000000000000000000000000000000000000000173180000000000000000000000000000000000000000000000000000000025cd0f7f000000000000000000000000000000000000000000000000000000011b81f43d00000000000000000000000000000000000000000000000000000003b10683770000000000000000000000000000000000000000000000000000000000015180000000000000000000000000000000000000000000000000000000000000002ab50a96253abdf803d85efcdce07ad8becbc52bd52d9fd7466f987fd4c45a5bbde22ed8aba5bc8d72d12d00000000000000000000000000000000000000000000

Deployed Bytecode

0x608060408181526004918236101561001657600080fd5b600092833560e01c9182624c98af146108375750816306fdde031461074257816317784ca41461070757816331bf879d146106cc57816340797eda1461069157816354fd4d501461066a5781636cd3cc771461064c5781638e75618c1461061157816391474c49146105ee57816395da99fc146105b35781639c07327014610578578163c41681251461053d578163cd3181d51461019f575063f7073c3a146100be57600080fd5b3461019b578160031936011261019b578051908280546100dd816108ba565b808552916001918083169081156101735750600114610117575b505050610109826101139403836108f4565b5191829182610871565b0390f35b80809650527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b82861061015b5750505061010982602061011395820101946100f7565b8054602087870181019190915290950194810161013e565b61011397508693506020925061010994915060ff191682840152151560051b820101946100f7565b5080fd5b8391503461019b57606036600319011261019b57803591602490813560443567ffffffffffffffff9586821691828103610539577f0000000000000000000000000000000000000000000000000000000000009c40908185101561044e5750610208848261092c565b670de0b6b3a76400009081810291818304149015171561043c579061022c91610962565b6ec097ce7bc90715b34b9f10000000007f0000000000000000000000000000000000000000000000000000000000015180818102939291811591850414171561043c57889695949361029f8894610299610293879661028e876102a49861094f565b61094f565b82610982565b9261094f565b610962565b165b7f00000000000000000000000000000000000000000000000000000003b106837790828116828111156103fd57505016925b847f0000000000000000000000000000000000000000000000000000000025cd0f7f94169561034485670de0b6b3a764000061033e610317838c61092c565b7f00000000000000000000000000000000000000000000000000071afd498d00009061094f565b04610982565b917f0000000000000000000000000000000000000000000000000000000000011170948585106000146103a6575050509161029f6103909261038a86610396979661092c565b9061094f565b90610982565b16915b8351921682526020820152f35b92965092846103c5929596506103bb9161092c565b61038a878961092c565b92620186a09485039485116103ed57505050916103906103e6928694610962565b1691610399565b634e487b7160e01b825260119052fd5b90959291507f000000000000000000000000000000000000000000000000000000011b81f43d809110610432575b50506102d8565b169350848961042b565b634e487b7160e01b8652601188528686fd5b9192917f0000000000000000000000000000000000000000000000000000000000017318915088908286111561052a57505061048a818561092c565b670de0b6b3a76400009081810291818304149015171561043c57620186a091820391821161043c57906104bc91610962565b6ec097ce7bc90715b34b9f10000000007f0000000000000000000000000000000000000000000000000000000000015180818102949291811591860414171561043c57889695949361029f889461038a61051e879661028e876105249861094f565b84610982565b166102a6565b915095949392508591506102a6565b8480fd5b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000111708152f35b50503461019b578160031936011261019b57602090517f0000000000000000000000000000000000000000000000000000000000009c408152f35b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000071afd498d00008152f35b50503461019b578160031936011261019b5760209051670de0b6b3a76400008152f35b50503461019b578160031936011261019b57602090517f0000000000000000000000000000000000000000000000000000000025cd0f7f8152f35b50503461019b578160031936011261019b5760209051620186a08152f35b50503461019b578160031936011261019b5760609181519160028352816020840152820152f35b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000173188152f35b50503461019b578160031936011261019b57602090517f000000000000000000000000000000000000000000000000000000011b81f43d8152f35b50503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000151808152f35b50503461019b578160031936011261019b578051906020927002b30b934b0b13632902930ba32902b191607d1b848401528093815491610781836108ba565b9260019081811690811561080d57506001146107b0575b6101138686610109828b03601f1981018452836108f4565b90808093949750527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8683106107f95750505050610109826031610113958201019438610798565b8054868401603101529183019181016107da565b905061011397508693506031925061010994915060ff191682840152801515028201019438610798565b84903461019b578160031936011261019b576020907f00000000000000000000000000000000000000000000000000000003b10683778152f35b6020808252825181830181905290939260005b8281106108a657505060409293506000838284010152601f8019910116010190565b818101860151848201604001528501610884565b90600182811c921680156108ea575b60208310146108d457565b634e487b7160e01b600052602260045260246000fd5b91607f16916108c9565b90601f8019910116810190811067ffffffffffffffff82111761091657604052565b634e487b7160e01b600052604160045260246000fd5b9190820391821161093957565b634e487b7160e01b600052601160045260246000fd5b8181029291811591840414171561093957565b811561096c570490565b634e487b7160e01b600052601260045260246000fd5b919082018092116109395756fea2646970667358221220557623f64ab430858f29113c8b96dac24a2b0615adf8e378d5663111148cd7d064736f6c63430008130033

Block Transaction 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

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.