APE Price: $1.21 (-0.56%)

Contract

0xFc2a322C052C03B0F64B150DA2561Ae76fb24A68

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo0 APE

APE 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:
TripleSlopeRateModel

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
london EvmVersion
File 1 of 2 : TripleSlopeRateModel.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../../interfaces/IInterestRateModel.sol";

contract TripleSlopeRateModel is IInterestRateModel {
    uint256 public immutable baseBorrowPerSecond;
    uint256 public immutable borrowPerSecond1;
    uint256 public immutable kink1;
    uint256 public immutable borrowPerSecond2;
    uint256 public immutable kink2;
    uint256 public immutable borrowPerSecond3;

    constructor(
        uint256 baseRatePerSecond_,
        uint256 borrowPerSecond1_,
        uint256 kink1_,
        uint256 borrowPerSecond2_,
        uint256 kink2_,
        uint256 borrowPerSecond3_
    ) {
        baseBorrowPerSecond = baseRatePerSecond_;
        borrowPerSecond1 = borrowPerSecond1_;
        kink1 = kink1_;
        borrowPerSecond2 = borrowPerSecond2_;
        kink2 = kink2_;
        borrowPerSecond3 = borrowPerSecond3_;
    }

    /**
     * @notice Calculate the utilization rate.
     * @param cash The cash in the market
     * @param borrow The borrow in the market
     * @return The utilization rate
     */
    function getUtilization(uint256 cash, uint256 borrow) public pure returns (uint256) {
        if (borrow == 0) {
            return 0;
        }
        return (borrow * 1e18) / (cash + borrow);
    }

    /**
     * @notice Get the borrow rate per second.
     * @param cash The cash in the market
     * @param borrow The borrow in the market
     * @return The borrow rate per second
     */
    function getBorrowRate(uint256 cash, uint256 borrow) public view returns (uint256) {
        uint256 utilization = getUtilization(cash, borrow);
        if (utilization <= kink1) {
            // base + utilization * slope1
            return baseBorrowPerSecond + (utilization * borrowPerSecond1) / 1e18;
        } else if (utilization <= kink2) {
            // base + kink1 * slope1 + (utilization - kink1) * slope2
            return baseBorrowPerSecond + (kink1 * borrowPerSecond1) / 1e18
                + ((utilization - kink1) * borrowPerSecond2) / 1e18;
        } else {
            // base + kink1 * slope1 + (kink2 - kink1) * slope2 + (utilization - kink2) * slope3
            return baseBorrowPerSecond + (kink1 * borrowPerSecond1) / 1e18 + ((kink2 - kink1) * borrowPerSecond2) / 1e18
                + (utilization - kink2) * borrowPerSecond3 / 1e18;
        }
    }

    /**
     * @notice Get the supply rate per second.
     * @param cash The cash in the market
     * @param borrow The borrow in the market
     * @return The supply rate per second
     */
    function getSupplyRate(uint256 cash, uint256 borrow) public view returns (uint256) {
        uint256 borrowRate = getBorrowRate(cash, borrow);
        uint256 utilization = getUtilization(cash, borrow);
        return (utilization * borrowRate) / 1e18;
    }
}

File 2 of 2 : IInterestRateModel.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IInterestRateModel {
    function getUtilization(uint256 cash, uint256 borrow) external pure returns (uint256);

    function getBorrowRate(uint256 cash, uint256 borrow) external view returns (uint256);

    function getSupplyRate(uint256 cash, uint256 borrow) external view returns (uint256);
}

Settings
{
  "remappings": [
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"baseRatePerSecond_","type":"uint256"},{"internalType":"uint256","name":"borrowPerSecond1_","type":"uint256"},{"internalType":"uint256","name":"kink1_","type":"uint256"},{"internalType":"uint256","name":"borrowPerSecond2_","type":"uint256"},{"internalType":"uint256","name":"kink2_","type":"uint256"},{"internalType":"uint256","name":"borrowPerSecond3_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"baseBorrowPerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowPerSecond1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowPerSecond2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowPerSecond3","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cash","type":"uint256"},{"internalType":"uint256","name":"borrow","type":"uint256"}],"name":"getBorrowRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cash","type":"uint256"},{"internalType":"uint256","name":"borrow","type":"uint256"}],"name":"getSupplyRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cash","type":"uint256"},{"internalType":"uint256","name":"borrow","type":"uint256"}],"name":"getUtilization","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"kink1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"kink2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

61014060405234801561001157600080fd5b506040516107d23803806107d283398101604081905261003091610052565b60809590955260a09390935260c09190915260e052610100526101205261009c565b60008060008060008060c0878903121561006b57600080fd5b865195506020870151945060408701519350606087015192506080870151915060a087015190509295509295509295565b60805160a05160c05160e0516101005161012051610672610160600039600081816101ab015261041e01526000818161014a015281816102f50152818161044201526104cb015260008181609d0152818161032501526104860152600081816101840152818161025f01528181610349015281816103b1015281816104aa01526105320152600081816101100152818161029201528181610390015261051101526000818160e9015281816102c7015281816103e5015261056601526106726000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c806346dda3581161006657806346dda3581461013257806350af8cd614610145578063a5cdfa941461016c578063d34f61141461017f578063e3a6fe25146101a657600080fd5b8063158e9c4a146100985780632a11a8a0146100d15780632f1f2c42146100e4578063382be1cd1461010b575b600080fd5b6100bf7f000000000000000000000000000000000000000000000000000000000000000081565b60405190815260200160405180910390f35b6100bf6100df366004610594565b6101cd565b6100bf7f000000000000000000000000000000000000000000000000000000000000000081565b6100bf7f000000000000000000000000000000000000000000000000000000000000000081565b6100bf610140366004610594565b610212565b6100bf7f000000000000000000000000000000000000000000000000000000000000000081565b6100bf61017a366004610594565b61024e565b6100bf7f000000000000000000000000000000000000000000000000000000000000000081565b6100bf7f000000000000000000000000000000000000000000000000000000000000000081565b6000806101da848461024e565b905060006101e88585610212565b9050670de0b6b3a76400006101fd83836105cc565b61020791906105eb565b925050505b92915050565b6000816102215750600061020c565b61022b828461060d565b61023d83670de0b6b3a76400006105cc565b61024791906105eb565b9392505050565b60008061025b8484610212565b90507f000000000000000000000000000000000000000000000000000000000000000081116102f357670de0b6b3a76400006102b77f0000000000000000000000000000000000000000000000000000000000000000836105cc565b6102c191906105eb565b6102eb907f000000000000000000000000000000000000000000000000000000000000000061060d565b91505061020c565b7f0000000000000000000000000000000000000000000000000000000000000000811161041357670de0b6b3a76400007f000000000000000000000000000000000000000000000000000000000000000061036e7f000000000000000000000000000000000000000000000000000000000000000084610625565b61037891906105cc565b61038291906105eb565b670de0b6b3a76400006103d57f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006105cc565b6103df91906105eb565b610409907f000000000000000000000000000000000000000000000000000000000000000061060d565b6102eb919061060d565b670de0b6b3a76400007f00000000000000000000000000000000000000000000000000000000000000006104677f000000000000000000000000000000000000000000000000000000000000000084610625565b61047191906105cc565b61047b91906105eb565b670de0b6b3a76400007f00000000000000000000000000000000000000000000000000000000000000006104ef7f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000610625565b6104f991906105cc565b61050391906105eb565b670de0b6b3a76400006105567f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006105cc565b61056091906105eb565b61058a907f000000000000000000000000000000000000000000000000000000000000000061060d565b610409919061060d565b600080604083850312156105a757600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156105e6576105e66105b6565b500290565b60008261060857634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115610620576106206105b6565b500190565b600082821015610637576106376105b6565b50039056fea2646970667358221220f0288840ba84cad827b7d507ee2ccf5e0f9c73c816d9f4c0735ef77311ecd96064736f6c634300080a0033000000000000000000000000000000000000000000000000000000001c59cb9f0000000000000000000000000000000000000000000000000000000071672e7f0000000000000000000000000000000000000000000000000c7d713b49da000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c7d713b49da000000000000000000000000000000000000000000000000000000000016262714cf

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100935760003560e01c806346dda3581161006657806346dda3581461013257806350af8cd614610145578063a5cdfa941461016c578063d34f61141461017f578063e3a6fe25146101a657600080fd5b8063158e9c4a146100985780632a11a8a0146100d15780632f1f2c42146100e4578063382be1cd1461010b575b600080fd5b6100bf7f000000000000000000000000000000000000000000000000000000000000000081565b60405190815260200160405180910390f35b6100bf6100df366004610594565b6101cd565b6100bf7f000000000000000000000000000000000000000000000000000000001c59cb9f81565b6100bf7f0000000000000000000000000000000000000000000000000000000071672e7f81565b6100bf610140366004610594565b610212565b6100bf7f0000000000000000000000000000000000000000000000000c7d713b49da000081565b6100bf61017a366004610594565b61024e565b6100bf7f0000000000000000000000000000000000000000000000000c7d713b49da000081565b6100bf7f00000000000000000000000000000000000000000000000000000016262714cf81565b6000806101da848461024e565b905060006101e88585610212565b9050670de0b6b3a76400006101fd83836105cc565b61020791906105eb565b925050505b92915050565b6000816102215750600061020c565b61022b828461060d565b61023d83670de0b6b3a76400006105cc565b61024791906105eb565b9392505050565b60008061025b8484610212565b90507f0000000000000000000000000000000000000000000000000c7d713b49da000081116102f357670de0b6b3a76400006102b77f0000000000000000000000000000000000000000000000000000000071672e7f836105cc565b6102c191906105eb565b6102eb907f000000000000000000000000000000000000000000000000000000001c59cb9f61060d565b91505061020c565b7f0000000000000000000000000000000000000000000000000c7d713b49da0000811161041357670de0b6b3a76400007f000000000000000000000000000000000000000000000000000000000000000061036e7f0000000000000000000000000000000000000000000000000c7d713b49da000084610625565b61037891906105cc565b61038291906105eb565b670de0b6b3a76400006103d57f0000000000000000000000000000000000000000000000000000000071672e7f7f0000000000000000000000000000000000000000000000000c7d713b49da00006105cc565b6103df91906105eb565b610409907f000000000000000000000000000000000000000000000000000000001c59cb9f61060d565b6102eb919061060d565b670de0b6b3a76400007f00000000000000000000000000000000000000000000000000000016262714cf6104677f0000000000000000000000000000000000000000000000000c7d713b49da000084610625565b61047191906105cc565b61047b91906105eb565b670de0b6b3a76400007f00000000000000000000000000000000000000000000000000000000000000006104ef7f0000000000000000000000000000000000000000000000000c7d713b49da00007f0000000000000000000000000000000000000000000000000c7d713b49da0000610625565b6104f991906105cc565b61050391906105eb565b670de0b6b3a76400006105567f0000000000000000000000000000000000000000000000000000000071672e7f7f0000000000000000000000000000000000000000000000000c7d713b49da00006105cc565b61056091906105eb565b61058a907f000000000000000000000000000000000000000000000000000000001c59cb9f61060d565b610409919061060d565b600080604083850312156105a757600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156105e6576105e66105b6565b500290565b60008261060857634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115610620576106206105b6565b500190565b600082821015610637576106376105b6565b50039056fea2646970667358221220f0288840ba84cad827b7d507ee2ccf5e0f9c73c816d9f4c0735ef77311ecd96064736f6c634300080a0033

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

000000000000000000000000000000000000000000000000000000001c59cb9f0000000000000000000000000000000000000000000000000000000071672e7f0000000000000000000000000000000000000000000000000c7d713b49da000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c7d713b49da000000000000000000000000000000000000000000000000000000000016262714cf

-----Decoded View---------------
Arg [0] : baseRatePerSecond_ (uint256): 475646879
Arg [1] : borrowPerSecond1_ (uint256): 1902587519
Arg [2] : kink1_ (uint256): 900000000000000000
Arg [3] : borrowPerSecond2_ (uint256): 0
Arg [4] : kink2_ (uint256): 900000000000000000
Arg [5] : borrowPerSecond3_ (uint256): 95129375951

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000000000000000000000000001c59cb9f
Arg [1] : 0000000000000000000000000000000000000000000000000000000071672e7f
Arg [2] : 0000000000000000000000000000000000000000000000000c7d713b49da0000
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [4] : 0000000000000000000000000000000000000000000000000c7d713b49da0000
Arg [5] : 00000000000000000000000000000000000000000000000000000016262714cf


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