ETH Price: $3,288.56 (-3.12%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Withdraw116057592021-01-07 5:53:351462 days ago1609998815IN
0x5CA353CC...2195138b5
0 ETH0.0088421285
Withdraw116050342021-01-07 3:08:071462 days ago1609988887IN
0x5CA353CC...2195138b5
0 ETH0.007905976
Withdraw116006962021-01-06 11:16:561463 days ago1609931816IN
0x5CA353CC...2195138b5
0 ETH0.0107499133.352
Stake116004572021-01-06 10:21:551463 days ago1609928515IN
0x5CA353CC...2195138b5
0 ETH0.01484453107.39863437
Withdraw115980542021-01-06 1:23:421463 days ago1609896222IN
0x5CA353CC...2195138b5
0 ETH0.0090369376.00000145
Withdraw115978762021-01-06 0:37:501463 days ago1609893470IN
0x5CA353CC...2195138b5
0 ETH0.0099450495.7
Withdraw115977942021-01-06 0:21:241463 days ago1609892484IN
0x5CA353CC...2195138b5
0 ETH0.01132847109
Set Reward Rate115976602021-01-05 23:54:141463 days ago1609890854IN
0x5CA353CC...2195138b5
0 ETH0.003443250
Exit115976472021-01-05 23:51:321463 days ago1609890692IN
0x5CA353CC...2195138b5
0 ETH0.0114251865
Get Reward115975802021-01-05 23:38:451463 days ago1609889925IN
0x5CA353CC...2195138b5
0 ETH0.01357986124
Withdraw115975792021-01-05 23:38:321463 days ago1609889912IN
0x5CA353CC...2195138b5
0 ETH0.01450375134
Exit115975642021-01-05 23:32:451463 days ago1609889565IN
0x5CA353CC...2195138b5
0 ETH0.02214727126
Get Reward115963852021-01-05 19:18:071464 days ago1609874287IN
0x5CA353CC...2195138b5
0 ETH0.01568595143
Exit115963322021-01-05 19:05:121464 days ago1609873512IN
0x5CA353CC...2195138b5
0 ETH0.0118424962
Stake115959802021-01-05 17:52:081464 days ago1609869128IN
0x5CA353CC...2195138b5
0 ETH0.0132559493
Exit115959402021-01-05 17:42:391464 days ago1609868559IN
0x5CA353CC...2195138b5
0 ETH0.02162496120
Get Reward115958912021-01-05 17:31:561464 days ago1609867916IN
0x5CA353CC...2195138b5
0 ETH0.0074561468.01
Stake115958402021-01-05 17:22:591464 days ago1609867379IN
0x5CA353CC...2195138b5
0 ETH0.0102058480
Exit115956942021-01-05 16:53:191464 days ago1609865599IN
0x5CA353CC...2195138b5
0 ETH0.02775494168.00000123
Stake115948272021-01-05 13:35:041464 days ago1609853704IN
0x5CA353CC...2195138b5
0 ETH0.0106920775
Get Reward115947802021-01-05 13:28:061464 days ago1609853286IN
0x5CA353CC...2195138b5
0 ETH0.0080729667
Withdraw115945422021-01-05 12:41:051464 days ago1609850465IN
0x5CA353CC...2195138b5
0 ETH0.0085600479.00000145
Get Reward115945392021-01-05 12:40:121464 days ago1609850412IN
0x5CA353CC...2195138b5
0 ETH0.0095188679
Exit115942692021-01-05 11:37:371464 days ago1609846657IN
0x5CA353CC...2195138b5
0 ETH0.014325675
Exit115941292021-01-05 11:03:551464 days ago1609844635IN
0x5CA353CC...2195138b5
0 ETH0.02215692116
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Stake_XUSD

Compiler Version
v0.6.11+commit.5ef660b1

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion
File 1 of 28 : Stake_XUSD.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;

import "../StakingRewards.sol";

contract Stake_XUSD is StakingRewards {
    constructor(
        address _dev,
        uint256 _fee,
        address _rewardsToken,
        address _stakingToken,
        address _xusd_address,
        address _timelock_address,
        uint256 _pool_weight,
        uint256 _start_time
    ) 
    StakingRewards(_dev, _fee, _rewardsToken, _stakingToken, _xusd_address, _timelock_address, _pool_weight, _start_time)
    public {}
}

File 2 of 28 : Context.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

/*
 * @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 { }

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

    function _msgData() internal view virtual 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 28 : ERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

import "../Common/Context.sol";
import "./IERC20.sol";
import "../Math/SafeMath.sol";
import "../Utils/Address.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 SafeMath for uint256;

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;
    
    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name, string memory symbol) public {
        _name = name;
        _symbol = symbol;
        _decimals = 18;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view returns (uint8) {
        return _decimals;
    }

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

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view override 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 virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.approve(address spender, uint256 amount)
     */
    function approve(address spender, uint256 amount) public virtual override 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 virtual override 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 virtual 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 virtual 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 virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _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 virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

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

    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for `accounts`'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");

        _approve(account, _msgSender(), decreasedAllowance);
        _burn(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 virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _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 virtual {
        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 virtual {
        _burn(account, amount);
        _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of `from`'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of `from`'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:using-hooks.adoc[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

File 4 of 28 : ERC20Custom.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

import "../Common/Context.sol";
import "./IERC20.sol";
import "../Math/SafeMath.sol";
import "../Utils/Address.sol";

// Due to compiling issues, _name, _symbol, and _decimals were removed


/**
 * @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 ERC20Custom is Context, IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) internal _balances;

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

    uint256 private _totalSupply;

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

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view override 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 virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.approve(address spender, uint256 amount)
     */
    function approve(address spender, uint256 amount) public virtual override 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 virtual override 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 virtual 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 virtual 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 virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _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 virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

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

    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for `accounts`'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");

        _approve(account, _msgSender(), decreasedAllowance);
        _burn(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 virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _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 virtual {
        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 virtual {
        _burn(account, amount);
        _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of `from`'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of `from`'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:using-hooks.adoc[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

File 5 of 28 : IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

import "../Common/Context.sol";
import "../Math/SafeMath.sol";

/**
 * @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 6 of 28 : SafeERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

import "./IERC20.sol";
import "../Math/SafeMath.sol";
import "../Utils/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 IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath 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));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    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. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "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");
        }
    }
}

File 7 of 28 : Babylonian.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

// computes square roots using the babylonian method
// https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
library Babylonian {
    function sqrt(uint y) internal pure returns (uint z) {
        if (y > 3) {
            z = y;
            uint x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
        // else z = 0
    }
}

File 8 of 28 : FixedPoint.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

import './Babylonian.sol';

// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
library FixedPoint {
    // range: [0, 2**112 - 1]
    // resolution: 1 / 2**112
    struct uq112x112 {
        uint224 _x;
    }

    // range: [0, 2**144 - 1]
    // resolution: 1 / 2**112
    struct uq144x112 {
        uint _x;
    }

    uint8 private constant RESOLUTION = 112;
    uint private constant Q112 = uint(1) << RESOLUTION;
    uint private constant Q224 = Q112 << RESOLUTION;

    // encode a uint112 as a UQ112x112
    function encode(uint112 x) internal pure returns (uq112x112 memory) {
        return uq112x112(uint224(x) << RESOLUTION);
    }

    // encodes a uint144 as a UQ144x112
    function encode144(uint144 x) internal pure returns (uq144x112 memory) {
        return uq144x112(uint256(x) << RESOLUTION);
    }

    // divide a UQ112x112 by a uint112, returning a UQ112x112
    function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
        require(x != 0, 'FixedPoint: DIV_BY_ZERO');
        return uq112x112(self._x / uint224(x));
    }

    // multiply a UQ112x112 by a uint, returning a UQ144x112
    // reverts on overflow
    function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
        uint z;
        require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
        return uq144x112(z);
    }

    // returns a UQ112x112 which represents the ratio of the numerator to the denominator
    // equivalent to encode(numerator).div(denominator)
    function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
        require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
        return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
    }

    // decode a UQ112x112 into a uint112 by truncating after the radix point
    function decode(uq112x112 memory self) internal pure returns (uint112) {
        return uint112(self._x >> RESOLUTION);
    }

    // decode a UQ144x112 into a uint144 by truncating after the radix point
    function decode144(uq144x112 memory self) internal pure returns (uint144) {
        return uint144(self._x >> RESOLUTION);
    }

    // take the reciprocal of a UQ112x112
    function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
        require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
        return uq112x112(uint224(Q224 / self._x));
    }

    // square root of a UQ112x112
    function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
        return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
    }
}

File 9 of 28 : Math.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

/**
 * @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);
    }

    // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
    function sqrt(uint y) internal pure returns (uint z) {
        if (y > 3) {
            z = y;
            uint x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }
}

File 10 of 28 : SafeMath.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

/**
 * @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.
 */
library SafeMath {
    /**
     * @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 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 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 11 of 28 : AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

interface AggregatorV3Interface {

  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

}

File 12 of 28 : ChainlinkETHUSDPriceConsumer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;

import "./AggregatorV3Interface.sol";

contract ChainlinkETHUSDPriceConsumer {

    AggregatorV3Interface internal priceFeed;


    constructor() public {
        priceFeed = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);
    }

    /**
     * Returns the latest price
     */
    function getLatestPrice() public view returns (int) {
        (
            , 
            int price,
            ,
            ,
            
        ) = priceFeed.latestRoundData();
        return price;
    }

    function getDecimals() public view returns (uint8) {
        return priceFeed.decimals();
    }
}

File 13 of 28 : UniswapPairOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

import '../Uniswap/Interfaces/IUniswapV2Factory.sol';
import '../Uniswap/Interfaces/IUniswapV2Pair.sol';
import '../Math/FixedPoint.sol';

import '../Uniswap/UniswapV2OracleLibrary.sol';
import '../Uniswap/UniswapV2Library.sol';

// Fixed window oracle that recomputes the average price for the entire period once every period
// Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period
contract UniswapPairOracle {
    using FixedPoint for *;
    
    address owner_address;
    address timelock_address;

    uint public PERIOD = 3600; // 1 hour TWAP (time-weighted average price)

    IUniswapV2Pair public immutable pair;
    address public immutable token0;
    address public immutable token1;

    uint    public price0CumulativeLast;
    uint    public price1CumulativeLast;
    uint32  public blockTimestampLast;
    FixedPoint.uq112x112 public price0Average;
    FixedPoint.uq112x112 public price1Average;

    modifier onlyByOwnerOrGovernance() {
        require(msg.sender == owner_address || msg.sender == timelock_address, "You are not an owner or the governance timelock");
        _;
    }

    constructor(address factory, address tokenA, address tokenB, address _owner_address, address _timelock_address) public {
        IUniswapV2Pair _pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, tokenA, tokenB));
        pair = _pair;
        token0 = _pair.token0();
        token1 = _pair.token1();
        price0CumulativeLast = _pair.price0CumulativeLast(); // Fetch the current accumulated price value (1 / 0)
        price1CumulativeLast = _pair.price1CumulativeLast(); // Fetch the current accumulated price value (0 / 1)
        uint112 reserve0;
        uint112 reserve1;
        (reserve0, reserve1, blockTimestampLast) = _pair.getReserves();
        require(reserve0 != 0 && reserve1 != 0, 'UniswapPairOracle: NO_RESERVES'); // Ensure that there's liquidity in the pair

        owner_address = _owner_address;
        timelock_address = _timelock_address;
    }

    function setOwner(address _owner_address) external onlyByOwnerOrGovernance {
        owner_address = _owner_address;
    }

    function setTimelock(address _timelock_address) external onlyByOwnerOrGovernance {
        timelock_address = _timelock_address;
    }

    function setPeriod(uint _period) external onlyByOwnerOrGovernance {
        PERIOD = _period;
    }

    function update() external {
        (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) =
            UniswapV2OracleLibrary.currentCumulativePrices(address(pair));
        uint32 timeElapsed = blockTimestamp - blockTimestampLast; // Overflow is desired

        // Ensure that at least one full period has passed since the last update
        require(timeElapsed >= PERIOD, 'UniswapPairOracle: PERIOD_NOT_ELAPSED');

        // Overflow is desired, casting never truncates
        // Cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed
        price0Average = FixedPoint.uq112x112(uint224((price0Cumulative - price0CumulativeLast) / timeElapsed));
        price1Average = FixedPoint.uq112x112(uint224((price1Cumulative - price1CumulativeLast) / timeElapsed));

        price0CumulativeLast = price0Cumulative;
        price1CumulativeLast = price1Cumulative;
        blockTimestampLast = blockTimestamp;
    }

    // Note this will always return 0 before update has been called successfully for the first time.
    function consult(address token, uint amountIn) external view returns (uint amountOut) {
        if (token == token0) {
            amountOut = price0Average.mul(amountIn).decode144();
        } else {
            require(token == token1, 'UniswapPairOracle: INVALID_TOKEN');
            amountOut = price1Average.mul(amountIn).decode144();
        }
    }
}

File 14 of 28 : IStakingRewards.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;


interface IStakingRewards {
    // Views
    function lastTimeRewardApplicable() external view returns (uint256);

    function rewardPerToken() external view returns (uint256);

    function earned(address account) external view returns (uint256);

    function getRewardForDuration() external view returns (uint256);

    function totalSupply() external view returns (uint256);

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

    // Mutative

    function stake(uint256 amount) external;

    function withdraw(uint256 amount) external;

    function getReward() external;

    //function exit() external;
}

File 15 of 28 : Owned.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

// https://docs.synthetix.io/contracts/Owned
contract Owned {
    address public owner;
    address public nominatedOwner;

    constructor(address _owner) public {
        require(_owner != address(0), "Owner address cannot be 0");
        owner = _owner;
        emit OwnerChanged(address(0), _owner);
    }

    function nominateNewOwner(address _owner) external onlyOwner {
        nominatedOwner = _owner;
        emit OwnerNominated(_owner);
    }

    function acceptOwnership() external {
        require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
        emit OwnerChanged(owner, nominatedOwner);
        owner = nominatedOwner;
        nominatedOwner = address(0);
    }

    modifier onlyOwner {
        require(msg.sender == owner, "Only the contract owner may perform this action");
        _;
    }

    event OwnerNominated(address newOwner);
    event OwnerChanged(address oldOwner, address newOwner);
}

File 16 of 28 : Pausable.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

// Inheritance
import "./Owned.sol";

// https://docs.synthetix.io/contracts/Pausable
abstract contract Pausable is Owned {
    uint public lastPauseTime;
    bool public paused;

    constructor() internal {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner != address(0), "Owner must be set");
        // Paused will be false, and lastPauseTime will be 0 upon initialisation
    }

    /**
     * @notice Change the paused state of the contract
     * @dev Only the contract owner may call this.
     */
    function setPaused(bool _paused) external onlyOwner {
        // Ensure we're actually changing the state before we do anything
        if (_paused == paused) {
            return;
        }

        // Set our paused state.
        paused = _paused;

        // If applicable, set the last pause time.
        if (paused) {
            lastPauseTime = now;
        }

        // Let everyone know that our pause state has changed.
        emit PauseChanged(paused);
    }

    event PauseChanged(bool isPaused);

    modifier notPaused {
        require(!paused, "This action cannot be performed while the contract is paused");
        _;
    }
}

File 17 of 28 : StakingRewards.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;

// Stolen with love from Synthetixio
// https://raw.githubusercontent.com/Synthetixio/synthetix/develop/contracts/StakingRewards.sol

import "../Math/Math.sol";
import "../Math/SafeMath.sol";
import "../ERC20/ERC20.sol";
import '../Uniswap/TransferHelper.sol';
import "../ERC20/SafeERC20.sol";
import "../XUSD/XUSD.sol";
import "../XUS/XUS.sol";
import "../Utils/ReentrancyGuard.sol";
import "../Utils/StringHelpers.sol";

// Inheritance
import "./IStakingRewards.sol";
import "./Pausable.sol";

contract StakingRewards is IStakingRewards, ReentrancyGuard, Pausable {
    using SafeMath for uint256;
    using SafeERC20 for ERC20;

    /* ========== STATE VARIABLES ========== */

    XUSDStablecoin private XUSD;
    XUSDShares public rewardsToken;
    ERC20 public stakingToken;
    uint256 public periodFinish;

    // Constants for various precisions
    // uint256 private constant PRICE_PRECISION = 1e6;

    // Max reward per second
    uint256 public rewardRate;

    // uint256 public rewardsDuration = 86400 hours;
    uint256 public rewardsDuration = 2592000; // 30 * 86400  (30 days)

    uint256 public lastUpdateTime;
    uint256 public rewardPerTokenStored = 0;
    uint256 public pool_weight; // This staking pool's percentage of the total XUS being distributed by all pools, 6 decimals of precision

    address public owner_address;
    address public timelock_address; // Governance timelock address

    uint256 public cr_boost_max_multiplier = 3000000; // 6 decimals of precision. 1x = 1000000

    mapping(address => uint256) public userRewardPerTokenPaid;
    mapping(address => uint256) public rewards;

    uint256 private _staking_token_supply = 0;
    mapping(address => uint256) public override balanceOf;

    address private dev_address;
    uint256 private dev_fee;
    uint256 public start_time;

    /* ========== CONSTRUCTOR ========== */

    constructor(
        address _dev_address,
        uint256 _dev_fee,
        address _rewardsToken,
        address _stakingToken,
        address _xusd_address,
        address _timelock_address,
        uint256 _pool_weight,
        uint256 _start_time
    ) public Owned(msg.sender){
        owner_address = msg.sender;
        dev_address = _dev_address;
        dev_fee = _dev_fee; // 40000/1000000, 4% dev reward

        rewardsToken = XUSDShares(_rewardsToken);
        stakingToken = ERC20(_stakingToken);
        XUSD = XUSDStablecoin(_xusd_address);
        lastUpdateTime = block.timestamp;
        timelock_address = _timelock_address;
        pool_weight = _pool_weight;
        rewardRate = 771604938271604938; // (uint256(2000000e18)).div(30 * 86400); // Base emission rate of 2M XUS over the first month
        rewardRate = rewardRate.mul(pool_weight).div(1e6);

        start_time = _start_time;
    }

    modifier checkStart() {
        require(block.timestamp >= start_time, "not yet");
        _;
    }

    function setStart(uint256 _start_time) external {
        require(msg.sender == owner_address, "unauthorized");
        start_time = _start_time;
    }

    function setPoolWeight(uint256 _weight) external {
        require(msg.sender == owner_address, "unauthorized");
        pool_weight = _weight;
        rewardRate = rewardRate.mul(pool_weight).div(1e6);
    }

    /* ========== VIEWS ========== */

    function totalSupply() external override view returns (uint256) {
        return _staking_token_supply;
    }

    function crBoostMultiplier() public view returns (uint256) {
        uint256 multiplier = uint(1e6).add( (uint(1e6).sub(XUSD.global_collateral_ratio())).mul(cr_boost_max_multiplier.sub(1e6)).div(1e6) );
        return multiplier;
    }

    function stakingDecimals() external view returns (uint256) {
        return stakingToken.decimals();
    }

    function rewardsFor(address account) external view returns (uint256) {
        // You may have use earned() instead, because of the order in which the contract executes 
        return rewards[account];
    }

    function lastTimeRewardApplicable() public override view returns (uint256) {
        return Math.min(block.timestamp, periodFinish);
    }

    function rewardPerToken() public override view returns (uint256) {
        if (_staking_token_supply == 0) {
            return rewardPerTokenStored;
        }
        else {
            return rewardPerTokenStored.add(
                lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(crBoostMultiplier()).mul(1e18).div(1e6).div(_staking_token_supply)
            );
        }
    }

    function earned(address account) public override view returns (uint256) {
        return balanceOf[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]);
    }

    function getRewardForDuration() external override view returns (uint256) {
        return rewardRate.mul(rewardsDuration).mul(crBoostMultiplier()).div(1e6);
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    function stake(uint256 amount) external override nonReentrant notPaused updateReward(msg.sender) checkStart {
        require(amount > 0, "Cannot stake 0");

        _staking_token_supply = _staking_token_supply.add(amount);

        balanceOf[msg.sender] = balanceOf[msg.sender].add(amount);

        TransferHelper.safeTransferFrom(address(stakingToken), msg.sender, address(this), amount);
        emit Staked(msg.sender, amount);
    }

    function withdraw(uint256 amount) public override nonReentrant updateReward(msg.sender) checkStart {
        require(amount > 0, "Cannot withdraw 0");

        _staking_token_supply = _staking_token_supply.sub(amount);

        balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount);

        stakingToken.safeTransfer(msg.sender, amount);
        emit Withdrawn(msg.sender, amount);
    }

    function getReward() public override nonReentrant updateReward(msg.sender) checkStart {
        uint256 reward = rewards[msg.sender];
        uint256 dev_reward = reward.mul(dev_fee).div(1e6);
        if (reward > 0) {
            rewards[msg.sender] = 0;
            rewardsToken.mint_reward(dev_address, dev_reward);
            rewardsToken.mint_reward(msg.sender, reward.sub(dev_reward));
            emit RewardPaid(msg.sender, reward);
        }
    }

    function exit() external {
        withdraw(balanceOf[msg.sender]);
        getReward();
    }

    function renewIfApplicable() external {
        if (block.timestamp > periodFinish) {
            retroCatchUp();
        }
    }

    // If the period expired, renew it
    function retroCatchUp() internal {
        // halve reward
        rewardRate = rewardRate.mul(50).div(100);

        // Ensure the provided reward amount is not more than the balance in the contract.
        // This keeps the reward rate in the right range, preventing overflows due to
        // very high values of rewardRate in the earned and rewardsPerToken functions;
        // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
        uint256 num_periods_elapsed = uint256(block.timestamp.sub(periodFinish)) / rewardsDuration; // Floor division to the nearest period
        
        // lastUpdateTime = periodFinish;
        periodFinish = periodFinish.add((num_periods_elapsed.add(1)).mul(rewardsDuration));

        rewardPerTokenStored = rewardPerToken();
        lastUpdateTime = lastTimeRewardApplicable();

        emit RewardsPeriodRenewed(address(stakingToken));
    }

    /* ========== RESTRICTED FUNCTIONS ========== */

    function setDevInfo(address dev, uint256 fee) external onlyByOwnerOrGovernance {
        dev_address = dev;
        dev_fee = fee;
    }

    // Added to support recovering LP Rewards from other systems to be distributed to holders
    function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance {
        // Cannot recover the staking token or the rewards token
        require(
            tokenAddress != address(stakingToken),
            "Cannot withdraw staking token"
        );
        ERC20(tokenAddress).transfer(owner_address, tokenAmount);
        emit Recovered(tokenAddress, tokenAmount);
    }

    function setRewardsDuration(uint256 _rewardsDuration) external onlyByOwnerOrGovernance {
        require(
            periodFinish == 0 || block.timestamp > periodFinish,
            "Previous rewards period not complete"
        );
        rewardsDuration = _rewardsDuration;
        emit RewardsDurationUpdated(rewardsDuration);
    }

    function setMultipliers(uint256 _cr_boost_max_multiplier) external onlyByOwnerOrGovernance {
        require(_cr_boost_max_multiplier >= 1, "Max CR Boost must >= 1");
        cr_boost_max_multiplier = _cr_boost_max_multiplier;
        
        emit MaxCRBoostMultiplier(cr_boost_max_multiplier);
    }

    function initializeDefault() external onlyByOwnerOrGovernance {
        lastUpdateTime = block.timestamp;
        periodFinish = block.timestamp.add(rewardsDuration);
        emit DefaultInitialization();
    }

    function setRewardRate(uint256 _new_rate) external onlyByOwnerOrGovernance {
        rewardRate = _new_rate;
    }

    /* ========== MODIFIERS ========== */

    modifier updateReward(address account) {
        // Need to retro-adjust some things if the period hasn't been renewed, then start a new one
        if (block.timestamp > periodFinish) {
            retroCatchUp();
        }
        else {
            rewardPerTokenStored = rewardPerToken();
            lastUpdateTime = lastTimeRewardApplicable();
        }
        if (account != address(0)) {
            rewards[account] = earned(account);
            userRewardPerTokenPaid[account] = rewardPerTokenStored;
        }
        _;
    }

    modifier onlyByOwnerOrGovernance() {
        require(msg.sender == owner_address || msg.sender == timelock_address, "Not admin or timelock");
        _;
    }

    /* ========== EVENTS ========== */

    event RewardAdded(uint256 reward);
    event Staked(address indexed user, uint256 amount);
    event StakeLocked(address indexed user, uint256 amount, uint256 secs);
    event Withdrawn(address indexed user, uint256 amount);
    event WithdrawnLocked(address indexed user, uint256 amount, bytes32 kek_id);
    event RewardPaid(address indexed user, uint256 reward);
    event RewardsDurationUpdated(uint256 newDuration);
    event Recovered(address token, uint256 amount);
    event RewardsPeriodRenewed(address token);
    event DefaultInitialization();
    event MaxCRBoostMultiplier(uint256 multiplier);
}

File 18 of 28 : IUniswapV2Factory.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

File 19 of 28 : IUniswapV2Pair.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;












    
}

File 20 of 28 : TransferHelper.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
    function safeApprove(address token, address to, uint value) internal {
        // bytes4(keccak256(bytes('approve(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED');
    }

    function safeTransfer(address token, address to, uint value) internal {
        // bytes4(keccak256(bytes('transfer(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED');
    }

    function safeTransferFrom(address token, address from, address to, uint value) internal {
        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');
    }

    function safeTransferETH(address to, uint value) internal {
        (bool success,) = to.call{value:value}(new bytes(0));
        require(success, 'TransferHelper: ETH_TRANSFER_FAILED');
    }
}

File 21 of 28 : UniswapV2Library.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

import './Interfaces/IUniswapV2Pair.sol';
import './Interfaces/IUniswapV2Factory.sol';

import "../Math/SafeMath.sol";

library UniswapV2Library {
    using SafeMath for uint;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
    }

    // Less efficient than the CREATE2 method below
    function pairFor(address factory, address tokenA, address tokenB) internal view returns (address pair) {
        (address token0, address token1) = sortTokens(tokenA, tokenB);
        pair = IUniswapV2Factory(factory).getPair(token0, token1);
    }

    // calculates the CREATE2 address for a pair without making any external calls
    function pairForCreate2(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
        (address token0, address token1) = sortTokens(tokenA, tokenB);
        pair = address(uint(keccak256(abi.encodePacked(
                hex'ff',
                factory,
                keccak256(abi.encodePacked(token0, token1)),
                hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
            )))); // this matches the CREATE2 in UniswapV2Factory.createPair
    }

    // fetches and sorts the reserves for a pair
    function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
        (address token0,) = sortTokens(tokenA, tokenB);
        (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
    function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
        require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
        require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        amountB = amountA.mul(reserveB) / reserveA;
    }

    // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
        require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint amountInWithFee = amountIn.mul(997);
        uint numerator = amountInWithFee.mul(reserveOut);
        uint denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
        require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint numerator = reserveIn.mul(amountOut).mul(1000);
        uint denominator = reserveOut.sub(amountOut).mul(997);
        amountIn = (numerator / denominator).add(1);
    }

    // performs chained getAmountOut calculations on any number of pairs
    function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[0] = amountIn;
        for (uint i; i < path.length - 1; i++) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
            amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
        }
    }

    // performs chained getAmountIn calculations on any number of pairs
    function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint i = path.length - 1; i > 0; i--) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
            amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
        }
    }
}

File 22 of 28 : UniswapV2OracleLibrary.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

import '../Uniswap/Interfaces/IUniswapV2Pair.sol';
import '../Math/FixedPoint.sol';

// library with helper methods for oracles that are concerned with computing average prices
library UniswapV2OracleLibrary {
    using FixedPoint for *;

    // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]
    function currentBlockTimestamp() internal view returns (uint32) {
        return uint32(block.timestamp % 2 ** 32);
    }

    // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.
    function currentCumulativePrices(
        address pair
    ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) {
        blockTimestamp = currentBlockTimestamp();
        price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast();
        price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast();

        // if time has elapsed since the last update on the pair, mock the accumulated price values
        (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves();
        if (blockTimestampLast != blockTimestamp) {
            // subtraction overflow is desired
            uint32 timeElapsed = blockTimestamp - blockTimestampLast;
            // addition overflow is desired
            // counterfactual
            price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
            // counterfactual
            price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
        }
    }
}

File 23 of 28 : Address.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

/**
 * @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) {
        // This method relies in extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @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].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

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

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 24 of 28 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 25 of 28 : StringHelpers.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;


library StringHelpers {
    function parseAddr(string memory _a) internal pure returns (address _parsedAddress) {
        bytes memory tmp = bytes(_a);
        uint160 iaddr = 0;
        uint160 b1;
        uint160 b2;
        for (uint i = 2; i < 2 + 2 * 20; i += 2) {
            iaddr *= 256;
            b1 = uint160(uint8(tmp[i]));
            b2 = uint160(uint8(tmp[i + 1]));
            if ((b1 >= 97) && (b1 <= 102)) {
                b1 -= 87;
            } else if ((b1 >= 65) && (b1 <= 70)) {
                b1 -= 55;
            } else if ((b1 >= 48) && (b1 <= 57)) {
                b1 -= 48;
            }
            if ((b2 >= 97) && (b2 <= 102)) {
                b2 -= 87;
            } else if ((b2 >= 65) && (b2 <= 70)) {
                b2 -= 55;
            } else if ((b2 >= 48) && (b2 <= 57)) {
                b2 -= 48;
            }
            iaddr += (b1 * 16 + b2);
        }
        return address(iaddr);
    }

    function strCompare(string memory _a, string memory _b) internal pure returns (int _returnCode) {
        bytes memory a = bytes(_a);
        bytes memory b = bytes(_b);
        uint minLength = a.length;
        if (b.length < minLength) {
            minLength = b.length;
        }
        for (uint i = 0; i < minLength; i ++) {
            if (a[i] < b[i]) {
                return -1;
            } else if (a[i] > b[i]) {
                return 1;
            }
        }
        if (a.length < b.length) {
            return -1;
        } else if (a.length > b.length) {
            return 1;
        } else {
            return 0;
        }
    }

    function indexOf(string memory _haystack, string memory _needle) internal pure returns (int _returnCode) {
        bytes memory h = bytes(_haystack);
        bytes memory n = bytes(_needle);
        if (h.length < 1 || n.length < 1 || (n.length > h.length)) {
            return -1;
        } else if (h.length > (2 ** 128 - 1)) {
            return -1;
        } else {
            uint subindex = 0;
            for (uint i = 0; i < h.length; i++) {
                if (h[i] == n[0]) {
                    subindex = 1;
                    while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex]) {
                        subindex++;
                    }
                    if (subindex == n.length) {
                        return int(i);
                    }
                }
            }
            return -1;
        }
    }

    function strConcat(string memory _a, string memory _b) internal pure returns (string memory _concatenatedString) {
        return strConcat(_a, _b, "", "", "");
    }

    function strConcat(string memory _a, string memory _b, string memory _c) internal pure returns (string memory _concatenatedString) {
        return strConcat(_a, _b, _c, "", "");
    }

    function strConcat(string memory _a, string memory _b, string memory _c, string memory _d) internal pure returns (string memory _concatenatedString) {
        return strConcat(_a, _b, _c, _d, "");
    }

    function strConcat(string memory _a, string memory _b, string memory _c, string memory _d, string memory _e) internal pure returns (string memory _concatenatedString) {
        bytes memory _ba = bytes(_a);
        bytes memory _bb = bytes(_b);
        bytes memory _bc = bytes(_c);
        bytes memory _bd = bytes(_d);
        bytes memory _be = bytes(_e);
        string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length);
        bytes memory babcde = bytes(abcde);
        uint k = 0;
        uint i = 0;
        for (i = 0; i < _ba.length; i++) {
            babcde[k++] = _ba[i];
        }
        for (i = 0; i < _bb.length; i++) {
            babcde[k++] = _bb[i];
        }
        for (i = 0; i < _bc.length; i++) {
            babcde[k++] = _bc[i];
        }
        for (i = 0; i < _bd.length; i++) {
            babcde[k++] = _bd[i];
        }
        for (i = 0; i < _be.length; i++) {
            babcde[k++] = _be[i];
        }
        return string(babcde);
    }

    function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) {
        return safeParseInt(_a, 0);
    }

    function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) {
        bytes memory bresult = bytes(_a);
        uint mint = 0;
        bool decimals = false;
        for (uint i = 0; i < bresult.length; i++) {
            if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) {
                if (decimals) {
                   if (_b == 0) break;
                    else _b--;
                }
                mint *= 10;
                mint += uint(uint8(bresult[i])) - 48;
            } else if (uint(uint8(bresult[i])) == 46) {
                require(!decimals, 'More than one decimal encountered in string!');
                decimals = true;
            } else {
                revert("Non-numeral character encountered in string!");
            }
        }
        if (_b > 0) {
            mint *= 10 ** _b;
        }
        return mint;
    }

    function parseInt(string memory _a) internal pure returns (uint _parsedInt) {
        return parseInt(_a, 0);
    }

    function parseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) {
        bytes memory bresult = bytes(_a);
        uint mint = 0;
        bool decimals = false;
        for (uint i = 0; i < bresult.length; i++) {
            if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) {
                if (decimals) {
                   if (_b == 0) {
                       break;
                   } else {
                       _b--;
                   }
                }
                mint *= 10;
                mint += uint(uint8(bresult[i])) - 48;
            } else if (uint(uint8(bresult[i])) == 46) {
                decimals = true;
            }
        }
        if (_b > 0) {
            mint *= 10 ** _b;
        }
        return mint;
    }

    function uint2str(uint _i) internal pure returns (string memory _uintAsString) {
        if (_i == 0) {
            return "0";
        }
        uint j = _i;
        uint len;
        while (j != 0) {
            len++;
            j /= 10;
        }
        bytes memory bstr = new bytes(len);
        uint k = len - 1;
        while (_i != 0) {
            bstr[k--] = byte(uint8(48 + _i % 10));
            _i /= 10;
        }
        return string(bstr);
    }
}

File 26 of 28 : XUS.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;

import "../Common/Context.sol";
import "../ERC20/ERC20Custom.sol";
import "../ERC20/IERC20.sol";
import "../XUSD/XUSD.sol";
import "../Math/SafeMath.sol";

contract XUSDShares is ERC20Custom {
    using SafeMath for uint256;

    /* ========== STATE VARIABLES ========== */

    string public symbol;
    string public name;
    uint8 public constant decimals = 18;
    
    uint256 public constant genesis_supply = 500e18; // 500 is printed to bootstrap uniswap pool

    address public owner_address;
    address public oracle_address;
    address public timelock_address; // Governance timelock address
    XUSDStablecoin private XUSD;


    // LP staking reward pools
    mapping (address => bool) public rewardPools;
    // LP staking pool max reward
    mapping (address => uint256) public rewardCapOf;
    mapping (address => uint256) public rewardedAmountOf;

    /* ========== MODIFIERS ========== */

    modifier onlyPools() {
       require(XUSD.xusd_pools(msg.sender) == true, "Only xusd pools can mint new XUS");
        _;
    }

    modifier onlyRewardPools() {
        require(rewardPools[msg.sender] == true, "Only staking reward pools can mint new XUS");
        _;
    }
    
    modifier onlyByOwnerOrGovernance() {
        require(msg.sender == owner_address || msg.sender == timelock_address, "You are not an owner or the governance timelock");
        _;
    }

    /* ========== CONSTRUCTOR ========== */

    constructor(
        string memory _name,
        string memory _symbol, 
        address _oracle_address,
        address _timelock_address
    ) public {
        name = _name;
        symbol = _symbol;
        owner_address = msg.sender;
        oracle_address = _oracle_address;
        timelock_address = _timelock_address;
        _mint(owner_address, genesis_supply);
    }

    /* ========== RESTRICTED FUNCTIONS ========== */

    function setOracle(address new_oracle) external onlyByOwnerOrGovernance {
        oracle_address = new_oracle;
    }

    function setTimelock(address new_timelock) external onlyByOwnerOrGovernance {
        timelock_address = new_timelock;
    }
    
    function setXUSDAddress(address xusd_contract_address) external onlyByOwnerOrGovernance {
        XUSD = XUSDStablecoin(xusd_contract_address);
    }

    function setOwner(address _owner_address) external onlyByOwnerOrGovernance {
        owner_address = _owner_address;
    }

    function addRewardPool(address pool_address, uint256 reward_cap) external onlyByOwnerOrGovernance {
        require(rewardPools[pool_address] == false, "address already exists");
        rewardPools[pool_address] = true;
        rewardCapOf[pool_address] = reward_cap;
        rewardedAmountOf[pool_address] = 0;
    }

    function setRewardCap(address pool_address, uint256 reward_cap) external onlyByOwnerOrGovernance {
        require(rewardPools[pool_address] == true, "address not exist");
        rewardCapOf[pool_address] = reward_cap;
    }

    function removeRewardPool(address pool_address) external onlyByOwnerOrGovernance {
        require(rewardPools[pool_address] == true, "address not exist");
        rewardPools[pool_address] = false;
        rewardCapOf[pool_address] = 0;
    }

    function mint_reward(address to, uint256 amount) public onlyRewardPools {
        require(rewardedAmountOf[msg.sender].add(amount) < rewardCapOf[msg.sender]);
        rewardedAmountOf[msg.sender] = rewardedAmountOf[msg.sender].add(amount);
        _mint(to, amount);
    }

    function mint(address to, uint256 amount) public onlyPools {
        _mint(to, amount);
    }
    
    // This function is what other xusd pools will call to mint new XUS (similar to the XUSD mint) 
    function pool_mint(address m_address, uint256 m_amount) external onlyPools {        
        super._mint(m_address, m_amount);
        emit XUSMinted(address(this), m_address, m_amount);
    }

    // This function is what other xusd pools will call to burn XUS 
    function pool_burn_from(address b_address, uint256 b_amount) external onlyPools {
        super._burnFrom(b_address, b_amount);
        emit XUSBurned(b_address, address(this), b_amount);
    }

    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));

        return true;
    }

    function getChainId() internal pure returns (uint) {
        uint256 chainId;
        assembly { chainId := chainid() }
        return chainId;
    }

    // Track XUS burned
    event XUSBurned(address indexed from, address indexed to, uint256 amount);

    // Track XUS minted
    event XUSMinted(address indexed from, address indexed to, uint256 amount);

}

File 27 of 28 : IXUSDPool.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;

interface IXUSDPool {
    function collatDollarBalance() external view returns (uint256);
    function availableExcessCollatDV() external view returns (uint256);
    function getCollateralPrice() external view returns (uint256);
}

File 28 of 28 : XUSD.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;

import "../Common/Context.sol";
import "../ERC20/IERC20.sol";
import "../ERC20/ERC20Custom.sol";
import "../ERC20/ERC20.sol";
import "../Math/SafeMath.sol";
import "./Pools/IXUSDPool.sol";
import "../Oracle/UniswapPairOracle.sol";
import "../Oracle/ChainlinkETHUSDPriceConsumer.sol";

contract XUSDStablecoin is ERC20Custom {
    using SafeMath for uint256;

    /* ========== STATE VARIABLES ========== */
    enum PriceChoice { XUSD, XUS }
    ChainlinkETHUSDPriceConsumer private eth_usd_pricer;
    uint8 private eth_usd_pricer_decimals;
    UniswapPairOracle private xusdEthOracle;
    UniswapPairOracle private xusEthOracle;
    string public symbol;
    string public name;
    uint8 public constant decimals = 18;
    address public owner_address;
    address public timelock_address; // Governance timelock address
    address public controller_address; // Controller contract to dynamically adjust system parameters automatically
    address public xus_address;
    address public xusd_eth_oracle_address;
    address public xus_eth_oracle_address;
    address public weth_address;
    address public eth_usd_consumer_address;

    // mint 500 at genesis to bootstrap liquidity
    uint256 public constant genesis_supply = 500e18;

    // The addresses in this array are added by the oracle and these contracts are able to mint xusd
    address[] public xusd_pools_array;

    // Mapping is also used for faster verification
    mapping(address => bool) public xusd_pools; 

    // Constants for various precisions
    uint256 private constant PRICE_PRECISION = 1e6;
    
    uint256 public global_collateral_ratio; // 6 decimals of precision, e.g. 924102 = 0.924102
    uint256 public redemption_fee = 3000; // 6 decimals of precision, divide by 1000000 in calculations for fee
    uint256 public minting_fee = 7000; // 6 decimals of precision, divide by 1000000 in calculations for fee
    uint256 public xusd_step; // Amount to change the collateralization ratio by upon refreshCollateralRatio()
    uint256 public refresh_cooldown; // Seconds to wait before being able to run refreshCollateralRatio() again
    uint256 public price_target; // The price of XUSD at which the collateral ratio will respond to; this value is only used for the collateral ratio mechanism and not for minting and redeeming which are hardcoded at $1
    uint256 public price_band; // The bound above and below the price target at which the refreshCollateralRatio() will not change the collateral ratio

    bool public collateral_ratio_paused = false;

    /* ========== MODIFIERS ========== */

    modifier onlyPools() {
       require(xusd_pools[msg.sender] == true, "Only xusd pools can call this function");
        _;
    } 
    
    modifier onlyByOwnerOrGovernance() {
        require(msg.sender == owner_address || msg.sender == timelock_address || msg.sender == controller_address, "You are not the owner, controller, or the governance timelock");
        _;
    }

    modifier onlyByOwnerGovernanceOrPool() {
        require(
            msg.sender == owner_address 
            || msg.sender == timelock_address 
            || xusd_pools[msg.sender] == true, 
            "You are not the owner, the governance timelock, or a pool");
        _;
    }

    /* ========== CONSTRUCTOR ========== */

    constructor(
        string memory _name,
        string memory _symbol,
        address _timelock_address
    ) public {
        name = _name;
        symbol = _symbol;
        timelock_address = _timelock_address;
        owner_address = msg.sender;
        _mint(owner_address, genesis_supply);
        xusd_step = 2500; // 6 decimals of precision, equal to 0.25%
        global_collateral_ratio = 1000000; // XUSD system starts off fully collateralized (6 decimals of precision)
        refresh_cooldown = 3600; // Refresh cooldown period is set to 1 hour (3600 seconds) at genesis
        price_target = 1000000; // Collateral ratio will adjust according to the $1 price target at genesis
        price_band = 5000; // Collateral ratio will not adjust if between $0.995 and $1.005 at genesis
    }

    // FOR TEST ONLY! REMOVE WHEN MAINNET!!!
    // function setCR(uint256 _cr) external onlyByOwnerOrGovernance {
    //     global_collateral_ratio = _cr;
    // }

    /* ========== VIEWS ========== */

    // Choice = 'XUSD' or 'XUS' for now
    function oracle_price(PriceChoice choice) internal view returns (uint256) {
        // Get the ETH / USD price first, and cut it down to 1e6 precision
        uint256 eth_usd_price = uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals);
        uint256 price_vs_eth;

        if (choice == PriceChoice.XUSD) {
            price_vs_eth = uint256(xusdEthOracle.consult(weth_address, PRICE_PRECISION)); // How much XUSD if you put in PRICE_PRECISION WETH
        }
        else if (choice == PriceChoice.XUS) {
            price_vs_eth = uint256(xusEthOracle.consult(weth_address, PRICE_PRECISION)); // How much XUS if you put in PRICE_PRECISION WETH
        }
        else revert("INVALID PRICE CHOICE. Needs to be either 0 (XUSD) or 1 (XUS)");

        // Will be in 1e6 format
        return eth_usd_price.mul(PRICE_PRECISION).div(price_vs_eth);
    }

    // Returns X XUSD = 1 USD
    function xusd_price() public view returns (uint256) {
        return oracle_price(PriceChoice.XUSD);
    }

    // Returns X XUS = 1 USD
    function xus_price()  public view returns (uint256) {
        return oracle_price(PriceChoice.XUS);
    }

    function eth_usd_price() public view returns (uint256) {
        return uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals);
    }

    // This is needed to avoid costly repeat calls to different getter functions
    // It is cheaper gas-wise to just dump everything and only use some of the info
    function xusd_info() public view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
        return (
            oracle_price(PriceChoice.XUSD), // xusd_price()
            oracle_price(PriceChoice.XUS), // xus_price()
            totalSupply(), // totalSupply()
            global_collateral_ratio, // global_collateral_ratio()
            globalCollateralValue(), // globalCollateralValue
            minting_fee, // minting_fee()
            redemption_fee, // redemption_fee()
            uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals) //eth_usd_price
        );
    }

    // Iterate through all xusd pools and calculate all value of collateral in all pools globally 
    function globalCollateralValue() public view returns (uint256) {
        uint256 total_collateral_value_d18 = 0; 

        for (uint i = 0; i < xusd_pools_array.length; i++){ 
            // Exclude null addresses
            if (xusd_pools_array[i] != address(0)){
                total_collateral_value_d18 = total_collateral_value_d18.add(IXUSDPool(xusd_pools_array[i]).collatDollarBalance());
            }

        }
        return total_collateral_value_d18;
    }

    /* ========== PUBLIC FUNCTIONS ========== */
    
    // There needs to be a time interval that this can be called. Otherwise it can be called multiple times per expansion.
    uint256 public last_call_time; // Last time the refreshCollateralRatio function was called
    function refreshCollateralRatio() public {
        require(collateral_ratio_paused == false, "Collateral Ratio has been paused");
        uint256 xusd_price_cur = xusd_price();
        require(block.timestamp - last_call_time >= refresh_cooldown, "Must wait for the refresh cooldown since last refresh");

        // Step increments are 0.25% (upon genesis, changable by setXUSDStep()) 
        
        if (xusd_price_cur > price_target.add(price_band)) { //decrease collateral ratio
            if(global_collateral_ratio <= xusd_step){ //if within a step of 0, go to 0
                global_collateral_ratio = 0;
            } else {
                global_collateral_ratio = global_collateral_ratio.sub(xusd_step);
            }
        } else if (xusd_price_cur < price_target.sub(price_band)) { //increase collateral ratio
            if(global_collateral_ratio.add(xusd_step) >= 1000000){
                global_collateral_ratio = 1000000; // cap collateral ratio at 1.000000
            } else {
                global_collateral_ratio = global_collateral_ratio.add(xusd_step);
            }
        }

        last_call_time = block.timestamp; // Set the time of the last expansion
    }

    /* ========== RESTRICTED FUNCTIONS ========== */

    // Used by pools when user redeems
    function pool_burn_from(address b_address, uint256 b_amount) public onlyPools {
        super._burnFrom(b_address, b_amount);
        emit XUSDBurned(b_address, msg.sender, b_amount);
    }

    // This function is what other xusd pools will call to mint new XUSD 
    function pool_mint(address m_address, uint256 m_amount) public onlyPools {
        super._mint(m_address, m_amount);
        emit XUSDMinted(msg.sender, m_address, m_amount);
    }

    // Adds collateral addresses supported, such as tether and busd, must be ERC20 
    function addPool(address pool_address) public onlyByOwnerOrGovernance {
        require(xusd_pools[pool_address] == false, "address already exists");
        xusd_pools[pool_address] = true; 
        xusd_pools_array.push(pool_address);
    }

    // Remove a pool 
    function removePool(address pool_address) public onlyByOwnerOrGovernance {
        require(xusd_pools[pool_address] == true, "address doesn't exist already");
        
        // Delete from the mapping
        delete xusd_pools[pool_address];

        // 'Delete' from the array by setting the address to 0x0
        for (uint i = 0; i < xusd_pools_array.length; i++){ 
            if (xusd_pools_array[i] == pool_address) {
                xusd_pools_array[i] = address(0); // This will leave a null in the array and keep the indices the same
                break;
            }
        }
    }

    function setOwner(address _owner_address) external onlyByOwnerOrGovernance {
        owner_address = _owner_address;
    }

    function setRedemptionFee(uint256 red_fee) public onlyByOwnerOrGovernance {
        redemption_fee = red_fee;
    }

    function setMintingFee(uint256 min_fee) public onlyByOwnerOrGovernance {
        minting_fee = min_fee;
    }  

    function setXUSDStep(uint256 _new_step) public onlyByOwnerOrGovernance {
        xusd_step = _new_step;
    }  

    function setPriceTarget (uint256 _new_price_target) public onlyByOwnerOrGovernance {
        price_target = _new_price_target;
    }

    function setRefreshCooldown(uint256 _new_cooldown) public onlyByOwnerOrGovernance {
    	refresh_cooldown = _new_cooldown;
    }

    function setXUSAddress(address _xus_address) public onlyByOwnerOrGovernance {
        xus_address = _xus_address;
    }

    function setETHUSDOracle(address _eth_usd_consumer_address) public onlyByOwnerOrGovernance {
        eth_usd_consumer_address = _eth_usd_consumer_address;
        eth_usd_pricer = ChainlinkETHUSDPriceConsumer(eth_usd_consumer_address);
        eth_usd_pricer_decimals = eth_usd_pricer.getDecimals();
    }

    function setTimelock(address new_timelock) external onlyByOwnerOrGovernance {
        timelock_address = new_timelock;
    }

    function setController(address _controller_address) external onlyByOwnerOrGovernance {
        controller_address = _controller_address;
    }

    function setPriceBand(uint256 _price_band) external onlyByOwnerOrGovernance {
        price_band = _price_band;
    }

    // Sets the XUSD_ETH Uniswap oracle address 
    function setXUSDEthOracle(address _xusd_oracle_addr, address _weth_address) public onlyByOwnerOrGovernance {
        xusd_eth_oracle_address = _xusd_oracle_addr;
        xusdEthOracle = UniswapPairOracle(_xusd_oracle_addr); 
        weth_address = _weth_address;
    }

    // Sets the XUS_ETH Uniswap oracle address 
    function setXUSEthOracle(address _xus_oracle_addr, address _weth_address) public onlyByOwnerOrGovernance {
        xus_eth_oracle_address = _xus_oracle_addr;
        xusEthOracle = UniswapPairOracle(_xus_oracle_addr);
        weth_address = _weth_address;
    }

    function toggleCollateralRatio() public onlyByOwnerOrGovernance {
        collateral_ratio_paused = !collateral_ratio_paused;
    }

    /* ========== EVENTS ========== */

    // Track XUSD burned
    event XUSDBurned(address indexed from, address indexed to, uint256 amount);

    // Track XUSD minted
    event XUSDMinted(address indexed from, address indexed to, uint256 amount);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_dev","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"address","name":"_rewardsToken","type":"address"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_xusd_address","type":"address"},{"internalType":"address","name":"_timelock_address","type":"address"},{"internalType":"uint256","name":"_pool_weight","type":"uint256"},{"internalType":"uint256","name":"_start_time","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[],"name":"DefaultInitialization","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"multiplier","type":"uint256"}],"name":"MaxCRBoostMultiplier","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDuration","type":"uint256"}],"name":"RewardsDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"RewardsPeriodRenewed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"secs","type":"uint256"}],"name":"StakeLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"kek_id","type":"bytes32"}],"name":"WithdrawnLocked","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"crBoostMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cr_boost_max_multiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardForDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initializeDefault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner_address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool_weight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renewIfApplicable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"rewardsFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsToken","outputs":[{"internalType":"contract XUSDShares","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"dev","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"setDevInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cr_boost_max_multiplier","type":"uint256"}],"name":"setMultipliers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_weight","type":"uint256"}],"name":"setPoolWeight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_new_rate","type":"uint256"}],"name":"setRewardRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardsDuration","type":"uint256"}],"name":"setRewardsDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_start_time","type":"uint256"}],"name":"setStart","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"start_time","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timelock_address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405262278d006009556000600b55622dc6c0600f5560006012553480156200002957600080fd5b506040516200436f3803806200436f83398181016040528101906200004f919062000548565b8787878787878787336001600081905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415620000d3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620000ca90620007ef565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c600082604051620001489291906200075a565b60405180910390a150600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415620001e6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620001dd90620007cd565b60405180910390fd5b33600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555087601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508660158190555085600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600460016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555042600a8190555082600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600c81905550670ab54a9a6c9dc0ca600881905550620003ca620f4240620003b6600c54600854620003ed60201b620026021790919060201c565b6200046360201b620026721790919060201c565b600881905550806016819055505050505050505050505050505050505062000922565b6000808314156200040257600090506200045d565b60008284029050828482816200041457fe5b041462000458576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200044f90620007ab565b60405180910390fd5b809150505b92915050565b6000620004ad83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250620004b560201b60201c565b905092915050565b60008083118290620004ff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620004f6919062000787565b60405180910390fd5b5060008385816200050c57fe5b049050809150509392505050565b6000815190506200052b81620008ee565b92915050565b600081519050620005428162000908565b92915050565b600080600080600080600080610100898b0312156200056657600080fd5b6000620005768b828c016200051a565b9850506020620005898b828c0162000531565b97505060406200059c8b828c016200051a565b9650506060620005af8b828c016200051a565b9550506080620005c28b828c016200051a565b94505060a0620005d58b828c016200051a565b93505060c0620005e88b828c0162000531565b92505060e0620005fb8b828c0162000531565b9150509295985092959890939650565b62000616816200086b565b82525050565b62000627816200082d565b82525050565b60006200063a8262000811565b6200064681856200081c565b935062000658818560208601620008a7565b6200066381620008dd565b840191505092915050565b60006200067d6021836200081c565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000620006e56011836200081c565b91507f4f776e6572206d757374206265207365740000000000000000000000000000006000830152602082019050919050565b6000620007276019836200081c565b91507f4f776e657220616464726573732063616e6e6f742062652030000000000000006000830152602082019050919050565b60006040820190506200077160008301856200060b565b6200078060208301846200061c565b9392505050565b60006020820190508181036000830152620007a381846200062d565b905092915050565b60006020820190508181036000830152620007c6816200066e565b9050919050565b60006020820190508181036000830152620007e881620006d6565b9050919050565b600060208201905081810360008301526200080a8162000718565b9050919050565b600081519050919050565b600082825260208201905092915050565b60006200083a8262000841565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600062000878826200087f565b9050919050565b60006200088c8262000893565b9050919050565b6000620008a08262000841565b9050919050565b60005b83811015620008c7578082015181840152602081019050620008aa565b83811115620008d7576000848401525b50505050565b6000601f19601f8301169050919050565b620008f9816200082d565b81146200090557600080fd5b50565b620009138162000861565b81146200091f57600080fd5b50565b613a3d80620009326000396000f3fe608060405234801561001057600080fd5b50600436106102685760003560e01c80638980f11f11610151578063cc1a378f116100c3578063df136d6511610087578063df136d65146106cf578063e53c4cab146106ed578063e9fad8ee14610709578063ebe2b12b14610713578063f6a03ebf14610731578063fee2eae61461074d57610268565b8063cc1a378f1461063b578063cd3daf9d14610657578063ce08bf1314610675578063d1af0c7d14610693578063dc6663c7146106b157610268565b80639e447fc6116101155780639e447fc61461057b578063a694fc3a14610597578063b51f7902146105b3578063b5682318146105e3578063c11f5344146105ff578063c8f33c911461061d57610268565b80638980f11f146104d55780638b876347146104f15780638da5cb5b1461052157806391b4ded91461053f57806393b52be81461055d57610268565b80633d18b912116101ea57806372f702f3116101ae57806372f702f31461043557806379ba5097146104535780637b0a47ee1461045d57806380edef8e1461047b57806380faa57d14610499578063834ee417146104b757610268565b80633d18b912146103a357806347b9bc22146103ad57806353a47bb7146103c95780635c975abb146103e757806370a082311461040557610268565b806318160ddd1161023157806318160ddd1461030f5780631c1f78eb1461032d5780632e1a7d4d1461034b578063306792ea14610367578063386a95251461038557610268565b80628cc2621461026d5780630700037d1461029d5780631627540c146102cd578063169d27ef146102e957806316c38b3c146102f3575b600080fd5b61028760048036038101906102829190612d90565b610757565b6040516102949190613847565b60405180910390f35b6102b760048036038101906102b29190612d90565b610875565b6040516102c49190613847565b60405180910390f35b6102e760048036038101906102e29190612d90565b61088d565b005b6102f1610998565b005b61030d60048036038101906103089190612df5565b610ad0565b005b610317610c01565b6040516103249190613847565b60405180910390f35b610335610c0b565b6040516103429190613847565b60405180910390f35b61036560048036038101906103609190612e47565b610c57565b005b61036f610f80565b60405161037c9190613847565b60405180910390f35b61038d610f86565b60405161039a9190613847565b60405180910390f35b6103ab610f8c565b005b6103c760048036038101906103c29190612e47565b611389565b005b6103d16114f8565b6040516103de91906134e7565b60405180910390f35b6103ef61151e565b6040516103fc91906135b4565b60405180910390f35b61041f600480360381019061041a9190612d90565b611531565b60405161042c9190613847565b60405180910390f35b61043d611549565b60405161044a91906135cf565b60405180910390f35b61045b61156f565b005b610465611723565b6040516104729190613847565b60405180910390f35b610483611729565b60405161049091906134e7565b60405180910390f35b6104a161174f565b6040516104ae9190613847565b60405180910390f35b6104bf611762565b6040516104cc9190613847565b60405180910390f35b6104ef60048036038101906104ea9190612db9565b611768565b005b61050b60048036038101906105069190612d90565b6119ce565b6040516105189190613847565b60405180910390f35b6105296119e6565b60405161053691906134e7565b60405180910390f35b610547611a0c565b6040516105549190613847565b60405180910390f35b610565611a12565b6040516105729190613847565b60405180910390f35b61059560048036038101906105909190612e47565b611b26565b005b6105b160048036038101906105ac9190612e47565b611c18565b005b6105cd60048036038101906105c89190612d90565b611f72565b6040516105da9190613847565b60405180910390f35b6105fd60048036038101906105f89190612db9565b611fbb565b005b6106076120ef565b6040516106149190613847565b60405180910390f35b610625612199565b6040516106329190613847565b60405180910390f35b61065560048036038101906106509190612e47565b61219f565b005b61065f61231b565b60405161066c9190613847565b60405180910390f35b61067d6123d7565b60405161068a9190613847565b60405180910390f35b61069b6123dd565b6040516106a891906135ea565b60405180910390f35b6106b9612403565b6040516106c691906134e7565b60405180910390f35b6106d7612429565b6040516106e49190613847565b60405180910390f35b61070760048036038101906107029190612e47565b61242f565b005b6107116124fb565b005b61071b61254d565b6040516107289190613847565b60405180910390f35b61074b60048036038101906107469190612e47565b612553565b005b6107556125ed565b005b600061086e601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610860670de0b6b3a7640000610852610804601060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546107f661231b565b6126bc90919063ffffffff16565b601360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461260290919063ffffffff16565b61267290919063ffffffff16565b61270690919063ffffffff16565b9050919050565b60116020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461091d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610914906136a7565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce228160405161098d91906134e7565b60405180910390a150565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610a415750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610a80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a77906137c7565b60405180910390fd5b42600a81905550610a9c6009544261270690919063ffffffff16565b6007819055507fb5cfe3ccd03847076864f081609024cbc2eb98c38da4d8b2cebe9479a9a1ef3760405160405180910390a1565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b60576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b57906136a7565b60405180910390fd5b600460009054906101000a900460ff1615158115151415610b8057610bfe565b80600460006101000a81548160ff021916908315150217905550600460009054906101000a900460ff1615610bb757426003819055505b7f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5600460009054906101000a900460ff16604051610bf591906135b4565b60405180910390a15b50565b6000601254905090565b6000610c52620f4240610c44610c1f611a12565b610c3660095460085461260290919063ffffffff16565b61260290919063ffffffff16565b61267290919063ffffffff16565b905090565b60026000541415610c9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9490613827565b60405180910390fd5b600260008190555033600754421115610cbd57610cb861275b565b610cda565b610cc561231b565b600b81905550610cd361174f565b600a819055505b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610da157610d1781610757565b601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b601654421015610de6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ddd90613747565b60405180910390fd5b60008211610e29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e20906136c7565b60405180910390fd5b610e3e826012546126bc90919063ffffffff16565b601281905550610e9682601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546126bc90919063ffffffff16565b601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f263383600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166128689092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d583604051610f6c9190613847565b60405180910390a250600160008190555050565b600c5481565b60095481565b60026000541415610fd2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fc990613827565b60405180910390fd5b600260008190555033600754421115610ff257610fed61275b565b61100f565b610ffa61231b565b600b8190555061100861174f565b600a819055505b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146110d65761104c81610757565b601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60165442101561111b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111290613747565b60405180910390fd5b6000601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600061118b620f424061117d6015548561260290919063ffffffff16565b61267290919063ffffffff16565b9050600082111561137c576000601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166314b3f8d6601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b815260040161125a92919061358b565b600060405180830381600087803b15801561127457600080fd5b505af1158015611288573d6000803e3d6000fd5b50505050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166314b3f8d6336112de84866126bc90919063ffffffff16565b6040518363ffffffff1660e01b81526004016112fb929190613502565b600060405180830381600087803b15801561131557600080fd5b505af1158015611329573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486836040516113739190613847565b60405180910390a25b5050506001600081905550565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806114325750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611471576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611468906137c7565b60405180910390fd5b60018110156114b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114ac90613787565b60405180910390fd5b80600f819055507f687125c69e38f71137de9edade0dac562abc4f76d751bb1330f16c0ffd51fd58600f546040516114ed9190613847565b60405180910390a150565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900460ff1681565b60136020528060005260406000206000915090505481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146115ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f690613627565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660405161167492919061352b565b60405180910390a1600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60085481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061175d426007546128ee565b905090565b60165481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806118115750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611850576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611847906137c7565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d890613767565b60405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b815260040161193e92919061358b565b602060405180830381600087803b15801561195857600080fd5b505af115801561196c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119909190612e1e565b507f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa2882826040516119c292919061358b565b60405180910390a15050565b60106020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60035481565b600080611b1d611b0b620f4240611afd611a3a620f4240600f546126bc90919063ffffffff16565b611aef600460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632eb9771b6040518163ffffffff1660e01b815260040160206040518083038186803b158015611aa557600080fd5b505afa158015611ab9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611add9190612e70565b620f42406126bc90919063ffffffff16565b61260290919063ffffffff16565b61267290919063ffffffff16565b620f424061270690919063ffffffff16565b90508091505090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611bcf5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611c0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c05906137c7565b60405180910390fd5b8060088190555050565b60026000541415611c5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c5590613827565b60405180910390fd5b6002600081905550600460009054906101000a900460ff1615611cb6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cad90613727565b60405180910390fd5b33600754421115611cce57611cc961275b565b611ceb565b611cd661231b565b600b81905550611ce461174f565b600a819055505b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611db257611d2881610757565b601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b601654421015611df7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dee90613747565b60405180910390fd5b60008211611e3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e3190613647565b60405180910390fd5b611e4f8260125461270690919063ffffffff16565b601281905550611ea782601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270690919063ffffffff16565b601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f18600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16333085612907565b3373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d83604051611f5e9190613847565b60405180910390a250600160008190555050565b6000601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806120645750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6120a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161209a906137c7565b60405180910390fd5b81601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806015819055505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561215957600080fd5b505afa15801561216d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121919190612e99565b60ff16905090565b600a5481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806122485750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b612287576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161227e906137c7565b60405180910390fd5b60006007541480612299575060075442115b6122d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122cf90613687565b60405180910390fd5b806009819055507ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d36009546040516123109190613847565b60405180910390a150565b600080601254141561233157600b5490506123d4565b6123d16123c06012546123b2620f42406123a4670de0b6b3a7640000612396612358611a12565b61238860085461237a600a5461236c61174f565b6126bc90919063ffffffff16565b61260290919063ffffffff16565b61260290919063ffffffff16565b61260290919063ffffffff16565b61267290919063ffffffff16565b61267290919063ffffffff16565b600b5461270690919063ffffffff16565b90505b90565b600f5481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b5481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146124bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124b690613707565b60405180910390fd5b80600c819055506124f2620f42406124e4600c5460085461260290919063ffffffff16565b61267290919063ffffffff16565b60088190555050565b612543601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c57565b61254b610f8c565b565b60075481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146125e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125da90613707565b60405180910390fd5b8060168190555050565b600754421115612600576125ff61275b565b5b565b600080831415612615576000905061266c565b600082840290508284828161262657fe5b0414612667576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161265e906136e7565b60405180910390fd5b809150505b92915050565b60006126b483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612a41565b905092915050565b60006126fe83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612aa2565b905092915050565b600080828401905083811015612751576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161274890613667565b60405180910390fd5b8091505092915050565b6127846064612776603260085461260290919063ffffffff16565b61267290919063ffffffff16565b60088190555060006009546127a4600754426126bc90919063ffffffff16565b816127ab57fe5b0490506127ea6127d96009546127cb60018561270690919063ffffffff16565b61260290919063ffffffff16565b60075461270690919063ffffffff16565b6007819055506127f861231b565b600b8190555061280661174f565b600a819055507f6f2b3b3aaf1881d69a5d40565500f93ea73df36e7b6a29bf48b21479a9237fe9600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660405161285d91906134e7565b60405180910390a150565b6128e98363a9059cbb60e01b848460405160240161288792919061358b565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612afd565b505050565b60008183106128fd57816128ff565b825b905092915050565b600060608573ffffffffffffffffffffffffffffffffffffffff166323b872dd86868660405160240161293c93929190613554565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161298a91906134d0565b6000604051808303816000865af19150503d80600081146129c7576040519150601f19603f3d011682016040523d82523d6000602084013e6129cc565b606091505b50915091508180156129fa57506000815114806129f95750808060200190518101906129f89190612e1e565b5b5b612a39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a3090613807565b60405180910390fd5b505050505050565b60008083118290612a88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a7f9190613605565b60405180910390fd5b506000838581612a9457fe5b049050809150509392505050565b6000838311158290612aea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ae19190613605565b60405180910390fd5b5060008385039050809150509392505050565b6060612b5f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16612bc49092919063ffffffff16565b9050600081511115612bbf5780806020019051810190612b7f9190612e1e565b612bbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bb5906137e7565b60405180910390fd5b5b505050565b6060612bd38484600085612bdc565b90509392505050565b6060612be785612cff565b612c26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c1d906137a7565b60405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff168587604051612c5091906134d0565b60006040518083038185875af1925050503d8060008114612c8d576040519150601f19603f3d011682016040523d82523d6000602084013e612c92565b606091505b50915091508115612ca7578092505050612cf7565b600081511115612cba5780518082602001fd5b836040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cee9190613605565b60405180910390fd5b949350505050565b600080823b905060008111915050919050565b600081359050612d21816139ab565b92915050565b600081359050612d36816139c2565b92915050565b600081519050612d4b816139c2565b92915050565b600081359050612d60816139d9565b92915050565b600081519050612d75816139d9565b92915050565b600081519050612d8a816139f0565b92915050565b600060208284031215612da257600080fd5b6000612db084828501612d12565b91505092915050565b60008060408385031215612dcc57600080fd5b6000612dda85828601612d12565b9250506020612deb85828601612d51565b9150509250929050565b600060208284031215612e0757600080fd5b6000612e1584828501612d27565b91505092915050565b600060208284031215612e3057600080fd5b6000612e3e84828501612d3c565b91505092915050565b600060208284031215612e5957600080fd5b6000612e6784828501612d51565b91505092915050565b600060208284031215612e8257600080fd5b6000612e9084828501612d66565b91505092915050565b600060208284031215612eab57600080fd5b6000612eb984828501612d7b565b91505092915050565b612ecb816138e9565b82525050565b612eda81613894565b82525050565b612ee9816138a6565b82525050565b6000612efa82613862565b612f048185613878565b9350612f14818560208601613967565b80840191505092915050565b612f29816138fb565b82525050565b612f388161391f565b82525050565b6000612f498261386d565b612f538185613883565b9350612f63818560208601613967565b612f6c8161399a565b840191505092915050565b6000612f84603583613883565b91507f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560008301527f2063616e20616363657074206f776e65727368697000000000000000000000006020830152604082019050919050565b6000612fea600e83613883565b91507f43616e6e6f74207374616b6520300000000000000000000000000000000000006000830152602082019050919050565b600061302a601b83613883565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b600061306a602483613883565b91507f50726576696f7573207265776172647320706572696f64206e6f7420636f6d7060008301527f6c657465000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006130d0602f83613883565b91507f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660008301527f6f726d207468697320616374696f6e00000000000000000000000000000000006020830152604082019050919050565b6000613136601183613883565b91507f43616e6e6f7420776974686472617720300000000000000000000000000000006000830152602082019050919050565b6000613176602183613883565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006131dc600c83613883565b91507f756e617574686f72697a656400000000000000000000000000000000000000006000830152602082019050919050565b600061321c603c83613883565b91507f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060008301527f7768696c652074686520636f6e747261637420697320706175736564000000006020830152604082019050919050565b6000613282600783613883565b91507f6e6f7420796574000000000000000000000000000000000000000000000000006000830152602082019050919050565b60006132c2601d83613883565b91507f43616e6e6f74207769746864726177207374616b696e6720746f6b656e0000006000830152602082019050919050565b6000613302601683613883565b91507f4d617820435220426f6f7374206d757374203e3d2031000000000000000000006000830152602082019050919050565b6000613342601d83613883565b91507f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006000830152602082019050919050565b6000613382601583613883565b91507f4e6f742061646d696e206f722074696d656c6f636b00000000000000000000006000830152602082019050919050565b60006133c2602a83613883565b91507f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008301527f6f742073756363656564000000000000000000000000000000000000000000006020830152604082019050919050565b6000613428602483613883565b91507f5472616e7366657248656c7065723a205452414e534645525f46524f4d5f464160008301527f494c4544000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061348e601f83613883565b91507f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006000830152602082019050919050565b6134ca816138d2565b82525050565b60006134dc8284612eef565b915081905092915050565b60006020820190506134fc6000830184612ed1565b92915050565b60006040820190506135176000830185612ec2565b61352460208301846134c1565b9392505050565b60006040820190506135406000830185612ed1565b61354d6020830184612ed1565b9392505050565b60006060820190506135696000830186612ed1565b6135766020830185612ed1565b61358360408301846134c1565b949350505050565b60006040820190506135a06000830185612ed1565b6135ad60208301846134c1565b9392505050565b60006020820190506135c96000830184612ee0565b92915050565b60006020820190506135e46000830184612f20565b92915050565b60006020820190506135ff6000830184612f2f565b92915050565b6000602082019050818103600083015261361f8184612f3e565b905092915050565b6000602082019050818103600083015261364081612f77565b9050919050565b6000602082019050818103600083015261366081612fdd565b9050919050565b600060208201905081810360008301526136808161301d565b9050919050565b600060208201905081810360008301526136a08161305d565b9050919050565b600060208201905081810360008301526136c0816130c3565b9050919050565b600060208201905081810360008301526136e081613129565b9050919050565b6000602082019050818103600083015261370081613169565b9050919050565b60006020820190508181036000830152613720816131cf565b9050919050565b600060208201905081810360008301526137408161320f565b9050919050565b6000602082019050818103600083015261376081613275565b9050919050565b60006020820190508181036000830152613780816132b5565b9050919050565b600060208201905081810360008301526137a0816132f5565b9050919050565b600060208201905081810360008301526137c081613335565b9050919050565b600060208201905081810360008301526137e081613375565b9050919050565b60006020820190508181036000830152613800816133b5565b9050919050565b600060208201905081810360008301526138208161341b565b9050919050565b6000602082019050818103600083015261384081613481565b9050919050565b600060208201905061385c60008301846134c1565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061389f826138b2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006138f482613943565b9050919050565b60006139068261390d565b9050919050565b6000613918826138b2565b9050919050565b600061392a82613931565b9050919050565b600061393c826138b2565b9050919050565b600061394e82613955565b9050919050565b6000613960826138b2565b9050919050565b60005b8381101561398557808201518184015260208101905061396a565b83811115613994576000848401525b50505050565b6000601f19601f8301169050919050565b6139b481613894565b81146139bf57600080fd5b50565b6139cb816138a6565b81146139d657600080fd5b50565b6139e2816138d2565b81146139ed57600080fd5b50565b6139f9816138dc565b8114613a0457600080fd5b5056fea2646970667358221220819d43c0da45312bd35aab7a006a48d08f575c558418327127adcf824343cc9e64736f6c634300060b0033000000000000000000000000fb42719060e14888a569d20520fde5116a2b126f0000000000000000000000000000000000000000000000000000000000009c40000000000000000000000000875650dd46b60c592d5a69a6719e4e4187a3ca810000000000000000000000001c9ba9144505aaba12f4b126fda9807150b88f800000000000000000000000001c9ba9144505aaba12f4b126fda9807150b88f8000000000000000000000000075061b5c168477499b3e297ada97a1d22b72a26400000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000005ff3ac00

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102685760003560e01c80638980f11f11610151578063cc1a378f116100c3578063df136d6511610087578063df136d65146106cf578063e53c4cab146106ed578063e9fad8ee14610709578063ebe2b12b14610713578063f6a03ebf14610731578063fee2eae61461074d57610268565b8063cc1a378f1461063b578063cd3daf9d14610657578063ce08bf1314610675578063d1af0c7d14610693578063dc6663c7146106b157610268565b80639e447fc6116101155780639e447fc61461057b578063a694fc3a14610597578063b51f7902146105b3578063b5682318146105e3578063c11f5344146105ff578063c8f33c911461061d57610268565b80638980f11f146104d55780638b876347146104f15780638da5cb5b1461052157806391b4ded91461053f57806393b52be81461055d57610268565b80633d18b912116101ea57806372f702f3116101ae57806372f702f31461043557806379ba5097146104535780637b0a47ee1461045d57806380edef8e1461047b57806380faa57d14610499578063834ee417146104b757610268565b80633d18b912146103a357806347b9bc22146103ad57806353a47bb7146103c95780635c975abb146103e757806370a082311461040557610268565b806318160ddd1161023157806318160ddd1461030f5780631c1f78eb1461032d5780632e1a7d4d1461034b578063306792ea14610367578063386a95251461038557610268565b80628cc2621461026d5780630700037d1461029d5780631627540c146102cd578063169d27ef146102e957806316c38b3c146102f3575b600080fd5b61028760048036038101906102829190612d90565b610757565b6040516102949190613847565b60405180910390f35b6102b760048036038101906102b29190612d90565b610875565b6040516102c49190613847565b60405180910390f35b6102e760048036038101906102e29190612d90565b61088d565b005b6102f1610998565b005b61030d60048036038101906103089190612df5565b610ad0565b005b610317610c01565b6040516103249190613847565b60405180910390f35b610335610c0b565b6040516103429190613847565b60405180910390f35b61036560048036038101906103609190612e47565b610c57565b005b61036f610f80565b60405161037c9190613847565b60405180910390f35b61038d610f86565b60405161039a9190613847565b60405180910390f35b6103ab610f8c565b005b6103c760048036038101906103c29190612e47565b611389565b005b6103d16114f8565b6040516103de91906134e7565b60405180910390f35b6103ef61151e565b6040516103fc91906135b4565b60405180910390f35b61041f600480360381019061041a9190612d90565b611531565b60405161042c9190613847565b60405180910390f35b61043d611549565b60405161044a91906135cf565b60405180910390f35b61045b61156f565b005b610465611723565b6040516104729190613847565b60405180910390f35b610483611729565b60405161049091906134e7565b60405180910390f35b6104a161174f565b6040516104ae9190613847565b60405180910390f35b6104bf611762565b6040516104cc9190613847565b60405180910390f35b6104ef60048036038101906104ea9190612db9565b611768565b005b61050b60048036038101906105069190612d90565b6119ce565b6040516105189190613847565b60405180910390f35b6105296119e6565b60405161053691906134e7565b60405180910390f35b610547611a0c565b6040516105549190613847565b60405180910390f35b610565611a12565b6040516105729190613847565b60405180910390f35b61059560048036038101906105909190612e47565b611b26565b005b6105b160048036038101906105ac9190612e47565b611c18565b005b6105cd60048036038101906105c89190612d90565b611f72565b6040516105da9190613847565b60405180910390f35b6105fd60048036038101906105f89190612db9565b611fbb565b005b6106076120ef565b6040516106149190613847565b60405180910390f35b610625612199565b6040516106329190613847565b60405180910390f35b61065560048036038101906106509190612e47565b61219f565b005b61065f61231b565b60405161066c9190613847565b60405180910390f35b61067d6123d7565b60405161068a9190613847565b60405180910390f35b61069b6123dd565b6040516106a891906135ea565b60405180910390f35b6106b9612403565b6040516106c691906134e7565b60405180910390f35b6106d7612429565b6040516106e49190613847565b60405180910390f35b61070760048036038101906107029190612e47565b61242f565b005b6107116124fb565b005b61071b61254d565b6040516107289190613847565b60405180910390f35b61074b60048036038101906107469190612e47565b612553565b005b6107556125ed565b005b600061086e601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610860670de0b6b3a7640000610852610804601060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546107f661231b565b6126bc90919063ffffffff16565b601360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461260290919063ffffffff16565b61267290919063ffffffff16565b61270690919063ffffffff16565b9050919050565b60116020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461091d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610914906136a7565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce228160405161098d91906134e7565b60405180910390a150565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610a415750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610a80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a77906137c7565b60405180910390fd5b42600a81905550610a9c6009544261270690919063ffffffff16565b6007819055507fb5cfe3ccd03847076864f081609024cbc2eb98c38da4d8b2cebe9479a9a1ef3760405160405180910390a1565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b60576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b57906136a7565b60405180910390fd5b600460009054906101000a900460ff1615158115151415610b8057610bfe565b80600460006101000a81548160ff021916908315150217905550600460009054906101000a900460ff1615610bb757426003819055505b7f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5600460009054906101000a900460ff16604051610bf591906135b4565b60405180910390a15b50565b6000601254905090565b6000610c52620f4240610c44610c1f611a12565b610c3660095460085461260290919063ffffffff16565b61260290919063ffffffff16565b61267290919063ffffffff16565b905090565b60026000541415610c9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9490613827565b60405180910390fd5b600260008190555033600754421115610cbd57610cb861275b565b610cda565b610cc561231b565b600b81905550610cd361174f565b600a819055505b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610da157610d1781610757565b601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b601654421015610de6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ddd90613747565b60405180910390fd5b60008211610e29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e20906136c7565b60405180910390fd5b610e3e826012546126bc90919063ffffffff16565b601281905550610e9682601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546126bc90919063ffffffff16565b601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f263383600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166128689092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d583604051610f6c9190613847565b60405180910390a250600160008190555050565b600c5481565b60095481565b60026000541415610fd2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fc990613827565b60405180910390fd5b600260008190555033600754421115610ff257610fed61275b565b61100f565b610ffa61231b565b600b8190555061100861174f565b600a819055505b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146110d65761104c81610757565b601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60165442101561111b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111290613747565b60405180910390fd5b6000601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600061118b620f424061117d6015548561260290919063ffffffff16565b61267290919063ffffffff16565b9050600082111561137c576000601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166314b3f8d6601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b815260040161125a92919061358b565b600060405180830381600087803b15801561127457600080fd5b505af1158015611288573d6000803e3d6000fd5b50505050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166314b3f8d6336112de84866126bc90919063ffffffff16565b6040518363ffffffff1660e01b81526004016112fb929190613502565b600060405180830381600087803b15801561131557600080fd5b505af1158015611329573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486836040516113739190613847565b60405180910390a25b5050506001600081905550565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806114325750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611471576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611468906137c7565b60405180910390fd5b60018110156114b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114ac90613787565b60405180910390fd5b80600f819055507f687125c69e38f71137de9edade0dac562abc4f76d751bb1330f16c0ffd51fd58600f546040516114ed9190613847565b60405180910390a150565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900460ff1681565b60136020528060005260406000206000915090505481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146115ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f690613627565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660405161167492919061352b565b60405180910390a1600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60085481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061175d426007546128ee565b905090565b60165481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806118115750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611850576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611847906137c7565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d890613767565b60405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b815260040161193e92919061358b565b602060405180830381600087803b15801561195857600080fd5b505af115801561196c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119909190612e1e565b507f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa2882826040516119c292919061358b565b60405180910390a15050565b60106020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60035481565b600080611b1d611b0b620f4240611afd611a3a620f4240600f546126bc90919063ffffffff16565b611aef600460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632eb9771b6040518163ffffffff1660e01b815260040160206040518083038186803b158015611aa557600080fd5b505afa158015611ab9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611add9190612e70565b620f42406126bc90919063ffffffff16565b61260290919063ffffffff16565b61267290919063ffffffff16565b620f424061270690919063ffffffff16565b90508091505090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611bcf5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611c0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c05906137c7565b60405180910390fd5b8060088190555050565b60026000541415611c5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c5590613827565b60405180910390fd5b6002600081905550600460009054906101000a900460ff1615611cb6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cad90613727565b60405180910390fd5b33600754421115611cce57611cc961275b565b611ceb565b611cd661231b565b600b81905550611ce461174f565b600a819055505b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611db257611d2881610757565b601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b601654421015611df7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dee90613747565b60405180910390fd5b60008211611e3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e3190613647565b60405180910390fd5b611e4f8260125461270690919063ffffffff16565b601281905550611ea782601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270690919063ffffffff16565b601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f18600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16333085612907565b3373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d83604051611f5e9190613847565b60405180910390a250600160008190555050565b6000601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806120645750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6120a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161209a906137c7565b60405180910390fd5b81601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806015819055505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561215957600080fd5b505afa15801561216d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121919190612e99565b60ff16905090565b600a5481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806122485750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b612287576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161227e906137c7565b60405180910390fd5b60006007541480612299575060075442115b6122d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122cf90613687565b60405180910390fd5b806009819055507ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d36009546040516123109190613847565b60405180910390a150565b600080601254141561233157600b5490506123d4565b6123d16123c06012546123b2620f42406123a4670de0b6b3a7640000612396612358611a12565b61238860085461237a600a5461236c61174f565b6126bc90919063ffffffff16565b61260290919063ffffffff16565b61260290919063ffffffff16565b61260290919063ffffffff16565b61267290919063ffffffff16565b61267290919063ffffffff16565b600b5461270690919063ffffffff16565b90505b90565b600f5481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b5481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146124bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124b690613707565b60405180910390fd5b80600c819055506124f2620f42406124e4600c5460085461260290919063ffffffff16565b61267290919063ffffffff16565b60088190555050565b612543601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c57565b61254b610f8c565b565b60075481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146125e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125da90613707565b60405180910390fd5b8060168190555050565b600754421115612600576125ff61275b565b5b565b600080831415612615576000905061266c565b600082840290508284828161262657fe5b0414612667576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161265e906136e7565b60405180910390fd5b809150505b92915050565b60006126b483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612a41565b905092915050565b60006126fe83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612aa2565b905092915050565b600080828401905083811015612751576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161274890613667565b60405180910390fd5b8091505092915050565b6127846064612776603260085461260290919063ffffffff16565b61267290919063ffffffff16565b60088190555060006009546127a4600754426126bc90919063ffffffff16565b816127ab57fe5b0490506127ea6127d96009546127cb60018561270690919063ffffffff16565b61260290919063ffffffff16565b60075461270690919063ffffffff16565b6007819055506127f861231b565b600b8190555061280661174f565b600a819055507f6f2b3b3aaf1881d69a5d40565500f93ea73df36e7b6a29bf48b21479a9237fe9600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660405161285d91906134e7565b60405180910390a150565b6128e98363a9059cbb60e01b848460405160240161288792919061358b565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612afd565b505050565b60008183106128fd57816128ff565b825b905092915050565b600060608573ffffffffffffffffffffffffffffffffffffffff166323b872dd86868660405160240161293c93929190613554565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161298a91906134d0565b6000604051808303816000865af19150503d80600081146129c7576040519150601f19603f3d011682016040523d82523d6000602084013e6129cc565b606091505b50915091508180156129fa57506000815114806129f95750808060200190518101906129f89190612e1e565b5b5b612a39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a3090613807565b60405180910390fd5b505050505050565b60008083118290612a88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a7f9190613605565b60405180910390fd5b506000838581612a9457fe5b049050809150509392505050565b6000838311158290612aea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ae19190613605565b60405180910390fd5b5060008385039050809150509392505050565b6060612b5f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16612bc49092919063ffffffff16565b9050600081511115612bbf5780806020019051810190612b7f9190612e1e565b612bbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bb5906137e7565b60405180910390fd5b5b505050565b6060612bd38484600085612bdc565b90509392505050565b6060612be785612cff565b612c26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c1d906137a7565b60405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff168587604051612c5091906134d0565b60006040518083038185875af1925050503d8060008114612c8d576040519150601f19603f3d011682016040523d82523d6000602084013e612c92565b606091505b50915091508115612ca7578092505050612cf7565b600081511115612cba5780518082602001fd5b836040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cee9190613605565b60405180910390fd5b949350505050565b600080823b905060008111915050919050565b600081359050612d21816139ab565b92915050565b600081359050612d36816139c2565b92915050565b600081519050612d4b816139c2565b92915050565b600081359050612d60816139d9565b92915050565b600081519050612d75816139d9565b92915050565b600081519050612d8a816139f0565b92915050565b600060208284031215612da257600080fd5b6000612db084828501612d12565b91505092915050565b60008060408385031215612dcc57600080fd5b6000612dda85828601612d12565b9250506020612deb85828601612d51565b9150509250929050565b600060208284031215612e0757600080fd5b6000612e1584828501612d27565b91505092915050565b600060208284031215612e3057600080fd5b6000612e3e84828501612d3c565b91505092915050565b600060208284031215612e5957600080fd5b6000612e6784828501612d51565b91505092915050565b600060208284031215612e8257600080fd5b6000612e9084828501612d66565b91505092915050565b600060208284031215612eab57600080fd5b6000612eb984828501612d7b565b91505092915050565b612ecb816138e9565b82525050565b612eda81613894565b82525050565b612ee9816138a6565b82525050565b6000612efa82613862565b612f048185613878565b9350612f14818560208601613967565b80840191505092915050565b612f29816138fb565b82525050565b612f388161391f565b82525050565b6000612f498261386d565b612f538185613883565b9350612f63818560208601613967565b612f6c8161399a565b840191505092915050565b6000612f84603583613883565b91507f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560008301527f2063616e20616363657074206f776e65727368697000000000000000000000006020830152604082019050919050565b6000612fea600e83613883565b91507f43616e6e6f74207374616b6520300000000000000000000000000000000000006000830152602082019050919050565b600061302a601b83613883565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b600061306a602483613883565b91507f50726576696f7573207265776172647320706572696f64206e6f7420636f6d7060008301527f6c657465000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006130d0602f83613883565b91507f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660008301527f6f726d207468697320616374696f6e00000000000000000000000000000000006020830152604082019050919050565b6000613136601183613883565b91507f43616e6e6f7420776974686472617720300000000000000000000000000000006000830152602082019050919050565b6000613176602183613883565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006131dc600c83613883565b91507f756e617574686f72697a656400000000000000000000000000000000000000006000830152602082019050919050565b600061321c603c83613883565b91507f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060008301527f7768696c652074686520636f6e747261637420697320706175736564000000006020830152604082019050919050565b6000613282600783613883565b91507f6e6f7420796574000000000000000000000000000000000000000000000000006000830152602082019050919050565b60006132c2601d83613883565b91507f43616e6e6f74207769746864726177207374616b696e6720746f6b656e0000006000830152602082019050919050565b6000613302601683613883565b91507f4d617820435220426f6f7374206d757374203e3d2031000000000000000000006000830152602082019050919050565b6000613342601d83613883565b91507f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006000830152602082019050919050565b6000613382601583613883565b91507f4e6f742061646d696e206f722074696d656c6f636b00000000000000000000006000830152602082019050919050565b60006133c2602a83613883565b91507f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008301527f6f742073756363656564000000000000000000000000000000000000000000006020830152604082019050919050565b6000613428602483613883565b91507f5472616e7366657248656c7065723a205452414e534645525f46524f4d5f464160008301527f494c4544000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061348e601f83613883565b91507f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006000830152602082019050919050565b6134ca816138d2565b82525050565b60006134dc8284612eef565b915081905092915050565b60006020820190506134fc6000830184612ed1565b92915050565b60006040820190506135176000830185612ec2565b61352460208301846134c1565b9392505050565b60006040820190506135406000830185612ed1565b61354d6020830184612ed1565b9392505050565b60006060820190506135696000830186612ed1565b6135766020830185612ed1565b61358360408301846134c1565b949350505050565b60006040820190506135a06000830185612ed1565b6135ad60208301846134c1565b9392505050565b60006020820190506135c96000830184612ee0565b92915050565b60006020820190506135e46000830184612f20565b92915050565b60006020820190506135ff6000830184612f2f565b92915050565b6000602082019050818103600083015261361f8184612f3e565b905092915050565b6000602082019050818103600083015261364081612f77565b9050919050565b6000602082019050818103600083015261366081612fdd565b9050919050565b600060208201905081810360008301526136808161301d565b9050919050565b600060208201905081810360008301526136a08161305d565b9050919050565b600060208201905081810360008301526136c0816130c3565b9050919050565b600060208201905081810360008301526136e081613129565b9050919050565b6000602082019050818103600083015261370081613169565b9050919050565b60006020820190508181036000830152613720816131cf565b9050919050565b600060208201905081810360008301526137408161320f565b9050919050565b6000602082019050818103600083015261376081613275565b9050919050565b60006020820190508181036000830152613780816132b5565b9050919050565b600060208201905081810360008301526137a0816132f5565b9050919050565b600060208201905081810360008301526137c081613335565b9050919050565b600060208201905081810360008301526137e081613375565b9050919050565b60006020820190508181036000830152613800816133b5565b9050919050565b600060208201905081810360008301526138208161341b565b9050919050565b6000602082019050818103600083015261384081613481565b9050919050565b600060208201905061385c60008301846134c1565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061389f826138b2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006138f482613943565b9050919050565b60006139068261390d565b9050919050565b6000613918826138b2565b9050919050565b600061392a82613931565b9050919050565b600061393c826138b2565b9050919050565b600061394e82613955565b9050919050565b6000613960826138b2565b9050919050565b60005b8381101561398557808201518184015260208101905061396a565b83811115613994576000848401525b50505050565b6000601f19601f8301169050919050565b6139b481613894565b81146139bf57600080fd5b50565b6139cb816138a6565b81146139d657600080fd5b50565b6139e2816138d2565b81146139ed57600080fd5b50565b6139f9816138dc565b8114613a0457600080fd5b5056fea2646970667358221220819d43c0da45312bd35aab7a006a48d08f575c558418327127adcf824343cc9e64736f6c634300060b0033

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

000000000000000000000000fb42719060e14888a569d20520fde5116a2b126f0000000000000000000000000000000000000000000000000000000000009c40000000000000000000000000875650dd46b60c592d5a69a6719e4e4187a3ca810000000000000000000000001c9ba9144505aaba12f4b126fda9807150b88f800000000000000000000000001c9ba9144505aaba12f4b126fda9807150b88f8000000000000000000000000075061b5c168477499b3e297ada97a1d22b72a26400000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000005ff3ac00

-----Decoded View---------------
Arg [0] : _dev (address): 0xFb42719060e14888a569d20520FdE5116A2B126f
Arg [1] : _fee (uint256): 40000
Arg [2] : _rewardsToken (address): 0x875650dD46b60c592d5a69a6719e4e4187A3ca81
Arg [3] : _stakingToken (address): 0x1c9BA9144505aaBa12f4b126Fda9807150b88f80
Arg [4] : _xusd_address (address): 0x1c9BA9144505aaBa12f4b126Fda9807150b88f80
Arg [5] : _timelock_address (address): 0x75061b5c168477499b3e297AdA97a1d22b72A264
Arg [6] : _pool_weight (uint256): 100000
Arg [7] : _start_time (uint256): 1609804800

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000fb42719060e14888a569d20520fde5116a2b126f
Arg [1] : 0000000000000000000000000000000000000000000000000000000000009c40
Arg [2] : 000000000000000000000000875650dd46b60c592d5a69a6719e4e4187a3ca81
Arg [3] : 0000000000000000000000001c9ba9144505aaba12f4b126fda9807150b88f80
Arg [4] : 0000000000000000000000001c9ba9144505aaba12f4b126fda9807150b88f80
Arg [5] : 00000000000000000000000075061b5c168477499b3e297ada97a1d22b72a264
Arg [6] : 00000000000000000000000000000000000000000000000000000000000186a0
Arg [7] : 000000000000000000000000000000000000000000000000000000005ff3ac00


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.