Contract 0xd4c220CCaC0335334D425A90f58dE7C667896a06 3

 

Contract Overview

Balance:
0 BNB

BNB Value:
$0.00

Token:
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x93d5d0cb6e914e903498e509f17bb399a59ad475383fc3016bbb6d01545cb8bcSteer110252392021-09-18 15:24:092 hrs 50 mins ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00150256
0xad35adf4e4a246b7e383e26afe64f277a7c6e932540369da1a471bb69cb2122eSteer110156752021-09-18 7:24:1010 hrs 50 mins ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.001502015
0x54a607dce823e70730bd0f7be5037aa9c1cf98a8a957b670d1251f8047dca65dSteer110060992021-09-17 23:24:1018 hrs 50 mins ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00150262
0x32bb536b2761e646dc828fcdc15b8b60ab935d1fe31ccd0f8ee5056108d4d654Steer109965092021-09-17 15:24:081 day 2 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00150262
0x1d1d24f5c3be32f492d1cf67df47461eb66947d90ad34db3241da2c8046f6bc4Steer109869162021-09-17 7:24:091 day 10 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.001501955
0xfa2417845f7b3a1b336fbc87b8cc68482e75e0b7f439fa33745e65e373d18887Steer109773272021-09-16 23:24:091 day 18 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00150256
0xad5d4e96fc53b8a7b4445f8aa6751b741841e5103588767cd83c33294c3e3886Steer109677432021-09-16 15:24:092 days 2 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00150256
0xe1269af28b82ed4b35abd5e29115a621ba95280b87d838cc4e56184671213728Steer109581882021-09-16 7:24:082 days 10 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869175
0x49567d0473a6aa0eadd657e454870dc04f410246b95eda64efbddd6bb30bd10dSteer109485912021-09-15 23:24:082 days 18 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869235
0x528714241efb48afb441b285e7bedaa4c20122ad83dd9cea490cd945c3da8c93Steer109389922021-09-15 15:24:103 days 2 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869175
0xfbbeb925bba98a4247616dd4422cc5e892b04e28b6a6fd38e2ae46a885d8a80aSteer109295112021-09-15 7:24:083 days 10 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00086972
0x1754a5844c79c65cdc5a28f2a0eda43cb01e3041d989b05aaf7a5c2f0e51a028Steer109253192021-09-15 3:54:083 days 14 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869175
0xb65f8b600ac0a8301926edd11907eef9ab4ed7f516679cd064a8f3388cf3ace9Steer109157282021-09-14 19:54:143 days 22 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00086978
0x2ba727c92f93c66390256cccbf62fc399fd13cb9f3591b7c860e3ed874543a02Steer109107872021-09-14 15:46:104 days 2 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869235
0xd8951339ce02851d8137473819e6aff7ed0c81d20a82ab20a9c5b8f638efec67Steer109012212021-09-14 7:46:084 days 10 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869175
0x63c91967732a8a30945d36970ca447f199f174df10e1ce844ace4e2e3ed0c000Steer108916292021-09-13 23:46:084 days 18 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869115
0x0bf67a13330b4265942d6c294e7a17e85c055504435d5f05deb3acea313e13a7Steer108820332021-09-13 15:46:095 days 2 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00086978
0x5030d7ad058112ea0d3d8e799c6599daceaeaabd0971dc1549e053fba7f2caeeSteer108724862021-09-13 7:46:095 days 10 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00086984
0x23c478c185dca3e0c22ead1ecd25a788c4b6999521142426c74214f897e17767Steer108628902021-09-12 23:46:085 days 18 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00086978
0x774bb8f313e69bca1a7cf65cd69a06541137c8b3f0c37ea5d3c0acaa8da83c91Steer108533082021-09-12 15:46:086 days 2 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869235
0xdb99a605c46baddc1508c70fe26768002b5681fafba5324bd170cf9978d2f6a3Steer108437132021-09-12 7:46:096 days 10 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869175
0xafa4b2ae145d06a3ae242844bee54f00709b66512985b6da434897517fd55031Steer108341172021-09-11 23:46:096 days 18 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00086978
0x2bbbecad8d15eff789bccf8c74474c77124749562e53e5a5360a688f0a4c530aSteer108246352021-09-11 15:46:087 days 2 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000827235
0xd753041b0c6906a05530b94ce7a7916d00f3dfd61ba989d6a1250907bd948961Steer108151082021-09-11 7:46:097 days 10 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.000869175
0x33437454dc1633ace18bc865d54cf48c6c348fad0443a9df72101527b68c18dbSteer108056172021-09-10 23:46:097 days 18 hrs ago0x694f6c8ee9fc4aac80e23e6ae45096a7239d51b6 IN  0xd4c220ccac0335334d425a90f58de7c667896a060 BNB0.00086978
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
KaptainV2

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 14 : Address.sol
pragma solidity ^0.5.5;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following 
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @dev Converts an `address` into `address payable`. Note that this is
     * simply a type cast: the actual underlying value is not changed.
     *
     * _Available since v2.4.0._
     */
    function toPayable(address account) internal pure returns (address payable) {
        return address(uint160(account));
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     *
     * _Available since v2.4.0._
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-call-value
        (bool success, ) = recipient.call.value(amount)("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
}

File 2 of 14 : Context.sol
pragma solidity ^0.5.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
contract Context {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.
    constructor () internal { }
    // solhint-disable-previous-line no-empty-blocks

    function _msgSender() internal view returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 3 of 14 : ERC20.sol
pragma solidity ^0.5.0;

import "./Context.sol";
import "./IERC20.sol";
import "./KineSafeMath.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20Mintable}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    using KineSafeMath for uint256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20};
     *
     * Requirements:
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for `sender`'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal {
        require(account != address(0), "ERC20: mint to the zero address");

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal {
        require(account != address(0), "ERC20: burn from the zero address");

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
     *
     * This is internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`.`amount` is then deducted
     * from the caller's allowance.
     *
     * See {_burn} and {_approve}.
     */
    function _burnFrom(address account, uint256 amount) internal {
        _burn(account, amount);
        _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
    }
}

File 4 of 14 : IERC20.sol
pragma solidity ^0.5.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
 * the optional functions; to access them see {ERC20Detailed}.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 5 of 14 : KUSDMinter.sol
pragma solidity ^0.5.16;

import "./KineOracleInterface.sol";
import "./KineControllerInterface.sol";
import "./KUSDMinterDelegate.sol";
import "./Math.sol";
import "./IERC20.sol";
import "./ERC20.sol";
import "./SafeERC20.sol";

/// @notice IKineUSD, a simplified interface of KineUSD (see KineUSD)
interface IKineUSD {
    function mint(address account, uint amount) external;

    function burn(address account, uint amount) external;

    function balanceOf(address account) external view returns (uint256);
}

/// @notice IKMCD, a simplified interface of KMCD (see KMCD)
interface IKMCD {
    function borrowBehalf(address payable borrower, uint borrowAmount) external;

    function repayBorrowBehalf(address borrower, uint repayAmount) external;

    function liquidateBorrowBehalf(address liquidator, address borrower, uint repayAmount, address kTokenCollateral, uint minSeizeKToken) external;

    function borrowBalance(address account) external view returns (uint);

    function totalBorrows() external view returns (uint);
}

/**
 * @title IRewardDistributionRecipient
 */
contract IRewardDistributionRecipient is KUSDMinterDelegate {
    /// @notice Emitted when reward distributor changed
    event NewRewardDistribution(address oldRewardDistribution, address newRewardDistribution);

    /// @notice The reward distributor who is responsible to transfer rewards to this recipient and notify the recipient that reward is added.
    address public rewardDistribution;

    /// @notice Notify this recipient that reward is added.
    function notifyRewardAmount(uint reward) external;

    /// @notice Only reward distributor can notify that reward is added.
    modifier onlyRewardDistribution() {
        require(_msgSender() == rewardDistribution, "Caller is not reward distribution");
        _;
    }

    /// @notice Set reward distributor to new one.
    function setRewardDistribution(address _rewardDistribution) external onlyOwner {
        address oldRewardDistribution = rewardDistribution;
        rewardDistribution = _rewardDistribution;
        emit NewRewardDistribution(oldRewardDistribution, _rewardDistribution);
    }
}

/**
 * @title KUSDMinter is responsible to stake/unstake users' Kine MCD (see KMCD) and mint/burn KUSD (see KineUSD) on behalf of users.
 * When user want to mint KUSD against their collaterals (see KToken), KUSDMinter will borrow Knie MCD on behalf of user (which will increase user's debt ratio)
 * and then call KineUSD to mint KUSD to user. When user want to  burn KUSD, KUSDMinter will call KineUSD to burn KUSD from user and  repay Kine MCD on behalf of user.
 * KUSDMinter also let treasury account to mint/burn its balance to keep KUSD amount (the part that user transferred into Kine off-chain trading system) synced with Kine off-chain trading system.
 * @author Kine
 */
contract KUSDMinter is IRewardDistributionRecipient {
    using KineSafeMath for uint;
    using SafeERC20 for IERC20;

    /// @notice Emitted when KMCD changed
    event NewKMCD(address oldKMCD, address newKMCD);
    /// @notice Emitted when KineUSD changed
    event NewKUSD(address oldKUSD, address newKUSD);
    /// @notice Emitted when Kine changed
    event NewKine(address oldKine, address newKine);
    /// @notice Emitted when reward duration changed
    event NewRewardDuration(uint oldRewardDuration, uint newRewardDuration);
    /// @notice Emitted when reward release period changed
    event NewRewardReleasePeriod(uint oldRewardReleasePeriod, uint newRewardReleasePeriod);
    /// @notice Emitted when burn cool down time changed
    event NewBurnCooldownTime(uint oldCooldown, uint newCooldownTime);
    /// @notice Emitted when user mint KUSD
    event Mint(address indexed user, uint mintKUSDAmount, uint stakedKMCDAmount, uint userStakesNew, uint totalStakesNew);
    /// @notice Emitted when user burnt KUSD
    event Burn(address indexed user, uint burntKUSDAmount, uint unstakedKMCDAmount, uint userStakesNew, uint totalStakesNew);
    /// @notice Emitted when user burnt maximum KUSD
    event BurnMax(address indexed user, uint burntKUSDAmount, uint unstakedKMCDAmount, uint userStakesNew, uint totalStakesNew);
    /// @notice Emitted when liquidator liquidate staker's Kine MCD
    event Liquidate(address indexed liquidator, address indexed staker, uint burntKUSDAmount, uint unstakedKMCDAmount, uint stakerStakesNew, uint totalStakesNew);
    /// @notice Emitted when distributor notify reward is added
    event RewardAdded(uint reward);
    /// @notice Emitted when user claimed reward
    event RewardPaid(address indexed user, uint reward);
    /// @notice Emitted when treasury account mint kusd
    event TreasuryMint(uint amount);
    /// @notice Emitted when treasury account burn kusd
    event TreasuryBurn(uint amount);
    /// @notice Emitted when treasury account changed
    event NewTreasury(address oldTreasury, address newTreasury);
    /// @notice Emitted when vault account changed
    event NewVault(address oldVault, address newVault);
    /// @notice Emitted when controller changed
    event NewController(address oldController, address newController);

    /**
     * @notice This is for avoiding reward calculation overflow (see https://sips.synthetix.io/sips/sip-77)
     * 1.15792e59 < uint(-1) / 1e18
    */
    uint public constant REWARD_OVERFLOW_CHECK = 1.15792e59;

    /**
     * @notice Implementation address slot for delegation mode;
     */
    address public implementation;

    /// @notice Flag to mark if this contract has been initialized before
    bool public initialized;

    /// @notice Contract which holds Kine MCD
    IKMCD public kMCD;

    /// @notice Contract which holds Kine USD
    IKineUSD public kUSD;

    /// @notice Contract of controller which holds Kine Oracle
    KineControllerInterface public controller;

    /// @notice Treasury is responsible to keep KUSD amount consisted with Kine off-chain trading system
    address public treasury;

    /// @notice Vault is the place to store Kine trading system's reserved KUSD
    address public vault;

    /****************
    * Reward related
    ****************/

    /// @notice Contract which hold Kine Token
    IERC20 public kine;
    /// @notice Reward distribution duration. Added reward will be distribute to Kine MCD stakers within this duration.
    uint public rewardDuration;
    /// @notice Staker's reward will mature gradually in this period.
    uint public rewardReleasePeriod;
    /// @notice Start time that users can start staking/burning KUSD and claim their rewards.
    uint public startTime;
    /// @notice End time of this round of reward distribution.
    uint public periodFinish = 0;
    /// @notice Per second reward to be distributed
    uint public rewardRate = 0;
    /// @notice Accrued reward per Kine MCD staked per second.
    uint public rewardPerTokenStored;
    /// @notice Last time that rewardPerTokenStored is updated. Happens whenever total stakes going to be changed.
    uint public lastUpdateTime;
    /**
     * @notice The minium cool down time before user can burn kUSD after they mint kUSD everytime.
     * This is to raise risk and cost to arbitrageurs who front run our prices updates in oracle to drain profit from stakers.
     * Should be larger then minium price post interval.
     */
    uint public burnCooldownTime;

    struct AccountRewardDetail {
        /// @dev Last time account claimed its reward
        uint lastClaimTime;
        /// @dev RewardPerTokenStored at last time accrue rewards to this account
        uint rewardPerTokenUpdated;
        /// @dev Accrued rewards haven't been claimed of this account
        uint accruedReward;
        /// @dev Last time account mint kUSD
        uint lastMintTime;
    }

    /// @notice Mapping of account addresses to account reward detail
    mapping(address => AccountRewardDetail) public accountRewardDetails;

    function initialize(address kine_, address kUSD_, address kMCD_, address controller_, address treasury_, address vault_, address rewardDistribution_, uint startTime_, uint rewardDuration_, uint rewardReleasePeriod_) external {
        require(initialized == false, "KUSDMinter can only be initialized once");
        kine = IERC20(kine_);
        kUSD = IKineUSD(kUSD_);
        kMCD = IKMCD(kMCD_);
        controller = KineControllerInterface(controller_);
        treasury = treasury_;
        vault = vault_;
        rewardDistribution = rewardDistribution_;
        startTime = startTime_;
        rewardDuration = rewardDuration_;
        rewardReleasePeriod = rewardReleasePeriod_;
        initialized = true;
    }

    /**
     * @dev Local vars in calculating equivalent amount between KUSD and Kine MCD
     */
    struct CalculateVars {
        uint equivalentKMCDAmount;
        uint equivalentKUSDAmount;
    }

    /// @notice Prevent stakers' actions before start time
    modifier checkStart() {
        require(block.timestamp >= startTime, "not started yet");
        _;
    }

    /// @notice Prevent accounts other than treasury to mint/burn KUSD
    modifier onlyTreasury() {
        require(msg.sender == treasury, "only treasury account is allowed");
        _;
    }

    modifier afterCooldown(address staker) {
        require(accountRewardDetails[staker].lastMintTime.add(burnCooldownTime) < block.timestamp, "burn still cooling down");
        _;
    }

    /***
     * @notice Accrue account's rewards and store this time accrued results
     * @param account Reward status of whom to be updated
     */
    modifier updateReward(address account) {
        rewardPerTokenStored = rewardPerToken();
        lastUpdateTime = lastTimeRewardApplicable();
        if (account != address(0)) {
            accountRewardDetails[account].accruedReward = earned(account);
            accountRewardDetails[account].rewardPerTokenUpdated = rewardPerTokenStored;
            if (accountRewardDetails[account].lastClaimTime == 0) {
                accountRewardDetails[account].lastClaimTime = block.timestamp;
            }
        }
        _;
    }

    /**
     * @notice Current time which hasn't past this round reward's duration.
     * @return Current timestamp that hasn't past this round rewards' duration.
     */
    function lastTimeRewardApplicable() public view returns (uint) {
        return Math.min(block.timestamp, periodFinish);
    }

    /**
     * @notice Calculate new accrued reward per staked Kine MCD.
     * @return Current accrued reward per staked Kine MCD.
     */
    function rewardPerToken() public view returns (uint) {
        uint totalStakes = totalStakes();
        if (totalStakes == 0) {
            return rewardPerTokenStored;
        }
        return
        rewardPerTokenStored.add(
            lastTimeRewardApplicable()
            .sub(lastUpdateTime)
            .mul(rewardRate)
            .mul(1e18)
            .div(totalStakes)
        );
    }

    /**
     * @notice Calculate account's earned rewards so far.
     * @param account Which account to be viewed.
     * @return Account's earned rewards so far.
     */
    function earned(address account) public view returns (uint) {
        return accountStakes(account)
        .mul(rewardPerToken().sub(accountRewardDetails[account].rewardPerTokenUpdated))
        .div(1e18)
        .add(accountRewardDetails[account].accruedReward);
    }

    /**
     * @notice Calculate account's claimable rewards so far.
     * @param account Which account to be viewed.
     * @return Account's claimable rewards so far.
     */
    function claimable(address account) external view returns (uint) {
        uint accountNewAccruedReward = earned(account);
        uint pastTime = block.timestamp.sub(accountRewardDetails[account].lastClaimTime);
        uint maturedReward = rewardReleasePeriod == 0 ? accountNewAccruedReward : accountNewAccruedReward.mul(pastTime).div(rewardReleasePeriod);
        if (maturedReward > accountNewAccruedReward) {
            maturedReward = accountNewAccruedReward;
        }
        return maturedReward;
    }

    /**
    * @notice Mint will borrow equivalent Kine MCD for user, stake borrowed MCD and mint specified amount of KUSD. Call will fail if hasn't reached start time.
    * Mint will fail if hasn't reach start time.
    * @param kUSDAmount The amount of KUSD user want to mint
    */
    function mint(uint kUSDAmount) external checkStart updateReward(msg.sender) {
        address payable msgSender = _msgSender();
        // update sender's mint time
        accountRewardDetails[msgSender].lastMintTime = block.timestamp;

        uint kMCDPriceMantissa = KineOracleInterface(controller.getOracle()).getUnderlyingPrice(address(kMCD));
        require(kMCDPriceMantissa != 0, "Mint: get Kine MCD price zero");

        CalculateVars memory vars;

        // KUSD has 18 decimals
        // KMCD has 18 decimals
        // kMCDPriceMantissa is KMCD's price (quoted by KUSD, has 6 decimals) scaled by 1e36 / KMCD's decimals = 1e36 / 1e18 = 1e18
        // so the calculation of equivalent Kine MCD amount is as below
        //                          kUSDAmount        1e12 * 1e6               kUSDAmount * 1e18
        // equivalentKMCDAmount =  ----------- *  ------------------ * 1e18 =  -----------------
        //                             1e18         kMCDPriceMantissa           kMCDPriceMantissa

        vars.equivalentKMCDAmount = kUSDAmount.mul(1e18).div(kMCDPriceMantissa);

        // call KMCD contract to borrow Kine MCD for user and stake them
        kMCD.borrowBehalf(msgSender, vars.equivalentKMCDAmount);

        // mint KUSD to user
        kUSD.mint(msgSender, kUSDAmount);

        emit Mint(msgSender, kUSDAmount, vars.equivalentKMCDAmount, accountStakes(msgSender), totalStakes());
    }

    /**
    * @notice Burn repay equivalent Kine MCD for user and burn specified amount of KUSD
    * Burn will fail if hasn't reach start time.
    * @param kUSDAmount The amount of KUSD user want to burn
    */
    function burn(uint kUSDAmount) external checkStart afterCooldown(msg.sender) updateReward(msg.sender) {
        address msgSender = _msgSender();

        // burn user's KUSD
        kUSD.burn(msgSender, kUSDAmount);

        // calculate equivalent Kine MCD amount to specified amount of KUSD
        uint kMCDPriceMantissa = KineOracleInterface(controller.getOracle()).getUnderlyingPrice(address(kMCD));
        require(kMCDPriceMantissa != 0, "Burn: get Kine MCD price zero");

        CalculateVars memory vars;

        // KUSD has 18 decimals
        // KMCD has 18 decimals
        // kMCDPriceMantissa is KMCD's price (quoted by KUSD, has 6 decimals) scaled by 1e36 / KMCD's decimals = 1e36 / 1e18 = 1e18
        // so the calculation of equivalent Kine MCD amount is as below
        //                          kUSDAmount        1e12 * 1e6               kUSDAmount * 1e18
        // equivalentKMCDAmount =  ----------- *  ------------------ * 1e18 =  -----------------
        //                             1e18         kMCDPriceMantissa           kMCDPriceMantissa

        vars.equivalentKMCDAmount = kUSDAmount.mul(1e18).div(kMCDPriceMantissa);

        // call KMCD contract to repay Kine MCD for user
        kMCD.repayBorrowBehalf(msgSender, vars.equivalentKMCDAmount);

        emit Burn(msgSender, kUSDAmount, vars.equivalentKMCDAmount, accountStakes(msgSender), totalStakes());
    }

    /**
    * @notice BurnMax unstake and repay all borrowed Kine MCD for user and burn equivalent KUSD
    */
    function burnMax() external checkStart afterCooldown(msg.sender) updateReward(msg.sender) {
        address msgSender = _msgSender();

        uint kMCDPriceMantissa = KineOracleInterface(controller.getOracle()).getUnderlyingPrice(address(kMCD));
        require(kMCDPriceMantissa != 0, "BurnMax: get Kine MCD price zero");

        CalculateVars memory vars;

        // KUSD has 18 decimals
        // KMCD has 18 decimals
        // kMCDPriceMantissa is KMCD's price (quoted by KUSD, has 6 decimals) scaled by 1e36 / KMCD's decimals = 1e36 / 1e18 = 1e18
        // so the calculation of equivalent KUSD amount is as below
        //                         accountStakes     kMCDPriceMantissa         accountStakes * kMCDPriceMantissa
        // equivalentKUSDAmount =  ------------- *  ------------------ * 1e18 = ---------------------------------
        //                             1e18            1e12 * 1e6                          1e18
        //

        // try to unstake all Kine MCD
        uint userStakes = accountStakes(msgSender);
        vars.equivalentKMCDAmount = userStakes;
        vars.equivalentKUSDAmount = userStakes.mul(kMCDPriceMantissa).div(1e18);

        // in case user's kUSD is not enough to unstake all mcd, then just burn all kUSD and unstake part of MCD
        uint kUSDbalance = kUSD.balanceOf(msgSender);
        if (vars.equivalentKUSDAmount > kUSDbalance) {
            vars.equivalentKUSDAmount = kUSDbalance;
            vars.equivalentKMCDAmount = kUSDbalance.mul(1e18).div(kMCDPriceMantissa);
        }

        // burn user's equivalent KUSD
        kUSD.burn(msgSender, vars.equivalentKUSDAmount);

        // call KMCD contract to repay Kine MCD for user
        kMCD.repayBorrowBehalf(msgSender, vars.equivalentKMCDAmount);

        emit BurnMax(msgSender, vars.equivalentKUSDAmount, vars.equivalentKMCDAmount, accountStakes(msgSender), totalStakes());
    }

    /**
     * @notice Caller liquidates the staker's Kine MCD and seize staker's collateral.
     * Liquidate will fail if hasn't reach start time.
     * @param staker The staker of Kine MCD to be liquidated.
     * @param unstakeKMCDAmount The amount of Kine MCD to unstake.
     * @param maxBurnKUSDAmount The max amount limit of KUSD of liquidator to be burned.
     * @param kTokenCollateral The market in which to seize collateral from the staker.
     */
    function liquidate(address staker, uint unstakeKMCDAmount, uint maxBurnKUSDAmount, address kTokenCollateral, uint minSeizeKToken) external checkStart updateReward(staker) {
        address msgSender = _msgSender();

        uint kMCDPriceMantissa = KineOracleInterface(controller.getOracle()).getUnderlyingPrice(address(kMCD));
        require(kMCDPriceMantissa != 0, "Liquidate: get Kine MCD price zero");

        CalculateVars memory vars;

        // KUSD has 18 decimals
        // KMCD has 18 decimals
        // kMCDPriceMantissa is KMCD's price (quoted by KUSD, has 6 decimals) scaled by 1e36 / KMCD's decimals = 1e36 / 1e18 = 1e18
        // so the calculation of equivalent KUSD amount is as below
        //                         accountStakes     kMCDPriceMantissa         accountStakes * kMCDPriceMantissa
        // equivalentKUSDAmount =  ------------- *  ------------------ * 1e18 = ---------------------------------
        //                             1e18            1e12 * 1e6                          1e30
        //

        vars.equivalentKUSDAmount = unstakeKMCDAmount.mul(kMCDPriceMantissa).div(1e18);

        require(maxBurnKUSDAmount >= vars.equivalentKUSDAmount, "Liquidate: reach out max burn KUSD amount limit");

        // burn liquidator's KUSD
        kUSD.burn(msgSender, vars.equivalentKUSDAmount);

        // call KMCD contract to liquidate staker's Kine MCD and seize collateral
        kMCD.liquidateBorrowBehalf(msgSender, staker, unstakeKMCDAmount, kTokenCollateral, minSeizeKToken);

        emit Liquidate(msgSender, staker, vars.equivalentKUSDAmount, unstakeKMCDAmount, accountStakes(staker), totalStakes());
    }

    /**
     * @notice Show account's staked Kine MCD amount
     * @param account The account to be get MCD amount from
     */
    function accountStakes(address account) public view returns (uint) {
        return kMCD.borrowBalance(account);
    }

    /// @notice Show total staked Kine MCD amount
    function totalStakes() public view returns (uint) {
        return kMCD.totalBorrows();
    }

    /**
     * @notice Claim the matured rewards of caller.
     * Claim will fail if hasn't reach start time.
     */
    function getReward() external checkStart updateReward(msg.sender) {
        uint reward = accountRewardDetails[msg.sender].accruedReward;
        if (reward > 0) {
            uint pastTime = block.timestamp.sub(accountRewardDetails[msg.sender].lastClaimTime);
            uint maturedReward = rewardReleasePeriod == 0 ? reward : reward.mul(pastTime).div(rewardReleasePeriod);
            if (maturedReward > reward) {
                maturedReward = reward;
            }

            accountRewardDetails[msg.sender].accruedReward = reward.sub(maturedReward);
            accountRewardDetails[msg.sender].lastClaimTime = block.timestamp;
            kine.safeTransfer(msg.sender, maturedReward);
            emit RewardPaid(msg.sender, maturedReward);
        }
    }

    /**
     * @notice Notify rewards has been added, trigger a new round of reward period, recalculate reward rate and duration end time.
     * If distributor notify rewards before this round duration end time, then the leftover rewards of this round will roll over to
     * next round and will be distributed together with new rewards in next round of reward period.
     * @param reward How many of rewards has been added for new round of reward period.
     */
    function notifyRewardAmount(uint reward) external onlyRewardDistribution updateReward(address(0)) {
        if (block.timestamp > startTime) {
            if (block.timestamp >= periodFinish) {
                // @dev to avoid of rewardPerToken calculation overflow (see https://sips.synthetix.io/sips/sip-77), we check the reward to be inside a properate range
                // which is 2^256 / 10^18
                require(reward < REWARD_OVERFLOW_CHECK, "reward rate will overflow");
                rewardRate = reward.div(rewardDuration);
            } else {
                uint remaining = periodFinish.sub(block.timestamp);
                uint leftover = remaining.mul(rewardRate);
                // @dev to avoid of rewardPerToken calculation overflow (see https://sips.synthetix.io/sips/sip-77), we check the reward to be inside a properate range
                // which is 2^256 / 10^18
                require(reward.add(leftover) < REWARD_OVERFLOW_CHECK, "reward rate will overflow");
                rewardRate = reward.add(leftover).div(rewardDuration);
            }
            lastUpdateTime = block.timestamp;
            periodFinish = block.timestamp.add(rewardDuration);
            emit RewardAdded(reward);
        } else {
            // @dev to avoid of rewardPerToken calculation overflow (see https://sips.synthetix.io/sips/sip-77), we check the reward to be inside a properate range
            // which is 2^256 / 10^18
            require(reward < REWARD_OVERFLOW_CHECK, "reward rate will overflow");
            rewardRate = reward.div(rewardDuration);
            lastUpdateTime = startTime;
            periodFinish = startTime.add(rewardDuration);
            emit RewardAdded(reward);
        }
    }

    /**
     * @notice Set new reward duration, will start a new round of reward period immediately and recalculate rewardRate.
     * @param newRewardDuration New duration of each reward period round.
     */
    function _setRewardDuration(uint newRewardDuration) external onlyOwner updateReward(address(0)) {
        uint oldRewardDuration = rewardDuration;
        rewardDuration = newRewardDuration;

        if (block.timestamp > startTime) {
            if (block.timestamp >= periodFinish) {
                rewardRate = 0;
            } else {
                uint remaining = periodFinish.sub(block.timestamp);
                uint leftover = remaining.mul(rewardRate);
                rewardRate = leftover.div(rewardDuration);
            }
            lastUpdateTime = block.timestamp;
            periodFinish = block.timestamp.add(rewardDuration);
        } else {
            rewardRate = rewardRate.mul(oldRewardDuration).div(rewardDuration);
            lastUpdateTime = startTime;
            periodFinish = startTime.add(rewardDuration);
        }

        emit NewRewardDuration(oldRewardDuration, newRewardDuration);
    }

    /**
     * @notice Set new reward release period. The unclaimed rewards will be affected immediately.
     * @param newRewardReleasePeriod New release period of how long all earned rewards will be matured each time
     * before user claim reward.
     */
    function _setRewardReleasePeriod(uint newRewardReleasePeriod) external onlyOwner updateReward(address(0)) {
        uint oldRewardReleasePeriod = rewardReleasePeriod;
        rewardReleasePeriod = newRewardReleasePeriod;
        emit NewRewardReleasePeriod(oldRewardReleasePeriod, newRewardReleasePeriod);
    }

    function _setCooldownTime(uint newCooldownTime) external onlyOwner {
        uint oldCooldown = burnCooldownTime;
        burnCooldownTime = newCooldownTime;
        emit NewBurnCooldownTime(oldCooldown, newCooldownTime);
    }

    /**
     * @notice Mint KUSD to treasury account to keep on-chain KUSD consist with off-chain trading system
     * @param amount The amount of KUSD to mint to treasury
     */
    function treasuryMint(uint amount) external onlyTreasury {
        kUSD.mint(vault, amount);
        emit TreasuryMint(amount);
    }

    /**
     * @notice Burn KUSD from treasury account to keep on-chain KUSD consist with off-chain trading system
     * @param amount The amount of KUSD to burn from treasury
     */
    function treasuryBurn(uint amount) external onlyTreasury {
        kUSD.burn(vault, amount);
        emit TreasuryBurn(amount);
    }

    /**
     * @notice Change treasury account to a new one
     * @param newTreasury New treasury account address
     */
    function _setTreasury(address newTreasury) external onlyOwner {
        address oldTreasury = treasury;
        treasury = newTreasury;
        emit NewTreasury(oldTreasury, newTreasury);
    }

    /**
     * @notice Change vault account to a new one
     * @param newVault New vault account address
     */
    function _setVault(address newVault) external onlyOwner {
        address oldVault = vault;
        vault = newVault;
        emit NewVault(oldVault, newVault);
    }

    /**
     * @notice Change KMCD contract address to a new one.
     * @param newKMCD New KMCD contract address.
     */
    function _setKMCD(address newKMCD) external onlyOwner {
        address oldKMCD = address(kMCD);
        kMCD = IKMCD(newKMCD);
        emit NewKMCD(oldKMCD, newKMCD);
    }

    /**
     * @notice Change KUSD contract address to a new one.
     * @param newKUSD New KineUSD contract address.
     */
    function _setKUSD(address newKUSD) external onlyOwner {
        address oldKUSD = address(kUSD);
        kUSD = IKineUSD(newKUSD);
        emit NewKUSD(oldKUSD, newKUSD);
    }

    /**
     * @notice Change Kine contract address to a new one.
     * @param newKine New Kine contract address.
     */
    function _setKine(address newKine) external onlyOwner {
        address oldKine = address(kine);
        kine = IERC20(newKine);
        emit NewKine(oldKine, newKine);
    }
    /**
     * @notice Change Kine Controller address to a new one.
     * @param newController New Controller contract address.
     */
    function _setController(address newController) external onlyOwner {
        address oldController = address(controller);
        controller = KineControllerInterface(newController);
        emit NewController(oldController, newController);
    }
}

File 6 of 14 : KUSDMinterDelegate.sol
pragma solidity ^0.5.16;

import "./Ownable.sol";

/**
 * @title KUSDMinterDelegate
 * @author Kine
 */
contract KUSDMinterDelegate is Ownable {
    /**
     * @notice Emitted when implementation is changed
     */
    event NewImplementation(address oldImplementation, address newImplementation);

    /**
     * @notice Implementation address
     */
    address public implementation;
}

File 7 of 14 : KaptainV2.sol
pragma solidity ^0.5.16;

import "./KUSDMinter.sol";
import "./KineOracleInterfaceV2.sol";
import "./KineControllerInterface.sol";
import "./Ownable.sol";
import "./KineSafeMath.sol";

pragma experimental ABIEncoderV2;

/**
 * @title Kaptain allows Kine oracle reporter to report Kine token price and balance change of kUSD vault at the same time,
 * meanwhile will calculate the new MCD price according to new kUSD total supply and kMCD total amount.
 * Prices will be post to Kine oracle, and kUSD vault balance change will be submit to kUSD minter.
 * @author Kine
 *
 * V2 changes:
 * 1. steer function now is public, everyone who got the signed message can call steer to drive forward
 * 2. using oracle v2 instead of oracle v1
 * 3. replace poster to reporter since oracle v2 doesn't maintain reporter anymore
 */
contract KaptainV2 is Ownable {
    using KineSafeMath for uint;
    /// @notice Emitted when controller changed
    event NewController(address oldController, address newController);
    /// @notice Emitted when kUSD minter changed
    event NewMinter(address oldMinter, address newMinter);
    /// @notice Emitted when kUSD address changed
    event NewKUSD(address oldKUSD, address newKUSD);
    /// @notice Emitted when reporter address changed
    event NewReporter(address oldReporter, address newReporter);
    /// @notice Emitted when steered
    event Steer(uint256 scaledMCDPrice, bool isVaultIncreased, uint256 vaultKusdDelta, uint256 reporterNonce);

    /// @notice Oracle which gives the price of given asset
    KineControllerInterface public controller;
    /// @notice KUSD minter (see KUSDMinter) only allow treasury to mint/burn KUSD to vault account.
    /// @dev Minter need to set treasury to this Kaptain.
    KUSDMinter public minter;
    /// @notice kUSD address
    IERC20 public kUSD;
    /// @notice To prevent replaying reporter signed message and make sure posts are in sequence
    uint public reporterNonce;
    /// @notice Reporter address
    address public reporter;

    constructor (address controller_, address minter_, address kUSD_, address reporter_) public {
        controller = KineControllerInterface(controller_);
        minter = KUSDMinter(minter_);
        kUSD = IERC20(kUSD_);
        reporter = reporter_;
    }

    function _setInitialNonce(uint initialNonce) external onlyOwner {
        require(reporterNonce == 0, "initialNonce already set");
        reporterNonce = initialNonce;
    }

    /**
     * @notice everyone can post price, but only reporter signed message will be accepted
     * @param message Signed price data of tokens and kUSD vault balance change
     * @param signature Signature used to recover reporter public key
     */
    function steer(bytes calldata message, bytes calldata signature) external {
        // recover message signer
        address source = source(message, signature);

        // check if signer is Kine oracle reporter
        require(source == reporter, "only accept reporter signed message");
        KineOracleInterfaceV2 oracle = KineOracleInterfaceV2(controller.getOracle());

        // decode message
        (string[] memory symbols, uint[] memory prices, uint256 vaultKusdDelta, bool isVaultIncreased, uint256 nonce) = abi.decode(message, (string[], uint[], uint256, bool, uint256));
        // check if nonce is exactly +1, to make sure posts are in sequence
        reporterNonce = reporterNonce.add(1);
        require(reporterNonce == nonce, "bad reporter nonce");

        // call minter to update kUSD total supply
        if (isVaultIncreased) {
            minter.treasuryMint(vaultKusdDelta);
        } else {
            minter.treasuryBurn(vaultKusdDelta);
        }

        // calculate new kMCD price
        uint kMCDTotal = minter.totalStakes();
        uint kUSDTotal = kUSD.totalSupply();

        // kUSD has 18 decimals
        // kMCD has 18 decimals
        // mcdPrice = kUSD total supply / kMCD total amount * 1e6 (scaling factor)
        // if there is no borrowed kMCD, then the kMCD price will be set to inital value 1.
        uint mcdPrice;
        if(kMCDTotal == 0) {
            mcdPrice = 1e6;
        } else {
            mcdPrice = kUSDTotal.mul(1e18).div(kMCDTotal).div(1e12);
        }

        // post kMCD price to oracle, kMCD price will never be guarded by oracle.
        oracle.postMcdPrice(mcdPrice);

        oracle.postPrices(symbols, prices);

        emit Steer(mcdPrice, isVaultIncreased, vaultKusdDelta, reporterNonce);
    }

    /**
     * @notice Recovers the source address which signed a message
     * @dev Comparing to a claimed address would add nothing,
     *  as the caller could simply perform the recover and claim that address.
     * @param message The data that was presumably signed
     * @param signature The fingerprint of the data + private key
     * @return The source address which signed the message, presumably
     */
    function source(bytes memory message, bytes memory signature) public pure returns (address) {
        (bytes32 r, bytes32 s, uint8 v) = abi.decode(signature, (bytes32, bytes32, uint8));
        bytes32 hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", keccak256(message)));
        return ecrecover(hash, v, r, s);
    }

    /// @notice Change oracle to new one
    function _setController(address newController) external onlyOwner {
        address oldController = address(controller);
        controller = KineControllerInterface(newController);
        emit NewController(oldController, newController);
    }

    /// @notice Change minter to new one
    function _setMinter(address newMinter) external onlyOwner {
        address oldMinter = address(minter);
        minter = KUSDMinter(newMinter);
        emit NewMinter(oldMinter, newMinter);
    }

    /// @notice Change kUSD to new one
    function _setKUSD(address newKUSD) external onlyOwner {
        address oldKUSD = address(kUSD);
        kUSD = IERC20(newKUSD);
        emit NewKUSD(oldKUSD, newKUSD);
    }

    /// @notice Change reporter to new one
    function _setReporter(address newReporter) external onlyOwner {
        address oldReporter = reporter;
        reporter = newReporter;
        emit NewReporter(oldReporter, newReporter);
    }

}

File 8 of 14 : KineControllerInterface.sol
pragma solidity ^0.5.16;

/**
Copyright 2020 Compound Labs, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
* Original work from Compound: https://github.com/compound-finance/compound-protocol/blob/master/contracts/ComptrollerInterface.sol
* Modified to work in the Kine system.
* Main modifications:
*   1. removed Comp token related logics.
*   2. removed interest rate model related logics.
*   3. removed error code propagation mechanism to fail fast and loudly
*/

contract KineControllerInterface {
    /// @notice Indicator that this is a Controller contract (for inspection)
    bool public constant isController = true;

    /// @notice oracle getter function
    function getOracle() external view returns (address);

    /*** Assets You Are In ***/

    function enterMarkets(address[] calldata kTokens) external;

    function exitMarket(address kToken) external;

    /*** Policy Hooks ***/

    function mintAllowed(address kToken, address minter, uint mintAmount) external returns (bool, string memory);

    function mintVerify(address kToken, address minter, uint mintAmount, uint mintTokens) external;

    function redeemAllowed(address kToken, address redeemer, uint redeemTokens) external returns (bool, string memory);

    function redeemVerify(address kToken, address redeemer, uint redeemTokens) external;

    function borrowAllowed(address kToken, address borrower, uint borrowAmount) external returns (bool, string memory);

    function borrowVerify(address kToken, address borrower, uint borrowAmount) external;

    function repayBorrowAllowed(
        address kToken,
        address payer,
        address borrower,
        uint repayAmount) external returns (bool, string memory);

    function repayBorrowVerify(
        address kToken,
        address payer,
        address borrower,
        uint repayAmount) external;

    function liquidateBorrowAllowed(
        address kTokenBorrowed,
        address kTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount) external returns (bool, string memory);

    function liquidateBorrowVerify(
        address kTokenBorrowed,
        address kTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount,
        uint seizeTokens) external;

    function seizeAllowed(
        address kTokenCollateral,
        address kTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external returns (bool, string memory);

    function seizeVerify(
        address kTokenCollateral,
        address kTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external;

    function transferAllowed(address kToken, address src, address dst, uint transferTokens) external returns (bool, string memory);

    function transferVerify(address kToken, address src, address dst, uint transferTokens) external;

    /*** Liquidity/Liquidation Calculations ***/

    function liquidateCalculateSeizeTokens(
        address target,
        address kTokenBorrowed,
        address kTokenCollateral,
        uint repayAmount) external view returns (uint);
}

File 9 of 14 : KineOracleInterface.sol
pragma solidity ^0.5.16;
pragma experimental ABIEncoderV2;

/**
 * @title KineOracleInterface brief abstraction of Price Oracle
 */
interface KineOracleInterface {

    /**
     * @notice Get the underlying collateral price of given kToken.
     * @dev Returned kToken underlying price is scaled by 1e(36 - underlying token decimals)
     */
    function getUnderlyingPrice(address kToken) external view returns (uint);

    /**
     * @notice Post prices of tokens owned by Kine.
     * @param messages Signed price data of tokens
     * @param signatures Signatures used to recover reporter public key
     * @param symbols Token symbols
     */
    function postPrices(bytes[] calldata messages, bytes[] calldata signatures, string[] calldata symbols) external;

    /**
     * @notice Post Kine MCD price.
     */
    function postMcdPrice(uint mcdPrice) external;

    /**
     * @notice Get the reporter address.
     */
    function reporter() external returns (address);
}

File 10 of 14 : KineOracleInterfaceV2.sol
pragma solidity ^0.5.16;
pragma experimental ABIEncoderV2;

/**
 * @title KineOracleInterface brief abstraction of Price Oracle
 */
interface KineOracleInterfaceV2 {

    /**
     * @notice Get the underlying collateral price of given kToken.
     * @dev Returned kToken underlying price is scaled by 1e(36 - underlying token decimals)
     */
    function getUnderlyingPrice(address kToken) external view returns (uint);

    /**
     * @notice Post prices of tokens.
     * @param symbols Token symbols
     * @param prices Token prices
     */
    function postPrices(string[] calldata symbols, uint[] calldata prices) external;

    /**
     * @notice Post Kine MCD price.
     */
    function postMcdPrice(uint mcdPrice) external;
}

File 11 of 14 : KineSafeMath.sol
pragma solidity ^0.5.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */

/**
 * Original work from OpenZeppelin: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/math/SafeMath.sol
 * changes we made:
 * 1. add two methods that take errorMessage as input parameter
 */

library KineSafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     * added by Kine
     */
    function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, errorMessage);

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     * added by Kine
     */
    function mul(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, errorMessage);

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 12 of 14 : Math.sol
pragma solidity ^0.5.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @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, so we distribute
        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
    }
}

File 13 of 14 : Ownable.sol
pragma solidity ^0.5.0;

import "./Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 14 of 14 : SafeERC20.sol
pragma solidity ^0.5.0;

import "./IERC20.sol";
import "./KineSafeMath.sol";
import "./Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using KineSafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves.

        // A Solidity high level call has three parts:
        //  1. The target address is checked to verify it contains contract code
        //  2. The call itself is made, and success asserted
        //  3. The return value is decoded, which in turn checks the size of the returned data.
        // solhint-disable-next-line max-line-length
        require(address(token).isContract(), "SafeERC20: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = address(token).call(data);
        require(success, "SafeERC20: low-level call failed");

        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "evmVersion": "istanbul",
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"controller_","type":"address"},{"internalType":"address","name":"minter_","type":"address"},{"internalType":"address","name":"kUSD_","type":"address"},{"internalType":"address","name":"reporter_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldController","type":"address"},{"indexed":false,"internalType":"address","name":"newController","type":"address"}],"name":"NewController","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldKUSD","type":"address"},{"indexed":false,"internalType":"address","name":"newKUSD","type":"address"}],"name":"NewKUSD","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldMinter","type":"address"},{"indexed":false,"internalType":"address","name":"newMinter","type":"address"}],"name":"NewMinter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldReporter","type":"address"},{"indexed":false,"internalType":"address","name":"newReporter","type":"address"}],"name":"NewReporter","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"scaledMCDPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isVaultIncreased","type":"bool"},{"indexed":false,"internalType":"uint256","name":"vaultKusdDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reporterNonce","type":"uint256"}],"name":"Steer","type":"event"},{"constant":false,"inputs":[{"internalType":"address","name":"newController","type":"address"}],"name":"_setController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"initialNonce","type":"uint256"}],"name":"_setInitialNonce","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newKUSD","type":"address"}],"name":"_setKUSD","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newMinter","type":"address"}],"name":"_setMinter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newReporter","type":"address"}],"name":"_setReporter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"internalType":"contract KineControllerInterface","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"kUSD","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minter","outputs":[{"internalType":"contract KUSDMinter","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"reporter","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"reporterNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"source","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"steer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b50604051620017e9380380620017e98339810160408190526200003491620000fe565b6000620000496001600160e01b03620000e716565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600180546001600160a01b039586166001600160a01b031991821617909155600280549486169482169490941790935560038054928516928416929092179091556005805491909316911617905562000194565b3390565b8051620000f8816200017a565b92915050565b600080600080608085870312156200011557600080fd5b6000620001238787620000eb565b94505060206200013687828801620000eb565b93505060406200014987828801620000eb565b92505060606200015c87828801620000eb565b91505092959194509250565b60006001600160a01b038216620000f8565b620001858162000168565b81146200019157600080fd5b50565b61164580620001a46000396000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c80637ea3c3f411610097578063bd5542ed11610066578063bd5542ed146101db578063f2906798146101ee578063f2fde38b14610201578063f77c47911461021457610100565b80637ea3c3f41461019857806383de424e146101ab5780638da5cb5b146101be5780638f32d59b146101c657610100565b8063482a6193116100d3578063482a6193146101555780636398b06314610168578063678c9b5d1461017b578063715018a61461019057610100565b8063010ec4411461010557806307546172146101235780631210de7d146101385780632373f09114610140575b600080fd5b61010d61021c565b60405161011a9190611383565b60405180910390f35b61012b61022b565b60405161011a919061141d565b61012b61023a565b61015361014e366004610dd4565b610249565b005b61010d610163366004610f79565b6102d5565b610153610176366004610f09565b610383565b610183610826565b60405161011a91906114ac565b61015361082c565b6101536101a6366004610dd4565b61089a565b6101536101b9366004610dd4565b610911565b61010d610988565b6101ce610997565b60405161011a91906113d1565b6101536101e9366004610fe2565b6109bb565b6101536101fc366004610dd4565b610a04565b61015361020f366004610dd4565b610a7b565b61012b610aab565b6005546001600160a01b031681565b6002546001600160a01b031681565b6003546001600160a01b031681565b610251610997565b6102765760405162461bcd60e51b815260040161026d9061147c565b60405180910390fd5b600280546001600160a01b038381166001600160a01b03198316179092556040519116907f0b5e7be615a67a819aff3f47c967d1535cead1b98db60fafdcbf22dcaa8fa5a9906102c99083908590611391565b60405180910390a15050565b600080600080848060200190516102ef9190810190610ebc565b9250925092506000868051906020012060405160200161030f9190611363565b6040516020818303038152906040528051906020012090506001818386866040516000815260200160405260405161034a94939291906113df565b6020604051602081039080840390855afa15801561036c573d6000803e3d6000fd5b505050602060405103519450505050505b92915050565b60006103f885858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f890181900481028201810190925287815292508791508690819084018382808284376000920191909152506102d592505050565b6005549091506001600160a01b038083169116146104285760405162461bcd60e51b815260040161026d9061149c565b6001546040805163419d8fe760e11b815290516000926001600160a01b03169163833b1fce916004808301926020929190829003018186803b15801561046d57600080fd5b505afa158015610481573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104a59190810190610dfa565b9050606080600080806104ba8a8c018c610e18565b945094509450945094506104da6001600454610aba90919063ffffffff16565b600481905581146104fd5760405162461bcd60e51b815260040161026d9061145c565b811561056a57600254604051631dfb8ef160e31b81526001600160a01b039091169063efdc7788906105339086906004016114ac565b600060405180830381600087803b15801561054d57600080fd5b505af1158015610561573d6000803e3d6000fd5b505050506105cd565b6002546040516358c36c3760e01b81526001600160a01b03909116906358c36c379061059a9086906004016114ac565b600060405180830381600087803b1580156105b457600080fd5b505af11580156105c8573d6000803e3d6000fd5b505050505b6002546040805163bf9befb160e01b815290516000926001600160a01b03169163bf9befb1916004808301926020929190829003018186803b15801561061257600080fd5b505afa158015610626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061064a9190810190611000565b90506000600360009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561069c57600080fd5b505afa1580156106b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106d49190810190611000565b90506000826106e75750620f4240610719565b61071664e8d4a5100061070a858186670de0b6b3a764000063ffffffff610ae616565b9063ffffffff610b2016565b90505b604051639b23373360e01b81526001600160a01b038a1690639b233733906107459084906004016114ac565b600060405180830381600087803b15801561075f57600080fd5b505af1158015610773573d6000803e3d6000fd5b5050604051637098573160e11b81526001600160a01b038c16925063e130ae6291506107a5908b908b906004016113ac565b600060405180830381600087803b1580156107bf57600080fd5b505af11580156107d3573d6000803e3d6000fd5b505050507f2e41e8a64cd52e0fd035617e60e182173c21ca856f26c97f023839aed3cc078281868860045460405161080e94939291906114ba565b60405180910390a15050505050505050505050505050565b60045481565b610834610997565b6108505760405162461bcd60e51b815260040161026d9061147c565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6108a2610997565b6108be5760405162461bcd60e51b815260040161026d9061147c565b600580546001600160a01b038381166001600160a01b03198316179092556040519116907f5c37a58cb9bf8016914797277c8768ceec88e8f4fd0f181793b55c04fef06ca2906102c99083908590611391565b610919610997565b6109355760405162461bcd60e51b815260040161026d9061147c565b600180546001600160a01b038381166001600160a01b03198316179092556040519116907ff9b6a28700579d5c8fab50f0ac2dcaa52109b85c369c4f511fcc873330ab6cbb906102c99083908590611391565b6000546001600160a01b031690565b600080546001600160a01b03166109ac610b62565b6001600160a01b031614905090565b6109c3610997565b6109df5760405162461bcd60e51b815260040161026d9061147c565b600454156109ff5760405162461bcd60e51b815260040161026d9061148c565b600455565b610a0c610997565b610a285760405162461bcd60e51b815260040161026d9061147c565b600380546001600160a01b038381166001600160a01b03198316179092556040519116907fb3850c5019fd43a2b12888a929e21089f1e4284fda291366b2eb1f45a0b0c10e906102c99083908590611391565b610a83610997565b610a9f5760405162461bcd60e51b815260040161026d9061147c565b610aa881610b66565b50565b6001546001600160a01b031681565b600082820183811015610adf5760405162461bcd60e51b815260040161026d9061144c565b9392505050565b600082610af55750600061037d565b82820282848281610b0257fe5b0414610adf5760405162461bcd60e51b815260040161026d9061146c565b6000610adf83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610be7565b3390565b6001600160a01b038116610b8c5760405162461bcd60e51b815260040161026d9061143c565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60008183610c085760405162461bcd60e51b815260040161026d919061142b565b506000838581610c1457fe5b0495945050505050565b803561037d816115d3565b805161037d816115d3565b600082601f830112610c4557600080fd5b8135610c58610c53826114fc565b6114d5565b81815260209384019390925082018360005b83811015610c965781358601610c808882610d6f565b8452506020928301929190910190600101610c6a565b5050505092915050565b600082601f830112610cb157600080fd5b8135610cbf610c53826114fc565b91508181835260208401935060208101905083856020840282011115610ce457600080fd5b60005b83811015610c965781610cfa8882610dbe565b8452506020928301929190910190600101610ce7565b803561037d816115e7565b805161037d816115f0565b60008083601f840112610d3857600080fd5b50813567ffffffffffffffff811115610d5057600080fd5b602083019150836001820283011115610d6857600080fd5b9250929050565b600082601f830112610d8057600080fd5b8135610d8e610c538261151d565b91508082526020830160208301858383011115610daa57600080fd5b610db583828461158d565b50505092915050565b803561037d816115f0565b805161037d816115f9565b600060208284031215610de657600080fd5b6000610df28484610c1e565b949350505050565b600060208284031215610e0c57600080fd5b6000610df28484610c29565b600080600080600060a08688031215610e3057600080fd5b853567ffffffffffffffff811115610e4757600080fd5b610e5388828901610c34565b955050602086013567ffffffffffffffff811115610e7057600080fd5b610e7c88828901610ca0565b9450506040610e8d88828901610dbe565b9350506060610e9e88828901610d10565b9250506080610eaf88828901610dbe565b9150509295509295909350565b600080600060608486031215610ed157600080fd5b6000610edd8686610d1b565b9350506020610eee86828701610d1b565b9250506040610eff86828701610dc9565b9150509250925092565b60008060008060408587031215610f1f57600080fd5b843567ffffffffffffffff811115610f3657600080fd5b610f4287828801610d26565b9450945050602085013567ffffffffffffffff811115610f6157600080fd5b610f6d87828801610d26565b95989497509550505050565b60008060408385031215610f8c57600080fd5b823567ffffffffffffffff811115610fa357600080fd5b610faf85828601610d6f565b925050602083013567ffffffffffffffff811115610fcc57600080fd5b610fd885828601610d6f565b9150509250929050565b600060208284031215610ff457600080fd5b6000610df28484610dbe565b60006020828403121561101257600080fd5b6000610df28484610d1b565b6000610adf8383611140565b6000611036838361111d565b505060200190565b6110478161155d565b82525050565b60006110588261154b565b611062818561154f565b93508360208202850161107485611545565b8060005b858110156110ae5784840389528151611091858261101e565b945061109c83611545565b60209a909a0199925050600101611078565b5091979650505050505050565b60006110c68261154b565b6110d0818561154f565b93506110db83611545565b8060005b838110156111095781516110f3888261102a565b97506110fe83611545565b9250506001016110df565b509495945050505050565b61104781611568565b6110478161156d565b6110476111328261156d565b61156d565b61104781611582565b600061114b8261154b565b611155818561154f565b9350611165818560208601611599565b61116e816115c9565b9093019392505050565b6000611185601c83611558565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c0192915050565b60006111be60268361154f565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181526564647265737360d01b602082015260400192915050565b6000611206601b8361154f565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061123f60128361154f565b71626164207265706f72746572206e6f6e636560701b815260200192915050565b600061126d60218361154f565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b60006112b060208361154f565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572815260200192915050565b60006112e960188361154f565b7f696e697469616c4e6f6e636520616c7265616479207365740000000000000000815260200192915050565b600061132260238361154f565b7f6f6e6c7920616363657074207265706f72746572207369676e6564206d65737381526261676560e81b602082015260400192915050565b6110478161157c565b600061136e82611178565b915061137a8284611126565b50602001919050565b6020810161037d828461103e565b6040810161139f828561103e565b610adf602083018461103e565b604080825281016113bd818561104d565b90508181036020830152610df281846110bb565b6020810161037d8284611114565b608081016113ed828761111d565b6113fa602083018661135a565b611407604083018561111d565b611414606083018461111d565b95945050505050565b6020810161037d8284611137565b60208082528101610adf8184611140565b6020808252810161037d816111b1565b6020808252810161037d816111f9565b6020808252810161037d81611232565b6020808252810161037d81611260565b6020808252810161037d816112a3565b6020808252810161037d816112dc565b6020808252810161037d81611315565b6020810161037d828461111d565b608081016114c8828761111d565b6113fa6020830186611114565b60405181810167ffffffffffffffff811182821017156114f457600080fd5b604052919050565b600067ffffffffffffffff82111561151357600080fd5b5060209081020190565b600067ffffffffffffffff82111561153457600080fd5b506020601f91909101601f19160190565b60200190565b5190565b90815260200190565b919050565b600061037d82611570565b151590565b90565b6001600160a01b031690565b60ff1690565b600061037d8261155d565b82818337506000910152565b60005b838110156115b457818101518382015260200161159c565b838111156115c3576000848401525b50505050565b601f01601f191690565b6115dc8161155d565b8114610aa857600080fd5b6115dc81611568565b6115dc8161156d565b6115dc8161157c56fea365627a7a72315820823d444fd3993adb1ab6120b4bcfd9f837501ae12556155fd580766e848b913a6c6578706572696d656e74616cf564736f6c634300051000400000000000000000000000003c2ddd486c07343b711a4415cdc9ab90ed32b57100000000000000000000000042fe8ec54db8ea76c45673723fbd69116fd28989000000000000000000000000d819d96f9d28ea85c1dd78e66d7241134e8d4ab400000000000000000000000017d04113a3651e79e7d40a40e47aae23046f7761

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

0000000000000000000000003c2ddd486c07343b711a4415cdc9ab90ed32b57100000000000000000000000042fe8ec54db8ea76c45673723fbd69116fd28989000000000000000000000000d819d96f9d28ea85c1dd78e66d7241134e8d4ab400000000000000000000000017d04113a3651e79e7d40a40e47aae23046f7761

-----Decoded View---------------
Arg [0] : controller_ (address): 0x3c2ddd486c07343b711a4415cdc9ab90ed32b571
Arg [1] : minter_ (address): 0x42fe8ec54db8ea76c45673723fbd69116fd28989
Arg [2] : kUSD_ (address): 0xd819d96f9d28ea85c1dd78e66d7241134e8d4ab4
Arg [3] : reporter_ (address): 0x17d04113a3651e79e7d40a40e47aae23046f7761

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000003c2ddd486c07343b711a4415cdc9ab90ed32b571
Arg [1] : 00000000000000000000000042fe8ec54db8ea76c45673723fbd69116fd28989
Arg [2] : 000000000000000000000000d819d96f9d28ea85c1dd78e66d7241134e8d4ab4
Arg [3] : 00000000000000000000000017d04113a3651e79e7d40a40e47aae23046f7761


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
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.