ETH Price: $2,356.25 (+0.11%)
Gas: 42 Gwei

Contract

0x20C7349f6D6A746a25e66f7c235E96DAC880bc0D
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multi Chain

Multichain Addresses

0 address found via
Transaction Hash
Method
Block
From
To
Value
Daily Limits178702182023-08-08 12:31:23124 days 7 hrs ago1691497883IN
Inverse Finance: Borrow Controller
0 ETH0.0006108925.47099051
0x60806040161589642022-12-11 4:05:23364 days 16 hrs ago1670731523IN
 Create: BorrowController
0 ETH0.005611914.4442664

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BorrowController

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license
/**
 *Submitted for verification at Etherscan.io on 2022-12-11
*/

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

/**
@title Borrow Controller
@notice Contract for limiting the contracts that are allowed to interact with markets
*/
contract BorrowController {
    
    address public operator;
    mapping(address => bool) public contractAllowlist;
    mapping(address => uint) public dailyLimits;
    mapping(address => mapping(uint => uint)) public dailyBorrows;

    constructor(address _operator) {
        operator = _operator;
    }

    modifier onlyOperator {
        require(msg.sender == operator, "Only operator");
        _;
    }
    
    /**
    @notice Sets the operator of the borrow controller. Only callable by the operator.
    @param _operator The address of the new operator.
    */
    function setOperator(address _operator) public onlyOperator { operator = _operator; }

    /**
    @notice Allows a contract to use the associated market.
    @param allowedContract The address of the allowed contract
    */
    function allow(address allowedContract) public onlyOperator { contractAllowlist[allowedContract] = true; }

    /**
    @notice Denies a contract to use the associated market
    @param deniedContract The addres of the denied contract
    */
    function deny(address deniedContract) public onlyOperator { contractAllowlist[deniedContract] = false; }

    /**
    @notice Sets the daily borrow limit for a specific market
    @param market The addres of the market contract
    @param limit The daily borrow limit amount
    */
    function setDailyLimit(address market, uint limit) public onlyOperator { dailyLimits[market] = limit; }

    /**
    @notice Checks if a borrow is allowed
    @dev Currently the borrowController checks if contracts are part of an allow list and enforces a daily limit
    @param msgSender The message sender trying to borrow
    @param amount The amount to be borrowed
    @return A boolean that is true if borrowing is allowed and false if not.
    */
    function borrowAllowed(address msgSender, address, uint amount) public returns (bool) {
        uint day = block.timestamp / 1 days;
        uint dailyLimit = dailyLimits[msg.sender];
        if(dailyLimit > 0) {
            if(dailyBorrows[msg.sender][day] + amount > dailyLimit) {
                return false;
            } else {
                //Safe to use unchecked, as function will revert in if statement if overflow
                unchecked{
                    dailyBorrows[msg.sender][day] += amount;
                }
            }
        }
        if(msgSender == tx.origin) return true;
        return contractAllowlist[msgSender];
    }

    /**
    @notice Reduces the daily limit used, when a user repays debt
    @dev This is necessary to prevent a DOS attack, where a user borrows the daily limit and immediately repays it again.
    @param amount Amount repaid in the market
    */
    function onRepay(uint amount) public {
        uint day = block.timestamp / 1 days;
        if(dailyBorrows[msg.sender][day] < amount) {
            dailyBorrows[msg.sender][day] = 0;
        } else {
            //Safe to use unchecked, as dailyBorow is checked to be higher than amount
            unchecked{
                dailyBorrows[msg.sender][day] -= amount;
            }
        }
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"allowedContract","type":"address"}],"name":"allow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"borrowAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"contractAllowlist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"dailyBorrows","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"dailyLimits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"deniedContract","type":"address"}],"name":"deny","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"onRepay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"setDailyLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"name":"setOperator","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5060405161063338038061063383398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b6105a0806100936000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063aa81a2b511610066578063aa81a2b514610147578063b3ab15fb1461017a578063d7bffc921461018d578063da3d454c146101ad578063ff9913e8146101c057600080fd5b8063081e6641146100a3578063268951e6146100b85780632803212f146100f6578063570ca735146101095780639c52a7f114610134575b600080fd5b6100b66100b1366004610445565b6101d3565b005b6100e36100c636600461047a565b600360209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b6100b661010436600461047a565b610249565b60005461011c906001600160a01b031681565b6040516001600160a01b0390911681526020016100ed565b6100b66101423660046104a4565b610298565b61016a6101553660046104a4565b60016020526000908152604090205460ff1681565b60405190151581526020016100ed565b6100b66101883660046104a4565b6102e3565b6100e361019b3660046104a4565b60026020526000908152604090205481565b61016a6101bb3660046104bf565b61032f565b6100b66101ce3660046104a4565b6103f4565b60006101e262015180426104fb565b336000908152600360209081526040808320848452909152902054909150821115610226573360009081526003602090815260408083208484529091528120555050565b336000908152600360209081526040808320938352929052208054919091039055565b6000546001600160a01b0316331461027c5760405162461bcd60e51b81526004016102739061051d565b60405180910390fd5b6001600160a01b03909116600090815260026020526040902055565b6000546001600160a01b031633146102c25760405162461bcd60e51b81526004016102739061051d565b6001600160a01b03166000908152600160205260409020805460ff19169055565b6000546001600160a01b0316331461030d5760405162461bcd60e51b81526004016102739061051d565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b60008061033f62015180426104fb565b3360009081526002602052604090205490915080156103b2573360009081526003602090815260408083208584529091529020548190610380908690610544565b1115610391576000925050506103ed565b33600090815260036020908152604080832085845290915290208054850190555b326001600160a01b038716036103cd576001925050506103ed565b5050506001600160a01b03831660009081526001602052604090205460ff165b9392505050565b6000546001600160a01b0316331461041e5760405162461bcd60e51b81526004016102739061051d565b6001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b60006020828403121561045757600080fd5b5035919050565b80356001600160a01b038116811461047557600080fd5b919050565b6000806040838503121561048d57600080fd5b6104968361045e565b946020939093013593505050565b6000602082840312156104b657600080fd5b6103ed8261045e565b6000806000606084860312156104d457600080fd5b6104dd8461045e565b92506104eb6020850161045e565b9150604084013590509250925092565b60008261051857634e487b7160e01b600052601260045260246000fd5b500490565b6020808252600d908201526c27b7363c9037b832b930ba37b960991b604082015260600190565b6000821982111561056557634e487b7160e01b600052601160045260246000fd5b50019056fea2646970667358221220f3a5f7722346541d937c1991fa3f2ba4022a2c1be1a7c7ba551edb62195685f564736f6c634300080d0033000000000000000000000000926df14a23be491164dcf93f4c468a50ef659d5b

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063aa81a2b511610066578063aa81a2b514610147578063b3ab15fb1461017a578063d7bffc921461018d578063da3d454c146101ad578063ff9913e8146101c057600080fd5b8063081e6641146100a3578063268951e6146100b85780632803212f146100f6578063570ca735146101095780639c52a7f114610134575b600080fd5b6100b66100b1366004610445565b6101d3565b005b6100e36100c636600461047a565b600360209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b6100b661010436600461047a565b610249565b60005461011c906001600160a01b031681565b6040516001600160a01b0390911681526020016100ed565b6100b66101423660046104a4565b610298565b61016a6101553660046104a4565b60016020526000908152604090205460ff1681565b60405190151581526020016100ed565b6100b66101883660046104a4565b6102e3565b6100e361019b3660046104a4565b60026020526000908152604090205481565b61016a6101bb3660046104bf565b61032f565b6100b66101ce3660046104a4565b6103f4565b60006101e262015180426104fb565b336000908152600360209081526040808320848452909152902054909150821115610226573360009081526003602090815260408083208484529091528120555050565b336000908152600360209081526040808320938352929052208054919091039055565b6000546001600160a01b0316331461027c5760405162461bcd60e51b81526004016102739061051d565b60405180910390fd5b6001600160a01b03909116600090815260026020526040902055565b6000546001600160a01b031633146102c25760405162461bcd60e51b81526004016102739061051d565b6001600160a01b03166000908152600160205260409020805460ff19169055565b6000546001600160a01b0316331461030d5760405162461bcd60e51b81526004016102739061051d565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b60008061033f62015180426104fb565b3360009081526002602052604090205490915080156103b2573360009081526003602090815260408083208584529091529020548190610380908690610544565b1115610391576000925050506103ed565b33600090815260036020908152604080832085845290915290208054850190555b326001600160a01b038716036103cd576001925050506103ed565b5050506001600160a01b03831660009081526001602052604090205460ff165b9392505050565b6000546001600160a01b0316331461041e5760405162461bcd60e51b81526004016102739061051d565b6001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b60006020828403121561045757600080fd5b5035919050565b80356001600160a01b038116811461047557600080fd5b919050565b6000806040838503121561048d57600080fd5b6104968361045e565b946020939093013593505050565b6000602082840312156104b657600080fd5b6103ed8261045e565b6000806000606084860312156104d457600080fd5b6104dd8461045e565b92506104eb6020850161045e565b9150604084013590509250925092565b60008261051857634e487b7160e01b600052601260045260246000fd5b500490565b6020808252600d908201526c27b7363c9037b832b930ba37b960991b604082015260600190565b6000821982111561056557634e487b7160e01b600052601160045260246000fd5b50019056fea2646970667358221220f3a5f7722346541d937c1991fa3f2ba4022a2c1be1a7c7ba551edb62195685f564736f6c634300080d0033

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

000000000000000000000000926df14a23be491164dcf93f4c468a50ef659d5b

-----Decoded View---------------
Arg [0] : _operator (address): 0x926dF14a23BE491164dCF93f4c468A50ef659D5B

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000926df14a23be491164dcf93f4c468a50ef659d5b


Deployed Bytecode Sourcemap

190:3184:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2964:407;;;;;;:::i;:::-;;:::i;:::-;;365:61;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;782:25:1;;;770:2;755:18;365:61:0;;;;;;;;1566:103;;;;;;:::i;:::-;;:::i;229:23::-;;;;;-1:-1:-1;;;;;229:23:0;;;;;;-1:-1:-1;;;;;982:32:1;;;964:51;;952:2;937:18;229:23:0;818:203:1;1273:104:0;;;;;;:::i;:::-;;:::i;259:49::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1382:14:1;;1375:22;1357:41;;1345:2;1330:18;259:49:0;1217:187:1;786:85:0;;;;;;:::i;:::-;;:::i;315:43::-;;;;;;:::i;:::-;;;;;;;;;;;;;;2032:670;;;;;;:::i;:::-;;:::i;1021:106::-;;;;;;:::i;:::-;;:::i;2964:407::-;3012:8;3023:24;3041:6;3023:15;:24;:::i;:::-;3074:10;3061:24;;;;:12;:24;;;;;;;;:29;;;;;;;;;3012:35;;-1:-1:-1;3061:38:0;-1:-1:-1;3058:306:0;;;3129:10;3148:1;3116:24;;;:12;:24;;;;;;;;:29;;;;;;;;:33;3001:370;2964:407;:::o;3058:306::-;3311:10;3298:24;;;;:12;:24;;;;;;;;:29;;;;;;;:39;;;;;;;;2964:407::o;1566:103::-;568:8;;-1:-1:-1;;;;;568:8:0;554:10;:22;546:48;;;;-1:-1:-1;;;546:48:0;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;;;;;1639:19:0;;::::1;;::::0;;;:11:::1;:19;::::0;;;;:27;1566:103::o;1273:104::-;568:8;;-1:-1:-1;;;;;568:8:0;554:10;:22;546:48;;;;-1:-1:-1;;;546:48:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;1333:33:0::1;1369:5;1333:33:::0;;;:17:::1;:33;::::0;;;;:41;;-1:-1:-1;;1333:41:0::1;::::0;;1273:104::o;786:85::-;568:8;;-1:-1:-1;;;;;568:8:0;554:10;:22;546:48;;;;-1:-1:-1;;;546:48:0;;;;;;;:::i;:::-;848:8:::1;:20:::0;;-1:-1:-1;;;;;;848:20:0::1;-1:-1:-1::0;;;;;848:20:0;;;::::1;::::0;;;::::1;::::0;;786:85::o;2032:670::-;2112:4;;2140:24;2158:6;2140:15;:24;:::i;:::-;2205:10;2175:15;2193:23;;;:11;:23;;;;;;2129:35;;-1:-1:-1;2230:14:0;;2227:373;;2277:10;2264:24;;;;:12;:24;;;;;;;;:29;;;;;;;;;2305:10;;2264:38;;2296:6;;2264:38;:::i;:::-;:51;2261:328;;;2343:5;2336:12;;;;;;2261:328;2528:10;2515:24;;;;:12;:24;;;;;;;;:29;;;;;;;;:39;;;;;;2261:328;2626:9;-1:-1:-1;;;;;2613:22:0;;;2610:38;;2644:4;2637:11;;;;;;2610:38;-1:-1:-1;;;;;;;;2666:28:0;;;;;;:17;:28;;;;;;;;2032:670;;;;;;:::o;1021:106::-;568:8;;-1:-1:-1;;;;;568:8:0;554:10;:22;546:48;;;;-1:-1:-1;;;546:48:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;1083:34:0::1;;::::0;;;1120:4:::1;1083:34;::::0;;;;;;;:41;;-1:-1:-1;;1083:41:0::1;::::0;;::::1;::::0;;1021:106::o;14:180:1:-;73:6;126:2;114:9;105:7;101:23;97:32;94:52;;;142:1;139;132:12;94:52;-1:-1:-1;165:23:1;;14:180;-1:-1:-1;14:180:1:o;199:173::-;267:20;;-1:-1:-1;;;;;316:31:1;;306:42;;296:70;;362:1;359;352:12;296:70;199:173;;;:::o;377:254::-;445:6;453;506:2;494:9;485:7;481:23;477:32;474:52;;;522:1;519;512:12;474:52;545:29;564:9;545:29;:::i;:::-;535:39;621:2;606:18;;;;593:32;;-1:-1:-1;;;377:254:1:o;1026:186::-;1085:6;1138:2;1126:9;1117:7;1113:23;1109:32;1106:52;;;1154:1;1151;1144:12;1106:52;1177:29;1196:9;1177:29;:::i;1409:328::-;1486:6;1494;1502;1555:2;1543:9;1534:7;1530:23;1526:32;1523:52;;;1571:1;1568;1561:12;1523:52;1594:29;1613:9;1594:29;:::i;:::-;1584:39;;1642:38;1676:2;1665:9;1661:18;1642:38;:::i;:::-;1632:48;;1727:2;1716:9;1712:18;1699:32;1689:42;;1409:328;;;;;:::o;1742:217::-;1782:1;1808;1798:132;;1852:10;1847:3;1843:20;1840:1;1833:31;1887:4;1884:1;1877:15;1915:4;1912:1;1905:15;1798:132;-1:-1:-1;1944:9:1;;1742:217::o;1964:337::-;2166:2;2148:21;;;2205:2;2185:18;;;2178:30;-1:-1:-1;;;2239:2:1;2224:18;;2217:43;2292:2;2277:18;;1964:337::o;2306:225::-;2346:3;2377:1;2373:6;2370:1;2367:13;2364:136;;;2422:10;2417:3;2413:20;2410:1;2403:31;2457:4;2454:1;2447:15;2485:4;2482:1;2475:15;2364:136;-1:-1:-1;2516:9:1;;2306:225::o

Swarm Source

ipfs://f3a5f7722346541d937c1991fa3f2ba4022a2c1be1a7c7ba551edb62195685f5

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

Validator Index Block Amount
View All Withdrawals

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