S Price: $0.536768 (+0.26%)

Contract

0x5d2526EF306E85A51eBef9883Ec9d00e5b12B394

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
JumpRateModelV2

Compiler Version
v0.8.22+commit.4fc1097e

Optimization Enabled:
Yes with 200 runs

Other Settings:
shanghai EvmVersion
File 1 of 3 : JumpRateModelV2.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.22;

import "./BaseJumpRateModelV2.sol";
import "./InterestRateModel.sol";

/**
 * @title Mach's JumpRateModel Contract V2 for V2 cTokens
 * @author Arr00
 * @notice Supports only for V2 cTokens
 */
contract JumpRateModelV2 is InterestRateModel, BaseJumpRateModelV2 {
    /**
     * @notice Calculates the current borrow rate per timestamp
     * @param cash The amount of cash in the market
     * @param borrows The amount of borrows in the market
     * @param reserves The amount of reserves in the market
     * @return The borrow rate percentage per timestamp as a mantissa (scaled by 1e18)
     */
    function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) external view override returns (uint256) {
        return getBorrowRateInternal(cash, borrows, reserves);
    }

    constructor(
        uint256 baseRatePerYear,
        uint256 multiplierPerYear,
        uint256 jumpMultiplierPerYear,
        uint256 kink_,
        address owner_
    ) public BaseJumpRateModelV2(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_, owner_) {}
}

File 2 of 3 : BaseJumpRateModelV2.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.22;

import "./InterestRateModel.sol";

/**
 * @title Logic for Mach's JumpRateModel Contract V2.
 * @author Compound (modified by Dharma Labs, refactored by Arr00)
 * @notice Version 2 modifies Version 1 by enabling updateable parameters.
 */
abstract contract BaseJumpRateModelV2 is InterestRateModel {
    event NewInterestParams(
        uint256 baseRatePerTimestamp, uint256 multiplierPerTimestamp, uint256 jumpMultiplierPerTimestamp, uint256 kink
    );

    uint256 private constant BASE = 1e18;

    /**
     * @notice The address of the owner, i.e. the Timelock contract, which can update parameters directly
     */
    address public owner;

    /**
     * @notice The approximate number of timestamps per year that is assumed by the interest rate model
     */
    uint256 public constant timestampsPerYear = 60 * 60 * 24 * 365;

    /**
     * @notice The multiplier of utilization rate that gives the slope of the interest rate
     */
    uint256 public multiplierPerTimestamp;

    /**
     * @notice The base interest rate which is the y-intercept when utilization rate is 0
     */
    uint256 public baseRatePerTimestamp;

    /**
     * @notice The multiplierPerTimestamp after hitting a specified utilization point
     */
    uint256 public jumpMultiplierPerTimestamp;

    /**
     * @notice The utilization point at which the jump multiplier is applied
     */
    uint256 public kink;

    /**
     * @notice Construct an interest rate model
     * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by BASE)
     * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by BASE)
     * @param jumpMultiplierPerYear The multiplierPerTimestamp after hitting a specified utilization point
     * @param kink_ The utilization point at which the jump multiplier is applied
     * @param owner_ The address of the owner, i.e. the Timelock contract (which has the ability to update parameters directly)
     */
    constructor(
        uint256 baseRatePerYear,
        uint256 multiplierPerYear,
        uint256 jumpMultiplierPerYear,
        uint256 kink_,
        address owner_
    ) internal {
        owner = owner_;

        updateJumpRateModelInternal(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_);
    }

    /**
     * @notice Update the parameters of the interest rate model (only callable by owner, i.e. Timelock)
     * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by BASE)
     * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by BASE)
     * @param jumpMultiplierPerYear The multiplierPerTimestamp after hitting a specified utilization point
     * @param kink_ The utilization point at which the jump multiplier is applied
     */
    function updateJumpRateModel(
        uint256 baseRatePerYear,
        uint256 multiplierPerYear,
        uint256 jumpMultiplierPerYear,
        uint256 kink_
    ) external virtual {
        require(msg.sender == owner, "only the owner may call this function.");

        updateJumpRateModelInternal(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_);
    }

    /**
     * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`
     * @param cash The amount of cash in the market
     * @param borrows The amount of borrows in the market
     * @param reserves The amount of reserves in the market (currently unused)
     * @return The utilization rate as a mantissa between [0, BASE]
     */
    function utilizationRate(uint256 cash, uint256 borrows, uint256 reserves) public pure returns (uint256) {
        // Utilization rate is 0 when there are no borrows
        if (borrows == 0) {
            return 0;
        }

        return (borrows * BASE) / (cash + borrows - reserves);
    }

    /**
     * @notice Calculates the current borrow rate per timestamp, with the error code expected by the market
     * @param cash The amount of cash in the market
     * @param borrows The amount of borrows in the market
     * @param reserves The amount of reserves in the market
     * @return The borrow rate percentage per timestamp as a mantissa (scaled by BASE)
     */
    function getBorrowRateInternal(uint256 cash, uint256 borrows, uint256 reserves) internal view returns (uint256) {
        uint256 util = utilizationRate(cash, borrows, reserves);

        if (util <= kink) {
            return ((util * multiplierPerTimestamp) / BASE) + baseRatePerTimestamp;
        } else {
            uint256 normalRate = ((kink * multiplierPerTimestamp) / BASE) + baseRatePerTimestamp;
            uint256 excessUtil = util - kink;
            return ((excessUtil * jumpMultiplierPerTimestamp) / BASE) + normalRate;
        }
    }

    /**
     * @notice Calculates the current supply rate per timestamp
     * @param cash The amount of cash in the market
     * @param borrows The amount of borrows in the market
     * @param reserves The amount of reserves in the market
     * @param reserveFactorMantissa The current reserve factor for the market
     * @return The supply rate percentage per timestamp as a mantissa (scaled by BASE)
     */
    function getSupplyRate(uint256 cash, uint256 borrows, uint256 reserves, uint256 reserveFactorMantissa)
        public
        view
        virtual
        override
        returns (uint256)
    {
        uint256 oneMinusReserveFactor = BASE - reserveFactorMantissa;
        uint256 borrowRate = getBorrowRateInternal(cash, borrows, reserves);
        uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / BASE;
        return (utilizationRate(cash, borrows, reserves) * rateToPool) / BASE;
    }

    /**
     * @notice Internal function to update the parameters of the interest rate model
     * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by BASE)
     * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by BASE)
     * @param jumpMultiplierPerYear The multiplierPerTimestamp after hitting a specified utilization point
     * @param kink_ The utilization point at which the jump multiplier is applied
     */
    function updateJumpRateModelInternal(
        uint256 baseRatePerYear,
        uint256 multiplierPerYear,
        uint256 jumpMultiplierPerYear,
        uint256 kink_
    ) internal {
        baseRatePerTimestamp = ((baseRatePerYear * BASE) / timestampsPerYear) / BASE;
        multiplierPerTimestamp = (multiplierPerYear * BASE) / (timestampsPerYear * kink_);
        jumpMultiplierPerTimestamp = ((jumpMultiplierPerYear * BASE) / timestampsPerYear) / BASE;
        kink = kink_;

        emit NewInterestParams(baseRatePerTimestamp, multiplierPerTimestamp, jumpMultiplierPerTimestamp, kink);
    }
}

File 3 of 3 : InterestRateModel.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.22;

/**
 * @title Mach's InterestRateModel Interface
 * @author Mach Finance
 */
abstract contract InterestRateModel {
    /// @notice Indicator that this is an InterestRateModel contract (for inspection)
    bool public constant isInterestRateModel = true;

    /**
     * @notice Calculates the current borrow interest rate per timestamp
     * @param cash The total amount of cash the market has
     * @param borrows The total amount of borrows the market has outstanding
     * @param reserves The total amount of reserves the market has
     * @return The borrow rate per timestamp (as a percentage, and scaled by 1e18)
     */
    function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) external view virtual returns (uint256);

    /**
     * @notice Calculates the current supply interest rate per timestamp
     * @param cash The total amount of cash the market has
     * @param borrows The total amount of borrows the market has outstanding
     * @param reserves The total amount of reserves the market has
     * @param reserveFactorMantissa The current reserve factor the market has
     * @return The supply rate per timestamp (as a percentage, and scaled by 1e18)
     */
    function getSupplyRate(uint256 cash, uint256 borrows, uint256 reserves, uint256 reserveFactorMantissa)
        external
        view
        virtual
        returns (uint256);
}

Settings
{
  "remappings": [
    "@pythnetwork/pyth-sdk-solidity/=lib/pyth-crosschain/target_chains/ethereum/sdk/solidity/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/",
    "@api3/contracts/=lib/contracts/contracts/",
    "ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/",
    "pyth-crosschain/=lib/pyth-crosschain/",
    "solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "shanghai",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"baseRatePerYear","type":"uint256"},{"internalType":"uint256","name":"multiplierPerYear","type":"uint256"},{"internalType":"uint256","name":"jumpMultiplierPerYear","type":"uint256"},{"internalType":"uint256","name":"kink_","type":"uint256"},{"internalType":"address","name":"owner_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"baseRatePerTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"multiplierPerTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"jumpMultiplierPerTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"kink","type":"uint256"}],"name":"NewInterestParams","type":"event"},{"inputs":[],"name":"baseRatePerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cash","type":"uint256"},{"internalType":"uint256","name":"borrows","type":"uint256"},{"internalType":"uint256","name":"reserves","type":"uint256"}],"name":"getBorrowRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cash","type":"uint256"},{"internalType":"uint256","name":"borrows","type":"uint256"},{"internalType":"uint256","name":"reserves","type":"uint256"},{"internalType":"uint256","name":"reserveFactorMantissa","type":"uint256"}],"name":"getSupplyRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInterestRateModel","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"jumpMultiplierPerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"kink","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"multiplierPerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timestampsPerYear","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"baseRatePerYear","type":"uint256"},{"internalType":"uint256","name":"multiplierPerYear","type":"uint256"},{"internalType":"uint256","name":"jumpMultiplierPerYear","type":"uint256"},{"internalType":"uint256","name":"kink_","type":"uint256"}],"name":"updateJumpRateModel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"cash","type":"uint256"},{"internalType":"uint256","name":"borrows","type":"uint256"},{"internalType":"uint256","name":"reserves","type":"uint256"}],"name":"utilizationRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"}]

608060405234801561000f575f80fd5b5060405161077638038061077683398101604081905261002e9161014f565b5f80546001600160a01b0319166001600160a01b038316179055848484848461005985858585610068565b505050505050505050506101ed565b670de0b6b3a76400006301e1338061008082876101a5565b61008a91906101ce565b61009491906101ce565b6002556100a5816301e133806101a5565b6100b7670de0b6b3a7640000856101a5565b6100c191906101ce565b600155670de0b6b3a76400006301e133806100dc82856101a5565b6100e691906101ce565b6100f091906101ce565b60038190556004829055600254600154604080519283526020830191909152810191909152606081018290527f6960ab234c7ef4b0c9197100f5393cfcde7c453ac910a27bd2000aa1dd4c068d9060800160405180910390a150505050565b5f805f805f60a08688031215610163575f80fd5b855160208701516040880151606089015160808a0151939850919650945092506001600160a01b0381168114610197575f80fd5b809150509295509295909350565b80820281158282048414176101c857634e487b7160e01b5f52601160045260245ffd5b92915050565b5f826101e857634e487b7160e01b5f52601260045260245ffd5b500490565b61057c806101fa5f395ff3fe608060405234801561000f575f80fd5b50600436106100a6575f3560e01c806340bc0af41161006e57806340bc0af4146101115780636c2df6a71461011a5780636e71e2d8146101235780638da5cb5b14610136578063b816881614610160578063fd2da33914610173575f80fd5b80630c574861146100aa57806315f24053146100c85780632037f3e7146100db5780632191f92a146100f057806326c394f714610108575b5f80fd5b6100b56301e1338081565b6040519081526020015b60405180910390f35b6100b56100d6366004610478565b61017c565b6100ee6100e93660046104a1565b610192565b005b6100f8600181565b60405190151581526020016100bf565b6100b560035481565b6100b560025481565b6100b560015481565b6100b5610131366004610478565b610210565b5f54610148906001600160a01b031681565b6040516001600160a01b0390911681526020016100bf565b6100b561016e3660046104a1565b610250565b6100b560045481565b5f6101888484846102c9565b90505b9392505050565b5f546001600160a01b031633146101fe5760405162461bcd60e51b815260206004820152602660248201527f6f6e6c7920746865206f776e6572206d61792063616c6c20746869732066756e60448201526531ba34b7b71760d11b606482015260840160405180910390fd5b61020a84848484610391565b50505050565b5f825f0361021f57505f61018b565b8161022a84866104e4565b61023491906104fd565b610246670de0b6b3a764000085610510565b6101889190610527565b5f8061026483670de0b6b3a76400006104fd565b90505f6102728787876102c9565b90505f670de0b6b3a76400006102888484610510565b6102929190610527565b9050670de0b6b3a7640000816102a98a8a8a610210565b6102b39190610510565b6102bd9190610527565b98975050505050505050565b5f806102d6858585610210565b9050600454811161031757600254670de0b6b3a7640000600154836102fb9190610510565b6103059190610527565b61030f91906104e4565b91505061018b565b5f600254670de0b6b3a76400006001546004546103349190610510565b61033e9190610527565b61034891906104e4565b90505f6004548361035991906104fd565b905081670de0b6b3a7640000600354836103739190610510565b61037d9190610527565b61038791906104e4565b935050505061018b565b670de0b6b3a76400006301e133806103a98287610510565b6103b39190610527565b6103bd9190610527565b6002556103ce816301e13380610510565b6103e0670de0b6b3a764000085610510565b6103ea9190610527565b600155670de0b6b3a76400006301e133806104058285610510565b61040f9190610527565b6104199190610527565b60038190556004829055600254600154604080519283526020830191909152810191909152606081018290527f6960ab234c7ef4b0c9197100f5393cfcde7c453ac910a27bd2000aa1dd4c068d9060800160405180910390a150505050565b5f805f6060848603121561048a575f80fd5b505081359360208301359350604090920135919050565b5f805f80608085870312156104b4575f80fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b5f52601160045260245ffd5b808201808211156104f7576104f76104d0565b92915050565b818103818111156104f7576104f76104d0565b80820281158282048414176104f7576104f76104d0565b5f8261054157634e487b7160e01b5f52601260045260245ffd5b50049056fea2646970667358221220d8cb20a7d5ef8140c2eba57bade72fb447785f3c4e317e2d44b4d46e6d35e38964736f6c634300081600330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007c5850872380000000000000000000000000000000000000000000000000006124fee993bc00000000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000009a74a959ab5f706c1dff414f580560287fcb7576

Deployed Bytecode

0x608060405234801561000f575f80fd5b50600436106100a6575f3560e01c806340bc0af41161006e57806340bc0af4146101115780636c2df6a71461011a5780636e71e2d8146101235780638da5cb5b14610136578063b816881614610160578063fd2da33914610173575f80fd5b80630c574861146100aa57806315f24053146100c85780632037f3e7146100db5780632191f92a146100f057806326c394f714610108575b5f80fd5b6100b56301e1338081565b6040519081526020015b60405180910390f35b6100b56100d6366004610478565b61017c565b6100ee6100e93660046104a1565b610192565b005b6100f8600181565b60405190151581526020016100bf565b6100b560035481565b6100b560025481565b6100b560015481565b6100b5610131366004610478565b610210565b5f54610148906001600160a01b031681565b6040516001600160a01b0390911681526020016100bf565b6100b561016e3660046104a1565b610250565b6100b560045481565b5f6101888484846102c9565b90505b9392505050565b5f546001600160a01b031633146101fe5760405162461bcd60e51b815260206004820152602660248201527f6f6e6c7920746865206f776e6572206d61792063616c6c20746869732066756e60448201526531ba34b7b71760d11b606482015260840160405180910390fd5b61020a84848484610391565b50505050565b5f825f0361021f57505f61018b565b8161022a84866104e4565b61023491906104fd565b610246670de0b6b3a764000085610510565b6101889190610527565b5f8061026483670de0b6b3a76400006104fd565b90505f6102728787876102c9565b90505f670de0b6b3a76400006102888484610510565b6102929190610527565b9050670de0b6b3a7640000816102a98a8a8a610210565b6102b39190610510565b6102bd9190610527565b98975050505050505050565b5f806102d6858585610210565b9050600454811161031757600254670de0b6b3a7640000600154836102fb9190610510565b6103059190610527565b61030f91906104e4565b91505061018b565b5f600254670de0b6b3a76400006001546004546103349190610510565b61033e9190610527565b61034891906104e4565b90505f6004548361035991906104fd565b905081670de0b6b3a7640000600354836103739190610510565b61037d9190610527565b61038791906104e4565b935050505061018b565b670de0b6b3a76400006301e133806103a98287610510565b6103b39190610527565b6103bd9190610527565b6002556103ce816301e13380610510565b6103e0670de0b6b3a764000085610510565b6103ea9190610527565b600155670de0b6b3a76400006301e133806104058285610510565b61040f9190610527565b6104199190610527565b60038190556004829055600254600154604080519283526020830191909152810191909152606081018290527f6960ab234c7ef4b0c9197100f5393cfcde7c453ac910a27bd2000aa1dd4c068d9060800160405180910390a150505050565b5f805f6060848603121561048a575f80fd5b505081359360208301359350604090920135919050565b5f805f80608085870312156104b4575f80fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b5f52601160045260245ffd5b808201808211156104f7576104f76104d0565b92915050565b818103818111156104f7576104f76104d0565b80820281158282048414176104f7576104f76104d0565b5f8261054157634e487b7160e01b5f52601260045260245ffd5b50049056fea2646970667358221220d8cb20a7d5ef8140c2eba57bade72fb447785f3c4e317e2d44b4d46e6d35e38964736f6c63430008160033

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

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007c5850872380000000000000000000000000000000000000000000000000006124fee993bc00000000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000009a74a959ab5f706c1dff414f580560287fcb7576

-----Decoded View---------------
Arg [0] : baseRatePerYear (uint256): 0
Arg [1] : multiplierPerYear (uint256): 35000000000000000
Arg [2] : jumpMultiplierPerYear (uint256): 7000000000000000000
Arg [3] : kink_ (uint256): 800000000000000000
Arg [4] : owner_ (address): 0x9A74A959Ab5F706c1DFf414F580560287FcB7576

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [1] : 000000000000000000000000000000000000000000000000007c585087238000
Arg [2] : 0000000000000000000000000000000000000000000000006124fee993bc0000
Arg [3] : 0000000000000000000000000000000000000000000000000b1a2bc2ec500000
Arg [4] : 0000000000000000000000009a74a959ab5f706c1dff414f580560287fcb7576


Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.