Contract 0xDDCea799fF1699e98EDF118e0629A974Df7DF012

 
 
Txn Hash
Method
Block
From
To
Value
0xcfedc2b083cdc7ccda5c3af26cb7f8d2aab20310f9285fad675bbd83ffe96023Set Governance125640032021-06-03 21:44:53551 days 11 hrs ago0x05f9e07afccd4ea69310e316f4c5ef81ed3ed9c8 IN  0xddcea799ff1699e98edf118e0629a974df7df0120 Ether0.000540120
0x00b21492a251274a2c8aaa4699633cdd31826ada12f85e34421db6fdb4154b25Set Management125639902021-06-03 21:42:32551 days 11 hrs ago0x05f9e07afccd4ea69310e316f4c5ef81ed3ed9c8 IN  0xddcea799ff1699e98edf118e0629a974df7df0120 Ether0.0006104921.00000145
0x25810340d1aa67d688301ec9dee94164010b084e2c04311e8615d7f458635bff0x60806040125639632021-06-03 21:38:10551 days 11 hrs ago0x05f9e07afccd4ea69310e316f4c5ef81ed3ed9c8 IN  Create: CommonHealthCheck0 Ether0.0156484126
[ Download CSV Export 
View more zero value Internal Transactions in Advanced View mode
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CommonHealthCheck

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, GNU GPLv3 license
/**
 *Submitted for verification at Etherscan.io on 2021-06-03
*/

// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

// Global Enums and Structs



struct LegacyStrategyParams {
    uint256 performanceFee;
    uint256 activation;
    uint256 debtRatio;
    uint256 rateLimit;
    uint256 lastReport;
    uint256 totalDebt;
    uint256 totalGain;
    uint256 totalLoss;
}
struct Limits {
    uint256 profitLimitRatio;
    uint256 lossLimitRatio;
    bool exists;
}

// Part: CustomHealthCheck

interface CustomHealthCheck {
    function check(
        uint256 profit,
        uint256 loss,
        uint256 debtPayment,
        uint256 debtOutstanding,
        address callerStrategy
    ) external view returns (bool);
}

// File: CommonHealthCheck.sol

contract CommonHealthCheck {
    // Default Settings for all strategies
    uint256 constant MAX_BPS = 10_000;
    uint256 public profitLimitRatio;
    uint256 public lossLimitRatio;
    // profit & loss for specific strategy
    mapping(address => Limits) public strategiesLimits;

    address public governance;
    address public management;

    mapping(address => address) public checks;

    modifier onlyGovernance() {
        require(msg.sender == governance, "!authorized");
        _;
    }

    modifier onlyAuthorized() {
        require(
            msg.sender == governance || msg.sender == management,
            "!authorized"
        );
        _;
    }

    constructor() public {
        governance = msg.sender;
        management = msg.sender;
        profitLimitRatio = 300;
        lossLimitRatio = 100; 
    }

    function setGovernance(address _governance) external onlyGovernance {
        require(_governance != address(0));
        governance = _governance;
    }

    function setManagement(address _management) external onlyGovernance {
        require(_management != address(0));
        management = _management;
    }

    function setProfitLimitRatio(uint256 _profitLimitRatio) external onlyAuthorized {
        require(_profitLimitRatio < MAX_BPS);
        profitLimitRatio = _profitLimitRatio; 
    }

    function setlossLimitRatio(uint256 _lossLimitRatio) external onlyAuthorized {
        require(_lossLimitRatio < MAX_BPS);
       lossLimitRatio = _lossLimitRatio;
    }

    function setStrategyLimits(address _strategy, uint256 _profitLimitRatio, uint256 _lossLimitRatio) external onlyAuthorized {
       require(_lossLimitRatio < MAX_BPS);
       require(_profitLimitRatio < MAX_BPS);
        strategiesLimits[_strategy] = Limits(_profitLimitRatio, _lossLimitRatio, true);
    }

    function setCheck(address _strategy, address _check)
        external
        onlyAuthorized
    {
        checks[_strategy] = _check;
    }

    function check(
        uint256 profit,
        uint256 loss,
        uint256 debtPayment,
        uint256 debtOutstanding,
        uint256 totalDebt
    ) external view returns (bool) {
        return
            _runChecks(profit, loss, debtPayment, debtOutstanding, totalDebt);
    }

    function _runChecks(
        uint256 profit,
        uint256 loss,
        uint256 debtPayment,
        uint256 debtOutstanding,
        uint256 totalDebt
    ) internal view returns (bool) {
        address customCheck = checks[msg.sender];

        if (customCheck == address(0)) {
            return _executeDefaultCheck(profit, loss, totalDebt);
        }

        return
            CustomHealthCheck(customCheck).check(
                profit,
                loss,
                debtPayment,
                debtOutstanding,
                msg.sender
            );
    }

    function _executeDefaultCheck(
        uint256 _profit,
        uint256 _loss,
        uint256 _totalDebt
    ) internal view returns (bool) {
        Limits memory limits = strategiesLimits[msg.sender];
        uint256 _profitLimitRatio;
        uint256 _lossLimitRatio;
        if(limits.exists) {
            _profitLimitRatio = limits.profitLimitRatio;
            _lossLimitRatio = limits.lossLimitRatio;

        } else {
            _profitLimitRatio = profitLimitRatio;
            _lossLimitRatio = lossLimitRatio;
        }
        
        if (_profit > ((_totalDebt * _profitLimitRatio) / MAX_BPS)) {
            return false;
        }
        if (_loss > ((_totalDebt * _lossLimitRatio) / MAX_BPS)) {
            return false;
        }
        // health checks pass
        return true;
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"profit","type":"uint256"},{"internalType":"uint256","name":"loss","type":"uint256"},{"internalType":"uint256","name":"debtPayment","type":"uint256"},{"internalType":"uint256","name":"debtOutstanding","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"}],"name":"check","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"checks","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lossLimitRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"management","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"profitLimitRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"},{"internalType":"address","name":"_check","type":"address"}],"name":"setCheck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_governance","type":"address"}],"name":"setGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_management","type":"address"}],"name":"setManagement","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_profitLimitRatio","type":"uint256"}],"name":"setProfitLimitRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"},{"internalType":"uint256","name":"_profitLimitRatio","type":"uint256"},{"internalType":"uint256","name":"_lossLimitRatio","type":"uint256"}],"name":"setStrategyLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lossLimitRatio","type":"uint256"}],"name":"setlossLimitRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"strategiesLimits","outputs":[{"internalType":"uint256","name":"profitLimitRatio","type":"uint256"},{"internalType":"uint256","name":"lossLimitRatio","type":"uint256"},{"internalType":"bool","name":"exists","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50600380546001600160a01b03199081163390811790925560048054909116909117905561012c600055606460015561084f8061004e6000396000f3fe608060405234801561001057600080fd5b50600436106100ce5760003560e01c80637d9699321161008c578063ab033ea911610066578063ab033ea914610177578063c70fa00b1461018a578063c9354337146101aa578063d4a22bde146101cc576100ce565b80637d9699321461015457806388a8d6021461015c578063950b3d7314610164576100ce565b8062fd31f0146100d35780630ef5ee02146100e85780631afdc5a2146100fb57806327fff0db1461010e5780634a5d0943146101375780635aa6e6751461014c575b600080fd5b6100e66100e13660046106e3565b6101df565b005b6100e66100f6366004610736565b61029a565b6100e66101093660046106af565b6102ec565b61012161011c366004610694565b610359565b60405161012e9190610788565b60405180910390f35b61013f610374565b60405161012e91906107cc565b61012161037a565b61013f610389565b61012161038f565b6100e6610172366004610736565b61039e565b6100e6610185366004610694565b6103f0565b61019d61019836600461074e565b61044f565b60405161012e919061079c565b6101bd6101b8366004610694565b61046a565b60405161012e939291906107d5565b6100e66101da366004610694565b61048d565b6003546001600160a01b031633148061020257506004546001600160a01b031633145b6102275760405162461bcd60e51b815260040161021e906107a7565b60405180910390fd5b612710811061023557600080fd5b612710821061024357600080fd5b60408051606081018252928352602080840192835260018483018181526001600160a01b03969096166000908152600292839052929092209351845591519083015591519101805460ff1916911515919091179055565b6003546001600160a01b03163314806102bd57506004546001600160a01b031633145b6102d95760405162461bcd60e51b815260040161021e906107a7565b61271081106102e757600080fd5b600155565b6003546001600160a01b031633148061030f57506004546001600160a01b031633145b61032b5760405162461bcd60e51b815260040161021e906107a7565b6001600160a01b03918216600090815260056020526040902080546001600160a01b03191691909216179055565b6005602052600090815260409020546001600160a01b031681565b60005481565b6003546001600160a01b031681565b60015481565b6004546001600160a01b031681565b6003546001600160a01b03163314806103c157506004546001600160a01b031633145b6103dd5760405162461bcd60e51b815260040161021e906107a7565b61271081106103eb57600080fd5b600055565b6003546001600160a01b0316331461041a5760405162461bcd60e51b815260040161021e906107a7565b6001600160a01b03811661042d57600080fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600061045e86868686866104ec565b90505b95945050505050565b600260208190526000918252604090912080546001820154919092015460ff1683565b6003546001600160a01b031633146104b75760405162461bcd60e51b815260040161021e906107a7565b6001600160a01b0381166104ca57600080fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b336000908152600560205260408120546001600160a01b03168061051d576105158787856105ac565b915050610461565b60405163e53ec13f60e01b81526001600160a01b0382169063e53ec13f90610551908a908a908a908a9033906004016107ed565b60206040518083038186803b15801561056957600080fd5b505afa15801561057d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a19190610716565b979650505050505050565b60006105b6610654565b503360009081526002602081815260408084208151606081018352815481526001820154938101939093529092015460ff16158015928201929092529190819061060857505080516020820151610611565b50506000546001545b6127108583020487111561062b576000935050505061064d565b61271085820204861115610645576000935050505061064d565b600193505050505b9392505050565b604051806060016040528060008152602001600081526020016000151581525090565b80356001600160a01b038116811461068e57600080fd5b92915050565b6000602082840312156106a5578081fd5b61064d8383610677565b600080604083850312156106c1578081fd5b6106cb8484610677565b91506106da8460208501610677565b90509250929050565b6000806000606084860312156106f7578081fd5b6107018585610677565b95602085013595506040909401359392505050565b600060208284031215610727578081fd5b8151801515811461064d578182fd5b600060208284031215610747578081fd5b5035919050565b600080600080600060a08688031215610765578081fd5b505083359560208501359550604085013594606081013594506080013592509050565b6001600160a01b0391909116815260200190565b901515815260200190565b6020808252600b908201526a08585d5d1a1bdc9a5e995960aa1b604082015260600190565b90815260200190565b92835260208301919091521515604082015260600190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a0019056fea2646970667358221220d89e65a3575ce7ff52b3cb593c20612b1f9dbdd91f6a5f6e33c8fe441c096e2c64736f6c634300060c0033

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

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.