ETH Price: $3,050.12 (+2.34%)
Gas: 1 Gwei

Contract

0xf13a49Eb6b2F6918500ee5cf8b39bb15a38F5b32
 
Transaction Hash
Method
Block
From
To
Value
Redeem Fractiona...174450352023-06-09 20:27:47393 days ago1686342467IN
0xf13a49Eb...5a38F5b32
0 ETH0.0096282525.79193681
Collect Redempti...174449952023-06-09 20:19:35393 days ago1686341975IN
0xf13a49Eb...5a38F5b32
0 ETH0.0028979426.37593058
Redeem Fractiona...174449892023-06-09 20:18:23393 days ago1686341903IN
0xf13a49Eb...5a38F5b32
0 ETH0.0069203321.49058298
Redeem Fractiona...174449712023-06-09 20:14:47393 days ago1686341687IN
0xf13a49Eb...5a38F5b32
0 ETH0.0082006218.93594505
Buy Back XUS161006172022-12-03 0:10:47582 days ago1670026247IN
0xf13a49Eb...5a38F5b32
0 ETH0.0022903311
Collect Redempti...158550092022-10-29 16:49:23616 days ago1667062163IN
0xf13a49Eb...5a38F5b32
0 ETH0.0006445921.29971601
Collect Redempti...143426052022-03-07 23:09:13852 days ago1646694553IN
0xf13a49Eb...5a38F5b32
0 ETH0.0010791835.66032791
Buy Back XUS135420232021-11-03 5:18:33976 days ago1635916713IN
0xf13a49Eb...5a38F5b32
0 ETH0.05323351120.59306903
Collect Redempti...135419872021-11-03 5:10:47976 days ago1635916247IN
0xf13a49Eb...5a38F5b32
0 ETH0.01318782142.15458369
Redeem Fractiona...135419712021-11-03 5:08:02976 days ago1635916082IN
0xf13a49Eb...5a38F5b32
0 ETH0.06827419157.86670981
Collect Redempti...132441782021-09-17 15:59:491023 days ago1631894389IN
0xf13a49Eb...5a38F5b32
0 ETH0.0075171999.34050408
Redeem Fractiona...132441342021-09-17 15:51:131023 days ago1631893873IN
0xf13a49Eb...5a38F5b32
0 ETH0.0319812783.9007181
Redeem Fractiona...132441242021-09-17 15:49:391023 days ago1631893779IN
0xf13a49Eb...5a38F5b32
0 ETH0.0372675497.76888658
Redeem Fractiona...132441122021-09-17 15:48:051023 days ago1631893685IN
0xf13a49Eb...5a38F5b32
0 ETH0.05815539140.00527672
Mint Fractional ...129018952021-07-26 12:46:351076 days ago1627303595IN
0xf13a49Eb...5a38F5b32
0 ETH0.0108873627.61
Buy Back XUS123982942021-05-09 5:31:271154 days ago1620538287IN
0xf13a49Eb...5a38F5b32
0 ETH0.04434258104.5
Buy Back XUS123658682021-05-04 5:20:321159 days ago1620105632IN
0xf13a49Eb...5a38F5b32
0 ETH0.0152759136
Buy Back XUS123624152021-05-03 16:52:391160 days ago1620060759IN
0xf13a49Eb...5a38F5b32
0 ETH0.0350072493
Buy Back XUS123588412021-05-03 3:30:351160 days ago1620012635IN
0xf13a49Eb...5a38F5b32
0 ETH0.0106082725
Buy Back XUS123457972021-05-01 3:11:451163 days ago1619838705IN
0xf13a49Eb...5a38F5b32
0 ETH0.0140025233
Buy Back XUS123382362021-04-29 23:02:311164 days ago1619737351IN
0xf13a49Eb...5a38F5b32
0 ETH0.0162148243
Collect Redempti...123079532021-04-25 6:59:271168 days ago1619333967IN
0xf13a49Eb...5a38F5b32
0 ETH0.0019897536
Redeem Fractiona...123079282021-04-25 6:54:421168 days ago1619333682IN
0xf13a49Eb...5a38F5b32
0 ETH0.0149528836
Buy Back XUS122413782021-04-15 0:17:121179 days ago1618445832IN
0xf13a49Eb...5a38F5b32
0 ETH0.05841825110
Buy Back XUS122412762021-04-14 23:51:221179 days ago1618444282IN
0xf13a49Eb...5a38F5b32
0 ETH0.0454617795
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:
Pool_DAI_NEW

Compiler Version
v0.6.11+commit.5ef660b1

Optimization Enabled:
No with 200 runs

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

import "../../Math/SafeMath.sol";
import "../../XUS/XUS.sol";
import "../../XUSD/XUSD.sol";
import "../../ERC20/ERC20.sol";
import "../../Oracle/UniswapPairOracle.sol";
import "./XUSDPoolLibrary.sol";

contract Pool_DAI_NEW {
    using SafeMath for uint256;

    ERC20 private collateral_token;
    address private collateral_address;
    address private owner_address;
    address private xusd_contract_address;
    address private xus_contract_address;
    address private timelock_address; // Timelock address for the governance contract
    XUSDShares private XUS;
    XUSDStablecoin private XUSD;
    UniswapPairOracle private collatEthOracle;
    address private collat_eth_oracle_address;
    address private weth_address;

    mapping (address => uint256) public redeemXUSBalances;
    mapping (address => uint256) public redeemCollateralBalances;
    uint256 public unclaimedPoolCollateral;
    uint256 public unclaimedPoolXUS;
    mapping (address => uint256) public lastRedeemed;

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

    // Number of decimals needed to get to 18
    uint256 private missing_decimals;
    
    // Pool_ceiling is the total units of collateral that a pool contract can hold
    uint256 public pool_ceiling = 0;

    // Stores price of the collateral, if price is paused
    uint256 public pausedPrice = 0;

    // Bonus rate on XUS minted during recollateralizeXUSD(); 6 decimals of precision, set to 0.75% on genesis
    uint256 public bonus_rate = 7500;

    // Number of blocks to wait before being able to collectRedemption()
    uint256 public redemption_delay = 1;
    
    // AccessControl state variables
    bool private mintPaused = false;
    bool private redeemPaused = false;
    bool private recollateralizePaused = false;
    bool private buyBackPaused = false;
    bool private collateralPricePaused = false;

    address feepool_address;

    ChainlinkETHUSDPriceConsumer private dai_usd_pricer;
    uint8 private dai_usd_pricer_decimals;
    address public dai_usd_consumer_address;
    /* ========== MODIFIERS ========== */

    modifier onlyByOwnerOrGovernance() {
        require(msg.sender == timelock_address || msg.sender == owner_address, "unauthorized");
        _;
    }

    modifier notRedeemPaused() {
        require(redeemPaused == false, "redeem paused");
        _;
    }

    modifier notMintPaused() {
        require(mintPaused == false, "mint paused");
        _;
    }
 
    /* ========== CONSTRUCTOR ========== */
    
    constructor(
        address _xusd_contract_address,
        address _xus_contract_address,
        address _collateral_address,
        address _timelock_address,
        uint256 _pool_ceiling
    ) public {
        XUSD = XUSDStablecoin(_xusd_contract_address);
        XUS = XUSDShares(_xus_contract_address);
        xusd_contract_address = _xusd_contract_address;
        xus_contract_address = _xus_contract_address;
        collateral_address = _collateral_address;
        timelock_address = _timelock_address;
        owner_address = msg.sender;
        collateral_token = ERC20(_collateral_address);
        pool_ceiling = _pool_ceiling;
        missing_decimals = uint(18).sub(collateral_token.decimals());
    }

    function setDAIUSDOracle(address _dai_usd_consumer_address) public onlyByOwnerOrGovernance {
        dai_usd_consumer_address = _dai_usd_consumer_address;
        dai_usd_pricer = ChainlinkETHUSDPriceConsumer(dai_usd_consumer_address);
        dai_usd_pricer_decimals = dai_usd_pricer.getDecimals();
    }

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

    // Returns dollar value of collateral held in this XUSD pool
    function collatDollarBalance() public view returns (uint256) {
        // uint256 eth_usd_price = XUSD.eth_usd_price();
        // uint256 eth_collat_price = collatEthOracle.consult(weth_address, (PRICE_PRECISION * (10 ** missing_decimals)));

        // uint256 collat_usd_price = eth_usd_price.mul(PRICE_PRECISION).div(eth_collat_price);
        uint256 collat_usd_price = uint256(dai_usd_pricer.getLatestPrice()).mul(1e6).div(uint256(10) ** dai_usd_pricer_decimals);
        return (collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral)).mul(10 ** missing_decimals).mul(collat_usd_price).div(PRICE_PRECISION); //.mul(getCollateralPrice()).div(1e6);    
    }

    // Returns the value of excess collateral held in this XUSD pool, compared to what is needed to maintain the global collateral ratio
    function availableExcessCollatDV() public view returns (uint256) {
        ( , , uint256 total_supply, uint256 global_collateral_ratio, uint256 global_collat_value, , ,) = XUSD.xusd_info();
        if (global_collateral_ratio > COLLATERAL_RATIO_PRECISION) global_collateral_ratio = COLLATERAL_RATIO_PRECISION; // Handles an overcollateralized contract with CR > 1
        uint256 required_collat_dollar_value_d18 = (total_supply.mul(global_collateral_ratio)).div(COLLATERAL_RATIO_PRECISION); // Calculates collateral needed to back each 1 XUSD with $1 of collateral at current collat ratio
        if (global_collat_value > required_collat_dollar_value_d18) return global_collat_value.sub(required_collat_dollar_value_d18);
        else return 0;
    }

    /* ========== PUBLIC FUNCTIONS ========== */
    
    // Returns the price of the pool collateral in USD
    function getCollateralPrice() public view returns (uint256) {
        if(collateralPricePaused == true) {
            return pausedPrice;
        } else {
            // ( , , , , , , , uint256 eth_usd_price) = XUSD.xusd_info();
            // return eth_usd_price.mul(PRICE_PRECISION).div(collatEthOracle.consult(weth_address, PRICE_PRECISION * (10 ** missing_decimals)));
            return uint256(dai_usd_pricer.getLatestPrice()).mul(1e6).div(uint256(10) ** dai_usd_pricer_decimals); //dai_usd_price
        }
    }

    function setCollatETHOracle(address _collateral_weth_oracle_address, address _weth_address) external onlyByOwnerOrGovernance {
        collat_eth_oracle_address = _collateral_weth_oracle_address;
        collatEthOracle = UniswapPairOracle(_collateral_weth_oracle_address);
        weth_address = _weth_address;
    }

    function setFeePool(address _feepool) external onlyByOwnerOrGovernance {
        feepool_address = _feepool;
    }

    function getMint1t1Out(uint256 collat_amount) public view returns (uint256, uint256) {
        uint256 collateral_amount_d18 = collat_amount * (10 ** missing_decimals);
        ( , , , uint256 global_collateral_ratio, , uint256 minting_fee, ,) = XUSD.xusd_info();
        require(global_collateral_ratio >= COLLATERAL_RATIO_MAX, "CR must >= 1");
        require((collateral_token.balanceOf(address(this))).sub(unclaimedPoolCollateral).add(collat_amount) <= pool_ceiling, "ceiling reached");
        (uint256 xusd_amount_d18, uint256 fee) = XUSDPoolLibrary.calcMint1t1XUSD(
            getCollateralPrice(),
            minting_fee,
            collateral_amount_d18
        );
        return (xusd_amount_d18, fee);
    }

    // We separate out the 1t1, fractional and algorithmic minting functions for gas efficiency 
    function mint1t1XUSD(uint256 collateral_amount, uint256 XUSD_out_min) external notMintPaused {
        (uint256 xusd_amount_d18, uint256 fee) = getMint1t1Out(collateral_amount);

        require(XUSD_out_min <= xusd_amount_d18, "slippage");
        collateral_token.transferFrom(msg.sender, address(this), collateral_amount);
        XUSD.pool_mint(msg.sender, xusd_amount_d18);
        XUSD.pool_mint(feepool_address, fee);
    }

    function getMintAlgoOut(uint256 xus_amount) public view returns (uint256, uint256) {
        ( , uint256 xus_price, , uint256 global_collateral_ratio, , uint256 minting_fee, ,) = XUSD.xusd_info();
        require(global_collateral_ratio == 0, "CR != 0");

        (uint256 xusd_amount_d18, uint256 fee) = XUSDPoolLibrary.calcMintAlgorithmicXUSD(
            minting_fee, 
            xus_price, // X XUS / 1 USD
            xus_amount
        );
        return (xusd_amount_d18, fee);
    }

    // 0% collateral-backed
    function mintAlgorithmicXUSD(uint256 xus_amount_d18, uint256 XUSD_out_min) external notMintPaused {
        (uint256 xusd_amount_d18, uint256 fee) = getMintAlgoOut(xus_amount_d18);

        require(XUSD_out_min <= xusd_amount_d18, "slippage");
        XUS.pool_burn_from(msg.sender, xus_amount_d18);
        XUSD.pool_mint(msg.sender, xusd_amount_d18);
        XUSD.pool_mint(feepool_address, fee);
    }

    function getMintFracOut(uint256 collat_amount) public view returns (uint256, uint256, uint256) {
        (, uint256 xus_price, , uint256 global_collateral_ratio, , uint256 minting_fee, ,) = XUSD.xusd_info();
        require(global_collateral_ratio < COLLATERAL_RATIO_MAX && global_collateral_ratio > 0, "CR not in range");
        require(collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral).add(collat_amount) <= pool_ceiling, "pool ceiling reached");
        
        uint256 collateral_amount_d18 = collat_amount * (10 ** missing_decimals);
        (uint256 mint_amount, uint256 xus_needed, uint256 fee) = XUSDPoolLibrary.calcMintFractionalXUSD(collateral_amount_d18, getCollateralPrice(), xus_price, global_collateral_ratio, minting_fee);
        return (mint_amount, xus_needed, fee);
    }

    // Will fail if fully collateralized or fully algorithmic
    // > 0% and < 100% collateral-backed
    function mintFractionalXUSD(uint256 collateral_amount, uint256 XUSD_out_min) external notMintPaused {
        (uint256 mint_amount, uint256 xus_needed, uint256 fee) = getMintFracOut(collateral_amount);

        require(XUSD_out_min <= mint_amount, "slippage");
        XUS.pool_burn_from(msg.sender, xus_needed);
        collateral_token.transferFrom(msg.sender, address(this), collateral_amount);
        XUSD.pool_mint(msg.sender, mint_amount);
        XUSD.pool_mint(feepool_address, fee);
    }

    function getRedeem1t1Out(uint256 xusd_amount) public view returns (uint256, uint256) {
        (, , , uint256 global_collateral_ratio, , , uint256 redemption_fee,) = XUSD.xusd_info();
        require(global_collateral_ratio == COLLATERAL_RATIO_MAX, "CR != 1");

        // Need to adjust for decimals of collateral
        uint256 XUSD_amount_precision = xusd_amount.div(10 ** missing_decimals);
        (uint256 collateral_needed, uint256 fee) = XUSDPoolLibrary.calcRedeem1t1XUSD(
            getCollateralPrice(),
            XUSD_amount_precision,
            redemption_fee
        );
        return (collateral_needed, fee);
    }

    // Redeem collateral. 100% collateral-backed
    function redeem1t1XUSD(uint256 XUSD_amount, uint256 COLLATERAL_out_min) external notRedeemPaused {
       
        (uint256 collateral_needed, uint256 fee) = getRedeem1t1Out(XUSD_amount);
        require(collateral_needed <= collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral), "Not enough collateral in pool");

        redeemCollateralBalances[msg.sender] = redeemCollateralBalances[msg.sender].add(collateral_needed);
        unclaimedPoolCollateral = unclaimedPoolCollateral.add(collateral_needed);
        lastRedeemed[msg.sender] = block.number;

        require(COLLATERAL_out_min <= collateral_needed, "slippage");
        
        // Move all external functions to the end
        XUSD.pool_burn_from(msg.sender, XUSD_amount);
        XUSD.pool_mint(feepool_address, fee);
    }

    function getRedeemFracOut(uint256 XUSD_amount) public view returns (uint256, uint256, uint256) {
        (, uint256 xus_price, , uint256 global_collateral_ratio, , , uint256 redemption_fee,) = XUSD.xusd_info();
        require(global_collateral_ratio < COLLATERAL_RATIO_MAX && global_collateral_ratio > 0, "CR not in range");
        uint256 col_price_usd = getCollateralPrice();

        uint256 fee = (XUSD_amount.mul(redemption_fee)).div(PRICE_PRECISION);
        uint256 XUSD_amount_post_fee = XUSD_amount.sub(fee);
        uint256 xus_dollar_value_d18 = XUSD_amount_post_fee.sub(XUSD_amount_post_fee.mul(global_collateral_ratio).div(PRICE_PRECISION));
        uint256 xus_amount = xus_dollar_value_d18.mul(PRICE_PRECISION).div(xus_price);

        // Need to adjust for decimals of collateral
        uint256 XUSD_amount_precision = XUSD_amount_post_fee.div(10 ** missing_decimals);
        uint256 collateral_dollar_value = XUSD_amount_precision.mul(global_collateral_ratio).div(PRICE_PRECISION);
        uint256 collateral_amount = collateral_dollar_value.mul(PRICE_PRECISION).div(col_price_usd);

        return (xus_amount, collateral_amount, fee);
    }

    // Will fail if fully collateralized or algorithmic
    // Redeem XUSD for collateral and XUS. > 0% and < 100% collateral-backed
    function redeemFractionalXUSD(uint256 XUSD_amount, uint256 XUS_out_min, uint256 COLLATERAL_out_min) external notRedeemPaused {
        (uint256 xus_amount, uint256 collateral_amount, uint256 fee) = getRedeemFracOut(XUSD_amount);

        redeemCollateralBalances[msg.sender] = redeemCollateralBalances[msg.sender].add(collateral_amount);
        unclaimedPoolCollateral = unclaimedPoolCollateral.add(collateral_amount);

        redeemXUSBalances[msg.sender] = redeemXUSBalances[msg.sender].add(xus_amount);
        unclaimedPoolXUS = unclaimedPoolXUS.add(xus_amount);

        lastRedeemed[msg.sender] = block.number;

        require(collateral_amount <= collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral), "not enough collateral");
        require(COLLATERAL_out_min <= collateral_amount && XUS_out_min <= xus_amount, "slippage");
        
        // Move all external functions to the end
        XUSD.pool_burn_from(msg.sender, XUSD_amount);
        XUS.pool_mint(address(this), xus_amount);
        XUSD.pool_mint(feepool_address, fee);
    }

    function getRedeemAlgoOut(uint256 XUSD_amount) public view returns (uint256, uint256) {
        (, uint256 xus_price, , uint256 global_collateral_ratio, , , uint256 redemption_fee,) = XUSD.xusd_info();
        require(global_collateral_ratio == 0, "CR != 0"); 
        uint256 fee = XUSD_amount.mul(redemption_fee).div(1e6);
        uint256 xus_dollar_value_d18 = XUSD_amount.sub(fee);

        uint256 xus_amount = xus_dollar_value_d18.mul(PRICE_PRECISION).div(xus_price);
        return (xus_amount, fee);
    }

    // Redeem XUSD for XUS. 0% collateral-backed
    function redeemAlgorithmicXUSD(uint256 XUSD_amount, uint256 XUS_out_min) external notRedeemPaused {

        (uint256 xus_amount, uint256 fee) = getRedeemAlgoOut(XUSD_amount);
        
        redeemXUSBalances[msg.sender] = redeemXUSBalances[msg.sender].add(xus_amount);
        unclaimedPoolXUS = unclaimedPoolXUS.add(xus_amount);
        
        lastRedeemed[msg.sender] = block.number;
        
        require(XUS_out_min <= xus_amount, "slippage");
        // Move all external functions to the end
        XUSD.pool_burn_from(msg.sender, XUSD_amount);
        XUS.pool_mint(address(this), xus_amount);
        XUSD.pool_mint(feepool_address, fee);
    }

    // After a redemption happens, transfer the newly minted XUS and owed collateral from this pool
    // contract to the user. Redemption is split into two functions to prevent flash loans from being able
    // to take out XUSD/collateral from the system, use an AMM to trade the new price, and then mint back into the system.
    function collectRedemption() external {
        require((lastRedeemed[msg.sender].add(redemption_delay)) <= block.number, "wait 1 block");
        bool sendXUS = false;
        bool sendCollateral = false;
        uint XUSAmount;
        uint CollateralAmount;

        // Use Checks-Effects-Interactions pattern
        if(redeemXUSBalances[msg.sender] > 0){
            XUSAmount = redeemXUSBalances[msg.sender];
            redeemXUSBalances[msg.sender] = 0;
            unclaimedPoolXUS = unclaimedPoolXUS.sub(XUSAmount);

            sendXUS = true;
        }
        
        if(redeemCollateralBalances[msg.sender] > 0){
            CollateralAmount = redeemCollateralBalances[msg.sender];
            redeemCollateralBalances[msg.sender] = 0;
            unclaimedPoolCollateral = unclaimedPoolCollateral.sub(CollateralAmount);

            sendCollateral = true;
        }

        if(sendXUS == true){
            XUS.transfer(msg.sender, XUSAmount);
        }
        if(sendCollateral == true){
            collateral_token.transfer(msg.sender, CollateralAmount);
        }
    }

    function getRecollatOut(uint256 collateral_amount) public view returns (uint256, uint256) {
        require(recollateralizePaused == false, "recollat paused");
        uint256 collateral_amount_d18 = collateral_amount * (10 ** missing_decimals);
        ( , uint256 xus_price, uint256 xusd_total_supply , uint256 global_collateral_ratio, uint256 global_collat_value, , , ) = XUSD.xusd_info();
        (uint256 collateral_units, uint256 amount_to_recollat) = XUSDPoolLibrary.calcRecollateralizeXUSDInner(
            collateral_amount_d18,
            getCollateralPrice(),
            global_collat_value,
            xusd_total_supply,
            global_collateral_ratio
        ); 

        uint256 xus_paid_back = amount_to_recollat.mul(uint(1e6).add(bonus_rate)).div(xus_price);
        uint256 collateral_units_precision = collateral_units.div(10 ** missing_decimals);
        return (collateral_units_precision, xus_paid_back);
    }

    // When the protocol is recollateralizing, we need to give a discount of XUS to hit the new CR target
    // Thus, if the target collateral ratio is higher than the actual value of collateral, minters get XUS for adding collateral
    // This function simply rewards anyone that sends collateral to a pool with the same amount of XUS + the bonus rate
    // Anyone can call this function to recollateralize the protocol and take the extra XUS value from the bonus rate as an arb opportunity
    function recollateralizeXUSD(uint256 collateral_amount, uint256 XUS_out_min) external { 

        (uint256 collateral_units_precision, uint256 xus_paid_back) = getRecollatOut(collateral_amount);

        require(XUS_out_min <= xus_paid_back, "slippage");
        collateral_token.transferFrom(msg.sender, address(this), collateral_units_precision);
        XUS.pool_mint(msg.sender, xus_paid_back);
    }

    function getBuybackOut(uint256 XUS_amount) public view returns (uint256) {
        require(buyBackPaused == false, "buyback paused");
        (, uint256 xus_price, , , , , ,) = XUSD.xusd_info();

        (uint256 collateral_equivalent_d18) = XUSDPoolLibrary.calcBuyBackXUS(XUS_amount, xus_price, availableExcessCollatDV(), getCollateralPrice());
        return collateral_equivalent_d18.div(10 ** missing_decimals);
    }

    // Function can be called by an XUS holder to have the protocol buy back XUS with excess collateral value from a desired collateral pool
    // This can also happen if the collateral ratio > 1
    function buyBackXUS(uint256 XUS_amount, uint256 COLLATERAL_out_min) external {
        uint256 collateral_precision = getBuybackOut(XUS_amount);

        require(COLLATERAL_out_min <= collateral_precision, "slippage");
        // Give the sender their desired collateral and burn the XUS
        XUS.pool_burn_from(msg.sender, XUS_amount);
        collateral_token.transfer(msg.sender, collateral_precision);
    }

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

    function toggleMinting() external onlyByOwnerOrGovernance {
        mintPaused = !mintPaused;
    }
    
    function toggleRedeeming() external onlyByOwnerOrGovernance {
        redeemPaused = !redeemPaused;
    }

    function toggleRecollateralize() external onlyByOwnerOrGovernance {
        recollateralizePaused = !recollateralizePaused;
    }
    
    function toggleBuyBack() external onlyByOwnerOrGovernance {
        buyBackPaused = !buyBackPaused;
    }

    function toggleCollateralPrice() external onlyByOwnerOrGovernance {
        // If pausing, set paused price; else if unpausing, clear pausedPrice
        if(collateralPricePaused == false){
            pausedPrice = getCollateralPrice();
        } else {
            pausedPrice = 0;
        }
        collateralPricePaused = !collateralPricePaused;
    }

    // Combined into one function due to 24KiB contract memory limit
    function setPoolParameters(uint256 new_ceiling, uint256 new_bonus_rate, uint256 new_redemption_delay) external onlyByOwnerOrGovernance {
        pool_ceiling = new_ceiling;
        bonus_rate = new_bonus_rate;
        redemption_delay = new_redemption_delay;
    }

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

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

File 2 of 20 : 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 20 : 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 20 : 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 20 : 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 20 : 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 7 of 20 : 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 8 of 20 : 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 9 of 20 : 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 10 of 20 : 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 11 of 20 : 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 12 of 20 : 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 13 of 20 : 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 14 of 20 : 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 15 of 20 : 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 16 of 20 : 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 17 of 20 : 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 18 of 20 : 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 19 of 20 : XUSDPoolLibrary.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;

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



library XUSDPoolLibrary {
    using SafeMath for uint256;

    // ================ Functions ================

    function calcMint1t1XUSD(uint256 col_price, uint256 mint_fee, uint256 collateral_amount_d18) public pure returns (uint256, uint256) {
        uint256 col_price_usd = col_price;
        uint256 c_dollar_value_d18 = (collateral_amount_d18.mul(col_price_usd)).div(1e6);
        uint256 fee = (c_dollar_value_d18.mul(mint_fee)).div(1e6);
        uint256 out = c_dollar_value_d18.sub(fee);
        return (out, fee);
    }

    function calcMintAlgorithmicXUSD(uint256 mint_fee, uint256 xus_price_usd, uint256 xus_amount_d18) public pure returns (uint256, uint256) {
        uint256 xus_dollar_value_d18 = xus_amount_d18.mul(xus_price_usd).div(1e6);
        uint256 fee = (xus_dollar_value_d18.mul(mint_fee)).div(1e6);
        uint256 out = xus_dollar_value_d18.sub(fee);
        return (out, fee);
    }
    
    // Must be internal because of the struct
    function calcMintFractionalXUSD(uint256 collat_amount, uint256 collat_price, uint256 xus_price, uint256 col_ratio, uint256 mint_fee) internal pure returns (uint256, uint256, uint256) {
        uint256 c_dollar_value_d18 = collat_amount.mul(collat_price).div(1e6);
        
        uint calculated_xus_dollar_value_d18 = 
                    (c_dollar_value_d18.mul(1e6).div(col_ratio))
                    .sub(c_dollar_value_d18);

        uint calculated_xus_needed = calculated_xus_dollar_value_d18.mul(1e6).div(xus_price);
        uint fee = ((c_dollar_value_d18.add(calculated_xus_dollar_value_d18)).mul(mint_fee)).div(1e6);
        uint out = (c_dollar_value_d18.add(calculated_xus_dollar_value_d18)).sub(fee);
        return (
            out,
            calculated_xus_needed,
            fee
        );
    }

    function calcRedeem1t1XUSD(uint256 col_price_usd, uint256 XUSD_amount, uint256 redemption_fee) public pure returns (uint256, uint256) {
        uint256 fee = XUSD_amount.mul(redemption_fee).div(1e6);
        uint256 left = XUSD_amount.sub(fee);
        uint256 collateral_needed_d18 = left.mul(1e6).div(col_price_usd);
        return (collateral_needed_d18, fee);
    }

    // Must be internal because of the struct
    function calcBuyBackXUS(uint256 XUS_amount, uint256 xus_price, uint256 excess_dv, uint256 col_price) internal pure returns (uint256) {
        // If the total collateral value is higher than the amount required at the current collateral ratio then buy back up to the possible XUS with the desired collateral
        require(excess_dv > 0, "no excess collateral");

        // Make sure not to take more than is available
        uint256 xus_dollar_value_d18 = XUS_amount.mul(xus_price).div(1e6);
        require(xus_dollar_value_d18 <= excess_dv, "excess collateral not enough");

        // Get the equivalent amount of collateral based on the market value of XUS provided 
        uint256 collateral_equivalent_d18 = xus_dollar_value_d18.mul(1e6).div(col_price);
        //collateral_equivalent_d18 = collateral_equivalent_d18.sub((collateral_equivalent_d18.mul(params.buyback_fee)).div(1e6));

        return (
            collateral_equivalent_d18
        );

    }

    // Returns value of collateral that must increase to reach recollateralization target (if 0 means no recollateralization)
    function recollateralizeAmount(uint256 total_supply, uint256 global_collateral_ratio, uint256 global_collat_value) public pure returns (uint256) {
        uint256 target_collat_value = total_supply.mul(global_collateral_ratio).div(1e6); // We want 18 decimals of precision so divide by 1e6; total_supply is 1e18 and global_collateral_ratio is 1e6
        // Subtract the current value of collateral from the target value needed, if higher than 0 then system needs to recollateralize
        uint256 recollateralization_left = target_collat_value.sub(global_collat_value); // If recollateralization is not needed, throws a subtraction underflow
        return(recollateralization_left);
    }

    function calcRecollateralizeXUSDInner(
        uint256 collateral_amount, 
        uint256 col_price,
        uint256 global_collat_value,
        uint256 xusd_total_supply,
        uint256 global_collateral_ratio
    ) public pure returns (uint256, uint256) {
        uint256 collat_value_attempted = collateral_amount.mul(col_price).div(1e6);
        uint256 effective_collateral_ratio = global_collat_value.mul(1e6).div(xusd_total_supply); //returns it in 1e6
        uint256 recollat_possible = (global_collateral_ratio.mul(xusd_total_supply).sub(xusd_total_supply.mul(effective_collateral_ratio))).div(1e6);

        uint256 amount_to_recollat;
        if(collat_value_attempted <= recollat_possible){
            amount_to_recollat = collat_value_attempted;
        } else {
            amount_to_recollat = recollat_possible;
        }

        return (amount_to_recollat.mul(1e6).div(col_price), amount_to_recollat);
    }
}

File 20 of 20 : 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": {
    "/root/new/xusd/contracts/XUSD/Pools/XUSDPoolLibrary.sol": {
      "XUSDPoolLibrary": "0xb8825e9b4E7A277e3de253f9F5455a153d1cda6a"
    }
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_xusd_contract_address","type":"address"},{"internalType":"address","name":"_xus_contract_address","type":"address"},{"internalType":"address","name":"_collateral_address","type":"address"},{"internalType":"address","name":"_timelock_address","type":"address"},{"internalType":"uint256","name":"_pool_ceiling","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"availableExcessCollatDV","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bonus_rate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"XUS_amount","type":"uint256"},{"internalType":"uint256","name":"COLLATERAL_out_min","type":"uint256"}],"name":"buyBackXUS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collatDollarBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collectRedemption","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dai_usd_consumer_address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"XUS_amount","type":"uint256"}],"name":"getBuybackOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCollateralPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collat_amount","type":"uint256"}],"name":"getMint1t1Out","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"xus_amount","type":"uint256"}],"name":"getMintAlgoOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collat_amount","type":"uint256"}],"name":"getMintFracOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateral_amount","type":"uint256"}],"name":"getRecollatOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"xusd_amount","type":"uint256"}],"name":"getRedeem1t1Out","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"XUSD_amount","type":"uint256"}],"name":"getRedeemAlgoOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"XUSD_amount","type":"uint256"}],"name":"getRedeemFracOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastRedeemed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateral_amount","type":"uint256"},{"internalType":"uint256","name":"XUSD_out_min","type":"uint256"}],"name":"mint1t1XUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"xus_amount_d18","type":"uint256"},{"internalType":"uint256","name":"XUSD_out_min","type":"uint256"}],"name":"mintAlgorithmicXUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateral_amount","type":"uint256"},{"internalType":"uint256","name":"XUSD_out_min","type":"uint256"}],"name":"mintFractionalXUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pausedPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool_ceiling","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateral_amount","type":"uint256"},{"internalType":"uint256","name":"XUS_out_min","type":"uint256"}],"name":"recollateralizeXUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"XUSD_amount","type":"uint256"},{"internalType":"uint256","name":"COLLATERAL_out_min","type":"uint256"}],"name":"redeem1t1XUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"XUSD_amount","type":"uint256"},{"internalType":"uint256","name":"XUS_out_min","type":"uint256"}],"name":"redeemAlgorithmicXUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"redeemCollateralBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"XUSD_amount","type":"uint256"},{"internalType":"uint256","name":"XUS_out_min","type":"uint256"},{"internalType":"uint256","name":"COLLATERAL_out_min","type":"uint256"}],"name":"redeemFractionalXUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"redeemXUSBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redemption_delay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral_weth_oracle_address","type":"address"},{"internalType":"address","name":"_weth_address","type":"address"}],"name":"setCollatETHOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_dai_usd_consumer_address","type":"address"}],"name":"setDAIUSDOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feepool","type":"address"}],"name":"setFeePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner_address","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"new_ceiling","type":"uint256"},{"internalType":"uint256","name":"new_bonus_rate","type":"uint256"},{"internalType":"uint256","name":"new_redemption_delay","type":"uint256"}],"name":"setPoolParameters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"new_timelock","type":"address"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleBuyBack","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleCollateralPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleMinting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleRecollateralize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleRedeeming","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unclaimedPoolCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unclaimedPoolXUS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405260006011556000601255611d4c60135560016014556000601560006101000a81548160ff0219169083151502179055506000601560016101000a81548160ff0219169083151502179055506000601560026101000a81548160ff0219169083151502179055506000601560036101000a81548160ff0219169083151502179055506000601560046101000a81548160ff021916908315150217905550348015620000ad57600080fd5b5060405162005eeb38038062005eeb8339818101604052810190620000d39190620004a7565b84600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601181905550620003a16000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156200034d57600080fd5b505afa15801562000362573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000388919062000529565b60ff166012620003b260201b620045bd1790919060201c565b6010819055505050505050620006b6565b6000620003fc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506200040460201b60201c565b905092915050565b60008383111582906200044f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000446919062000596565b60405180910390fd5b5060008385039050809150509392505050565b600081519050620004738162000668565b92915050565b6000815190506200048a8162000682565b92915050565b600081519050620004a1816200069c565b92915050565b600080600080600060a08688031215620004c057600080fd5b6000620004d08882890162000462565b9550506020620004e38882890162000462565b9450506040620004f68882890162000462565b9350506060620005098882890162000462565b92505060806200051c8882890162000479565b9150509295509295909350565b6000602082840312156200053c57600080fd5b60006200054c8482850162000490565b91505092915050565b60006200056282620005ba565b6200056e8185620005c5565b93506200058081856020860162000621565b6200058b8162000657565b840191505092915050565b60006020820190508181036000830152620005b2818462000555565b905092915050565b600081519050919050565b600082825260208201905092915050565b6000620005e382620005ea565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156200064157808201518184015260208101905062000624565b8381111562000651576000848401525b50505050565b6000601f19601f8301169050919050565b6200067381620005d6565b81146200067f57600080fd5b50565b6200068d816200060a565b81146200069957600080fd5b50565b620006a78162000614565b8114620006b357600080fd5b50565b61582580620006c66000396000f3fe608060405234801561001057600080fd5b50600436106102535760003560e01c806379cdb74d11610146578063bdacb303116100c3578063daa5048511610087578063daa50485146106c4578063db893006146106ce578063e2708e20146106ff578063eeeb96f614610709578063f61adab214610725578063f7683bbc1461074357610253565b8063bdacb303146105f8578063c32e26c314610614578063c6879f6a14610645578063c74ec56a14610676578063d4119de31461069457610253565b806388d42cf21161010a57806388d42cf21461052e57806397112bf81461054a5780639aa142a714610566578063a3816f5614610598578063abae2c4c146105c857610253565b806379cdb74d1461049d5780637a00e0e2146104ce5780637b0461e9146104ea5780637d55094d146105085780637e10c6bc1461051257610253565b80633258a70f116101d457806350c9ecd91161019857806350c9ecd91461041f5780636526a12a1461042957806368d83648146104475780637392e26614610463578063750f68be1461048157610253565b80633258a70f1461038e57806340ab38d1146103bf57806342d15aec146103db5780634c634934146103e55780634ca3984a1461040357610253565b8063153ebfc01161021b578063153ebfc0146102e857806317284c941461030657806319db22281461032457806321ecc8501461034057806325eb73111461035c57610253565b8063051141391461025857806308a7493d1461027457806312ace5a2146102a457806313af4035146102ae57806315128425146102ca575b600080fd5b610272600480360381019061026d9190614a56565b610761565b005b61028e60048036038101906102899190614a56565b6109aa565b60405161029b9190615582565b60405180910390f35b6102ac6109c2565b005b6102c860048036038101906102c39190614a56565b610dc4565b005b6102d2610ef0565b6040516102df9190615582565b60405180910390f35b6102f0610ef6565b6040516102fd919061525c565b60405180910390f35b61030e610f1c565b60405161031b9190615582565b60405180910390f35b61033e60048036038101906103399190614a56565b6110ff565b005b61035a60048036038101906103559190614b5f565b61122b565b005b61037660048036038101906103719190614b0d565b6114cb565b604051610385939291906155fd565b60405180910390f35b6103a860048036038101906103a39190614b0d565b611727565b6040516103b692919061559d565b60405180910390f35b6103d960048036038101906103d49190614b5f565b61194b565b005b6103e3611d2e565b005b6103ed611e42565b6040516103fa9190615582565b60405180910390f35b61041d60048036038101906104189190614b5f565b611e48565b005b6104276121ba565b005b6104316122ce565b60405161043e9190615582565b60405180910390f35b610461600480360381019061045c9190614bd7565b6122d4565b005b61046b612808565b6040516104789190615582565b60405180910390f35b61049b60048036038101906104969190614b5f565b61280e565b005b6104b760048036038101906104b29190614b0d565b612b42565b6040516104c592919061559d565b60405180910390f35b6104e860048036038101906104e39190614bd7565b612e01565b005b6104f2612f03565b6040516104ff9190615582565b60405180910390f35b610510612f09565b005b61052c60048036038101906105279190614b5f565b61301d565b005b61054860048036038101906105439190614a7f565b6131b0565b005b610564600480360381019061055f9190614b5f565b61335f565b005b610580600480360381019061057b9190614b0d565b6134f8565b60405161058f939291906155fd565b60405180910390f35b6105b260048036038101906105ad9190614a56565b613746565b6040516105bf9190615582565b60405180910390f35b6105e260048036038101906105dd9190614a56565b61375e565b6040516105ef9190615582565b60405180910390f35b610612600480360381019061060d9190614a56565b613776565b005b61062e60048036038101906106299190614b0d565b6138a2565b60405161063c92919061559d565b60405180910390f35b61065f600480360381019061065a9190614b0d565b613a19565b60405161066d92919061559d565b60405180910390f35b61067e613bd3565b60405161068b9190615582565b60405180910390f35b6106ae60048036038101906106a99190614b0d565b613bd9565b6040516106bb9190615582565b60405180910390f35b6106cc613d1b565b005b6106e860048036038101906106e39190614b0d565b613e2f565b6040516106f692919061559d565b60405180910390f35b610707613fc7565b005b610723600480360381019061071e9190614b5f565b614113565b005b61072d614391565b60405161073a9190615582565b60405180910390f35b61074b6144b3565b6040516107589190615582565b60405180910390f35b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061080a5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610849576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610840906154a2565b60405180910390fd5b80601760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16601660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f0141d846040518163ffffffff1660e01b815260040160206040518083038186803b15801561095557600080fd5b505afa158015610969573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098d9190614cd8565b601660146101000a81548160ff021916908360ff16021790555050565b600c6020528060005260406000206000915090505481565b43610a17601454600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b1115610a58576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4f906154e2565b60405180910390fd5b600080905060008090506000806000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610b5457600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205491506000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b4982600e546145bd90919063ffffffff16565b600e81905550600193505b6000600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610c4357600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c3881600d546145bd90919063ffffffff16565b600d81905550600192505b600115158415151415610d0157600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401610cad9291906152ae565b602060405180830381600087803b158015610cc757600080fd5b505af1158015610cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cff9190614abb565b505b600115158315151415610dbe576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401610d6a9291906152ae565b602060405180830381600087803b158015610d8457600080fd5b505af1158015610d98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbc9190614abb565b505b50505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610e6d5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610eac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea3906154a2565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60145481565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080610ffb601660149054906101000a900460ff1660ff16600a0a610fed620f4240601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e15f4736040518163ffffffff1660e01b815260040160206040518083038186803b158015610fa757600080fd5b505afa158015610fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fdf9190614ae4565b61465c90919063ffffffff16565b6146cc90919063ffffffff16565b90506110f9620f42406110eb836110dd601054600a0a6110cf600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611071919061525c565b60206040518083038186803b15801561108957600080fd5b505afa15801561109d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c19190614b36565b6145bd90919063ffffffff16565b61465c90919063ffffffff16565b61465c90919063ffffffff16565b6146cc90919063ffffffff16565b91505090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806111a85750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6111e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111de906154a2565b60405180910390fd5b80601560056101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60001515601560009054906101000a900460ff16151514611281576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127890615402565b60405180910390fd5b60008061128d84612b42565b91509150818311156112d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112cb90615322565b60405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330876040518463ffffffff1660e01b815260040161133293929190615277565b602060405180830381600087803b15801561134c57600080fd5b505af1158015611360573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113849190614abb565b50600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2633846040518363ffffffff1660e01b81526004016113e29291906152ae565b600060405180830381600087803b1580156113fc57600080fd5b505af1158015611410573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016114939291906152d7565b600060405180830381600087803b1580156114ad57600080fd5b505af11580156114c1573d6000803e3d6000fd5b5050505050505050565b600080600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561153d57600080fd5b505afa158015611551573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115759190614c26565b5050955050945050935050620f4240821080156115925750600082115b6115d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c890615462565b60405180910390fd5b6011546116a488611696600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611638919061525c565b60206040518083038186803b15801561165057600080fd5b505afa158015611664573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116889190614b36565b6145bd90919063ffffffff16565b61460790919063ffffffff16565b11156116e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116dc90615362565b60405180910390fd5b6000601054600a0a88029050600080600061170a846117026144b3565b898989614716565b925092509250828282995099509950505050505050509193909250565b60008060001515601560029054906101000a900460ff16151514611780576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161177790615562565b60405180910390fd5b6000601054600a0a84029050600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b1580156117fb57600080fd5b505afa15801561180f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118339190614c26565b50505094509450945094505060008073b8825e9b4e7a277e3de253f9f5455a153d1cda6a63e55e4afc886118656144b3565b8689896040518663ffffffff1660e01b8152600401611888959493929190615634565b604080518083038186803b15801561189f57600080fd5b505af41580156118b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d79190614b9b565b9150915060006119198761190b6118fc601354620f424061460790919063ffffffff16565b8561465c90919063ffffffff16565b6146cc90919063ffffffff16565b90506000611935601054600a0a856146cc90919063ffffffff16565b905080829a509a50505050505050505050915091565b60001515601560019054906101000a900460ff161515146119a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199890615502565b60405180910390fd5b6000806119ad84613a19565b91509150611a6f600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611a11919061525c565b60206040518083038186803b158015611a2957600080fd5b505afa158015611a3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a619190614b36565b6145bd90919063ffffffff16565b821115611ab1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aa890615542565b60405180910390fd5b611b0382600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611b5b82600d5461460790919063ffffffff16565b600d8190555043600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081831115611be8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bdf90615322565b60405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33866040518363ffffffff1660e01b8152600401611c459291906152ae565b600060405180830381600087803b158015611c5f57600080fd5b505af1158015611c73573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401611cf69291906152d7565b600060405180830381600087803b158015611d1057600080fd5b505af1158015611d24573d6000803e3d6000fd5b5050505050505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611dd75750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611e16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0d906154a2565b60405180910390fd5b601560029054906101000a900460ff1615601560026101000a81548160ff021916908315150217905550565b60135481565b60001515601560019054906101000a900460ff16151514611e9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e9590615502565b60405180910390fd5b600080611eaa846138a2565b91509150611f0082600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f5882600e5461460790919063ffffffff16565b600e8190555043600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081831115611fe5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fdc90615322565b60405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33866040518363ffffffff1660e01b81526004016120429291906152ae565b600060405180830381600087803b15801561205c57600080fd5b505af1158015612070573d6000803e3d6000fd5b50505050600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2630846040518363ffffffff1660e01b81526004016120d19291906152d7565b600060405180830381600087803b1580156120eb57600080fd5b505af11580156120ff573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016121829291906152d7565b600060405180830381600087803b15801561219c57600080fd5b505af11580156121b0573d6000803e3d6000fd5b5050505050505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806122635750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6122a2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612299906154a2565b60405180910390fd5b601560039054906101000a900460ff1615601560036101000a81548160ff021916908315150217905550565b60115481565b60001515601560019054906101000a900460ff1615151461232a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161232190615502565b60405180910390fd5b6000806000612338866134f8565b92509250925061239082600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506123e882600d5461460790919063ffffffff16565b600d8190555061244083600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061249883600e5461460790919063ffffffff16565b600e8190555043600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125a0600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612542919061525c565b60206040518083038186803b15801561255a57600080fd5b505afa15801561256e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125929190614b36565b6145bd90919063ffffffff16565b8211156125e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125d9906153e2565b60405180910390fd5b8184111580156125f25750828511155b612631576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161262890615322565b60405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33886040518363ffffffff1660e01b815260040161268e9291906152ae565b600060405180830381600087803b1580156126a857600080fd5b505af11580156126bc573d6000803e3d6000fd5b50505050600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2630856040518363ffffffff1660e01b815260040161271d9291906152d7565b600060405180830381600087803b15801561273757600080fd5b505af115801561274b573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016127ce9291906152d7565b600060405180830381600087803b1580156127e857600080fd5b505af11580156127fc573d6000803e3d6000fd5b50505050505050505050565b600e5481565b60001515601560009054906101000a900460ff16151514612864576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161285b90615402565b60405180910390fd5b6000806000612872856114cb565b925092509250828411156128bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128b290615322565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33846040518363ffffffff1660e01b81526004016129189291906152ae565b600060405180830381600087803b15801561293257600080fd5b505af1158015612946573d6000803e3d6000fd5b505050506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330886040518463ffffffff1660e01b81526004016129a893929190615277565b602060405180830381600087803b1580156129c257600080fd5b505af11580156129d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fa9190614abb565b50600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2633856040518363ffffffff1660e01b8152600401612a589291906152ae565b600060405180830381600087803b158015612a7257600080fd5b505af1158015612a86573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401612b099291906152d7565b600060405180830381600087803b158015612b2357600080fd5b505af1158015612b37573d6000803e3d6000fd5b505050505050505050565b6000806000601054600a0a84029050600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b158015612bbd57600080fd5b505afa158015612bd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bf59190614c26565b50509550509450505050620f4240821015612c45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c3c906154c2565b60405180910390fd5b601154612d1887612d0a600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612cac919061525c565b60206040518083038186803b158015612cc457600080fd5b505afa158015612cd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cfc9190614b36565b6145bd90919063ffffffff16565b61460790919063ffffffff16565b1115612d59576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d5090615342565b60405180910390fd5b60008073b8825e9b4e7a277e3de253f9f5455a153d1cda6a63d6cd4ef6612d7e6144b3565b85886040518463ffffffff1660e01b8152600401612d9e939291906155c6565b604080518083038186803b158015612db557600080fd5b505af4158015612dc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ded9190614b9b565b915091508181965096505050505050915091565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480612eaa5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b612ee9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ee0906154a2565b60405180910390fd5b826011819055508160138190555080601481905550505050565b600d5481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480612fb25750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b612ff1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fe8906154a2565b60405180910390fd5b601560009054906101000a900460ff1615601560006101000a81548160ff021916908315150217905550565b600061302883613bd9565b90508082111561306d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161306490615322565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33856040518363ffffffff1660e01b81526004016130ca9291906152ae565b600060405180830381600087803b1580156130e457600080fd5b505af11580156130f8573d6000803e3d6000fd5b505050506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b81526004016131589291906152ae565b602060405180830381600087803b15801561317257600080fd5b505af1158015613186573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131aa9190614abb565b50505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806132595750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b613298576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161328f906154a2565b60405180910390fd5b81600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b60008061336b84611727565b91509150808311156133b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133a990615322565b60405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b815260040161341093929190615277565b602060405180830381600087803b15801561342a57600080fd5b505af115801561343e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134629190614abb565b50600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2633836040518363ffffffff1660e01b81526004016134c09291906152ae565b600060405180830381600087803b1580156134da57600080fd5b505af11580156134ee573d6000803e3d6000fd5b5050505050505050565b600080600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561356a57600080fd5b505afa15801561357e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135a29190614c26565b5096505050945050935050620f4240821080156135bf5750600082115b6135fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135f590615462565b60405180910390fd5b60006136086144b3565b90506000613634620f4240613626858c61465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050600061364b828b6145bd90919063ffffffff16565b9050600061368961367a620f424061366c898661465c90919063ffffffff16565b6146cc90919063ffffffff16565b836145bd90919063ffffffff16565b905060006136b5886136a7620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006136d1601054600a0a856146cc90919063ffffffff16565b905060006136fd620f42406136ef8b8561465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006137298861371b620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b90508381889d509d509d5050505050505050505050509193909250565b600b6020528060005260406000206000915090505481565b600f6020528060005260406000206000915090505481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061381f5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61385e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613855906154a2565b60405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806000806000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561391357600080fd5b505afa158015613927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061394b9190614c26565b509650505094505093505060008214613999576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161399090615422565b60405180910390fd5b60006139c3620f42406139b5848a61465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006139da82896145bd90919063ffffffff16565b90506000613a06866139f8620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050808397509750505050505050915091565b600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b158015613a8857600080fd5b505afa158015613a9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ac09190614c26565b50965050509450505050620f42408214613b0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b0690615442565b60405180910390fd5b6000613b29601054600a0a876146cc90919063ffffffff16565b905060008073b8825e9b4e7a277e3de253f9f5455a153d1cda6a638cd974d9613b506144b3565b85876040518463ffffffff1660e01b8152600401613b70939291906155c6565b604080518083038186803b158015613b8757600080fd5b505af4158015613b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bbf9190614b9b565b915091508181965096505050505050915091565b60125481565b6000801515601560039054906101000a900460ff16151514613c30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613c27906153c2565b60405180910390fd5b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b158015613c9b57600080fd5b505afa158015613caf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cd39190614c26565b5050505050509150506000613cf88483613ceb614391565b613cf36144b3565b614830565b9050613d12601054600a0a826146cc90919063ffffffff16565b92505050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480613dc45750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b613e03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613dfa906154a2565b60405180910390fd5b601560019054906101000a900460ff1615601560016101000a81548160ff021916908315150217905550565b6000806000806000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b158015613ea057600080fd5b505afa158015613eb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ed89190614c26565b505095505094505093505060008214613f26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613f1d90615422565b60405180910390fd5b60008073b8825e9b4e7a277e3de253f9f5455a153d1cda6a63de6a6de484878b6040518463ffffffff1660e01b8152600401613f64939291906155c6565b604080518083038186803b158015613f7b57600080fd5b505af4158015613f8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fb39190614b9b565b915091508181965096505050505050915091565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806140705750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6140af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016140a6906154a2565b60405180910390fd5b60001515601560049054906101000a900460ff16151514156140de576140d36144b3565b6012819055506140e7565b60006012819055505b601560049054906101000a900460ff1615601560046101000a81548160ff021916908315150217905550565b60001515601560009054906101000a900460ff16151514614169576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161416090615402565b60405180910390fd5b60008061417584613e2f565b91509150818311156141bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016141b390615322565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33866040518363ffffffff1660e01b81526004016142199291906152ae565b600060405180830381600087803b15801561423357600080fd5b505af1158015614247573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2633846040518363ffffffff1660e01b81526004016142a89291906152ae565b600060405180830381600087803b1580156142c257600080fd5b505af11580156142d6573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016143599291906152d7565b600060405180830381600087803b15801561437357600080fd5b505af1158015614387573d6000803e3d6000fd5b5050505050505050565b600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561440057600080fd5b505afa158015614414573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144389190614c26565b5050509450945094505050620f424082111561445557620f424091505b600061447f620f4240614471858761465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050808211156144a75761449c81836145bd90919063ffffffff16565b9450505050506144b0565b60009450505050505b90565b600060011515601560049054906101000a900460ff16151514156144db5760125490506145ba565b6145b7601660149054906101000a900460ff1660ff16600a0a6145a9620f4240601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e15f4736040518163ffffffff1660e01b815260040160206040518083038186803b15801561456357600080fd5b505afa158015614577573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061459b9190614ae4565b61465c90919063ffffffff16565b6146cc90919063ffffffff16565b90505b90565b60006145ff83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061491c565b905092915050565b600080828401905083811015614652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161464990615382565b60405180910390fd5b8091505092915050565b60008083141561466f57600090506146c6565b600082840290508284828161468057fe5b04146146c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016146b890615482565b60405180910390fd5b809150505b92915050565b600061470e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614977565b905092915050565b600080600080614744620f42406147368a8c61465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006147828261477489614766620f42408761465c90919063ffffffff16565b6146cc90919063ffffffff16565b6145bd90919063ffffffff16565b905060006147ae896147a0620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006147ec620f42406147de8a6147d0878961460790919063ffffffff16565b61465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050600061481582614807868861460790919063ffffffff16565b6145bd90919063ffffffff16565b90508083839750975097505050505050955095509592505050565b6000808311614874576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161486b90615522565b60405180910390fd5b600061489e620f4240614890878961465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050838111156148e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016148da906153a2565b60405180910390fd5b600061490d846148ff620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b90508092505050949350505050565b6000838311158290614964576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161495b9190615300565b60405180910390fd5b5060008385039050809150509392505050565b600080831182906149be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016149b59190615300565b60405180910390fd5b5060008385816149ca57fe5b049050809150509392505050565b6000813590506149e78161577c565b92915050565b6000815190506149fc81615793565b92915050565b600081519050614a11816157aa565b92915050565b600081359050614a26816157c1565b92915050565b600081519050614a3b816157c1565b92915050565b600081519050614a50816157d8565b92915050565b600060208284031215614a6857600080fd5b6000614a76848285016149d8565b91505092915050565b60008060408385031215614a9257600080fd5b6000614aa0858286016149d8565b9250506020614ab1858286016149d8565b9150509250929050565b600060208284031215614acd57600080fd5b6000614adb848285016149ed565b91505092915050565b600060208284031215614af657600080fd5b6000614b0484828501614a02565b91505092915050565b600060208284031215614b1f57600080fd5b6000614b2d84828501614a17565b91505092915050565b600060208284031215614b4857600080fd5b6000614b5684828501614a2c565b91505092915050565b60008060408385031215614b7257600080fd5b6000614b8085828601614a17565b9250506020614b9185828601614a17565b9150509250929050565b60008060408385031215614bae57600080fd5b6000614bbc85828601614a2c565b9250506020614bcd85828601614a2c565b9150509250929050565b600080600060608486031215614bec57600080fd5b6000614bfa86828701614a17565b9350506020614c0b86828701614a17565b9250506040614c1c86828701614a17565b9150509250925092565b600080600080600080600080610100898b031215614c4357600080fd5b6000614c518b828c01614a2c565b9850506020614c628b828c01614a2c565b9750506040614c738b828c01614a2c565b9650506060614c848b828c01614a2c565b9550506080614c958b828c01614a2c565b94505060a0614ca68b828c01614a2c565b93505060c0614cb78b828c01614a2c565b92505060e0614cc88b828c01614a2c565b9150509295985092959890939650565b600060208284031215614cea57600080fd5b6000614cf884828501614a41565b91505092915050565b614d0a81615702565b82525050565b614d19816156a3565b82525050565b6000614d2a82615687565b614d348185615692565b9350614d44818560208601615738565b614d4d8161576b565b840191505092915050565b6000614d65600883615692565b91507f736c6970706167650000000000000000000000000000000000000000000000006000830152602082019050919050565b6000614da5600f83615692565b91507f6365696c696e67207265616368656400000000000000000000000000000000006000830152602082019050919050565b6000614de5601483615692565b91507f706f6f6c206365696c696e6720726561636865640000000000000000000000006000830152602082019050919050565b6000614e25601b83615692565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b6000614e65601c83615692565b91507f65786365737320636f6c6c61746572616c206e6f7420656e6f756768000000006000830152602082019050919050565b6000614ea5600e83615692565b91507f6275796261636b207061757365640000000000000000000000000000000000006000830152602082019050919050565b6000614ee5601583615692565b91507f6e6f7420656e6f75676820636f6c6c61746572616c00000000000000000000006000830152602082019050919050565b6000614f25600b83615692565b91507f6d696e74207061757365640000000000000000000000000000000000000000006000830152602082019050919050565b6000614f65600783615692565b91507f435220213d2030000000000000000000000000000000000000000000000000006000830152602082019050919050565b6000614fa5600783615692565b91507f435220213d2031000000000000000000000000000000000000000000000000006000830152602082019050919050565b6000614fe5600f83615692565b91507f4352206e6f7420696e2072616e676500000000000000000000000000000000006000830152602082019050919050565b6000615025602183615692565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061508b600c83615692565b91507f756e617574686f72697a656400000000000000000000000000000000000000006000830152602082019050919050565b60006150cb600c83615692565b91507f4352206d757374203e3d203100000000000000000000000000000000000000006000830152602082019050919050565b600061510b600c83615692565b91507f77616974203120626c6f636b00000000000000000000000000000000000000006000830152602082019050919050565b600061514b600d83615692565b91507f72656465656d20706175736564000000000000000000000000000000000000006000830152602082019050919050565b600061518b601483615692565b91507f6e6f2065786365737320636f6c6c61746572616c0000000000000000000000006000830152602082019050919050565b60006151cb601d83615692565b91507f4e6f7420656e6f75676820636f6c6c61746572616c20696e20706f6f6c0000006000830152602082019050919050565b600061520b600f83615692565b91507f7265636f6c6c61742070617573656400000000000000000000000000000000006000830152602082019050919050565b615247816156eb565b82525050565b615256816156eb565b82525050565b60006020820190506152716000830184614d10565b92915050565b600060608201905061528c6000830186614d01565b6152996020830185614d10565b6152a6604083018461523e565b949350505050565b60006040820190506152c36000830185614d01565b6152d0602083018461523e565b9392505050565b60006040820190506152ec6000830185614d10565b6152f9602083018461523e565b9392505050565b6000602082019050818103600083015261531a8184614d1f565b905092915050565b6000602082019050818103600083015261533b81614d58565b9050919050565b6000602082019050818103600083015261535b81614d98565b9050919050565b6000602082019050818103600083015261537b81614dd8565b9050919050565b6000602082019050818103600083015261539b81614e18565b9050919050565b600060208201905081810360008301526153bb81614e58565b9050919050565b600060208201905081810360008301526153db81614e98565b9050919050565b600060208201905081810360008301526153fb81614ed8565b9050919050565b6000602082019050818103600083015261541b81614f18565b9050919050565b6000602082019050818103600083015261543b81614f58565b9050919050565b6000602082019050818103600083015261545b81614f98565b9050919050565b6000602082019050818103600083015261547b81614fd8565b9050919050565b6000602082019050818103600083015261549b81615018565b9050919050565b600060208201905081810360008301526154bb8161507e565b9050919050565b600060208201905081810360008301526154db816150be565b9050919050565b600060208201905081810360008301526154fb816150fe565b9050919050565b6000602082019050818103600083015261551b8161513e565b9050919050565b6000602082019050818103600083015261553b8161517e565b9050919050565b6000602082019050818103600083015261555b816151be565b9050919050565b6000602082019050818103600083015261557b816151fe565b9050919050565b6000602082019050615597600083018461523e565b92915050565b60006040820190506155b2600083018561523e565b6155bf602083018461523e565b9392505050565b60006060820190506155db600083018661524d565b6155e8602083018561524d565b6155f5604083018461524d565b949350505050565b6000606082019050615612600083018661523e565b61561f602083018561523e565b61562c604083018461523e565b949350505050565b600060a082019050615649600083018861524d565b615656602083018761524d565b615663604083018661524d565b615670606083018561524d565b61567d608083018461524d565b9695505050505050565b600081519050919050565b600082825260208201905092915050565b60006156ae826156cb565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061570d82615714565b9050919050565b600061571f82615726565b9050919050565b6000615731826156cb565b9050919050565b60005b8381101561575657808201518184015260208101905061573b565b83811115615765576000848401525b50505050565b6000601f19601f8301169050919050565b615785816156a3565b811461579057600080fd5b50565b61579c816156b5565b81146157a757600080fd5b50565b6157b3816156c1565b81146157be57600080fd5b50565b6157ca816156eb565b81146157d557600080fd5b50565b6157e1816156f5565b81146157ec57600080fd5b5056fea26469706673582212205e0eb78011561786b131520edfceea76a9ff3fb2c3156fb560bb90b28738e3c964736f6c634300060b00330000000000000000000000001c9ba9144505aaba12f4b126fda9807150b88f80000000000000000000000000875650dd46b60c592d5a69a6719e4e4187a3ca810000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000075061b5c168477499b3e297ada97a1d22b72a264000000000000000000000000000000000000000000084595161401484a000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102535760003560e01c806379cdb74d11610146578063bdacb303116100c3578063daa5048511610087578063daa50485146106c4578063db893006146106ce578063e2708e20146106ff578063eeeb96f614610709578063f61adab214610725578063f7683bbc1461074357610253565b8063bdacb303146105f8578063c32e26c314610614578063c6879f6a14610645578063c74ec56a14610676578063d4119de31461069457610253565b806388d42cf21161010a57806388d42cf21461052e57806397112bf81461054a5780639aa142a714610566578063a3816f5614610598578063abae2c4c146105c857610253565b806379cdb74d1461049d5780637a00e0e2146104ce5780637b0461e9146104ea5780637d55094d146105085780637e10c6bc1461051257610253565b80633258a70f116101d457806350c9ecd91161019857806350c9ecd91461041f5780636526a12a1461042957806368d83648146104475780637392e26614610463578063750f68be1461048157610253565b80633258a70f1461038e57806340ab38d1146103bf57806342d15aec146103db5780634c634934146103e55780634ca3984a1461040357610253565b8063153ebfc01161021b578063153ebfc0146102e857806317284c941461030657806319db22281461032457806321ecc8501461034057806325eb73111461035c57610253565b8063051141391461025857806308a7493d1461027457806312ace5a2146102a457806313af4035146102ae57806315128425146102ca575b600080fd5b610272600480360381019061026d9190614a56565b610761565b005b61028e60048036038101906102899190614a56565b6109aa565b60405161029b9190615582565b60405180910390f35b6102ac6109c2565b005b6102c860048036038101906102c39190614a56565b610dc4565b005b6102d2610ef0565b6040516102df9190615582565b60405180910390f35b6102f0610ef6565b6040516102fd919061525c565b60405180910390f35b61030e610f1c565b60405161031b9190615582565b60405180910390f35b61033e60048036038101906103399190614a56565b6110ff565b005b61035a60048036038101906103559190614b5f565b61122b565b005b61037660048036038101906103719190614b0d565b6114cb565b604051610385939291906155fd565b60405180910390f35b6103a860048036038101906103a39190614b0d565b611727565b6040516103b692919061559d565b60405180910390f35b6103d960048036038101906103d49190614b5f565b61194b565b005b6103e3611d2e565b005b6103ed611e42565b6040516103fa9190615582565b60405180910390f35b61041d60048036038101906104189190614b5f565b611e48565b005b6104276121ba565b005b6104316122ce565b60405161043e9190615582565b60405180910390f35b610461600480360381019061045c9190614bd7565b6122d4565b005b61046b612808565b6040516104789190615582565b60405180910390f35b61049b60048036038101906104969190614b5f565b61280e565b005b6104b760048036038101906104b29190614b0d565b612b42565b6040516104c592919061559d565b60405180910390f35b6104e860048036038101906104e39190614bd7565b612e01565b005b6104f2612f03565b6040516104ff9190615582565b60405180910390f35b610510612f09565b005b61052c60048036038101906105279190614b5f565b61301d565b005b61054860048036038101906105439190614a7f565b6131b0565b005b610564600480360381019061055f9190614b5f565b61335f565b005b610580600480360381019061057b9190614b0d565b6134f8565b60405161058f939291906155fd565b60405180910390f35b6105b260048036038101906105ad9190614a56565b613746565b6040516105bf9190615582565b60405180910390f35b6105e260048036038101906105dd9190614a56565b61375e565b6040516105ef9190615582565b60405180910390f35b610612600480360381019061060d9190614a56565b613776565b005b61062e60048036038101906106299190614b0d565b6138a2565b60405161063c92919061559d565b60405180910390f35b61065f600480360381019061065a9190614b0d565b613a19565b60405161066d92919061559d565b60405180910390f35b61067e613bd3565b60405161068b9190615582565b60405180910390f35b6106ae60048036038101906106a99190614b0d565b613bd9565b6040516106bb9190615582565b60405180910390f35b6106cc613d1b565b005b6106e860048036038101906106e39190614b0d565b613e2f565b6040516106f692919061559d565b60405180910390f35b610707613fc7565b005b610723600480360381019061071e9190614b5f565b614113565b005b61072d614391565b60405161073a9190615582565b60405180910390f35b61074b6144b3565b6040516107589190615582565b60405180910390f35b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061080a5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610849576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610840906154a2565b60405180910390fd5b80601760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16601660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f0141d846040518163ffffffff1660e01b815260040160206040518083038186803b15801561095557600080fd5b505afa158015610969573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098d9190614cd8565b601660146101000a81548160ff021916908360ff16021790555050565b600c6020528060005260406000206000915090505481565b43610a17601454600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b1115610a58576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4f906154e2565b60405180910390fd5b600080905060008090506000806000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610b5457600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205491506000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b4982600e546145bd90919063ffffffff16565b600e81905550600193505b6000600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610c4357600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c3881600d546145bd90919063ffffffff16565b600d81905550600192505b600115158415151415610d0157600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401610cad9291906152ae565b602060405180830381600087803b158015610cc757600080fd5b505af1158015610cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cff9190614abb565b505b600115158315151415610dbe576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401610d6a9291906152ae565b602060405180830381600087803b158015610d8457600080fd5b505af1158015610d98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbc9190614abb565b505b50505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610e6d5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610eac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea3906154a2565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60145481565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080610ffb601660149054906101000a900460ff1660ff16600a0a610fed620f4240601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e15f4736040518163ffffffff1660e01b815260040160206040518083038186803b158015610fa757600080fd5b505afa158015610fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fdf9190614ae4565b61465c90919063ffffffff16565b6146cc90919063ffffffff16565b90506110f9620f42406110eb836110dd601054600a0a6110cf600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611071919061525c565b60206040518083038186803b15801561108957600080fd5b505afa15801561109d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c19190614b36565b6145bd90919063ffffffff16565b61465c90919063ffffffff16565b61465c90919063ffffffff16565b6146cc90919063ffffffff16565b91505090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806111a85750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6111e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111de906154a2565b60405180910390fd5b80601560056101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60001515601560009054906101000a900460ff16151514611281576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127890615402565b60405180910390fd5b60008061128d84612b42565b91509150818311156112d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112cb90615322565b60405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330876040518463ffffffff1660e01b815260040161133293929190615277565b602060405180830381600087803b15801561134c57600080fd5b505af1158015611360573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113849190614abb565b50600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2633846040518363ffffffff1660e01b81526004016113e29291906152ae565b600060405180830381600087803b1580156113fc57600080fd5b505af1158015611410573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016114939291906152d7565b600060405180830381600087803b1580156114ad57600080fd5b505af11580156114c1573d6000803e3d6000fd5b5050505050505050565b600080600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561153d57600080fd5b505afa158015611551573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115759190614c26565b5050955050945050935050620f4240821080156115925750600082115b6115d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c890615462565b60405180910390fd5b6011546116a488611696600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611638919061525c565b60206040518083038186803b15801561165057600080fd5b505afa158015611664573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116889190614b36565b6145bd90919063ffffffff16565b61460790919063ffffffff16565b11156116e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116dc90615362565b60405180910390fd5b6000601054600a0a88029050600080600061170a846117026144b3565b898989614716565b925092509250828282995099509950505050505050509193909250565b60008060001515601560029054906101000a900460ff16151514611780576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161177790615562565b60405180910390fd5b6000601054600a0a84029050600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b1580156117fb57600080fd5b505afa15801561180f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118339190614c26565b50505094509450945094505060008073b8825e9b4e7a277e3de253f9f5455a153d1cda6a63e55e4afc886118656144b3565b8689896040518663ffffffff1660e01b8152600401611888959493929190615634565b604080518083038186803b15801561189f57600080fd5b505af41580156118b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d79190614b9b565b9150915060006119198761190b6118fc601354620f424061460790919063ffffffff16565b8561465c90919063ffffffff16565b6146cc90919063ffffffff16565b90506000611935601054600a0a856146cc90919063ffffffff16565b905080829a509a50505050505050505050915091565b60001515601560019054906101000a900460ff161515146119a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199890615502565b60405180910390fd5b6000806119ad84613a19565b91509150611a6f600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611a11919061525c565b60206040518083038186803b158015611a2957600080fd5b505afa158015611a3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a619190614b36565b6145bd90919063ffffffff16565b821115611ab1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aa890615542565b60405180910390fd5b611b0382600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611b5b82600d5461460790919063ffffffff16565b600d8190555043600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081831115611be8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bdf90615322565b60405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33866040518363ffffffff1660e01b8152600401611c459291906152ae565b600060405180830381600087803b158015611c5f57600080fd5b505af1158015611c73573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401611cf69291906152d7565b600060405180830381600087803b158015611d1057600080fd5b505af1158015611d24573d6000803e3d6000fd5b5050505050505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611dd75750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611e16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0d906154a2565b60405180910390fd5b601560029054906101000a900460ff1615601560026101000a81548160ff021916908315150217905550565b60135481565b60001515601560019054906101000a900460ff16151514611e9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e9590615502565b60405180910390fd5b600080611eaa846138a2565b91509150611f0082600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f5882600e5461460790919063ffffffff16565b600e8190555043600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081831115611fe5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fdc90615322565b60405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33866040518363ffffffff1660e01b81526004016120429291906152ae565b600060405180830381600087803b15801561205c57600080fd5b505af1158015612070573d6000803e3d6000fd5b50505050600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2630846040518363ffffffff1660e01b81526004016120d19291906152d7565b600060405180830381600087803b1580156120eb57600080fd5b505af11580156120ff573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016121829291906152d7565b600060405180830381600087803b15801561219c57600080fd5b505af11580156121b0573d6000803e3d6000fd5b5050505050505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806122635750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6122a2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612299906154a2565b60405180910390fd5b601560039054906101000a900460ff1615601560036101000a81548160ff021916908315150217905550565b60115481565b60001515601560019054906101000a900460ff1615151461232a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161232190615502565b60405180910390fd5b6000806000612338866134f8565b92509250925061239082600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506123e882600d5461460790919063ffffffff16565b600d8190555061244083600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461460790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061249883600e5461460790919063ffffffff16565b600e8190555043600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125a0600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612542919061525c565b60206040518083038186803b15801561255a57600080fd5b505afa15801561256e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125929190614b36565b6145bd90919063ffffffff16565b8211156125e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125d9906153e2565b60405180910390fd5b8184111580156125f25750828511155b612631576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161262890615322565b60405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33886040518363ffffffff1660e01b815260040161268e9291906152ae565b600060405180830381600087803b1580156126a857600080fd5b505af11580156126bc573d6000803e3d6000fd5b50505050600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2630856040518363ffffffff1660e01b815260040161271d9291906152d7565b600060405180830381600087803b15801561273757600080fd5b505af115801561274b573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016127ce9291906152d7565b600060405180830381600087803b1580156127e857600080fd5b505af11580156127fc573d6000803e3d6000fd5b50505050505050505050565b600e5481565b60001515601560009054906101000a900460ff16151514612864576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161285b90615402565b60405180910390fd5b6000806000612872856114cb565b925092509250828411156128bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128b290615322565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33846040518363ffffffff1660e01b81526004016129189291906152ae565b600060405180830381600087803b15801561293257600080fd5b505af1158015612946573d6000803e3d6000fd5b505050506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330886040518463ffffffff1660e01b81526004016129a893929190615277565b602060405180830381600087803b1580156129c257600080fd5b505af11580156129d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fa9190614abb565b50600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2633856040518363ffffffff1660e01b8152600401612a589291906152ae565b600060405180830381600087803b158015612a7257600080fd5b505af1158015612a86573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401612b099291906152d7565b600060405180830381600087803b158015612b2357600080fd5b505af1158015612b37573d6000803e3d6000fd5b505050505050505050565b6000806000601054600a0a84029050600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b158015612bbd57600080fd5b505afa158015612bd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bf59190614c26565b50509550509450505050620f4240821015612c45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c3c906154c2565b60405180910390fd5b601154612d1887612d0a600d546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612cac919061525c565b60206040518083038186803b158015612cc457600080fd5b505afa158015612cd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cfc9190614b36565b6145bd90919063ffffffff16565b61460790919063ffffffff16565b1115612d59576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d5090615342565b60405180910390fd5b60008073b8825e9b4e7a277e3de253f9f5455a153d1cda6a63d6cd4ef6612d7e6144b3565b85886040518463ffffffff1660e01b8152600401612d9e939291906155c6565b604080518083038186803b158015612db557600080fd5b505af4158015612dc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ded9190614b9b565b915091508181965096505050505050915091565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480612eaa5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b612ee9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ee0906154a2565b60405180910390fd5b826011819055508160138190555080601481905550505050565b600d5481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480612fb25750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b612ff1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fe8906154a2565b60405180910390fd5b601560009054906101000a900460ff1615601560006101000a81548160ff021916908315150217905550565b600061302883613bd9565b90508082111561306d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161306490615322565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33856040518363ffffffff1660e01b81526004016130ca9291906152ae565b600060405180830381600087803b1580156130e457600080fd5b505af11580156130f8573d6000803e3d6000fd5b505050506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b81526004016131589291906152ae565b602060405180830381600087803b15801561317257600080fd5b505af1158015613186573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131aa9190614abb565b50505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806132595750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b613298576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161328f906154a2565b60405180910390fd5b81600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b60008061336b84611727565b91509150808311156133b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133a990615322565b60405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b815260040161341093929190615277565b602060405180830381600087803b15801561342a57600080fd5b505af115801561343e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134629190614abb565b50600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2633836040518363ffffffff1660e01b81526004016134c09291906152ae565b600060405180830381600087803b1580156134da57600080fd5b505af11580156134ee573d6000803e3d6000fd5b5050505050505050565b600080600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561356a57600080fd5b505afa15801561357e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135a29190614c26565b5096505050945050935050620f4240821080156135bf5750600082115b6135fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135f590615462565b60405180910390fd5b60006136086144b3565b90506000613634620f4240613626858c61465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050600061364b828b6145bd90919063ffffffff16565b9050600061368961367a620f424061366c898661465c90919063ffffffff16565b6146cc90919063ffffffff16565b836145bd90919063ffffffff16565b905060006136b5886136a7620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006136d1601054600a0a856146cc90919063ffffffff16565b905060006136fd620f42406136ef8b8561465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006137298861371b620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b90508381889d509d509d5050505050505050505050509193909250565b600b6020528060005260406000206000915090505481565b600f6020528060005260406000206000915090505481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061381f5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61385e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613855906154a2565b60405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806000806000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561391357600080fd5b505afa158015613927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061394b9190614c26565b509650505094505093505060008214613999576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161399090615422565b60405180910390fd5b60006139c3620f42406139b5848a61465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006139da82896145bd90919063ffffffff16565b90506000613a06866139f8620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050808397509750505050505050915091565b600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b158015613a8857600080fd5b505afa158015613a9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ac09190614c26565b50965050509450505050620f42408214613b0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b0690615442565b60405180910390fd5b6000613b29601054600a0a876146cc90919063ffffffff16565b905060008073b8825e9b4e7a277e3de253f9f5455a153d1cda6a638cd974d9613b506144b3565b85876040518463ffffffff1660e01b8152600401613b70939291906155c6565b604080518083038186803b158015613b8757600080fd5b505af4158015613b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bbf9190614b9b565b915091508181965096505050505050915091565b60125481565b6000801515601560039054906101000a900460ff16151514613c30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613c27906153c2565b60405180910390fd5b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b158015613c9b57600080fd5b505afa158015613caf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cd39190614c26565b5050505050509150506000613cf88483613ceb614391565b613cf36144b3565b614830565b9050613d12601054600a0a826146cc90919063ffffffff16565b92505050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480613dc45750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b613e03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613dfa906154a2565b60405180910390fd5b601560019054906101000a900460ff1615601560016101000a81548160ff021916908315150217905550565b6000806000806000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b158015613ea057600080fd5b505afa158015613eb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ed89190614c26565b505095505094505093505060008214613f26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613f1d90615422565b60405180910390fd5b60008073b8825e9b4e7a277e3de253f9f5455a153d1cda6a63de6a6de484878b6040518463ffffffff1660e01b8152600401613f64939291906155c6565b604080518083038186803b158015613f7b57600080fd5b505af4158015613f8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fb39190614b9b565b915091508181965096505050505050915091565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806140705750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6140af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016140a6906154a2565b60405180910390fd5b60001515601560049054906101000a900460ff16151514156140de576140d36144b3565b6012819055506140e7565b60006012819055505b601560049054906101000a900460ff1615601560046101000a81548160ff021916908315150217905550565b60001515601560009054906101000a900460ff16151514614169576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161416090615402565b60405180910390fd5b60008061417584613e2f565b91509150818311156141bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016141b390615322565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a8a778ae33866040518363ffffffff1660e01b81526004016142199291906152ae565b600060405180830381600087803b15801561423357600080fd5b505af1158015614247573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b2633846040518363ffffffff1660e01b81526004016142a89291906152ae565b600060405180830381600087803b1580156142c257600080fd5b505af11580156142d6573d6000803e3d6000fd5b50505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b4f56b26601560059054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016143599291906152d7565b600060405180830381600087803b15801561437357600080fd5b505af1158015614387573d6000803e3d6000fd5b5050505050505050565b600080600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e56b742c6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561440057600080fd5b505afa158015614414573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144389190614c26565b5050509450945094505050620f424082111561445557620f424091505b600061447f620f4240614471858761465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050808211156144a75761449c81836145bd90919063ffffffff16565b9450505050506144b0565b60009450505050505b90565b600060011515601560049054906101000a900460ff16151514156144db5760125490506145ba565b6145b7601660149054906101000a900460ff1660ff16600a0a6145a9620f4240601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e15f4736040518163ffffffff1660e01b815260040160206040518083038186803b15801561456357600080fd5b505afa158015614577573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061459b9190614ae4565b61465c90919063ffffffff16565b6146cc90919063ffffffff16565b90505b90565b60006145ff83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061491c565b905092915050565b600080828401905083811015614652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161464990615382565b60405180910390fd5b8091505092915050565b60008083141561466f57600090506146c6565b600082840290508284828161468057fe5b04146146c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016146b890615482565b60405180910390fd5b809150505b92915050565b600061470e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614977565b905092915050565b600080600080614744620f42406147368a8c61465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006147828261477489614766620f42408761465c90919063ffffffff16565b6146cc90919063ffffffff16565b6145bd90919063ffffffff16565b905060006147ae896147a0620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b905060006147ec620f42406147de8a6147d0878961460790919063ffffffff16565b61465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050600061481582614807868861460790919063ffffffff16565b6145bd90919063ffffffff16565b90508083839750975097505050505050955095509592505050565b6000808311614874576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161486b90615522565b60405180910390fd5b600061489e620f4240614890878961465c90919063ffffffff16565b6146cc90919063ffffffff16565b9050838111156148e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016148da906153a2565b60405180910390fd5b600061490d846148ff620f42408561465c90919063ffffffff16565b6146cc90919063ffffffff16565b90508092505050949350505050565b6000838311158290614964576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161495b9190615300565b60405180910390fd5b5060008385039050809150509392505050565b600080831182906149be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016149b59190615300565b60405180910390fd5b5060008385816149ca57fe5b049050809150509392505050565b6000813590506149e78161577c565b92915050565b6000815190506149fc81615793565b92915050565b600081519050614a11816157aa565b92915050565b600081359050614a26816157c1565b92915050565b600081519050614a3b816157c1565b92915050565b600081519050614a50816157d8565b92915050565b600060208284031215614a6857600080fd5b6000614a76848285016149d8565b91505092915050565b60008060408385031215614a9257600080fd5b6000614aa0858286016149d8565b9250506020614ab1858286016149d8565b9150509250929050565b600060208284031215614acd57600080fd5b6000614adb848285016149ed565b91505092915050565b600060208284031215614af657600080fd5b6000614b0484828501614a02565b91505092915050565b600060208284031215614b1f57600080fd5b6000614b2d84828501614a17565b91505092915050565b600060208284031215614b4857600080fd5b6000614b5684828501614a2c565b91505092915050565b60008060408385031215614b7257600080fd5b6000614b8085828601614a17565b9250506020614b9185828601614a17565b9150509250929050565b60008060408385031215614bae57600080fd5b6000614bbc85828601614a2c565b9250506020614bcd85828601614a2c565b9150509250929050565b600080600060608486031215614bec57600080fd5b6000614bfa86828701614a17565b9350506020614c0b86828701614a17565b9250506040614c1c86828701614a17565b9150509250925092565b600080600080600080600080610100898b031215614c4357600080fd5b6000614c518b828c01614a2c565b9850506020614c628b828c01614a2c565b9750506040614c738b828c01614a2c565b9650506060614c848b828c01614a2c565b9550506080614c958b828c01614a2c565b94505060a0614ca68b828c01614a2c565b93505060c0614cb78b828c01614a2c565b92505060e0614cc88b828c01614a2c565b9150509295985092959890939650565b600060208284031215614cea57600080fd5b6000614cf884828501614a41565b91505092915050565b614d0a81615702565b82525050565b614d19816156a3565b82525050565b6000614d2a82615687565b614d348185615692565b9350614d44818560208601615738565b614d4d8161576b565b840191505092915050565b6000614d65600883615692565b91507f736c6970706167650000000000000000000000000000000000000000000000006000830152602082019050919050565b6000614da5600f83615692565b91507f6365696c696e67207265616368656400000000000000000000000000000000006000830152602082019050919050565b6000614de5601483615692565b91507f706f6f6c206365696c696e6720726561636865640000000000000000000000006000830152602082019050919050565b6000614e25601b83615692565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b6000614e65601c83615692565b91507f65786365737320636f6c6c61746572616c206e6f7420656e6f756768000000006000830152602082019050919050565b6000614ea5600e83615692565b91507f6275796261636b207061757365640000000000000000000000000000000000006000830152602082019050919050565b6000614ee5601583615692565b91507f6e6f7420656e6f75676820636f6c6c61746572616c00000000000000000000006000830152602082019050919050565b6000614f25600b83615692565b91507f6d696e74207061757365640000000000000000000000000000000000000000006000830152602082019050919050565b6000614f65600783615692565b91507f435220213d2030000000000000000000000000000000000000000000000000006000830152602082019050919050565b6000614fa5600783615692565b91507f435220213d2031000000000000000000000000000000000000000000000000006000830152602082019050919050565b6000614fe5600f83615692565b91507f4352206e6f7420696e2072616e676500000000000000000000000000000000006000830152602082019050919050565b6000615025602183615692565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061508b600c83615692565b91507f756e617574686f72697a656400000000000000000000000000000000000000006000830152602082019050919050565b60006150cb600c83615692565b91507f4352206d757374203e3d203100000000000000000000000000000000000000006000830152602082019050919050565b600061510b600c83615692565b91507f77616974203120626c6f636b00000000000000000000000000000000000000006000830152602082019050919050565b600061514b600d83615692565b91507f72656465656d20706175736564000000000000000000000000000000000000006000830152602082019050919050565b600061518b601483615692565b91507f6e6f2065786365737320636f6c6c61746572616c0000000000000000000000006000830152602082019050919050565b60006151cb601d83615692565b91507f4e6f7420656e6f75676820636f6c6c61746572616c20696e20706f6f6c0000006000830152602082019050919050565b600061520b600f83615692565b91507f7265636f6c6c61742070617573656400000000000000000000000000000000006000830152602082019050919050565b615247816156eb565b82525050565b615256816156eb565b82525050565b60006020820190506152716000830184614d10565b92915050565b600060608201905061528c6000830186614d01565b6152996020830185614d10565b6152a6604083018461523e565b949350505050565b60006040820190506152c36000830185614d01565b6152d0602083018461523e565b9392505050565b60006040820190506152ec6000830185614d10565b6152f9602083018461523e565b9392505050565b6000602082019050818103600083015261531a8184614d1f565b905092915050565b6000602082019050818103600083015261533b81614d58565b9050919050565b6000602082019050818103600083015261535b81614d98565b9050919050565b6000602082019050818103600083015261537b81614dd8565b9050919050565b6000602082019050818103600083015261539b81614e18565b9050919050565b600060208201905081810360008301526153bb81614e58565b9050919050565b600060208201905081810360008301526153db81614e98565b9050919050565b600060208201905081810360008301526153fb81614ed8565b9050919050565b6000602082019050818103600083015261541b81614f18565b9050919050565b6000602082019050818103600083015261543b81614f58565b9050919050565b6000602082019050818103600083015261545b81614f98565b9050919050565b6000602082019050818103600083015261547b81614fd8565b9050919050565b6000602082019050818103600083015261549b81615018565b9050919050565b600060208201905081810360008301526154bb8161507e565b9050919050565b600060208201905081810360008301526154db816150be565b9050919050565b600060208201905081810360008301526154fb816150fe565b9050919050565b6000602082019050818103600083015261551b8161513e565b9050919050565b6000602082019050818103600083015261553b8161517e565b9050919050565b6000602082019050818103600083015261555b816151be565b9050919050565b6000602082019050818103600083015261557b816151fe565b9050919050565b6000602082019050615597600083018461523e565b92915050565b60006040820190506155b2600083018561523e565b6155bf602083018461523e565b9392505050565b60006060820190506155db600083018661524d565b6155e8602083018561524d565b6155f5604083018461524d565b949350505050565b6000606082019050615612600083018661523e565b61561f602083018561523e565b61562c604083018461523e565b949350505050565b600060a082019050615649600083018861524d565b615656602083018761524d565b615663604083018661524d565b615670606083018561524d565b61567d608083018461524d565b9695505050505050565b600081519050919050565b600082825260208201905092915050565b60006156ae826156cb565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061570d82615714565b9050919050565b600061571f82615726565b9050919050565b6000615731826156cb565b9050919050565b60005b8381101561575657808201518184015260208101905061573b565b83811115615765576000848401525b50505050565b6000601f19601f8301169050919050565b615785816156a3565b811461579057600080fd5b50565b61579c816156b5565b81146157a757600080fd5b50565b6157b3816156c1565b81146157be57600080fd5b50565b6157ca816156eb565b81146157d557600080fd5b50565b6157e1816156f5565b81146157ec57600080fd5b5056fea26469706673582212205e0eb78011561786b131520edfceea76a9ff3fb2c3156fb560bb90b28738e3c964736f6c634300060b0033

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

0000000000000000000000001c9ba9144505aaba12f4b126fda9807150b88f80000000000000000000000000875650dd46b60c592d5a69a6719e4e4187a3ca810000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000075061b5c168477499b3e297ada97a1d22b72a264000000000000000000000000000000000000000000084595161401484a000000

-----Decoded View---------------
Arg [0] : _xusd_contract_address (address): 0x1c9BA9144505aaBa12f4b126Fda9807150b88f80
Arg [1] : _xus_contract_address (address): 0x875650dD46b60c592d5a69a6719e4e4187A3ca81
Arg [2] : _collateral_address (address): 0x6B175474E89094C44Da98b954EedeAC495271d0F
Arg [3] : _timelock_address (address): 0x75061b5c168477499b3e297AdA97a1d22b72A264
Arg [4] : _pool_ceiling (uint256): 10000000000000000000000000

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000001c9ba9144505aaba12f4b126fda9807150b88f80
Arg [1] : 000000000000000000000000875650dd46b60c592d5a69a6719e4e4187a3ca81
Arg [2] : 0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f
Arg [3] : 00000000000000000000000075061b5c168477499b3e297ada97a1d22b72a264
Arg [4] : 000000000000000000000000000000000000000000084595161401484a000000


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.