ETH Price: $2,812.79 (+7.17%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Accept Ownership209615442024-10-14 4:52:1124 days ago1728881531IN
0xC407d683...26ad02358
0 ETH0.0002854410
Nominate New Own...209611532024-10-14 3:33:3524 days ago1728876815IN
0xC407d683...26ad02358
0 ETH0.000427449
Accept Ownership197008052024-04-21 2:28:35200 days ago1713666515IN
0xC407d683...26ad02358
0 ETH0.000171266
Nominate New Own...197007282024-04-21 2:13:11200 days ago1713665591IN
0xC407d683...26ad02358
0 ETH0.000284966
Accept Ownership156740582022-10-04 10:04:23765 days ago1664877863IN
0xC407d683...26ad02358
0 ETH0.00019987
Nominate New Own...156739932022-10-04 9:51:11765 days ago1664877071IN
0xC407d683...26ad02358
0 ETH0.000379958
0x60806040130030152021-08-11 9:18:031184 days ago1628673483IN
 Create: CollateralShort
0 ETH0.242144545

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CollateralShort

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2021-08-11
*/

/*
    ___            _       ___  _                          
    | .\ ___  _ _ <_> ___ | __><_>._ _  ___ ._ _  ___  ___ 
    |  _// ._>| '_>| ||___|| _> | || ' |<_> || ' |/ | '/ ._>
    |_|  \___.|_|  |_|     |_|  |_||_|_|<___||_|_|\_|_.\___.
    
* PeriFinance: CollateralShort.sol
*
* Latest source (may be newer): https://github.com/perifinance/peri-finance/blob/master/contracts/CollateralShort.sol
* Docs: Will be added in the future. 
* https://docs.peri.finance/contracts/source/contracts/CollateralShort
*
* Contract Dependencies: 
*	- Collateral
*	- IAddressResolver
*	- ICollateralLoan
*	- MixinResolver
*	- MixinSystemSettings
*	- Owned
*	- State
* Libraries: 
*	- SafeDecimalMath
*	- SafeMath
*
* MIT License
* ===========
*
* Copyright (c) 2021 PeriFinance
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/



pragma solidity 0.5.16;

// https://docs.peri.finance/contracts/source/contracts/owned
contract Owned {
    address public owner;
    address public nominatedOwner;

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

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

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

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

    function _onlyOwner() private view {
        require(msg.sender == owner, "Only the contract owner may perform this action");
    }

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


// https://docs.peri.finance/contracts/source/interfaces/iaddressresolver
interface IAddressResolver {
    function getAddress(bytes32 name) external view returns (address);

    function getPynth(bytes32 key) external view returns (address);

    function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address);
}


// https://docs.peri.finance/contracts/source/interfaces/ipynth
interface IPynth {
    // Views
    function currencyKey() external view returns (bytes32);

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

    // Mutative functions
    function transferAndSettle(address to, uint value) external returns (bool);

    function transferFromAndSettle(
        address from,
        address to,
        uint value
    ) external returns (bool);

    // Restricted: used internally to PeriFinance
    function burn(address account, uint amount) external;

    function issue(address account, uint amount) external;
}


// https://docs.peri.finance/contracts/source/interfaces/iissuer
interface IIssuer {
    // Views
    function anyPynthOrPERIRateIsInvalid() external view returns (bool anyRateInvalid);

    function availableCurrencyKeys() external view returns (bytes32[] memory);

    function availablePynthCount() external view returns (uint);

    function availablePynths(uint index) external view returns (IPynth);

    function canBurnPynths(address account) external view returns (bool);

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

    function collateralisationRatio(address issuer) external view returns (uint);

    function collateralisationRatioAndAnyRatesInvalid(address _issuer)
        external
        view
        returns (uint cratio, bool anyRateIsInvalid);

    function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint debtBalance);

    function issuanceRatio() external view returns (uint);

    function externalTokenLimit() external view returns (uint);

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

    function maxIssuablePynths(address issuer) external view returns (uint maxIssuable);

    function externalTokenQuota(
        address _account,
        uint _addtionalpUSD,
        uint _addtionalExToken,
        bool _isIssue
    ) external view returns (uint);

    function maxExternalTokenStakeAmount(address _account, bytes32 _currencyKey)
        external
        view
        returns (uint issueAmountToQuota, uint stakeAmountToQuota);

    function minimumStakeTime() external view returns (uint);

    function remainingIssuablePynths(address issuer)
        external
        view
        returns (
            uint maxIssuable,
            uint alreadyIssued,
            uint totalSystemDebt
        );

    function pynths(bytes32 currencyKey) external view returns (IPynth);

    function getPynths(bytes32[] calldata currencyKeys) external view returns (IPynth[] memory);

    function pynthsByAddress(address pynthAddress) external view returns (bytes32);

    function totalIssuedPynths(bytes32 currencyKey, bool excludeEtherCollateral) external view returns (uint);

    function transferablePeriFinanceAndAnyRateIsInvalid(address account, uint balance)
        external
        view
        returns (uint transferable, bool anyRateIsInvalid);

    // Restricted: used internally to PeriFinance
    function issuePynths(
        address _issuer,
        bytes32 _currencyKey,
        uint _issueAmount
    ) external;

    function issueMaxPynths(address _issuer) external;

    function issuePynthsToMaxQuota(address _issuer, bytes32 _currencyKey) external;

    function burnPynths(
        address _from,
        bytes32 _currencyKey,
        uint _burnAmount
    ) external;

    function fitToClaimable(address _from) external;

    function exit(address _from) external;

    function liquidateDelinquentAccount(
        address account,
        uint pusdAmount,
        address liquidator
    ) external returns (uint totalRedeemed, uint amountToLiquidate);
}


// Inheritance


// Internal references


// https://docs.peri.finance/contracts/source/contracts/addressresolver
contract AddressResolver is Owned, IAddressResolver {
    mapping(bytes32 => address) public repository;

    constructor(address _owner) public Owned(_owner) {}

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

    function importAddresses(bytes32[] calldata names, address[] calldata destinations) external onlyOwner {
        require(names.length == destinations.length, "Input lengths must match");

        for (uint i = 0; i < names.length; i++) {
            bytes32 name = names[i];
            address destination = destinations[i];
            repository[name] = destination;
            emit AddressImported(name, destination);
        }
    }

    /* ========= PUBLIC FUNCTIONS ========== */

    function rebuildCaches(MixinResolver[] calldata destinations) external {
        for (uint i = 0; i < destinations.length; i++) {
            destinations[i].rebuildCache();
        }
    }

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

    function areAddressesImported(bytes32[] calldata names, address[] calldata destinations) external view returns (bool) {
        for (uint i = 0; i < names.length; i++) {
            if (repository[names[i]] != destinations[i]) {
                return false;
            }
        }
        return true;
    }

    function getAddress(bytes32 name) external view returns (address) {
        return repository[name];
    }

    function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address) {
        address _foundAddress = repository[name];
        require(_foundAddress != address(0), reason);
        return _foundAddress;
    }

    function getPynth(bytes32 key) external view returns (address) {
        IIssuer issuer = IIssuer(repository["Issuer"]);
        require(address(issuer) != address(0), "Cannot find Issuer address");
        return address(issuer.pynths(key));
    }

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

    event AddressImported(bytes32 name, address destination);
}


// solhint-disable payable-fallback

// https://docs.peri.finance/contracts/source/contracts/readproxy
contract ReadProxy is Owned {
    address public target;

    constructor(address _owner) public Owned(_owner) {}

    function setTarget(address _target) external onlyOwner {
        target = _target;
        emit TargetUpdated(target);
    }

    function() external {
        // The basics of a proxy read call
        // Note that msg.sender in the underlying will always be the address of this contract.
        assembly {
            calldatacopy(0, 0, calldatasize)

            // Use of staticcall - this will revert if the underlying function mutates state
            let result := staticcall(gas, sload(target_slot), 0, calldatasize, 0, 0)
            returndatacopy(0, 0, returndatasize)

            if iszero(result) {
                revert(0, returndatasize)
            }
            return(0, returndatasize)
        }
    }

    event TargetUpdated(address newTarget);
}


// Inheritance


// Internal references


// https://docs.peri.finance/contracts/source/contracts/mixinresolver
contract MixinResolver {
    AddressResolver public resolver;

    mapping(bytes32 => address) private addressCache;

    constructor(address _resolver) internal {
        resolver = AddressResolver(_resolver);
    }

    /* ========== INTERNAL FUNCTIONS ========== */

    function combineArrays(bytes32[] memory first, bytes32[] memory second)
        internal
        pure
        returns (bytes32[] memory combination)
    {
        combination = new bytes32[](first.length + second.length);

        for (uint i = 0; i < first.length; i++) {
            combination[i] = first[i];
        }

        for (uint j = 0; j < second.length; j++) {
            combination[first.length + j] = second[j];
        }
    }

    /* ========== PUBLIC FUNCTIONS ========== */

    // Note: this function is public not external in order for it to be overridden and invoked via super in subclasses
    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {}

    function rebuildCache() public {
        bytes32[] memory requiredAddresses = resolverAddressesRequired();
        // The resolver must call this function whenver it updates its state
        for (uint i = 0; i < requiredAddresses.length; i++) {
            bytes32 name = requiredAddresses[i];
            // Note: can only be invoked once the resolver has all the targets needed added
            address destination =
                resolver.requireAndGetAddress(name, string(abi.encodePacked("Resolver missing target: ", name)));
            addressCache[name] = destination;
            emit CacheUpdated(name, destination);
        }
    }

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

    function isResolverCached() external view returns (bool) {
        bytes32[] memory requiredAddresses = resolverAddressesRequired();
        for (uint i = 0; i < requiredAddresses.length; i++) {
            bytes32 name = requiredAddresses[i];
            // false if our cache is invalid or if the resolver doesn't have the required address
            if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) {
                return false;
            }
        }

        return true;
    }

    /* ========== INTERNAL FUNCTIONS ========== */

    function requireAndGetAddress(bytes32 name) internal view returns (address) {
        address _foundAddress = addressCache[name];
        require(_foundAddress != address(0), string(abi.encodePacked("Missing address: ", name)));
        return _foundAddress;
    }

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

    event CacheUpdated(bytes32 name, address destination);
}


// https://docs.peri.finance/contracts/source/interfaces/iflexiblestorage
interface IFlexibleStorage {
    // Views
    function getUIntValue(bytes32 contractName, bytes32 record) external view returns (uint);

    function getUIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (uint[] memory);

    function getIntValue(bytes32 contractName, bytes32 record) external view returns (int);

    function getIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (int[] memory);

    function getAddressValue(bytes32 contractName, bytes32 record) external view returns (address);

    function getAddressValues(bytes32 contractName, bytes32[] calldata records) external view returns (address[] memory);

    function getBoolValue(bytes32 contractName, bytes32 record) external view returns (bool);

    function getBoolValues(bytes32 contractName, bytes32[] calldata records) external view returns (bool[] memory);

    function getBytes32Value(bytes32 contractName, bytes32 record) external view returns (bytes32);

    function getBytes32Values(bytes32 contractName, bytes32[] calldata records) external view returns (bytes32[] memory);

    // Mutative functions
    function deleteUIntValue(bytes32 contractName, bytes32 record) external;

    function deleteIntValue(bytes32 contractName, bytes32 record) external;

    function deleteAddressValue(bytes32 contractName, bytes32 record) external;

    function deleteBoolValue(bytes32 contractName, bytes32 record) external;

    function deleteBytes32Value(bytes32 contractName, bytes32 record) external;

    function setUIntValue(
        bytes32 contractName,
        bytes32 record,
        uint value
    ) external;

    function setUIntValues(
        bytes32 contractName,
        bytes32[] calldata records,
        uint[] calldata values
    ) external;

    function setIntValue(
        bytes32 contractName,
        bytes32 record,
        int value
    ) external;

    function setIntValues(
        bytes32 contractName,
        bytes32[] calldata records,
        int[] calldata values
    ) external;

    function setAddressValue(
        bytes32 contractName,
        bytes32 record,
        address value
    ) external;

    function setAddressValues(
        bytes32 contractName,
        bytes32[] calldata records,
        address[] calldata values
    ) external;

    function setBoolValue(
        bytes32 contractName,
        bytes32 record,
        bool value
    ) external;

    function setBoolValues(
        bytes32 contractName,
        bytes32[] calldata records,
        bool[] calldata values
    ) external;

    function setBytes32Value(
        bytes32 contractName,
        bytes32 record,
        bytes32 value
    ) external;

    function setBytes32Values(
        bytes32 contractName,
        bytes32[] calldata records,
        bytes32[] calldata values
    ) external;
}


// Internal references


// https://docs.peri.finance/contracts/source/contracts/mixinsystemsettings
contract MixinSystemSettings is MixinResolver {
    bytes32 internal constant SETTING_CONTRACT_NAME = "SystemSettings";

    bytes32 internal constant SETTING_WAITING_PERIOD_SECS = "waitingPeriodSecs";
    bytes32 internal constant SETTING_PRICE_DEVIATION_THRESHOLD_FACTOR = "priceDeviationThresholdFactor";
    bytes32 internal constant SETTING_ISSUANCE_RATIO = "issuanceRatio";
    bytes32 internal constant SETTING_FEE_PERIOD_DURATION = "feePeriodDuration";
    bytes32 internal constant SETTING_TARGET_THRESHOLD = "targetThreshold";
    bytes32 internal constant SETTING_LIQUIDATION_DELAY = "liquidationDelay";
    bytes32 internal constant SETTING_LIQUIDATION_RATIO = "liquidationRatio";
    bytes32 internal constant SETTING_LIQUIDATION_PENALTY = "liquidationPenalty";
    bytes32 internal constant SETTING_RATE_STALE_PERIOD = "rateStalePeriod";
    bytes32 internal constant SETTING_EXCHANGE_FEE_RATE = "exchangeFeeRate";
    bytes32 internal constant SETTING_MINIMUM_STAKE_TIME = "minimumStakeTime";
    bytes32 internal constant SETTING_AGGREGATOR_WARNING_FLAGS = "aggregatorWarningFlags";
    bytes32 internal constant SETTING_TRADING_REWARDS_ENABLED = "tradingRewardsEnabled";
    bytes32 internal constant SETTING_DEBT_SNAPSHOT_STALE_TIME = "debtSnapshotStaleTime";
    bytes32 internal constant SETTING_CROSS_DOMAIN_DEPOSIT_GAS_LIMIT = "crossDomainDepositGasLimit";
    bytes32 internal constant SETTING_CROSS_DOMAIN_ESCROW_GAS_LIMIT = "crossDomainEscrowGasLimit";
    bytes32 internal constant SETTING_CROSS_DOMAIN_REWARD_GAS_LIMIT = "crossDomainRewardGasLimit";
    bytes32 internal constant SETTING_CROSS_DOMAIN_WITHDRAWAL_GAS_LIMIT = "crossDomainWithdrawalGasLimit";
    bytes32 internal constant SETTING_EXTERNAL_TOKEN_QUOTA = "externalTokenQuota";

    bytes32 internal constant CONTRACT_FLEXIBLESTORAGE = "FlexibleStorage";

    enum CrossDomainMessageGasLimits {Deposit, Escrow, Reward, Withdrawal}

    constructor(address _resolver) internal MixinResolver(_resolver) {}

    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
        addresses = new bytes32[](1);
        addresses[0] = CONTRACT_FLEXIBLESTORAGE;
    }

    function flexibleStorage() internal view returns (IFlexibleStorage) {
        return IFlexibleStorage(requireAndGetAddress(CONTRACT_FLEXIBLESTORAGE));
    }

    function _getGasLimitSetting(CrossDomainMessageGasLimits gasLimitType) internal pure returns (bytes32) {
        if (gasLimitType == CrossDomainMessageGasLimits.Deposit) {
            return SETTING_CROSS_DOMAIN_DEPOSIT_GAS_LIMIT;
        } else if (gasLimitType == CrossDomainMessageGasLimits.Escrow) {
            return SETTING_CROSS_DOMAIN_ESCROW_GAS_LIMIT;
        } else if (gasLimitType == CrossDomainMessageGasLimits.Reward) {
            return SETTING_CROSS_DOMAIN_REWARD_GAS_LIMIT;
        } else if (gasLimitType == CrossDomainMessageGasLimits.Withdrawal) {
            return SETTING_CROSS_DOMAIN_WITHDRAWAL_GAS_LIMIT;
        } else {
            revert("Unknown gas limit type");
        }
    }

    function getCrossDomainMessageGasLimit(CrossDomainMessageGasLimits gasLimitType) internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, _getGasLimitSetting(gasLimitType));
    }

    function getTradingRewardsEnabled() internal view returns (bool) {
        return flexibleStorage().getBoolValue(SETTING_CONTRACT_NAME, SETTING_TRADING_REWARDS_ENABLED);
    }

    function getWaitingPeriodSecs() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_WAITING_PERIOD_SECS);
    }

    function getPriceDeviationThresholdFactor() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_PRICE_DEVIATION_THRESHOLD_FACTOR);
    }

    function getIssuanceRatio() internal view returns (uint) {
        // lookup on flexible storage directly for gas savings (rather than via SystemSettings)
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ISSUANCE_RATIO);
    }

    function getFeePeriodDuration() internal view returns (uint) {
        // lookup on flexible storage directly for gas savings (rather than via SystemSettings)
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_FEE_PERIOD_DURATION);
    }

    function getTargetThreshold() internal view returns (uint) {
        // lookup on flexible storage directly for gas savings (rather than via SystemSettings)
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_TARGET_THRESHOLD);
    }

    function getLiquidationDelay() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_DELAY);
    }

    function getLiquidationRatio() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_RATIO);
    }

    function getLiquidationPenalty() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_PENALTY);
    }

    function getRateStalePeriod() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_RATE_STALE_PERIOD);
    }

    function getExchangeFeeRate(bytes32 currencyKey) internal view returns (uint) {
        return
            flexibleStorage().getUIntValue(
                SETTING_CONTRACT_NAME,
                keccak256(abi.encodePacked(SETTING_EXCHANGE_FEE_RATE, currencyKey))
            );
    }

    function getMinimumStakeTime() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_MINIMUM_STAKE_TIME);
    }

    function getAggregatorWarningFlags() internal view returns (address) {
        return flexibleStorage().getAddressValue(SETTING_CONTRACT_NAME, SETTING_AGGREGATOR_WARNING_FLAGS);
    }

    function getDebtSnapshotStaleTime() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_DEBT_SNAPSHOT_STALE_TIME);
    }

    function getExternalTokenQuota() internal view returns (uint) {
        return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_EXTERNAL_TOKEN_QUOTA);
    }
}


pragma experimental ABIEncoderV2;

interface ICollateralLoan {
    struct Loan {
        // ID for the loan
        uint id;
        //  Acccount that created the loan
        address payable account;
        //  Amount of collateral deposited
        uint collateral;
        // The pynth that was borowed
        bytes32 currency;
        //  Amount of pynths borrowed
        uint amount;
        // Indicates if the position was short sold
        bool short;
        // interest amounts accrued
        uint accruedInterest;
        // last interest index
        uint interestIndex;
        // time of last interaction.
        uint lastInteraction;
    }
}


/**
 * @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) {
        require(b <= a, "SafeMath: subtraction overflow");
        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-solidity/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) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, "SafeMath: division by zero");
        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) {
        require(b != 0, "SafeMath: modulo by zero");
        return a % b;
    }
}


// Libraries


// https://docs.peri.finance/contracts/source/libraries/safedecimalmath
library SafeDecimalMath {
    using SafeMath for uint;

    /* Number of decimal places in the representations. */
    uint8 public constant decimals = 18;
    uint8 public constant highPrecisionDecimals = 27;

    /* The number representing 1.0. */
    uint public constant UNIT = 10**uint(decimals);

    /* The number representing 1.0 for higher fidelity numbers. */
    uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals);
    uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals);

    /**
     * @return Provides an interface to UNIT.
     */
    function unit() external pure returns (uint) {
        return UNIT;
    }

    /**
     * @return Provides an interface to PRECISE_UNIT.
     */
    function preciseUnit() external pure returns (uint) {
        return PRECISE_UNIT;
    }

    /**
     * @return The result of multiplying x and y, interpreting the operands as fixed-point
     * decimals.
     *
     * @dev A unit factor is divided out after the product of x and y is evaluated,
     * so that product must be less than 2**256. As this is an integer division,
     * the internal division always rounds down. This helps save on gas. Rounding
     * is more expensive on gas.
     */
    function multiplyDecimal(uint x, uint y) internal pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        return x.mul(y) / UNIT;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of the specified precision unit.
     *
     * @dev The operands should be in the form of a the specified unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function _multiplyDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        uint quotientTimesTen = x.mul(y) / (precisionUnit / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a precise unit.
     *
     * @dev The operands should be in the precise unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a standard unit.
     *
     * @dev The operands should be in the standard unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is a high
     * precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and UNIT must be less than 2**256. As
     * this is an integer division, the result is always rounded down.
     * This helps save on gas. Rounding is more expensive on gas.
     */
    function divideDecimal(uint x, uint y) internal pure returns (uint) {
        /* Reintroduce the UNIT factor that will be divided out by y. */
        return x.mul(UNIT).div(y);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * decimal in the precision unit specified in the parameter.
     *
     * @dev y is divided after the product of x and the specified precision unit
     * is evaluated, so the product of x and the specified precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function _divideDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        uint resultTimesTen = x.mul(precisionUnit * 10).div(y);

        if (resultTimesTen % 10 >= 5) {
            resultTimesTen += 10;
        }

        return resultTimesTen / 10;
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * standard precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and the standard precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * high precision decimal.
     *
     * @dev y is divided after the product of x and the high precision unit
     * is evaluated, so the product of x and the high precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @dev Convert a standard decimal representation to a high precision one.
     */
    function decimalToPreciseDecimal(uint i) internal pure returns (uint) {
        return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
    }

    /**
     * @dev Convert a high precision decimal to a standard decimal representation.
     */
    function preciseDecimalToDecimal(uint i) internal pure returns (uint) {
        uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }

    /**
     * @dev Round down the value with given number
     */
    function roundDownDecimal(uint x, uint d) internal pure returns (uint) {
        return x.div(10**d).mul(10**d);
    }

    /**
     * @dev Round up the value with given number
     */
    function roundUpDecimal(uint x, uint d) internal pure returns (uint) {
        uint _decimal = 10**d;

        if (x % _decimal > 0) {
            x = x.add(10**d);
        }

        return x.div(_decimal).mul(_decimal);
    }
}


// Inheritance


// https://docs.peri.finance/contracts/source/contracts/state
contract State is Owned {
    // the address of the contract that can modify variables
    // this can only be changed by the owner of this contract
    address public associatedContract;

    constructor(address _associatedContract) internal {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner != address(0), "Owner must be set");

        associatedContract = _associatedContract;
        emit AssociatedContractUpdated(_associatedContract);
    }

    /* ========== SETTERS ========== */

    // Change the associated contract to a new address
    function setAssociatedContract(address _associatedContract) external onlyOwner {
        associatedContract = _associatedContract;
        emit AssociatedContractUpdated(_associatedContract);
    }

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

    modifier onlyAssociatedContract {
        require(msg.sender == associatedContract, "Only the associated contract can perform this action");
        _;
    }

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

    event AssociatedContractUpdated(address associatedContract);
}


// Inheritance


// Libraries


contract CollateralState is Owned, State, ICollateralLoan {
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    mapping(address => Loan[]) public loans;

    constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {}

    /* ========== VIEWS ========== */
    // If we do not find the loan, this returns a struct with 0'd values.
    function getLoan(address account, uint256 loanID) external view returns (Loan memory) {
        Loan[] memory accountLoans = loans[account];
        for (uint i = 0; i < accountLoans.length; i++) {
            if (accountLoans[i].id == loanID) {
                return (accountLoans[i]);
            }
        }
    }

    function getNumLoans(address account) external view returns (uint numLoans) {
        return loans[account].length;
    }

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

    function createLoan(Loan memory loan) public onlyAssociatedContract {
        loans[loan.account].push(loan);
    }

    function updateLoan(Loan memory loan) public onlyAssociatedContract {
        Loan[] storage accountLoans = loans[loan.account];
        for (uint i = 0; i < accountLoans.length; i++) {
            if (accountLoans[i].id == loan.id) {
                loans[loan.account][i] = loan;
            }
        }
    }
}


interface ICollateralManager {
    // Manager information
    function hasCollateral(address collateral) external view returns (bool);

    function isPynthManaged(bytes32 currencyKey) external view returns (bool);

    // State information
    function long(bytes32 pynth) external view returns (uint amount);

    function short(bytes32 pynth) external view returns (uint amount);

    function totalLong() external view returns (uint pusdValue, bool anyRateIsInvalid);

    function totalShort() external view returns (uint pusdValue, bool anyRateIsInvalid);

    function getBorrowRate() external view returns (uint borrowRate, bool anyRateIsInvalid);

    function getShortRate(bytes32 pynth) external view returns (uint shortRate, bool rateIsInvalid);

    function getRatesAndTime(uint index)
        external
        view
        returns (
            uint entryRate,
            uint lastRate,
            uint lastUpdated,
            uint newIndex
        );

    function getShortRatesAndTime(bytes32 currency, uint index)
        external
        view
        returns (
            uint entryRate,
            uint lastRate,
            uint lastUpdated,
            uint newIndex
        );

    function exceedsDebtLimit(uint amount, bytes32 currency) external view returns (bool canIssue, bool anyRateIsInvalid);

    function arePynthsAndCurrenciesSet(bytes32[] calldata requiredPynthNamesInResolver, bytes32[] calldata pynthKeys)
        external
        view
        returns (bool);

    function areShortablePynthsSet(bytes32[] calldata requiredPynthNamesInResolver, bytes32[] calldata pynthKeys)
        external
        view
        returns (bool);

    // Loans
    function getNewLoanId() external returns (uint id);

    // Manager mutative
    function addCollaterals(address[] calldata collaterals) external;

    function removeCollaterals(address[] calldata collaterals) external;

    function addPynths(bytes32[] calldata pynthNamesInResolver, bytes32[] calldata pynthKeys) external;

    function removePynths(bytes32[] calldata pynths, bytes32[] calldata pynthKeys) external;

    function addShortablePynths(bytes32[2][] calldata requiredPynthAndInverseNamesInResolver, bytes32[] calldata pynthKeys)
        external;

    function removeShortablePynths(bytes32[] calldata pynths) external;

    // State mutative
    function updateBorrowRates(uint rate) external;

    function updateShortRates(bytes32 currency, uint rate) external;

    function incrementLongs(bytes32 pynth, uint amount) external;

    function decrementLongs(bytes32 pynth, uint amount) external;

    function incrementShorts(bytes32 pynth, uint amount) external;

    function decrementShorts(bytes32 pynth, uint amount) external;
}


// https://docs.peri.finance/contracts/source/interfaces/isystemstatus
interface ISystemStatus {
    struct Status {
        bool canSuspend;
        bool canResume;
    }

    struct Suspension {
        bool suspended;
        // reason is an integer code,
        // 0 => no reason, 1 => upgrading, 2+ => defined by system usage
        uint248 reason;
    }

    // Views
    function accessControl(bytes32 section, address account) external view returns (bool canSuspend, bool canResume);

    function requireSystemActive() external view;

    function requireIssuanceActive() external view;

    function requireExchangeActive() external view;

    function requireExchangeBetweenPynthsAllowed(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view;

    function requirePynthActive(bytes32 currencyKey) external view;

    function requirePynthsActive(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view;

    function systemSuspension() external view returns (bool suspended, uint248 reason);

    function issuanceSuspension() external view returns (bool suspended, uint248 reason);

    function exchangeSuspension() external view returns (bool suspended, uint248 reason);

    function pynthExchangeSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason);

    function pynthSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason);

    function getPynthExchangeSuspensions(bytes32[] calldata pynths)
        external
        view
        returns (bool[] memory exchangeSuspensions, uint256[] memory reasons);

    function getPynthSuspensions(bytes32[] calldata pynths)
        external
        view
        returns (bool[] memory suspensions, uint256[] memory reasons);

    // Restricted functions
    function suspendPynth(bytes32 currencyKey, uint256 reason) external;

    function updateAccessControl(
        bytes32 section,
        address account,
        bool canSuspend,
        bool canResume
    ) external;
}


// https://docs.peri.finance/contracts/source/interfaces/ifeepool
interface IFeePool {
    // Views

    // solhint-disable-next-line func-name-mixedcase
    function FEE_ADDRESS() external view returns (address);

    function feesAvailable(address account) external view returns (uint, uint);

    function feePeriodDuration() external view returns (uint);

    function isFeesClaimable(address account) external view returns (bool);

    function targetThreshold() external view returns (uint);

    function totalFeesAvailable() external view returns (uint);

    function totalRewardsAvailable() external view returns (uint);

    // Mutative Functions
    function claimFees() external returns (bool);

    function claimOnBehalf(address claimingForAddress) external returns (bool);

    function closeCurrentFeePeriod() external;

    // Restricted: used internally to PeriFinance
    function appendAccountIssuanceRecord(
        address account,
        uint lockedAmount,
        uint debtEntryIndex
    ) external;

    function recordFeePaid(uint pUSDAmount) external;

    function setRewardsToDistribute(uint amount) external;
}


// https://docs.peri.finance/contracts/source/interfaces/ierc20
interface IERC20 {
    // ERC20 Optional Views
    function name() external view returns (string memory);

    function symbol() external view returns (string memory);

    function decimals() external view returns (uint8);

    // Views
    function totalSupply() external view returns (uint);

    function balanceOf(address owner) external view returns (uint);

    function allowance(address owner, address spender) external view returns (uint);

    // Mutative functions
    function transfer(address to, uint value) external returns (bool);

    function approve(address spender, uint value) external returns (bool);

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

    // Events
    event Transfer(address indexed from, address indexed to, uint value);

    event Approval(address indexed owner, address indexed spender, uint value);
}


// https://docs.peri.finance/contracts/source/interfaces/iexchangerates
interface IExchangeRates {
    // Structs
    struct RateAndUpdatedTime {
        uint216 rate;
        uint40 time;
    }

    struct InversePricing {
        uint entryPoint;
        uint upperLimit;
        uint lowerLimit;
        bool frozenAtUpperLimit;
        bool frozenAtLowerLimit;
    }

    // Views
    function aggregators(bytes32 currencyKey) external view returns (address);

    function aggregatorWarningFlags() external view returns (address);

    function anyRateIsInvalid(bytes32[] calldata currencyKeys) external view returns (bool);

    function canFreezeRate(bytes32 currencyKey) external view returns (bool);

    function currentRoundForRate(bytes32 currencyKey) external view returns (uint);

    function currenciesUsingAggregator(address aggregator) external view returns (bytes32[] memory);

    function effectiveValue(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external view returns (uint value);

    function effectiveValueAndRates(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    )
        external
        view
        returns (
            uint value,
            uint sourceRate,
            uint destinationRate
        );

    function effectiveValueAtRound(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        uint roundIdForSrc,
        uint roundIdForDest
    ) external view returns (uint value);

    function getCurrentRoundId(bytes32 currencyKey) external view returns (uint);

    function getLastRoundIdBeforeElapsedSecs(
        bytes32 currencyKey,
        uint startingRoundId,
        uint startingTimestamp,
        uint timediff
    ) external view returns (uint);

    function inversePricing(bytes32 currencyKey)
        external
        view
        returns (
            uint entryPoint,
            uint upperLimit,
            uint lowerLimit,
            bool frozenAtUpperLimit,
            bool frozenAtLowerLimit
        );

    function lastRateUpdateTimes(bytes32 currencyKey) external view returns (uint256);

    function oracle() external view returns (address);

    function rateAndTimestampAtRound(bytes32 currencyKey, uint roundId) external view returns (uint rate, uint time);

    function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time);

    function rateAndInvalid(bytes32 currencyKey) external view returns (uint rate, bool isInvalid);

    function rateForCurrency(bytes32 currencyKey) external view returns (uint);

    function rateIsFlagged(bytes32 currencyKey) external view returns (bool);

    function rateIsFrozen(bytes32 currencyKey) external view returns (bool);

    function rateIsInvalid(bytes32 currencyKey) external view returns (bool);

    function rateIsStale(bytes32 currencyKey) external view returns (bool);

    function rateStalePeriod() external view returns (uint);

    function ratesAndUpdatedTimeForCurrencyLastNRounds(bytes32 currencyKey, uint numRounds)
        external
        view
        returns (uint[] memory rates, uint[] memory times);

    function ratesAndInvalidForCurrencies(bytes32[] calldata currencyKeys)
        external
        view
        returns (uint[] memory rates, bool anyRateInvalid);

    function ratesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory);

    // Mutative functions
    function freezeRate(bytes32 currencyKey) external;
}


interface IVirtualPynth {
    // Views
    function balanceOfUnderlying(address account) external view returns (uint);

    function rate() external view returns (uint);

    function readyToSettle() external view returns (bool);

    function secsLeftInWaitingPeriod() external view returns (uint);

    function settled() external view returns (bool);

    function pynth() external view returns (IPynth);

    // Mutative functions
    function settle(address account) external;
}


// https://docs.peri.finance/contracts/source/interfaces/iexchanger
interface IExchanger {
    // Views
    function calculateAmountAfterSettlement(
        address from,
        bytes32 currencyKey,
        uint amount,
        uint refunded
    ) external view returns (uint amountAfterSettlement);

    function isPynthRateInvalid(bytes32 currencyKey) external view returns (bool);

    function maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) external view returns (uint);

    function settlementOwing(address account, bytes32 currencyKey)
        external
        view
        returns (
            uint reclaimAmount,
            uint rebateAmount,
            uint numEntries
        );

    function hasWaitingPeriodOrSettlementOwing(address account, bytes32 currencyKey) external view returns (bool);

    function feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey)
        external
        view
        returns (uint exchangeFeeRate);

    function getAmountsForExchange(
        uint sourceAmount,
        bytes32 sourceCurrencyKey,
        bytes32 destinationCurrencyKey
    )
        external
        view
        returns (
            uint amountReceived,
            uint fee,
            uint exchangeFeeRate
        );

    function priceDeviationThresholdFactor() external view returns (uint);

    function waitingPeriodSecs() external view returns (uint);

    // Mutative functions
    function exchange(
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address destinationAddress
    ) external returns (uint amountReceived);

    function exchangeOnBehalf(
        address exchangeForAddress,
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external returns (uint amountReceived);

    function exchangeWithTracking(
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address destinationAddress,
        address originator,
        bytes32 trackingCode
    ) external returns (uint amountReceived);

    function exchangeOnBehalfWithTracking(
        address exchangeForAddress,
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address originator,
        bytes32 trackingCode
    ) external returns (uint amountReceived);

    function exchangeWithVirtual(
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address destinationAddress,
        bytes32 trackingCode
    ) external returns (uint amountReceived, IVirtualPynth vPynth);

    function settle(address from, bytes32 currencyKey)
        external
        returns (
            uint reclaimed,
            uint refunded,
            uint numEntries
        );

    function setLastExchangeRateForPynth(bytes32 currencyKey, uint rate) external;

    function suspendPynthWithInvalidRate(bytes32 currencyKey) external;
}


// https://docs.peri.finance/contracts/source/interfaces/istakingrewards
interface IShortingRewards {
    // Views
    function lastTimeRewardApplicable() external view returns (uint256);

    function rewardPerToken() external view returns (uint256);

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

    function getRewardForDuration() external view returns (uint256);

    function totalSupply() external view returns (uint256);

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

    // Mutative

    function enrol(address account, uint256 amount) external;

    function withdraw(address account, uint256 amount) external;

    function getReward(address account) external;
}


// Inheritance


// Libraries


// Internal references


contract Collateral is ICollateralLoan, Owned, MixinSystemSettings {
    /* ========== LIBRARIES ========== */
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    /* ========== CONSTANTS ========== */

    bytes32 private constant pUSD = "pUSD";

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

    // The pynth corresponding to the collateral.
    bytes32 public collateralKey;

    // Stores loans
    CollateralState public state;

    address public manager;

    // The pynths that this contract can issue.
    bytes32[] public pynths;

    // Map from currency key to pynth contract name.
    mapping(bytes32 => bytes32) public pynthsByKey;

    // Map from currency key to the shorting rewards contract
    mapping(bytes32 => address) public shortingRewards;

    // ========== SETTER STATE VARIABLES ==========

    // The minimum collateral ratio required to avoid liquidation.
    uint public minCratio;

    // The minimum amount of collateral to create a loan.
    uint public minCollateral;

    // The fee charged for issuing a loan.
    uint public issueFeeRate;

    // The maximum number of loans that an account can create with this collateral.
    uint public maxLoansPerAccount = 50;

    // Time in seconds that a user must wait between interacting with a loan.
    // Provides front running and flash loan protection.
    uint public interactionDelay = 300;

    bool public canOpenLoans = true;

    /* ========== ADDRESS RESOLVER CONFIGURATION ========== */

    bytes32 private constant CONTRACT_SYSTEMSTATUS = "SystemStatus";
    bytes32 private constant CONTRACT_EXRATES = "ExchangeRates";
    bytes32 private constant CONTRACT_EXCHANGER = "Exchanger";
    bytes32 private constant CONTRACT_FEEPOOL = "FeePool";
    bytes32 private constant CONTRACT_PYNTHPUSD = "PynthpUSD";

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

    constructor(
        CollateralState _state,
        address _owner,
        address _manager,
        address _resolver,
        bytes32 _collateralKey,
        uint _minCratio,
        uint _minCollateral
    ) public Owned(_owner) MixinSystemSettings(_resolver) {
        manager = _manager;
        state = _state;
        collateralKey = _collateralKey;
        minCratio = _minCratio;
        minCollateral = _minCollateral;
    }

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

    function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
        bytes32[] memory existingAddresses = MixinSystemSettings.resolverAddressesRequired();
        bytes32[] memory newAddresses = new bytes32[](5);
        newAddresses[0] = CONTRACT_FEEPOOL;
        newAddresses[1] = CONTRACT_EXRATES;
        newAddresses[2] = CONTRACT_EXCHANGER;
        newAddresses[3] = CONTRACT_SYSTEMSTATUS;
        newAddresses[4] = CONTRACT_PYNTHPUSD;

        bytes32[] memory combined = combineArrays(existingAddresses, newAddresses);

        addresses = combineArrays(combined, pynths);
    }

    /* ---------- Related Contracts ---------- */

    function _systemStatus() internal view returns (ISystemStatus) {
        return ISystemStatus(requireAndGetAddress(CONTRACT_SYSTEMSTATUS));
    }

    function _pynth(bytes32 pynthName) internal view returns (IPynth) {
        return IPynth(requireAndGetAddress(pynthName));
    }

    function _pynthpUSD() internal view returns (IPynth) {
        return IPynth(requireAndGetAddress(CONTRACT_PYNTHPUSD));
    }

    function _exchangeRates() internal view returns (IExchangeRates) {
        return IExchangeRates(requireAndGetAddress(CONTRACT_EXRATES));
    }

    function _exchanger() internal view returns (IExchanger) {
        return IExchanger(requireAndGetAddress(CONTRACT_EXCHANGER));
    }

    function _feePool() internal view returns (IFeePool) {
        return IFeePool(requireAndGetAddress(CONTRACT_FEEPOOL));
    }

    function _manager() internal view returns (ICollateralManager) {
        return ICollateralManager(manager);
    }

    /* ---------- Public Views ---------- */

    function collateralRatio(Loan memory loan) public view returns (uint cratio) {
        uint cvalue = _exchangeRates().effectiveValue(collateralKey, loan.collateral, pUSD);
        uint dvalue = _exchangeRates().effectiveValue(loan.currency, loan.amount.add(loan.accruedInterest), pUSD);
        cratio = cvalue.divideDecimal(dvalue);
    }

    // The maximum number of pynths issuable for this amount of collateral
    function maxLoan(uint amount, bytes32 currency) public view returns (uint max) {
        max = issuanceRatio().multiplyDecimal(_exchangeRates().effectiveValue(collateralKey, amount, currency));
    }

    /**
     * r = target issuance ratio
     * D = debt value in pUSD
     * V = collateral value in pUSD
     * P = liquidation penalty
     * Calculates amount of pynths = (D - V * r) / (1 - (1 + P) * r)
     * Note: if you pass a loan in here that is not eligible for liquidation it will revert.
     * We check the ratio first in liquidateInternal and only pass eligible loans in.
     */
    function liquidationAmount(Loan memory loan) public view returns (uint amount) {
        uint liquidationPenalty = getLiquidationPenalty();
        uint debtValue = _exchangeRates().effectiveValue(loan.currency, loan.amount.add(loan.accruedInterest), pUSD);
        uint collateralValue = _exchangeRates().effectiveValue(collateralKey, loan.collateral, pUSD);
        uint unit = SafeDecimalMath.unit();

        uint dividend = debtValue.sub(collateralValue.divideDecimal(minCratio));
        uint divisor = unit.sub(unit.add(liquidationPenalty).divideDecimal(minCratio));

        uint pUSDamount = dividend.divideDecimal(divisor);

        return _exchangeRates().effectiveValue(pUSD, pUSDamount, loan.currency);
    }

    // amount is the amount of pynths we are liquidating
    function collateralRedeemed(bytes32 currency, uint amount) public view returns (uint collateral) {
        uint liquidationPenalty = getLiquidationPenalty();
        collateral = _exchangeRates().effectiveValue(currency, amount, collateralKey);

        collateral = collateral.multiplyDecimal(SafeDecimalMath.unit().add(liquidationPenalty));
    }

    function arePynthsAndCurrenciesSet(bytes32[] calldata _pynthNamesInResolver, bytes32[] calldata _pynthKeys)
        external
        view
        returns (bool)
    {
        if (pynths.length != _pynthNamesInResolver.length) {
            return false;
        }

        for (uint i = 0; i < _pynthNamesInResolver.length; i++) {
            bytes32 pynthName = _pynthNamesInResolver[i];
            if (pynths[i] != pynthName) {
                return false;
            }
            if (pynthsByKey[_pynthKeys[i]] != pynths[i]) {
                return false;
            }
        }

        return true;
    }

    /* ---------- UTILITIES ---------- */

    // Check the account has enough of the pynth to make the payment
    function _checkPynthBalance(
        address payer,
        bytes32 key,
        uint amount
    ) internal view {
        require(IERC20(address(_pynth(pynthsByKey[key]))).balanceOf(payer) >= amount, "Not enough pynth balance");
    }

    // We set the interest index to 0 to indicate the loan has been closed.
    function _checkLoanAvailable(Loan memory _loan) internal view {
        require(_loan.interestIndex > 0, "Loan does not exist");
        require(_loan.lastInteraction.add(interactionDelay) <= block.timestamp, "Loan recently interacted with");
    }

    function issuanceRatio() internal view returns (uint ratio) {
        ratio = SafeDecimalMath.unit().divideDecimalRound(minCratio);
    }

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

    /* ---------- Pynths ---------- */

    function addPynths(bytes32[] calldata _pynthNamesInResolver, bytes32[] calldata _pynthKeys) external onlyOwner {
        require(_pynthNamesInResolver.length == _pynthKeys.length, "Input array length mismatch");

        for (uint i = 0; i < _pynthNamesInResolver.length; i++) {
            bytes32 pynthName = _pynthNamesInResolver[i];
            pynths.push(pynthName);
            pynthsByKey[_pynthKeys[i]] = pynthName;
        }

        // ensure cache has the latest
        rebuildCache();
    }

    /* ---------- Rewards Contracts ---------- */

    function addRewardsContracts(address rewardsContract, bytes32 pynth) external onlyOwner {
        shortingRewards[pynth] = rewardsContract;
    }

    /* ---------- SETTERS ---------- */

    function setMinCratio(uint _minCratio) external onlyOwner {
        require(_minCratio > SafeDecimalMath.unit(), "Must be greater than 1");
        minCratio = _minCratio;
        emit MinCratioRatioUpdated(minCratio);
    }

    function setIssueFeeRate(uint _issueFeeRate) external onlyOwner {
        issueFeeRate = _issueFeeRate;
        emit IssueFeeRateUpdated(issueFeeRate);
    }

    function setInteractionDelay(uint _interactionDelay) external onlyOwner {
        require(_interactionDelay <= SafeDecimalMath.unit() * 3600, "Max 1 hour");
        interactionDelay = _interactionDelay;
        emit InteractionDelayUpdated(interactionDelay);
    }

    function setManager(address _newManager) external onlyOwner {
        manager = _newManager;
        emit ManagerUpdated(manager);
    }

    function setCanOpenLoans(bool _canOpenLoans) external onlyOwner {
        canOpenLoans = _canOpenLoans;
        emit CanOpenLoansUpdated(canOpenLoans);
    }

    /* ---------- LOAN INTERACTIONS ---------- */

    function openInternal(
        uint collateral,
        uint amount,
        bytes32 currency,
        bool short
    ) internal rateIsValid returns (uint id) {
        // 0. Check the system is active.
        _systemStatus().requireIssuanceActive();

        require(canOpenLoans, "Opening is disabled");

        // 1. We can only issue certain pynths.
        require(pynthsByKey[currency] > 0, "Not allowed to issue this pynth");

        // 2. Make sure the pynth rate is not invalid.
        require(!_exchangeRates().rateIsInvalid(currency), "Currency rate is invalid");

        // 3. Collateral >= minimum collateral size.
        require(collateral >= minCollateral, "Not enough collateral to open");

        // 4. Cap the number of loans so that the array doesn't get too big.
        require(state.getNumLoans(msg.sender) < maxLoansPerAccount, "Max loans exceeded");

        // 5. Check we haven't hit the debt cap for non peri collateral.
        (bool canIssue, bool anyRateIsInvalid) = _manager().exceedsDebtLimit(amount, currency);

        require(canIssue && !anyRateIsInvalid, "Debt limit or invalid rate");

        // 6. Require requested loan < max loan
        require(amount <= maxLoan(collateral, currency), "Exceeds max borrowing power");

        // 7. This fee is denominated in the currency of the loan
        uint issueFee = amount.multiplyDecimalRound(issueFeeRate);

        // 8. Calculate the minting fee and subtract it from the loan amount
        uint loanAmountMinusFee = amount.sub(issueFee);

        // 9. Get a Loan ID
        id = _manager().getNewLoanId();

        // 10. Create the loan struct.
        Loan memory loan =
            Loan({
                id: id,
                account: msg.sender,
                collateral: collateral,
                currency: currency,
                amount: amount,
                short: short,
                accruedInterest: 0,
                interestIndex: 0,
                lastInteraction: block.timestamp
            });

        // 11. Accrue interest on the loan.
        loan = accrueInterest(loan);

        // 12. Save the loan to storage
        state.createLoan(loan);

        // 13. Pay the minting fees to the fee pool
        _payFees(issueFee, currency);

        // 14. If its short, convert back to pUSD, otherwise issue the loan.
        if (short) {
            _pynthpUSD().issue(msg.sender, _exchangeRates().effectiveValue(currency, loanAmountMinusFee, pUSD));
            _manager().incrementShorts(currency, amount);

            if (shortingRewards[currency] != address(0)) {
                IShortingRewards(shortingRewards[currency]).enrol(msg.sender, amount);
            }
        } else {
            _pynth(pynthsByKey[currency]).issue(msg.sender, loanAmountMinusFee);
            _manager().incrementLongs(currency, amount);
        }

        // 15. Emit event
        emit LoanCreated(msg.sender, id, amount, collateral, currency, issueFee);
    }

    function closeInternal(address borrower, uint id) internal rateIsValid returns (uint collateral) {
        // 0. Check the system is active.
        _systemStatus().requireIssuanceActive();

        // 1. Get the loan.
        Loan memory loan = state.getLoan(borrower, id);

        // 2. Check loan is open and the last interaction time.
        _checkLoanAvailable(loan);

        // 3. Accrue interest on the loan.
        loan = accrueInterest(loan);

        // 4. Work out the total amount owing on the loan.
        uint total = loan.amount.add(loan.accruedInterest);

        // 5. Check they have enough balance to close the loan.
        _checkPynthBalance(loan.account, loan.currency, total);

        // 6. Burn the pynths
        require(
            !_exchanger().hasWaitingPeriodOrSettlementOwing(borrower, loan.currency),
            "Waiting secs or settlement owing"
        );
        _pynth(pynthsByKey[loan.currency]).burn(borrower, total);

        // 7. Tell the manager.
        if (loan.short) {
            _manager().decrementShorts(loan.currency, loan.amount);

            if (shortingRewards[loan.currency] != address(0)) {
                IShortingRewards(shortingRewards[loan.currency]).withdraw(borrower, loan.amount);
            }
        } else {
            _manager().decrementLongs(loan.currency, loan.amount);
        }

        // 8. Assign the collateral to be returned.
        collateral = loan.collateral;

        // 9. Pay fees
        _payFees(loan.accruedInterest, loan.currency);

        // 10. Record loan as closed
        loan.amount = 0;
        loan.collateral = 0;
        loan.accruedInterest = 0;
        loan.interestIndex = 0;
        loan.lastInteraction = block.timestamp;
        state.updateLoan(loan);

        // 11. Emit the event
        emit LoanClosed(borrower, id);
    }

    function closeByLiquidationInternal(
        address borrower,
        address liquidator,
        Loan memory loan
    ) internal returns (uint collateral) {
        // 1. Work out the total amount owing on the loan.
        uint total = loan.amount.add(loan.accruedInterest);

        // 2. Store this for the event.
        uint amount = loan.amount;

        // 3. Return collateral to the child class so it knows how much to transfer.
        collateral = loan.collateral;

        // 4. Burn the pynths
        require(!_exchanger().hasWaitingPeriodOrSettlementOwing(liquidator, loan.currency), "Waiting or settlement owing");
        _pynth(pynthsByKey[loan.currency]).burn(liquidator, total);

        // 5. Tell the manager.
        if (loan.short) {
            _manager().decrementShorts(loan.currency, loan.amount);

            if (shortingRewards[loan.currency] != address(0)) {
                IShortingRewards(shortingRewards[loan.currency]).withdraw(borrower, loan.amount);
            }
        } else {
            _manager().decrementLongs(loan.currency, loan.amount);
        }

        // 6. Pay fees
        _payFees(loan.accruedInterest, loan.currency);

        // 7. Record loan as closed
        loan.amount = 0;
        loan.collateral = 0;
        loan.accruedInterest = 0;
        loan.interestIndex = 0;
        loan.lastInteraction = block.timestamp;
        state.updateLoan(loan);

        // 8. Emit the event.
        emit LoanClosedByLiquidation(borrower, loan.id, liquidator, amount, collateral);
    }

    function depositInternal(
        address account,
        uint id,
        uint amount
    ) internal rateIsValid {
        // 0. Check the system is active.
        _systemStatus().requireIssuanceActive();

        // 1. They sent some value > 0
        require(amount > 0, "Deposit must be greater than 0");

        // 2. Get the loan
        Loan memory loan = state.getLoan(account, id);

        // 3. Check loan is open and last interaction time.
        _checkLoanAvailable(loan);

        // 4. Accrue interest
        loan = accrueInterest(loan);

        // 5. Add the collateral
        loan.collateral = loan.collateral.add(amount);

        // 6. Update the last interaction time.
        loan.lastInteraction = block.timestamp;

        // 7. Store the loan
        state.updateLoan(loan);

        // 8. Emit the event
        emit CollateralDeposited(account, id, amount, loan.collateral);
    }

    function withdrawInternal(uint id, uint amount) internal rateIsValid returns (uint withdraw) {
        // 0. Check the system is active.
        _systemStatus().requireIssuanceActive();

        // 1. Get the loan.
        Loan memory loan = state.getLoan(msg.sender, id);

        // 2. Check loan is open and last interaction time.
        _checkLoanAvailable(loan);

        // 3. Accrue interest.
        loan = accrueInterest(loan);

        // 4. Subtract the collateral.
        loan.collateral = loan.collateral.sub(amount);

        // 5. Update the last interaction time.
        loan.lastInteraction = block.timestamp;

        // 6. Check that the new amount does not put them under the minimum c ratio.
        require(collateralRatio(loan) > minCratio, "Cratio too low");

        // 7. Store the loan.
        state.updateLoan(loan);

        // 8. Assign the return variable.
        withdraw = amount;

        // 9. Emit the event.
        emit CollateralWithdrawn(msg.sender, id, amount, loan.collateral);
    }

    function liquidateInternal(
        address borrower,
        uint id,
        uint payment
    ) internal rateIsValid returns (uint collateralLiquidated) {
        // 0. Check the system is active.
        _systemStatus().requireIssuanceActive();

        // 1. Check the payment amount.
        require(payment > 0, "Payment must be greater than 0");

        // 2. Get the loan.
        Loan memory loan = state.getLoan(borrower, id);

        // 3. Check loan is open and last interaction time.
        _checkLoanAvailable(loan);

        // 4. Accrue interest.
        loan = accrueInterest(loan);

        // 5. Check they have enough balance to make the payment.
        _checkPynthBalance(msg.sender, loan.currency, payment);

        // 6. Check they are eligible for liquidation.
        require(collateralRatio(loan) < minCratio, "Cratio above liquidation ratio");

        // 7. Determine how much needs to be liquidated to fix their c ratio.
        uint liqAmount = liquidationAmount(loan);

        // 8. Only allow them to liquidate enough to fix the c ratio.
        uint amountToLiquidate = liqAmount < payment ? liqAmount : payment;

        // 9. Work out the total amount owing on the loan.
        uint amountOwing = loan.amount.add(loan.accruedInterest);

        // 10. If its greater than the amount owing, we need to close the loan.
        if (amountToLiquidate >= amountOwing) {
            return closeByLiquidationInternal(borrower, msg.sender, loan);
        }

        // 11. Process the payment to workout interest/principal split.
        loan = _processPayment(loan, amountToLiquidate);

        // 12. Work out how much collateral to redeem.
        collateralLiquidated = collateralRedeemed(loan.currency, amountToLiquidate);
        loan.collateral = loan.collateral.sub(collateralLiquidated);

        // 13. Update the last interaction time.
        loan.lastInteraction = block.timestamp;

        // 14. Burn the pynths from the liquidator.
        require(!_exchanger().hasWaitingPeriodOrSettlementOwing(msg.sender, loan.currency), "Waiting or settlement owing");
        _pynth(pynthsByKey[loan.currency]).burn(msg.sender, amountToLiquidate);

        // 15. Store the loan.
        state.updateLoan(loan);

        // 16. Emit the event
        emit LoanPartiallyLiquidated(borrower, id, msg.sender, amountToLiquidate, collateralLiquidated);
    }

    function repayInternal(
        address borrower,
        address repayer,
        uint id,
        uint payment
    ) internal rateIsValid {
        // 0. Check the system is active.
        _systemStatus().requireIssuanceActive();

        // 1. Check the payment amount.
        require(payment > 0, "Payment must be greater than 0");

        // 2. Get loan
        Loan memory loan = state.getLoan(borrower, id);

        // 3. Check loan is open and last interaction time.
        _checkLoanAvailable(loan);

        // 4. Accrue interest.
        loan = accrueInterest(loan);

        // 5. Check the spender has enough pynths to make the repayment
        _checkPynthBalance(repayer, loan.currency, payment);

        // 6. Process the payment.
        loan = _processPayment(loan, payment);

        // 7. Update the last interaction time.
        loan.lastInteraction = block.timestamp;

        // 8. Burn pynths from the payer
        require(!_exchanger().hasWaitingPeriodOrSettlementOwing(repayer, loan.currency), "Waiting or settlement owing");
        _pynth(pynthsByKey[loan.currency]).burn(repayer, payment);

        // 9. Store the loan
        state.updateLoan(loan);

        // 10. Emit the event.
        emit LoanRepaymentMade(borrower, repayer, id, payment, loan.amount);
    }

    function drawInternal(uint id, uint amount) internal rateIsValid {
        // 0. Check the system is active.
        _systemStatus().requireIssuanceActive();

        // 1. Get loan.
        Loan memory loan = state.getLoan(msg.sender, id);

        // 2. Check loan is open and last interaction time.
        _checkLoanAvailable(loan);

        // 3. Accrue interest.
        loan = accrueInterest(loan);

        // 4. Add the requested amount.
        loan.amount = loan.amount.add(amount);

        // 5. If it is below the minimum, don't allow this draw.
        require(collateralRatio(loan) > minCratio, "Cannot draw this much");

        // 6. This fee is denominated in the currency of the loan
        uint issueFee = amount.multiplyDecimalRound(issueFeeRate);

        // 7. Calculate the minting fee and subtract it from the draw amount
        uint amountMinusFee = amount.sub(issueFee);

        // 8. If its short, let the child handle it, otherwise issue the pynths.
        if (loan.short) {
            _manager().incrementShorts(loan.currency, amount);
            _pynthpUSD().issue(msg.sender, _exchangeRates().effectiveValue(loan.currency, amountMinusFee, pUSD));

            if (shortingRewards[loan.currency] != address(0)) {
                IShortingRewards(shortingRewards[loan.currency]).enrol(msg.sender, amount);
            }
        } else {
            _manager().incrementLongs(loan.currency, amount);
            _pynth(pynthsByKey[loan.currency]).issue(msg.sender, amountMinusFee);
        }

        // 9. Pay the minting fees to the fee pool
        _payFees(issueFee, loan.currency);

        // 10. Update the last interaction time.
        loan.lastInteraction = block.timestamp;

        // 11. Store the loan
        state.updateLoan(loan);

        // 12. Emit the event.
        emit LoanDrawnDown(msg.sender, id, amount);
    }

    // Update the cumulative interest rate for the currency that was interacted with.
    function accrueInterest(Loan memory loan) internal returns (Loan memory loanAfter) {
        loanAfter = loan;

        // 1. Get the rates we need.
        (uint entryRate, uint lastRate, uint lastUpdated, uint newIndex) =
            loan.short
                ? _manager().getShortRatesAndTime(loan.currency, loan.interestIndex)
                : _manager().getRatesAndTime(loan.interestIndex);

        // 2. Get the instantaneous rate.
        (uint rate, bool invalid) =
            loan.short ? _manager().getShortRate(pynthsByKey[loan.currency]) : _manager().getBorrowRate();

        require(!invalid, "Rates are invalid");

        // 3. Get the time since we last updated the rate.
        uint timeDelta = block.timestamp.sub(lastUpdated).mul(SafeDecimalMath.unit());

        // 4. Get the latest cumulative rate. F_n+1 = F_n + F_last
        uint latestCumulative = lastRate.add(rate.multiplyDecimal(timeDelta));

        // 5. If the loan was just opened, don't record any interest. Otherwise multiple by the amount outstanding.
        uint interest = loan.interestIndex == 0 ? 0 : loan.amount.multiplyDecimal(latestCumulative.sub(entryRate));

        // 7. Update rates with the lastest cumulative rate. This also updates the time.
        loan.short
            ? _manager().updateShortRates(loan.currency, latestCumulative)
            : _manager().updateBorrowRates(latestCumulative);

        // 8. Update loan
        loanAfter.accruedInterest = loan.accruedInterest.add(interest);
        loanAfter.interestIndex = newIndex;
        state.updateLoan(loanAfter);
    }

    // Works out the amount of interest and principal after a repayment is made.
    function _processPayment(Loan memory loanBefore, uint payment) internal returns (Loan memory loanAfter) {
        loanAfter = loanBefore;

        if (payment > 0 && loanBefore.accruedInterest > 0) {
            uint interestPaid = payment > loanBefore.accruedInterest ? loanBefore.accruedInterest : payment;
            loanAfter.accruedInterest = loanBefore.accruedInterest.sub(interestPaid);
            payment = payment.sub(interestPaid);

            _payFees(interestPaid, loanBefore.currency);
        }

        // If there is more payment left after the interest, pay down the principal.
        if (payment > 0) {
            loanAfter.amount = loanBefore.amount.sub(payment);

            // And get the manager to reduce the total long/short balance.
            if (loanAfter.short) {
                _manager().decrementShorts(loanAfter.currency, payment);

                if (shortingRewards[loanAfter.currency] != address(0)) {
                    IShortingRewards(shortingRewards[loanAfter.currency]).withdraw(loanAfter.account, payment);
                }
            } else {
                _manager().decrementLongs(loanAfter.currency, payment);
            }
        }
    }

    // Take an amount of fees in a certain pynth and convert it to pUSD before paying the fee pool.
    function _payFees(uint amount, bytes32 pynth) internal {
        if (amount > 0) {
            if (pynth != pUSD) {
                amount = _exchangeRates().effectiveValue(pynth, amount, pUSD);
            }
            _pynthpUSD().issue(_feePool().FEE_ADDRESS(), amount);
            _feePool().recordFeePaid(amount);
        }
    }

    // ========== MODIFIERS ==========

    modifier rateIsValid() {
        _requireRateIsValid();
        _;
    }

    function _requireRateIsValid() private view {
        require(!_exchangeRates().rateIsInvalid(collateralKey), "Collateral rate is invalid");
    }

    // ========== EVENTS ==========
    // Setters
    event MinCratioRatioUpdated(uint minCratio);
    event MinCollateralUpdated(uint minCollateral);
    event IssueFeeRateUpdated(uint issueFeeRate);
    event MaxLoansPerAccountUpdated(uint maxLoansPerAccount);
    event InteractionDelayUpdated(uint interactionDelay);
    event ManagerUpdated(address manager);
    event CanOpenLoansUpdated(bool canOpenLoans);

    // Loans
    event LoanCreated(address indexed account, uint id, uint amount, uint collateral, bytes32 currency, uint issuanceFee);
    event LoanClosed(address indexed account, uint id);
    event CollateralDeposited(address indexed account, uint id, uint amountDeposited, uint collateralAfter);
    event CollateralWithdrawn(address indexed account, uint id, uint amountWithdrawn, uint collateralAfter);
    event LoanRepaymentMade(address indexed account, address indexed repayer, uint id, uint amountRepaid, uint amountAfter);
    event LoanDrawnDown(address indexed account, uint id, uint amount);
    event LoanPartiallyLiquidated(
        address indexed account,
        uint id,
        address liquidator,
        uint amountLiquidated,
        uint collateralLiquidated
    );
    event LoanClosedByLiquidation(
        address indexed account,
        uint id,
        address indexed liquidator,
        uint amountLiquidated,
        uint collateralLiquidated
    );
}


// Inheritance


// Internal references


contract CollateralShort is Collateral {
    constructor(
        CollateralState _state,
        address _owner,
        address _manager,
        address _resolver,
        bytes32 _collateralKey,
        uint _minCratio,
        uint _minCollateral
    ) public Collateral(_state, _owner, _manager, _resolver, _collateralKey, _minCratio, _minCollateral) {}

    function open(
        uint collateral,
        uint amount,
        bytes32 currency
    ) external {
        require(
            collateral <= IERC20(address(_pynthpUSD())).allowance(msg.sender, address(this)),
            "Allowance not high enough"
        );

        openInternal(collateral, amount, currency, true);

        IERC20(address(_pynthpUSD())).transferFrom(msg.sender, address(this), collateral);
    }

    function close(uint id) external {
        uint collateral = closeInternal(msg.sender, id);

        IERC20(address(_pynthpUSD())).transfer(msg.sender, collateral);
    }

    function deposit(
        address borrower,
        uint id,
        uint amount
    ) external {
        require(amount <= IERC20(address(_pynthpUSD())).allowance(msg.sender, address(this)), "Allowance not high enough");

        IERC20(address(_pynthpUSD())).transferFrom(msg.sender, address(this), amount);

        depositInternal(borrower, id, amount);
    }

    function withdraw(uint id, uint amount) external {
        uint withdrawnAmount = withdrawInternal(id, amount);

        IERC20(address(_pynthpUSD())).transfer(msg.sender, withdrawnAmount);
    }

    function repay(
        address borrower,
        uint id,
        uint amount
    ) external {
        repayInternal(borrower, msg.sender, id, amount);
    }

    function draw(uint id, uint amount) external {
        drawInternal(id, amount);
    }

    function liquidate(
        address borrower,
        uint id,
        uint amount
    ) external {
        uint collateralLiquidated = liquidateInternal(borrower, id, amount);

        IERC20(address(_pynthpUSD())).transfer(msg.sender, collateralLiquidated);
    }

    function getReward(bytes32 currency, address account) external {
        if (shortingRewards[currency] != address(0)) {
            IShortingRewards(shortingRewards[currency]).getReward(account);
        }
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract CollateralState","name":"_state","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_manager","type":"address"},{"internalType":"address","name":"_resolver","type":"address"},{"internalType":"bytes32","name":"_collateralKey","type":"bytes32"},{"internalType":"uint256","name":"_minCratio","type":"uint256"},{"internalType":"uint256","name":"_minCollateral","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"CacheUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"canOpenLoans","type":"bool"}],"name":"CanOpenLoansUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountDeposited","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralAfter","type":"uint256"}],"name":"CollateralDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountWithdrawn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralAfter","type":"uint256"}],"name":"CollateralWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"interactionDelay","type":"uint256"}],"name":"InteractionDelayUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"issueFeeRate","type":"uint256"}],"name":"IssueFeeRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"LoanClosed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"liquidator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountLiquidated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralLiquidated","type":"uint256"}],"name":"LoanClosedByLiquidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateral","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"currency","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"issuanceFee","type":"uint256"}],"name":"LoanCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LoanDrawnDown","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"liquidator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountLiquidated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralLiquidated","type":"uint256"}],"name":"LoanPartiallyLiquidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"repayer","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountRepaid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountAfter","type":"uint256"}],"name":"LoanRepaymentMade","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"manager","type":"address"}],"name":"ManagerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxLoansPerAccount","type":"uint256"}],"name":"MaxLoansPerAccountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minCollateral","type":"uint256"}],"name":"MinCollateralUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minCratio","type":"uint256"}],"name":"MinCratioRatioUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[]","name":"_pynthNamesInResolver","type":"bytes32[]"},{"internalType":"bytes32[]","name":"_pynthKeys","type":"bytes32[]"}],"name":"addPynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"rewardsContract","type":"address"},{"internalType":"bytes32","name":"pynth","type":"bytes32"}],"name":"addRewardsContracts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"_pynthNamesInResolver","type":"bytes32[]"},{"internalType":"bytes32[]","name":"_pynthKeys","type":"bytes32[]"}],"name":"arePynthsAndCurrenciesSet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"canOpenLoans","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"close","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"collateralKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"short","type":"bool"},{"internalType":"uint256","name":"accruedInterest","type":"uint256"},{"internalType":"uint256","name":"interestIndex","type":"uint256"},{"internalType":"uint256","name":"lastInteraction","type":"uint256"}],"internalType":"struct ICollateralLoan.Loan","name":"loan","type":"tuple"}],"name":"collateralRatio","outputs":[{"internalType":"uint256","name":"cratio","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"collateralRedeemed","outputs":[{"internalType":"uint256","name":"collateral","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"draw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"getReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"interactionDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"issueFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"liquidate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"short","type":"bool"},{"internalType":"uint256","name":"accruedInterest","type":"uint256"},{"internalType":"uint256","name":"interestIndex","type":"uint256"},{"internalType":"uint256","name":"lastInteraction","type":"uint256"}],"internalType":"struct ICollateralLoan.Loan","name":"loan","type":"tuple"}],"name":"liquidationAmount","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"}],"name":"maxLoan","outputs":[{"internalType":"uint256","name":"max","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxLoansPerAccount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minCratio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"}],"name":"open","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pynths","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"pynthsByKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"repay","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"resolver","outputs":[{"internalType":"contract AddressResolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"resolverAddressesRequired","outputs":[{"internalType":"bytes32[]","name":"addresses","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"_canOpenLoans","type":"bool"}],"name":"setCanOpenLoans","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_interactionDelay","type":"uint256"}],"name":"setInteractionDelay","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_issueFeeRate","type":"uint256"}],"name":"setIssueFeeRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_newManager","type":"address"}],"name":"setManager","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_minCratio","type":"uint256"}],"name":"setMinCratio","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"shortingRewards","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"state","outputs":[{"internalType":"contract CollateralState","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

60806040526032600d5561012c600e55600f805460ff191660011790553480156200002957600080fd5b5060405162005f3a38038062005f3a8339810160408190526200004c9162000167565b868686868686868380876001600160a01b038116620000885760405162461bcd60e51b81526004016200007f906200028f565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000d591849062000269565b60405180910390a150600280546001600160a01b03199081166001600160a01b03938416179091556006805482169883169890981790975560058054909716981697909717909455600491909155600a5550600b555062000310975050505050505050565b80516200014781620002e0565b92915050565b80516200014781620002fa565b8051620001478162000305565b600080600080600080600060e0888a0312156200018357600080fd5b6000620001918a8a6200015a565b9750506020620001a48a828b016200013a565b9650506040620001b78a828b016200013a565b9550506060620001ca8a828b016200013a565b9450506080620001dd8a828b016200014d565b93505060a0620001f08a828b016200014d565b92505060c0620002038a828b016200014d565b91505092959891949750929550565b6200021d81620002d3565b82525050565b6200021d81620002aa565b60006200023d601983620002a1565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b6040810162000279828562000212565b62000288602083018462000223565b9392505050565b6020808252810162000147816200022e565b90815260200190565b60006200014782620002c7565b90565b60006200014782620002aa565b6001600160a01b031690565b60006200014782620002ba565b620002eb81620002aa565b8114620002f757600080fd5b50565b620002eb81620002b7565b620002eb81620002ba565b615c1a80620003206000396000f3fe608060405234801561001057600080fd5b50600436106102485760003560e01c8063741853601161013b578063ba2de9bc116100b8578063dac8cf681161007c578063dac8cf681461048d578063de81eda9146104a0578063e74337c6146104b3578063eb8e3b65146104c6578063f93451ed146104ce57610248565b8063ba2de9bc14610444578063c19d93fb1461044c578063cd28502014610454578063d0ebdbe714610467578063d2b8035a1461047a57610248565b80638da5cb5b116100ff5780638da5cb5b1461040657806390abb4d91461040e578063925ead1114610421578063a76cdfa514610429578063b562a1ab1461043c57610248565b806374185360146103bb57806379ba5097146103c35780637e132355146103cb578063899ffef4146103de5780638cd2e0c7146103f357610248565b8063361e2086116101c95780634c17ace41161018d5780634c17ace41461036757806353a47bb71461037a57806355bd615c1461038257806356dc04a1146103955780635eb2ad01146103a857610248565b8063361e20861461031c57806337551ec6146103245780634065b81b14610337578063441a3e701461033f578063481c6a751461035257610248565b80630e54a19b116102105780630e54a19b146102c65780630efe6a8b146102e657806315aaf4dd146102f95780631627540c146103015780632af64bd31461031457610248565b806304f3bcec1461024d5780630710285c1461026b5780630a153c97146102805780630aebeb4e146102a05780630cdd1c65146102b3575b600080fd5b6102556104e1565b6040516102629190615886565b60405180910390f35b61027e610279366004614c5a565b6104f0565b005b61029361028e366004614dd1565b61058d565b6040516102629190615821565b61027e6102ae366004614d83565b6106c9565b61027e6102c1366004614d83565b610763565b6102d96102d4366004614ca7565b61084e565b6040516102629190615813565b61027e6102f4366004614c5a565b610910565b610293610a49565b61027e61030f366004614be4565b610a4f565b6102d9610aa2565b610293610bba565b610293610332366004614d83565b610bc0565b6102d9610bde565b61027e61034d366004614dd1565b610be7565b61035a610c82565b604051610262919061576c565b61027e610375366004614d83565b610c91565b61035a610d6d565b61027e610390366004614ca7565b610d7c565b61027e6103a3366004614da1565b610e3c565b61027e6103b6366004614c20565b610ecd565b61027e610f03565b61027e611055565b6102936103d9366004614dd1565b6110f1565b6103e661119a565b6040516102629190615802565b61027e610401366004614c5a565b6112ff565b61035a61130b565b61027e61041c366004614d17565b61131a565b610293611366565b61027e610437366004614d83565b61136c565b6102936113a9565b6102936113af565b6102556113b5565b610293610462366004614d83565b6113c4565b61027e610475366004614be4565b6113d6565b61027e610488366004614dd1565b61142f565b61029361049b366004614df0565b611439565b61035a6104ae366004614d83565b611592565b6102936104c1366004614df0565b6115ad565b610293611897565b61027e6104dc366004614e6b565b61189d565b6002546001600160a01b031681565b60006104fd848484611986565b9050610507611d51565b6001600160a01b031663a9059cbb33836040518363ffffffff1660e01b81526004016105349291906157cb565b602060405180830381600087803b15801561054e57600080fd5b505af1158015610562573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105869190810190614d35565b5050505050565b600080610598611d6d565b90506105a2611e1a565b6001600160a01b031663654a60ac85856004546040518463ffffffff1660e01b81526004016105d39392919061586b565b60206040518083038186803b1580156105eb57600080fd5b505afa1580156105ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106239190810190614e2e565b91506106c16106b482736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561067057600080fd5b505af4158015610684573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106a89190810190614e2e565b9063ffffffff611e3516565b839063ffffffff611e6316565b949350505050565b60006106d53383611e8d565b90506106df611d51565b6001600160a01b031663a9059cbb33836040518363ffffffff1660e01b815260040161070c9291906157cb565b602060405180830381600087803b15801561072657600080fd5b505af115801561073a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061075e9190810190614d35565b505050565b61076b612358565b736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156107af57600080fd5b505af41580156107c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107e79190810190614e2e565b811161080e5760405162461bcd60e51b8152600401610805906158b5565b60405180910390fd5b600a8190556040517f813a44586e8ecb9390b2568dbe810e193087f80e415c8845340ef06d4cbb42a590610843908390615821565b60405180910390a150565b6007546000908414610862575060006106c1565b60005b8481101561090457600086868381811061087b57fe5b905060200201359050806007838154811061089257fe5b9060005260206000200154146108ad576000925050506106c1565b600782815481106108ba57fe5b9060005260206000200154600860008787868181106108d557fe5b90506020020135815260200190815260200160002054146108fb576000925050506106c1565b50600101610865565b50600195945050505050565b610918611d51565b6001600160a01b031663dd62ed3e33306040518363ffffffff1660e01b8152600401610945929190615788565b60206040518083038186803b15801561095d57600080fd5b505afa158015610971573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109959190810190614e2e565b8111156109b45760405162461bcd60e51b8152600401610805906158f5565b6109bc611d51565b6001600160a01b03166323b872dd3330846040518463ffffffff1660e01b81526004016109eb939291906157a3565b602060405180830381600087803b158015610a0557600080fd5b505af1158015610a19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a3d9190810190614d35565b5061075e838383612384565b600e5481565b610a57612358565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229061084390839061576c565b60006060610aae61119a565b905060005b8151811015610bb0576000828281518110610aca57fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a72190610b1b908590600401615821565b60206040518083038186803b158015610b3357600080fd5b505afa158015610b47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b6b9190810190614c02565b6001600160a01b0316141580610b9657506000818152600360205260409020546001600160a01b0316155b15610ba75760009350505050610bb7565b50600101610ab3565b5060019150505b90565b600c5481565b60078181548110610bcd57fe5b600091825260209091200154905081565b600f5460ff1681565b6000610bf3838361257b565b9050610bfd611d51565b6001600160a01b031663a9059cbb33836040518363ffffffff1660e01b8152600401610c2a9291906157cb565b602060405180830381600087803b158015610c4457600080fd5b505af1158015610c58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c7c9190810190614d35565b50505050565b6006546001600160a01b031681565b610c99612358565b736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b158015610cdd57600080fd5b505af4158015610cf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d159190810190614e2e565b610e1002811115610d385760405162461bcd60e51b8152600401610805906159c5565b600e8190556040517f4d71c92b0a9dc236066597b95637bb04d58cd135e9165aee13eb68e3199c236190610843908390615821565b6001546001600160a01b031681565b610d84612358565b828114610da35760405162461bcd60e51b8152600401610805906158a5565b60005b83811015610e33576000858583818110610dbc57fe5b600780546001810182556000918252602090920293909301357fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6889091018190559250829160089150868686818110610e1057fe5b602090810292909201358352508101919091526040016000205550600101610da6565b50610c7c610f03565b6000828152600960205260409020546001600160a01b031615610ec95760008281526009602052604090819020549051630c00007b60e41b81526001600160a01b039091169063c00007b090610e9690849060040161576c565b600060405180830381600087803b158015610eb057600080fd5b505af1158015610ec4573d6000803e3d6000fd5b505050505b5050565b610ed5612358565b600090815260096020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b6060610f0d61119a565b905060005b8151811015610ec9576000828281518110610f2957fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d018384604051602001610f6b9190615761565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610f9792919061584b565b60206040518083038186803b158015610faf57600080fd5b505afa158015610fc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610fe79190810190614c02565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890611043908490849061582f565b60405180910390a15050600101610f12565b6001546001600160a01b0316331461107f5760405162461bcd60e51b8152600401610805906158e5565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c926110c2926001600160a01b03918216929116906157e6565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b60006111936110fe611e1a565b6001600160a01b031663654a60ac60045486866040518463ffffffff1660e01b815260040161112f9392919061586b565b60206040518083038186803b15801561114757600080fd5b505afa15801561115b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061117f9190810190614e2e565b61118761277e565b9063ffffffff611e6316565b9392505050565b6060806111a561280e565b60408051600580825260c08201909252919250606091906020820160a08038833901905050905066119959541bdbdb60ca1b816000815181106111e457fe5b6020026020010181815250506c45786368616e6765526174657360981b8160018151811061120e57fe5b6020026020010181815250506822bc31b430b733b2b960b91b8160028151811061123457fe5b6020026020010181815250506b53797374656d53746174757360a01b8160038151811061125d57fe5b60200260200101818152505068141e5b9d1a1c1554d160ba1b8160048151811061128357fe5b602002602001018181525050606061129b838361285f565b90506112f78160078054806020026020016040519081016040528092919081815260200182805480156112ed57602002820191906000526020600020905b8154815260200190600101908083116112d9575b505050505061285f565b935050505090565b61075e8333848461291b565b6000546001600160a01b031681565b611322612358565b600f805460ff191682151517908190556040517f261991749e1b2436706a31bde8bf184bb37fe21e303709b78d3b881afacadaa2916108439160ff90911690615813565b600a5481565b611374612358565b600c8190556040517fe7bd72551c54d568cd97b00dc52d2787b5c5d4f0070d3582c1e8ba25141f799c90610843908390615821565b60045481565b600b5481565b6005546001600160a01b031681565b60086020526000908152604090205481565b6113de612358565b600680546001600160a01b0319166001600160a01b0383811691909117918290556040517f2c1c11af44aa5608f1dca38c00275c30ea091e02417d36e70e9a1538689c433d9261084392169061576c565b610ec98282612c3c565b600080611444611e1a565b6001600160a01b031663654a60ac6004548560400151631c1554d160e21b6040518463ffffffff1660e01b81526004016114809392919061586b565b60206040518083038186803b15801561149857600080fd5b505afa1580156114ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114d09190810190614e2e565b905060006114dc611e1a565b6001600160a01b031663654a60ac856060015161150a8760c001518860800151611e3590919063ffffffff16565b631c1554d160e21b6040518463ffffffff1660e01b81526004016115309392919061586b565b60206040518083038186803b15801561154857600080fd5b505afa15801561155c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115809190810190614e2e565b90506106c1828263ffffffff61316216565b6009602052600090815260409020546001600160a01b031681565b6000806115b8611d6d565b905060006115c4611e1a565b6001600160a01b031663654a60ac85606001516115f28760c001518860800151611e3590919063ffffffff16565b631c1554d160e21b6040518463ffffffff1660e01b81526004016116189392919061586b565b60206040518083038186803b15801561163057600080fd5b505afa158015611644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116689190810190614e2e565b90506000611674611e1a565b6001600160a01b031663654a60ac6004548760400151631c1554d160e21b6040518463ffffffff1660e01b81526004016116b09392919061586b565b60206040518083038186803b1580156116c857600080fd5b505afa1580156116dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117009190810190614e2e565b90506000736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561174857600080fd5b505af415801561175c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117809190810190614e2e565b905060006117a961179c600a548561316290919063ffffffff16565b859063ffffffff61318c16565b905060006117e26117d5600a546117c98987611e3590919063ffffffff16565b9063ffffffff61316216565b849063ffffffff61318c16565b905060006117f6838363ffffffff61316216565b9050611800611e1a565b6001600160a01b031663654a60ac631c1554d160e21b838c606001516040518463ffffffff1660e01b815260040161183a9392919061586b565b60206040518083038186803b15801561185257600080fd5b505afa158015611866573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061188a9190810190614e2e565b9998505050505050505050565b600d5481565b6118a5611d51565b6001600160a01b031663dd62ed3e33306040518363ffffffff1660e01b81526004016118d2929190615788565b60206040518083038186803b1580156118ea57600080fd5b505afa1580156118fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506119229190810190614e2e565b8311156119415760405162461bcd60e51b8152600401610805906158f5565b61194e83838360016131b4565b50611957611d51565b6001600160a01b03166323b872dd3330866040518463ffffffff1660e01b8152600401610c2a939291906157a3565b6000611990613943565b6119986139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156119d057600080fd5b505afa1580156119e4573d6000803e3d6000fd5b5050505060008211611a085760405162461bcd60e51b815260040161080590615915565b611a1061495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c5158690611a4290889088906004016157f4565b6101206040518083038186803b158015611a5b57600080fd5b505afa158015611a6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a939190810190614e0f565b9050611a9e816139ff565b611aa781613a5f565b9050611ab833826060015185613f4b565b600a54611ac482611439565b10611ae15760405162461bcd60e51b815260040161080590615945565b6000611aec826115ad565b90506000848210611afd5784611aff565b815b90506000611b1e8460c001518560800151611e3590919063ffffffff16565b9050808210611b3d57611b32883386613ffe565b945050505050611193565b611b4784836143cd565b9350611b5784606001518361058d565b6040850151909550611b6f908663ffffffff61318c16565b604085015242610100850152611b836145f0565b6001600160a01b031663d6f32e063386606001516040518363ffffffff1660e01b8152600401611bb49291906157cb565b60206040518083038186803b158015611bcc57600080fd5b505afa158015611be0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611c049190810190614d35565b15611c215760405162461bcd60e51b815260040161080590615a65565b6060840151600090815260086020526040902054611c3e90614607565b6001600160a01b0316639dc29fac33846040518363ffffffff1660e01b8152600401611c6b9291906157cb565b600060405180830381600087803b158015611c8557600080fd5b505af1158015611c99573d6000803e3d6000fd5b5050600554604051631137390760e21b81526001600160a01b0390911692506344dce41c9150611ccd908790600401615a75565b600060405180830381600087803b158015611ce757600080fd5b505af1158015611cfb573d6000803e3d6000fd5b50505050876001600160a01b03167fb6e43890aeea54fbe6c0ed628e78172a0ff30bbcb1d70d8b130b12c366bac4c588338589604051611d3e9493929190615a84565b60405180910390a2505050509392505050565b6000611d6868141e5b9d1a1c1554d160ba1b61460e565b905090565b6000611d7761466b565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b716c69717569646174696f6e50656e616c747960701b6040518363ffffffff1660e01b8152600401611dca92919061583d565b60206040518083038186803b158015611de257600080fd5b505afa158015611df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611d689190810190614e2e565b6000611d686c45786368616e6765526174657360981b61460e565b600082820183811015611e5a5760405162461bcd60e51b815260040161080590615925565b90505b92915050565b6000670de0b6b3a7640000611e7e848463ffffffff61468816565b81611e8557fe5b049392505050565b6000611e97613943565b611e9f6139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b158015611ed757600080fd5b505afa158015611eeb573d6000803e3d6000fd5b50505050611ef761495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c5158690611f2990879087906004016157f4565b6101206040518083038186803b158015611f4257600080fd5b505afa158015611f56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f7a9190810190614e0f565b9050611f85816139ff565b611f8e81613a5f565b90506000611fad8260c001518360800151611e3590919063ffffffff16565b9050611fc28260200151836060015183613f4b565b611fca6145f0565b6001600160a01b031663d6f32e068684606001516040518363ffffffff1660e01b8152600401611ffb9291906157f4565b60206040518083038186803b15801561201357600080fd5b505afa158015612027573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061204b9190810190614d35565b156120685760405162461bcd60e51b815260040161080590615975565b606082015160009081526008602052604090205461208590614607565b6001600160a01b0316639dc29fac86836040518363ffffffff1660e01b81526004016120b29291906157f4565b600060405180830381600087803b1580156120cc57600080fd5b505af11580156120e0573d6000803e3d6000fd5b505050508160a00151156121fe576120f66146c2565b6001600160a01b0316635246f2b9836060015184608001516040518363ffffffff1660e01b815260040161212b92919061583d565b600060405180830381600087803b15801561214557600080fd5b505af1158015612159573d6000803e3d6000fd5b5050505060608201516000908152600960205260409020546001600160a01b0316156121f957606082015160009081526009602052604090819020546080840151915163f3fef3a360e01b81526001600160a01b039091169163f3fef3a3916121c69189916004016157f4565b600060405180830381600087803b1580156121e057600080fd5b505af11580156121f4573d6000803e3d6000fd5b505050505b61226e565b6122066146c2565b6001600160a01b031663e50a31b3836060015184608001516040518363ffffffff1660e01b815260040161223b92919061583d565b600060405180830381600087803b15801561225557600080fd5b505af1158015612269573d6000803e3d6000fd5b505050505b816040015192506122878260c0015183606001516146d1565b600060808301819052604080840182905260c0840182905260e0840191909152426101008401526005549051631137390760e21b81526001600160a01b03909116906344dce41c906122dd908590600401615a75565b600060405180830381600087803b1580156122f757600080fd5b505af115801561230b573d6000803e3d6000fd5b50505050846001600160a01b03167fcab22a4e95d29d40da2ace3f6ec72b49954a9bc7b2584f8fd47bf7f357a3ed6f856040516123489190615821565b60405180910390a2505092915050565b6000546001600160a01b031633146123825760405162461bcd60e51b8152600401610805906159f5565b565b61238c613943565b6123946139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156123cc57600080fd5b505afa1580156123e0573d6000803e3d6000fd5b50505050600081116124045760405162461bcd60e51b815260040161080590615a25565b61240c61495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c515869061243e90879087906004016157f4565b6101206040518083038186803b15801561245757600080fd5b505afa15801561246b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061248f9190810190614e0f565b905061249a816139ff565b6124a381613a5f565b60408101519091506124bb908363ffffffff611e3516565b604080830191909152426101008301526005549051631137390760e21b81526001600160a01b03909116906344dce41c906124fa908490600401615a75565b600060405180830381600087803b15801561251457600080fd5b505af1158015612528573d6000803e3d6000fd5b50505050836001600160a01b03167f0b1992dffc262be88559dcaf96464e9d661d8bfca7e82f2bb73e31932a82187c8484846040015160405161256d9392919061586b565b60405180910390a250505050565b6000612585613943565b61258d6139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156125c557600080fd5b505afa1580156125d9573d6000803e3d6000fd5b505050506125e561495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c515869061261790339088906004016157cb565b6101206040518083038186803b15801561263057600080fd5b505afa158015612644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506126689190810190614e0f565b9050612673816139ff565b61267c81613a5f565b6040810151909150612694908463ffffffff61318c16565b604082015242610100820152600a546126ac82611439565b116126c95760405162461bcd60e51b8152600401610805906158c5565b600554604051631137390760e21b81526001600160a01b03909116906344dce41c906126f9908490600401615a75565b600060405180830381600087803b15801561271357600080fd5b505af1158015612727573d6000803e3d6000fd5b50505050829150336001600160a01b03167ffae26280bca25d80f1501a9e363c73d3845e651c9aaae54f1fc09a9dcd5f33038585846040015160405161276f9392919061586b565b60405180910390a25092915050565b6000611d68600a54736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156127ca57600080fd5b505af41580156127de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506128029190810190614e2e565b9063ffffffff61488716565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b8160008151811061285057fe5b60200260200101818152505090565b6060815183510160405190808252806020026020018201604052801561288f578160200160208202803883390190505b50905060005b83518110156128d1578381815181106128aa57fe5b60200260200101518282815181106128be57fe5b6020908102919091010152600101612895565b5060005b8251811015612914578281815181106128ea57fe5b602002602001015182828651018151811061290157fe5b60209081029190910101526001016128d5565b5092915050565b612923613943565b61292b6139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b15801561296357600080fd5b505afa158015612977573d6000803e3d6000fd5b505050506000811161299b5760405162461bcd60e51b815260040161080590615915565b6129a361495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c51586906129d590889087906004016157f4565b6101206040518083038186803b1580156129ee57600080fd5b505afa158015612a02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a269190810190614e0f565b9050612a31816139ff565b612a3a81613a5f565b9050612a4b84826060015184613f4b565b612a5581836143cd565b426101008201529050612a666145f0565b6001600160a01b031663d6f32e068583606001516040518363ffffffff1660e01b8152600401612a979291906157f4565b60206040518083038186803b158015612aaf57600080fd5b505afa158015612ac3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612ae79190810190614d35565b15612b045760405162461bcd60e51b815260040161080590615a65565b6060810151600090815260086020526040902054612b2190614607565b6001600160a01b0316639dc29fac85846040518363ffffffff1660e01b8152600401612b4e9291906157f4565b600060405180830381600087803b158015612b6857600080fd5b505af1158015612b7c573d6000803e3d6000fd5b5050600554604051631137390760e21b81526001600160a01b0390911692506344dce41c9150612bb0908490600401615a75565b600060405180830381600087803b158015612bca57600080fd5b505af1158015612bde573d6000803e3d6000fd5b50505050836001600160a01b0316856001600160a01b03167fdf10512219e869922340b1b24b21d7d79bf71f411a6391cc7c3ef5dd2fe89e7f85858560800151604051612c2d9392919061586b565b60405180910390a35050505050565b612c44613943565b612c4c6139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b158015612c8457600080fd5b505afa158015612c98573d6000803e3d6000fd5b50505050612ca461495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c5158690612cd690339087906004016157cb565b6101206040518083038186803b158015612cef57600080fd5b505afa158015612d03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612d279190810190614e0f565b9050612d32816139ff565b612d3b81613a5f565b6080810151909150612d53908363ffffffff611e3516565b6080820152600a54612d6482611439565b11612d815760405162461bcd60e51b8152600401610805906158d5565b6000612d98600c548461489c90919063ffffffff16565b90506000612dac848363ffffffff61318c16565b90508260a0015115612fb957612dc06146c2565b6001600160a01b031663e31f27c18460600151866040518363ffffffff1660e01b8152600401612df192919061583d565b600060405180830381600087803b158015612e0b57600080fd5b505af1158015612e1f573d6000803e3d6000fd5b50505050612e2b611d51565b6001600160a01b031663867904b433612e42611e1a565b6001600160a01b031663654a60ac876060015186631c1554d160e21b6040518463ffffffff1660e01b8152600401612e7c9392919061586b565b60206040518083038186803b158015612e9457600080fd5b505afa158015612ea8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612ecc9190810190614e2e565b6040518363ffffffff1660e01b8152600401612ee99291906157cb565b600060405180830381600087803b158015612f0357600080fd5b505af1158015612f17573d6000803e3d6000fd5b5050505060608301516000908152600960205260409020546001600160a01b031615612fb45760608301516000908152600960205260409081902054905163db454a5160e01b81526001600160a01b039091169063db454a5190612f8190339088906004016157cb565b600060405180830381600087803b158015612f9b57600080fd5b505af1158015612faf573d6000803e3d6000fd5b505050505b6130a1565b612fc16146c2565b6001600160a01b031663eb94bbde8460600151866040518363ffffffff1660e01b8152600401612ff292919061583d565b600060405180830381600087803b15801561300c57600080fd5b505af1158015613020573d6000803e3d6000fd5b50505060608401516000908152600860205260409020546130419150614607565b6001600160a01b031663867904b433836040518363ffffffff1660e01b815260040161306e9291906157cb565b600060405180830381600087803b15801561308857600080fd5b505af115801561309c573d6000803e3d6000fd5b505050505b6130af8284606001516146d1565b42610100840152600554604051631137390760e21b81526001600160a01b03909116906344dce41c906130e6908690600401615a75565b600060405180830381600087803b15801561310057600080fd5b505af1158015613114573d6000803e3d6000fd5b50505050336001600160a01b03167f5754fe57f36ac0f121901d7555aba517e6608590429d86a81c662cf358310654868660405161315392919061583d565b60405180910390a25050505050565b60006111938261318085670de0b6b3a764000063ffffffff61468816565b9063ffffffff6148b116565b6000828211156131ae5760405162461bcd60e51b815260040161080590615985565b50900390565b60006131be613943565b6131c66139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156131fe57600080fd5b505afa158015613212573d6000803e3d6000fd5b5050600f5460ff16915061323a90505760405162461bcd60e51b8152600401610805906159b5565b6000838152600860205260409020546132655760405162461bcd60e51b815260040161080590615a15565b61326d611e1a565b6001600160a01b0316632528f0fe846040518263ffffffff1660e01b81526004016132989190615821565b60206040518083038186803b1580156132b057600080fd5b505afa1580156132c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506132e89190810190614d35565b156133055760405162461bcd60e51b815260040161080590615965565b600b548510156133275760405162461bcd60e51b815260040161080590615955565b600d5460055460405163382dab6f60e21b81526001600160a01b039091169063e0b6adbc9061335a90339060040161577a565b60206040518083038186803b15801561337257600080fd5b505afa158015613386573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506133aa9190810190614e2e565b106133c75760405162461bcd60e51b815260040161080590615935565b6000806133d26146c2565b6001600160a01b031663b4d6cb4087876040518363ffffffff1660e01b81526004016133ff92919061583d565b604080518083038186803b15801561341657600080fd5b505afa15801561342a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061344e9190810190614d53565b9150915081801561345d575080155b6134795760405162461bcd60e51b815260040161080590615a35565b61348387866110f1565b8611156134a25760405162461bcd60e51b8152600401610805906159e5565b60006134b9600c548861489c90919063ffffffff16565b905060006134cd888363ffffffff61318c16565b90506134d76146c2565b6001600160a01b031663b3b467326040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561351157600080fd5b505af1158015613525573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506135499190810190614e2e565b945061355361495e565b604051806101200160405280878152602001336001600160a01b031681526020018b81526020018981526020018a8152602001881515815260200160008152602001600081526020014281525090506135ab81613a5f565b60055460405163170cc48160e21b81529192506001600160a01b031690635c331204906135dc908490600401615a75565b600060405180830381600087803b1580156135f657600080fd5b505af115801561360a573d6000803e3d6000fd5b5050505061361883896146d1565b861561380e57613626611d51565b6001600160a01b031663867904b43361363d611e1a565b6001600160a01b031663654a60ac8c87631c1554d160e21b6040518463ffffffff1660e01b81526004016136739392919061586b565b60206040518083038186803b15801561368b57600080fd5b505afa15801561369f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506136c39190810190614e2e565b6040518363ffffffff1660e01b81526004016136e09291906157cb565b600060405180830381600087803b1580156136fa57600080fd5b505af115801561370e573d6000803e3d6000fd5b5050505061371a6146c2565b6001600160a01b031663e31f27c1898b6040518363ffffffff1660e01b815260040161374792919061583d565b600060405180830381600087803b15801561376157600080fd5b505af1158015613775573d6000803e3d6000fd5b5050506000898152600960205260409020546001600160a01b0316159050613809576000888152600960205260409081902054905163db454a5160e01b81526001600160a01b039091169063db454a51906137d69033908d906004016157cb565b600060405180830381600087803b1580156137f057600080fd5b505af1158015613804573d6000803e3d6000fd5b505050505b6138ed565b60008881526008602052604090205461382690614607565b6001600160a01b031663867904b433846040518363ffffffff1660e01b81526004016138539291906157cb565b600060405180830381600087803b15801561386d57600080fd5b505af1158015613881573d6000803e3d6000fd5b5050505061388d6146c2565b6001600160a01b031663eb94bbde898b6040518363ffffffff1660e01b81526004016138ba92919061583d565b600060405180830381600087803b1580156138d457600080fd5b505af11580156138e8573d6000803e3d6000fd5b505050505b336001600160a01b03167f604952b18be5fed608cbdd28101dc57bd667055c9678ec6d44fb1d8e4c7c172a878b8d8c8860405161392e959493929190615ac2565b60405180910390a25050505050949350505050565b61394b611e1a565b6001600160a01b0316632528f0fe6004546040518263ffffffff1660e01b81526004016139789190615821565b60206040518083038186803b15801561399057600080fd5b505afa1580156139a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506139c89190810190614d35565b156123825760405162461bcd60e51b8152600401610805906159d5565b6000611d686b53797374656d53746174757360a01b61460e565b60008160e0015111613a235760405162461bcd60e51b815260040161080590615a45565b42613a3e600e54836101000151611e3590919063ffffffff16565b1115613a5c5760405162461bcd60e51b815260040161080590615905565b50565b613a6761495e565b8190506000806000808560a00151613b0557613a816146c2565b6001600160a01b03166303f048b08760e001516040518263ffffffff1660e01b8152600401613ab09190615821565b60806040518083038186803b158015613ac857600080fd5b505afa158015613adc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613b009190810190614e8c565b613b92565b613b0d6146c2565b6001600160a01b031663af07aa9d87606001518860e001516040518363ffffffff1660e01b8152600401613b4292919061583d565b60806040518083038186803b158015613b5a57600080fd5b505afa158015613b6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613b929190810190614e8c565b93509350935093506000808760a00151613c2257613bae6146c2565b6001600160a01b031663ba1c5e806040518163ffffffff1660e01b8152600401604080518083038186803b158015613be557600080fd5b505afa158015613bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613c1d9190810190614e4c565b613cba565b613c2a6146c2565b606089015160009081526008602052604090819020549051630ee81f7960e41b81526001600160a01b03929092169163ee81f79091613c6b91600401615821565b604080518083038186803b158015613c8257600080fd5b505afa158015613c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613cba9190810190614e4c565b915091508015613cdc5760405162461bcd60e51b8152600401610805906159a5565b6000613d79736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b158015613d2557600080fd5b505af4158015613d39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613d5d9190810190614e2e565b613d6d428863ffffffff61318c16565b9063ffffffff61468816565b90506000613d9d613d90858463ffffffff611e6316565b889063ffffffff611e3516565b905060008a60e00151600014613dd657613dd1613dc0838b63ffffffff61318c16565b60808d01519063ffffffff611e6316565b613dd9565b60005b90508a60a00151613e4e57613dec6146c2565b6001600160a01b031663f53037b6836040518263ffffffff1660e01b8152600401613e179190615821565b600060405180830381600087803b158015613e3157600080fd5b505af1158015613e45573d6000803e3d6000fd5b50505050613eba565b613e566146c2565b6001600160a01b031663246206398c60600151846040518363ffffffff1660e01b8152600401613e8792919061583d565b600060405180830381600087803b158015613ea157600080fd5b505af1158015613eb5573d6000803e3d6000fd5b505050505b60c08b0151613ecf908263ffffffff611e3516565b60c08b015260e08a01869052600554604051631137390760e21b81526001600160a01b03909116906344dce41c90613f0b908d90600401615a75565b600060405180830381600087803b158015613f2557600080fd5b505af1158015613f39573d6000803e3d6000fd5b50505050505050505050505050919050565b6000828152600860205260409020548190613f6590614607565b6001600160a01b03166370a08231856040518263ffffffff1660e01b8152600401613f90919061576c565b60206040518083038186803b158015613fa857600080fd5b505afa158015613fbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613fe09190810190614e2e565b101561075e5760405162461bcd60e51b815260040161080590615a55565b60008061401c8360c001518460800151611e3590919063ffffffff16565b6080840151604085015193509091506140336145f0565b6001600160a01b031663d6f32e068686606001516040518363ffffffff1660e01b81526004016140649291906157f4565b60206040518083038186803b15801561407c57600080fd5b505afa158015614090573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506140b49190810190614d35565b156140d15760405162461bcd60e51b815260040161080590615a65565b60608401516000908152600860205260409020546140ee90614607565b6001600160a01b0316639dc29fac86846040518363ffffffff1660e01b815260040161411b9291906157f4565b600060405180830381600087803b15801561413557600080fd5b505af1158015614149573d6000803e3d6000fd5b505050508360a00151156142675761415f6146c2565b6001600160a01b0316635246f2b9856060015186608001516040518363ffffffff1660e01b815260040161419492919061583d565b600060405180830381600087803b1580156141ae57600080fd5b505af11580156141c2573d6000803e3d6000fd5b5050505060608401516000908152600960205260409020546001600160a01b03161561426257606084015160009081526009602052604090819020546080860151915163f3fef3a360e01b81526001600160a01b039091169163f3fef3a39161422f918a916004016157f4565b600060405180830381600087803b15801561424957600080fd5b505af115801561425d573d6000803e3d6000fd5b505050505b6142d7565b61426f6146c2565b6001600160a01b031663e50a31b3856060015186608001516040518363ffffffff1660e01b81526004016142a492919061583d565b600060405180830381600087803b1580156142be57600080fd5b505af11580156142d2573d6000803e3d6000fd5b505050505b6142e98460c0015185606001516146d1565b600060808501819052604080860182905260c0860182905260e0860191909152426101008601526005549051631137390760e21b81526001600160a01b03909116906344dce41c9061433f908790600401615a75565b600060405180830381600087803b15801561435957600080fd5b505af115801561436d573d6000803e3d6000fd5b50505050846001600160a01b0316866001600160a01b03167f697721ed1b9d4866cb1aaa0692f62bb3abc1b01c2dafeaad053ffd4532aa7dbb866000015184876040516143bc9392919061586b565b60405180910390a350509392505050565b6143d561495e565b508181158015906143ea575060008360c00151115b156144475760008360c0015183116144025782614408565b8360c001515b60c0850151909150614420908263ffffffff61318c16565b60c0830152614435838263ffffffff61318c16565b92506144458185606001516146d1565b505b8115611e5d576080830151614462908363ffffffff61318c16565b608082015260a08101511561457f576144796146c2565b6001600160a01b0316635246f2b98260600151846040518363ffffffff1660e01b81526004016144aa92919061583d565b600060405180830381600087803b1580156144c457600080fd5b505af11580156144d8573d6000803e3d6000fd5b5050505060608101516000908152600960205260409020546001600160a01b03161561457a5760608101516000908152600960209081526040918290205490830151915163f3fef3a360e01b81526001600160a01b039091169163f3fef3a391614547919086906004016157cb565b600060405180830381600087803b15801561456157600080fd5b505af1158015614575573d6000803e3d6000fd5b505050505b611e5d565b6145876146c2565b6001600160a01b031663e50a31b38260600151846040518363ffffffff1660e01b81526004016145b892919061583d565b600060405180830381600087803b1580156145d257600080fd5b505af11580156145e6573d6000803e3d6000fd5b5050505092915050565b6000611d686822bc31b430b733b2b960b91b61460e565b6000611e5d825b60008181526003602090815260408083205490516001600160a01b03909116918215159161463e91869101615741565b604051602081830303815290604052906129145760405162461bcd60e51b81526004016108059190615894565b6000611d686e466c657869626c6553746f7261676560881b61460e565b60008261469757506000611e5d565b828202828482816146a457fe5b0414611e5a5760405162461bcd60e51b815260040161080590615a05565b6006546001600160a01b031690565b8115610ec957631c1554d160e21b8114614776576146ed611e1a565b6001600160a01b031663654a60ac8284631c1554d160e21b6040518463ffffffff1660e01b81526004016147239392919061586b565b60206040518083038186803b15801561473b57600080fd5b505afa15801561474f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506147739190810190614e2e565b91505b61477e611d51565b6001600160a01b031663867904b46147946148e6565b6001600160a01b031663eb1edd616040518163ffffffff1660e01b815260040160206040518083038186803b1580156147cc57600080fd5b505afa1580156147e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506148049190810190614c02565b846040518363ffffffff1660e01b81526004016148229291906157f4565b600060405180830381600087803b15801561483c57600080fd5b505af1158015614850573d6000803e3d6000fd5b5050505061485c6148e6565b6001600160a01b03166322bf55ef836040518263ffffffff1660e01b8152600401610e969190615821565b60006111938383670de0b6b3a76400006148fb565b60006111938383670de0b6b3a7640000614933565b60008082116148d25760405162461bcd60e51b815260040161080590615995565b60008284816148dd57fe5b04949350505050565b6000611d6866119959541bdbdb60ca1b61460e565b6000806149158461318087600a870263ffffffff61468816565b90506005600a825b061061492757600a015b600a9004949350505050565b600080600a830461494a868663ffffffff61468816565b8161495157fe5b0490506005600a8261491d565b6040518061012001604052806000815260200160006001600160a01b031681526020016000815260200160008019168152602001600081526020016000151581526020016000815260200160008152602001600081525090565b8035611e5d81615bb1565b8051611e5d81615bb1565b60008083601f8401126149e057600080fd5b50813567ffffffffffffffff8111156149f857600080fd5b602083019150836020820283011115614a1057600080fd5b9250929050565b8035611e5d81615bc5565b8051611e5d81615bc5565b8035611e5d81615bce565b8051611e5d81615bce565b60006101208284031215614a5657600080fd5b614a61610120615b0e565b90506000614a6f8484614a2d565b8252506020614a80848483016149b8565b6020830152506040614a9484828501614a2d565b6040830152506060614aa884828501614a2d565b6060830152506080614abc84828501614a2d565b60808301525060a0614ad084828501614a17565b60a08301525060c0614ae484828501614a2d565b60c08301525060e0614af884828501614a2d565b60e083015250610100614b0d84828501614a2d565b6101008301525092915050565b60006101208284031215614b2d57600080fd5b614b38610120615b0e565b90506000614b468484614a38565b8252506020614b57848483016149c3565b6020830152506040614b6b84828501614a38565b6040830152506060614b7f84828501614a38565b6060830152506080614b9384828501614a38565b60808301525060a0614ba784828501614a22565b60a08301525060c0614bbb84828501614a38565b60c08301525060e0614bcf84828501614a38565b60e083015250610100614b0d84828501614a38565b600060208284031215614bf657600080fd5b60006106c184846149b8565b600060208284031215614c1457600080fd5b60006106c184846149c3565b60008060408385031215614c3357600080fd5b6000614c3f85856149b8565b9250506020614c5085828601614a2d565b9150509250929050565b600080600060608486031215614c6f57600080fd5b6000614c7b86866149b8565b9350506020614c8c86828701614a2d565b9250506040614c9d86828701614a2d565b9150509250925092565b60008060008060408587031215614cbd57600080fd5b843567ffffffffffffffff811115614cd457600080fd5b614ce0878288016149ce565b9450945050602085013567ffffffffffffffff811115614cff57600080fd5b614d0b878288016149ce565b95989497509550505050565b600060208284031215614d2957600080fd5b60006106c18484614a17565b600060208284031215614d4757600080fd5b60006106c18484614a22565b60008060408385031215614d6657600080fd5b6000614d728585614a22565b9250506020614c5085828601614a22565b600060208284031215614d9557600080fd5b60006106c18484614a2d565b60008060408385031215614db457600080fd5b6000614dc08585614a2d565b9250506020614c50858286016149b8565b60008060408385031215614de457600080fd5b6000614c3f8585614a2d565b60006101208284031215614e0357600080fd5b60006106c18484614a43565b60006101208284031215614e2257600080fd5b60006106c18484614b1a565b600060208284031215614e4057600080fd5b60006106c18484614a38565b60008060408385031215614e5f57600080fd5b6000614d728585614a38565b600080600060608486031215614e8057600080fd5b6000614c7b8686614a2d565b60008060008060808587031215614ea257600080fd5b6000614eae8787614a38565b9450506020614ebf87828801614a38565b9350506040614ed087828801614a38565b9250506060614ee187828801614a38565b91505092959194509250565b6000614ef98383614f7b565b505060200190565b614f0a81615b69565b82525050565b614f0a81615b4d565b6000614f2482615b3b565b614f2e8185615b3f565b9350614f3983615b35565b8060005b83811015614f67578151614f518882614eed565b9750614f5c83615b35565b925050600101614f3d565b509495945050505050565b614f0a81615b58565b614f0a81610bb7565b614f0a614f9082610bb7565b610bb7565b614f0a81615b70565b6000614fa982615b3b565b614fb38185615b3f565b9350614fc3818560208601615b7b565b614fcc81615ba7565b9093019392505050565b6000614fe3601b83615b3f565b7f496e707574206172726179206c656e677468206d69736d617463680000000000815260200192915050565b600061501c601683615b3f565b754d7573742062652067726561746572207468616e203160501b815260200192915050565b600061504e600e83615b3f565b6d43726174696f20746f6f206c6f7760901b815260200192915050565b6000615078601583615b3f565b74086c2dcdcdee840c8e4c2ee40e8d0d2e640daeac6d605b1b815260200192915050565b60006150a9603583615b3f565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000615100601983615b3f565b7f416c6c6f77616e6365206e6f74206869676820656e6f75676800000000000000815260200192915050565b6000615139601d83615b3f565b7f4c6f616e20726563656e746c7920696e74657261637465642077697468000000815260200192915050565b6000615172601e83615b3f565b7f5061796d656e74206d7573742062652067726561746572207468616e20300000815260200192915050565b60006151ab601b83615b3f565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b60006151e4601283615b3f565b7113585e081b1bd85b9cc8195e18d95959195960721b815260200192915050565b6000615212601e83615b3f565b7f43726174696f2061626f7665206c69717569646174696f6e20726174696f0000815260200192915050565b600061524b601d83615b3f565b7f4e6f7420656e6f75676820636f6c6c61746572616c20746f206f70656e000000815260200192915050565b6000615284601883615b3f565b7f43757272656e6379207261746520697320696e76616c69640000000000000000815260200192915050565b60006152bd602083615b3f565b7f57616974696e672073656373206f7220736574746c656d656e74206f77696e67815260200192915050565b60006152f6601e83615b3f565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b600061532f601a83615b3f565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b6000615368601183615b48565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b6000615395601183615b3f565b7014985d195cc8185c99481a5b9d985b1a59607a1b815260200192915050565b60006153c2601383615b3f565b7213dc195b9a5b99c81a5cc8191a5cd8589b1959606a1b815260200192915050565b60006153f1600a83615b3f565b6926b0bc1018903437bab960b11b815260200192915050565b6000615417601a83615b3f565b7f436f6c6c61746572616c207261746520697320696e76616c6964000000000000815260200192915050565b6000615450601b83615b3f565b7f45786365656473206d617820626f72726f77696e6720706f7765720000000000815260200192915050565b6000615489602f83615b3f565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b60006154da602183615b3f565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b600061551d601f83615b3f565b7f4e6f7420616c6c6f77656420746f20697373756520746869732070796e746800815260200192915050565b6000615556601e83615b3f565b7f4465706f736974206d7573742062652067726561746572207468616e20300000815260200192915050565b600061558f601a83615b3f565b7f44656274206c696d6974206f7220696e76616c69642072617465000000000000815260200192915050565b60006155c8601983615b48565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b6000615601601383615b3f565b72131bd85b88191bd95cc81b9bdd08195e1a5cdd606a1b815260200192915050565b6000615630601883615b3f565b7f4e6f7420656e6f7567682070796e74682062616c616e63650000000000000000815260200192915050565b6000615669601b83615b3f565b7f57616974696e67206f7220736574746c656d656e74206f77696e670000000000815260200192915050565b80516101208301906156a78482614f7b565b5060208201516156ba6020850182614f10565b5060408201516156cd6040850182614f7b565b5060608201516156e06060850182614f7b565b5060808201516156f36080850182614f7b565b5060a082015161570660a0850182614f72565b5060c082015161571960c0850182614f7b565b5060e082015161572c60e0850182614f7b565b50610100820151610c7c610100850182614f7b565b600061574c8261535b565b91506157588284614f84565b50602001919050565b600061574c826155bb565b60208101611e5d8284614f10565b60208101611e5d8284614f01565b604081016157968285614f01565b6111936020830184614f10565b606081016157b18286614f01565b6157be6020830185614f10565b6106c16040830184614f7b565b604081016157d98285614f01565b6111936020830184614f7b565b604081016157968285614f10565b604081016157d98285614f10565b602080825281016111938184614f19565b60208101611e5d8284614f72565b60208101611e5d8284614f7b565b604081016157968285614f7b565b604081016157d98285614f7b565b604081016158598285614f7b565b81810360208301526106c18184614f9e565b606081016158798286614f7b565b6157be6020830185614f7b565b60208101611e5d8284614f95565b602080825281016111938184614f9e565b60208082528101611e5d81614fd6565b60208082528101611e5d8161500f565b60208082528101611e5d81615041565b60208082528101611e5d8161506b565b60208082528101611e5d8161509c565b60208082528101611e5d816150f3565b60208082528101611e5d8161512c565b60208082528101611e5d81615165565b60208082528101611e5d8161519e565b60208082528101611e5d816151d7565b60208082528101611e5d81615205565b60208082528101611e5d8161523e565b60208082528101611e5d81615277565b60208082528101611e5d816152b0565b60208082528101611e5d816152e9565b60208082528101611e5d81615322565b60208082528101611e5d81615388565b60208082528101611e5d816153b5565b60208082528101611e5d816153e4565b60208082528101611e5d8161540a565b60208082528101611e5d81615443565b60208082528101611e5d8161547c565b60208082528101611e5d816154cd565b60208082528101611e5d81615510565b60208082528101611e5d81615549565b60208082528101611e5d81615582565b60208082528101611e5d816155f4565b60208082528101611e5d81615623565b60208082528101611e5d8161565c565b6101208101611e5d8284615695565b60808101615a928287614f7b565b615a9f6020830186614f01565b615aac6040830185614f7b565b615ab96060830184614f7b565b95945050505050565b60a08101615ad08288614f7b565b615add6020830187614f7b565b615aea6040830186614f7b565b615af76060830185614f7b565b615b046080830184614f7b565b9695505050505050565b60405181810167ffffffffffffffff81118282101715615b2d57600080fd5b604052919050565b60200190565b5190565b90815260200190565b919050565b6000611e5d82615b5d565b151590565b6001600160a01b031690565b6000611e5d825b6000611e5d82615b4d565b60005b83811015615b96578181015183820152602001615b7e565b83811115610c7c5750506000910152565b601f01601f191690565b615bba81615b4d565b8114613a5c57600080fd5b615bba81615b58565b615bba81610bb756fea365627a7a72315820dac7714ef2ab70337423ed3c553ca7094d75c689995b757354be01dc503d16a66c6578706572696d656e74616cf564736f6c6343000510004000000000000000000000000062d0a4428f97fd398840dcd1c321f757430983ee000000000000000000000000918153d6e806df9d4d33664d1cc580416171f7200000000000000000000000005d20d931cc3b02195d2484b7fd80bbb4d14d2a9f0000000000000000000000007015cd1e78ba1428d103b0c2513077b2826b64fc705553440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010a741a46278000000000000000000000000000000000000000000000000003635c9adc5dea00000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102485760003560e01c8063741853601161013b578063ba2de9bc116100b8578063dac8cf681161007c578063dac8cf681461048d578063de81eda9146104a0578063e74337c6146104b3578063eb8e3b65146104c6578063f93451ed146104ce57610248565b8063ba2de9bc14610444578063c19d93fb1461044c578063cd28502014610454578063d0ebdbe714610467578063d2b8035a1461047a57610248565b80638da5cb5b116100ff5780638da5cb5b1461040657806390abb4d91461040e578063925ead1114610421578063a76cdfa514610429578063b562a1ab1461043c57610248565b806374185360146103bb57806379ba5097146103c35780637e132355146103cb578063899ffef4146103de5780638cd2e0c7146103f357610248565b8063361e2086116101c95780634c17ace41161018d5780634c17ace41461036757806353a47bb71461037a57806355bd615c1461038257806356dc04a1146103955780635eb2ad01146103a857610248565b8063361e20861461031c57806337551ec6146103245780634065b81b14610337578063441a3e701461033f578063481c6a751461035257610248565b80630e54a19b116102105780630e54a19b146102c65780630efe6a8b146102e657806315aaf4dd146102f95780631627540c146103015780632af64bd31461031457610248565b806304f3bcec1461024d5780630710285c1461026b5780630a153c97146102805780630aebeb4e146102a05780630cdd1c65146102b3575b600080fd5b6102556104e1565b6040516102629190615886565b60405180910390f35b61027e610279366004614c5a565b6104f0565b005b61029361028e366004614dd1565b61058d565b6040516102629190615821565b61027e6102ae366004614d83565b6106c9565b61027e6102c1366004614d83565b610763565b6102d96102d4366004614ca7565b61084e565b6040516102629190615813565b61027e6102f4366004614c5a565b610910565b610293610a49565b61027e61030f366004614be4565b610a4f565b6102d9610aa2565b610293610bba565b610293610332366004614d83565b610bc0565b6102d9610bde565b61027e61034d366004614dd1565b610be7565b61035a610c82565b604051610262919061576c565b61027e610375366004614d83565b610c91565b61035a610d6d565b61027e610390366004614ca7565b610d7c565b61027e6103a3366004614da1565b610e3c565b61027e6103b6366004614c20565b610ecd565b61027e610f03565b61027e611055565b6102936103d9366004614dd1565b6110f1565b6103e661119a565b6040516102629190615802565b61027e610401366004614c5a565b6112ff565b61035a61130b565b61027e61041c366004614d17565b61131a565b610293611366565b61027e610437366004614d83565b61136c565b6102936113a9565b6102936113af565b6102556113b5565b610293610462366004614d83565b6113c4565b61027e610475366004614be4565b6113d6565b61027e610488366004614dd1565b61142f565b61029361049b366004614df0565b611439565b61035a6104ae366004614d83565b611592565b6102936104c1366004614df0565b6115ad565b610293611897565b61027e6104dc366004614e6b565b61189d565b6002546001600160a01b031681565b60006104fd848484611986565b9050610507611d51565b6001600160a01b031663a9059cbb33836040518363ffffffff1660e01b81526004016105349291906157cb565b602060405180830381600087803b15801561054e57600080fd5b505af1158015610562573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105869190810190614d35565b5050505050565b600080610598611d6d565b90506105a2611e1a565b6001600160a01b031663654a60ac85856004546040518463ffffffff1660e01b81526004016105d39392919061586b565b60206040518083038186803b1580156105eb57600080fd5b505afa1580156105ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106239190810190614e2e565b91506106c16106b482736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561067057600080fd5b505af4158015610684573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106a89190810190614e2e565b9063ffffffff611e3516565b839063ffffffff611e6316565b949350505050565b60006106d53383611e8d565b90506106df611d51565b6001600160a01b031663a9059cbb33836040518363ffffffff1660e01b815260040161070c9291906157cb565b602060405180830381600087803b15801561072657600080fd5b505af115801561073a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061075e9190810190614d35565b505050565b61076b612358565b736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156107af57600080fd5b505af41580156107c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107e79190810190614e2e565b811161080e5760405162461bcd60e51b8152600401610805906158b5565b60405180910390fd5b600a8190556040517f813a44586e8ecb9390b2568dbe810e193087f80e415c8845340ef06d4cbb42a590610843908390615821565b60405180910390a150565b6007546000908414610862575060006106c1565b60005b8481101561090457600086868381811061087b57fe5b905060200201359050806007838154811061089257fe5b9060005260206000200154146108ad576000925050506106c1565b600782815481106108ba57fe5b9060005260206000200154600860008787868181106108d557fe5b90506020020135815260200190815260200160002054146108fb576000925050506106c1565b50600101610865565b50600195945050505050565b610918611d51565b6001600160a01b031663dd62ed3e33306040518363ffffffff1660e01b8152600401610945929190615788565b60206040518083038186803b15801561095d57600080fd5b505afa158015610971573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109959190810190614e2e565b8111156109b45760405162461bcd60e51b8152600401610805906158f5565b6109bc611d51565b6001600160a01b03166323b872dd3330846040518463ffffffff1660e01b81526004016109eb939291906157a3565b602060405180830381600087803b158015610a0557600080fd5b505af1158015610a19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a3d9190810190614d35565b5061075e838383612384565b600e5481565b610a57612358565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229061084390839061576c565b60006060610aae61119a565b905060005b8151811015610bb0576000828281518110610aca57fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a72190610b1b908590600401615821565b60206040518083038186803b158015610b3357600080fd5b505afa158015610b47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b6b9190810190614c02565b6001600160a01b0316141580610b9657506000818152600360205260409020546001600160a01b0316155b15610ba75760009350505050610bb7565b50600101610ab3565b5060019150505b90565b600c5481565b60078181548110610bcd57fe5b600091825260209091200154905081565b600f5460ff1681565b6000610bf3838361257b565b9050610bfd611d51565b6001600160a01b031663a9059cbb33836040518363ffffffff1660e01b8152600401610c2a9291906157cb565b602060405180830381600087803b158015610c4457600080fd5b505af1158015610c58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c7c9190810190614d35565b50505050565b6006546001600160a01b031681565b610c99612358565b736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b158015610cdd57600080fd5b505af4158015610cf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d159190810190614e2e565b610e1002811115610d385760405162461bcd60e51b8152600401610805906159c5565b600e8190556040517f4d71c92b0a9dc236066597b95637bb04d58cd135e9165aee13eb68e3199c236190610843908390615821565b6001546001600160a01b031681565b610d84612358565b828114610da35760405162461bcd60e51b8152600401610805906158a5565b60005b83811015610e33576000858583818110610dbc57fe5b600780546001810182556000918252602090920293909301357fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6889091018190559250829160089150868686818110610e1057fe5b602090810292909201358352508101919091526040016000205550600101610da6565b50610c7c610f03565b6000828152600960205260409020546001600160a01b031615610ec95760008281526009602052604090819020549051630c00007b60e41b81526001600160a01b039091169063c00007b090610e9690849060040161576c565b600060405180830381600087803b158015610eb057600080fd5b505af1158015610ec4573d6000803e3d6000fd5b505050505b5050565b610ed5612358565b600090815260096020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b6060610f0d61119a565b905060005b8151811015610ec9576000828281518110610f2957fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d018384604051602001610f6b9190615761565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610f9792919061584b565b60206040518083038186803b158015610faf57600080fd5b505afa158015610fc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610fe79190810190614c02565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890611043908490849061582f565b60405180910390a15050600101610f12565b6001546001600160a01b0316331461107f5760405162461bcd60e51b8152600401610805906158e5565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c926110c2926001600160a01b03918216929116906157e6565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b60006111936110fe611e1a565b6001600160a01b031663654a60ac60045486866040518463ffffffff1660e01b815260040161112f9392919061586b565b60206040518083038186803b15801561114757600080fd5b505afa15801561115b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061117f9190810190614e2e565b61118761277e565b9063ffffffff611e6316565b9392505050565b6060806111a561280e565b60408051600580825260c08201909252919250606091906020820160a08038833901905050905066119959541bdbdb60ca1b816000815181106111e457fe5b6020026020010181815250506c45786368616e6765526174657360981b8160018151811061120e57fe5b6020026020010181815250506822bc31b430b733b2b960b91b8160028151811061123457fe5b6020026020010181815250506b53797374656d53746174757360a01b8160038151811061125d57fe5b60200260200101818152505068141e5b9d1a1c1554d160ba1b8160048151811061128357fe5b602002602001018181525050606061129b838361285f565b90506112f78160078054806020026020016040519081016040528092919081815260200182805480156112ed57602002820191906000526020600020905b8154815260200190600101908083116112d9575b505050505061285f565b935050505090565b61075e8333848461291b565b6000546001600160a01b031681565b611322612358565b600f805460ff191682151517908190556040517f261991749e1b2436706a31bde8bf184bb37fe21e303709b78d3b881afacadaa2916108439160ff90911690615813565b600a5481565b611374612358565b600c8190556040517fe7bd72551c54d568cd97b00dc52d2787b5c5d4f0070d3582c1e8ba25141f799c90610843908390615821565b60045481565b600b5481565b6005546001600160a01b031681565b60086020526000908152604090205481565b6113de612358565b600680546001600160a01b0319166001600160a01b0383811691909117918290556040517f2c1c11af44aa5608f1dca38c00275c30ea091e02417d36e70e9a1538689c433d9261084392169061576c565b610ec98282612c3c565b600080611444611e1a565b6001600160a01b031663654a60ac6004548560400151631c1554d160e21b6040518463ffffffff1660e01b81526004016114809392919061586b565b60206040518083038186803b15801561149857600080fd5b505afa1580156114ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114d09190810190614e2e565b905060006114dc611e1a565b6001600160a01b031663654a60ac856060015161150a8760c001518860800151611e3590919063ffffffff16565b631c1554d160e21b6040518463ffffffff1660e01b81526004016115309392919061586b565b60206040518083038186803b15801561154857600080fd5b505afa15801561155c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115809190810190614e2e565b90506106c1828263ffffffff61316216565b6009602052600090815260409020546001600160a01b031681565b6000806115b8611d6d565b905060006115c4611e1a565b6001600160a01b031663654a60ac85606001516115f28760c001518860800151611e3590919063ffffffff16565b631c1554d160e21b6040518463ffffffff1660e01b81526004016116189392919061586b565b60206040518083038186803b15801561163057600080fd5b505afa158015611644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116689190810190614e2e565b90506000611674611e1a565b6001600160a01b031663654a60ac6004548760400151631c1554d160e21b6040518463ffffffff1660e01b81526004016116b09392919061586b565b60206040518083038186803b1580156116c857600080fd5b505afa1580156116dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117009190810190614e2e565b90506000736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561174857600080fd5b505af415801561175c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117809190810190614e2e565b905060006117a961179c600a548561316290919063ffffffff16565b859063ffffffff61318c16565b905060006117e26117d5600a546117c98987611e3590919063ffffffff16565b9063ffffffff61316216565b849063ffffffff61318c16565b905060006117f6838363ffffffff61316216565b9050611800611e1a565b6001600160a01b031663654a60ac631c1554d160e21b838c606001516040518463ffffffff1660e01b815260040161183a9392919061586b565b60206040518083038186803b15801561185257600080fd5b505afa158015611866573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061188a9190810190614e2e565b9998505050505050505050565b600d5481565b6118a5611d51565b6001600160a01b031663dd62ed3e33306040518363ffffffff1660e01b81526004016118d2929190615788565b60206040518083038186803b1580156118ea57600080fd5b505afa1580156118fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506119229190810190614e2e565b8311156119415760405162461bcd60e51b8152600401610805906158f5565b61194e83838360016131b4565b50611957611d51565b6001600160a01b03166323b872dd3330866040518463ffffffff1660e01b8152600401610c2a939291906157a3565b6000611990613943565b6119986139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156119d057600080fd5b505afa1580156119e4573d6000803e3d6000fd5b5050505060008211611a085760405162461bcd60e51b815260040161080590615915565b611a1061495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c5158690611a4290889088906004016157f4565b6101206040518083038186803b158015611a5b57600080fd5b505afa158015611a6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a939190810190614e0f565b9050611a9e816139ff565b611aa781613a5f565b9050611ab833826060015185613f4b565b600a54611ac482611439565b10611ae15760405162461bcd60e51b815260040161080590615945565b6000611aec826115ad565b90506000848210611afd5784611aff565b815b90506000611b1e8460c001518560800151611e3590919063ffffffff16565b9050808210611b3d57611b32883386613ffe565b945050505050611193565b611b4784836143cd565b9350611b5784606001518361058d565b6040850151909550611b6f908663ffffffff61318c16565b604085015242610100850152611b836145f0565b6001600160a01b031663d6f32e063386606001516040518363ffffffff1660e01b8152600401611bb49291906157cb565b60206040518083038186803b158015611bcc57600080fd5b505afa158015611be0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611c049190810190614d35565b15611c215760405162461bcd60e51b815260040161080590615a65565b6060840151600090815260086020526040902054611c3e90614607565b6001600160a01b0316639dc29fac33846040518363ffffffff1660e01b8152600401611c6b9291906157cb565b600060405180830381600087803b158015611c8557600080fd5b505af1158015611c99573d6000803e3d6000fd5b5050600554604051631137390760e21b81526001600160a01b0390911692506344dce41c9150611ccd908790600401615a75565b600060405180830381600087803b158015611ce757600080fd5b505af1158015611cfb573d6000803e3d6000fd5b50505050876001600160a01b03167fb6e43890aeea54fbe6c0ed628e78172a0ff30bbcb1d70d8b130b12c366bac4c588338589604051611d3e9493929190615a84565b60405180910390a2505050509392505050565b6000611d6868141e5b9d1a1c1554d160ba1b61460e565b905090565b6000611d7761466b565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b716c69717569646174696f6e50656e616c747960701b6040518363ffffffff1660e01b8152600401611dca92919061583d565b60206040518083038186803b158015611de257600080fd5b505afa158015611df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611d689190810190614e2e565b6000611d686c45786368616e6765526174657360981b61460e565b600082820183811015611e5a5760405162461bcd60e51b815260040161080590615925565b90505b92915050565b6000670de0b6b3a7640000611e7e848463ffffffff61468816565b81611e8557fe5b049392505050565b6000611e97613943565b611e9f6139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b158015611ed757600080fd5b505afa158015611eeb573d6000803e3d6000fd5b50505050611ef761495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c5158690611f2990879087906004016157f4565b6101206040518083038186803b158015611f4257600080fd5b505afa158015611f56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f7a9190810190614e0f565b9050611f85816139ff565b611f8e81613a5f565b90506000611fad8260c001518360800151611e3590919063ffffffff16565b9050611fc28260200151836060015183613f4b565b611fca6145f0565b6001600160a01b031663d6f32e068684606001516040518363ffffffff1660e01b8152600401611ffb9291906157f4565b60206040518083038186803b15801561201357600080fd5b505afa158015612027573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061204b9190810190614d35565b156120685760405162461bcd60e51b815260040161080590615975565b606082015160009081526008602052604090205461208590614607565b6001600160a01b0316639dc29fac86836040518363ffffffff1660e01b81526004016120b29291906157f4565b600060405180830381600087803b1580156120cc57600080fd5b505af11580156120e0573d6000803e3d6000fd5b505050508160a00151156121fe576120f66146c2565b6001600160a01b0316635246f2b9836060015184608001516040518363ffffffff1660e01b815260040161212b92919061583d565b600060405180830381600087803b15801561214557600080fd5b505af1158015612159573d6000803e3d6000fd5b5050505060608201516000908152600960205260409020546001600160a01b0316156121f957606082015160009081526009602052604090819020546080840151915163f3fef3a360e01b81526001600160a01b039091169163f3fef3a3916121c69189916004016157f4565b600060405180830381600087803b1580156121e057600080fd5b505af11580156121f4573d6000803e3d6000fd5b505050505b61226e565b6122066146c2565b6001600160a01b031663e50a31b3836060015184608001516040518363ffffffff1660e01b815260040161223b92919061583d565b600060405180830381600087803b15801561225557600080fd5b505af1158015612269573d6000803e3d6000fd5b505050505b816040015192506122878260c0015183606001516146d1565b600060808301819052604080840182905260c0840182905260e0840191909152426101008401526005549051631137390760e21b81526001600160a01b03909116906344dce41c906122dd908590600401615a75565b600060405180830381600087803b1580156122f757600080fd5b505af115801561230b573d6000803e3d6000fd5b50505050846001600160a01b03167fcab22a4e95d29d40da2ace3f6ec72b49954a9bc7b2584f8fd47bf7f357a3ed6f856040516123489190615821565b60405180910390a2505092915050565b6000546001600160a01b031633146123825760405162461bcd60e51b8152600401610805906159f5565b565b61238c613943565b6123946139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156123cc57600080fd5b505afa1580156123e0573d6000803e3d6000fd5b50505050600081116124045760405162461bcd60e51b815260040161080590615a25565b61240c61495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c515869061243e90879087906004016157f4565b6101206040518083038186803b15801561245757600080fd5b505afa15801561246b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061248f9190810190614e0f565b905061249a816139ff565b6124a381613a5f565b60408101519091506124bb908363ffffffff611e3516565b604080830191909152426101008301526005549051631137390760e21b81526001600160a01b03909116906344dce41c906124fa908490600401615a75565b600060405180830381600087803b15801561251457600080fd5b505af1158015612528573d6000803e3d6000fd5b50505050836001600160a01b03167f0b1992dffc262be88559dcaf96464e9d661d8bfca7e82f2bb73e31932a82187c8484846040015160405161256d9392919061586b565b60405180910390a250505050565b6000612585613943565b61258d6139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156125c557600080fd5b505afa1580156125d9573d6000803e3d6000fd5b505050506125e561495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c515869061261790339088906004016157cb565b6101206040518083038186803b15801561263057600080fd5b505afa158015612644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506126689190810190614e0f565b9050612673816139ff565b61267c81613a5f565b6040810151909150612694908463ffffffff61318c16565b604082015242610100820152600a546126ac82611439565b116126c95760405162461bcd60e51b8152600401610805906158c5565b600554604051631137390760e21b81526001600160a01b03909116906344dce41c906126f9908490600401615a75565b600060405180830381600087803b15801561271357600080fd5b505af1158015612727573d6000803e3d6000fd5b50505050829150336001600160a01b03167ffae26280bca25d80f1501a9e363c73d3845e651c9aaae54f1fc09a9dcd5f33038585846040015160405161276f9392919061586b565b60405180910390a25092915050565b6000611d68600a54736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156127ca57600080fd5b505af41580156127de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506128029190810190614e2e565b9063ffffffff61488716565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b8160008151811061285057fe5b60200260200101818152505090565b6060815183510160405190808252806020026020018201604052801561288f578160200160208202803883390190505b50905060005b83518110156128d1578381815181106128aa57fe5b60200260200101518282815181106128be57fe5b6020908102919091010152600101612895565b5060005b8251811015612914578281815181106128ea57fe5b602002602001015182828651018151811061290157fe5b60209081029190910101526001016128d5565b5092915050565b612923613943565b61292b6139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b15801561296357600080fd5b505afa158015612977573d6000803e3d6000fd5b505050506000811161299b5760405162461bcd60e51b815260040161080590615915565b6129a361495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c51586906129d590889087906004016157f4565b6101206040518083038186803b1580156129ee57600080fd5b505afa158015612a02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a269190810190614e0f565b9050612a31816139ff565b612a3a81613a5f565b9050612a4b84826060015184613f4b565b612a5581836143cd565b426101008201529050612a666145f0565b6001600160a01b031663d6f32e068583606001516040518363ffffffff1660e01b8152600401612a979291906157f4565b60206040518083038186803b158015612aaf57600080fd5b505afa158015612ac3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612ae79190810190614d35565b15612b045760405162461bcd60e51b815260040161080590615a65565b6060810151600090815260086020526040902054612b2190614607565b6001600160a01b0316639dc29fac85846040518363ffffffff1660e01b8152600401612b4e9291906157f4565b600060405180830381600087803b158015612b6857600080fd5b505af1158015612b7c573d6000803e3d6000fd5b5050600554604051631137390760e21b81526001600160a01b0390911692506344dce41c9150612bb0908490600401615a75565b600060405180830381600087803b158015612bca57600080fd5b505af1158015612bde573d6000803e3d6000fd5b50505050836001600160a01b0316856001600160a01b03167fdf10512219e869922340b1b24b21d7d79bf71f411a6391cc7c3ef5dd2fe89e7f85858560800151604051612c2d9392919061586b565b60405180910390a35050505050565b612c44613943565b612c4c6139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b158015612c8457600080fd5b505afa158015612c98573d6000803e3d6000fd5b50505050612ca461495e565b6005546040516350e28ac360e11b81526001600160a01b039091169063a1c5158690612cd690339087906004016157cb565b6101206040518083038186803b158015612cef57600080fd5b505afa158015612d03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612d279190810190614e0f565b9050612d32816139ff565b612d3b81613a5f565b6080810151909150612d53908363ffffffff611e3516565b6080820152600a54612d6482611439565b11612d815760405162461bcd60e51b8152600401610805906158d5565b6000612d98600c548461489c90919063ffffffff16565b90506000612dac848363ffffffff61318c16565b90508260a0015115612fb957612dc06146c2565b6001600160a01b031663e31f27c18460600151866040518363ffffffff1660e01b8152600401612df192919061583d565b600060405180830381600087803b158015612e0b57600080fd5b505af1158015612e1f573d6000803e3d6000fd5b50505050612e2b611d51565b6001600160a01b031663867904b433612e42611e1a565b6001600160a01b031663654a60ac876060015186631c1554d160e21b6040518463ffffffff1660e01b8152600401612e7c9392919061586b565b60206040518083038186803b158015612e9457600080fd5b505afa158015612ea8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612ecc9190810190614e2e565b6040518363ffffffff1660e01b8152600401612ee99291906157cb565b600060405180830381600087803b158015612f0357600080fd5b505af1158015612f17573d6000803e3d6000fd5b5050505060608301516000908152600960205260409020546001600160a01b031615612fb45760608301516000908152600960205260409081902054905163db454a5160e01b81526001600160a01b039091169063db454a5190612f8190339088906004016157cb565b600060405180830381600087803b158015612f9b57600080fd5b505af1158015612faf573d6000803e3d6000fd5b505050505b6130a1565b612fc16146c2565b6001600160a01b031663eb94bbde8460600151866040518363ffffffff1660e01b8152600401612ff292919061583d565b600060405180830381600087803b15801561300c57600080fd5b505af1158015613020573d6000803e3d6000fd5b50505060608401516000908152600860205260409020546130419150614607565b6001600160a01b031663867904b433836040518363ffffffff1660e01b815260040161306e9291906157cb565b600060405180830381600087803b15801561308857600080fd5b505af115801561309c573d6000803e3d6000fd5b505050505b6130af8284606001516146d1565b42610100840152600554604051631137390760e21b81526001600160a01b03909116906344dce41c906130e6908690600401615a75565b600060405180830381600087803b15801561310057600080fd5b505af1158015613114573d6000803e3d6000fd5b50505050336001600160a01b03167f5754fe57f36ac0f121901d7555aba517e6608590429d86a81c662cf358310654868660405161315392919061583d565b60405180910390a25050505050565b60006111938261318085670de0b6b3a764000063ffffffff61468816565b9063ffffffff6148b116565b6000828211156131ae5760405162461bcd60e51b815260040161080590615985565b50900390565b60006131be613943565b6131c66139e5565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156131fe57600080fd5b505afa158015613212573d6000803e3d6000fd5b5050600f5460ff16915061323a90505760405162461bcd60e51b8152600401610805906159b5565b6000838152600860205260409020546132655760405162461bcd60e51b815260040161080590615a15565b61326d611e1a565b6001600160a01b0316632528f0fe846040518263ffffffff1660e01b81526004016132989190615821565b60206040518083038186803b1580156132b057600080fd5b505afa1580156132c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506132e89190810190614d35565b156133055760405162461bcd60e51b815260040161080590615965565b600b548510156133275760405162461bcd60e51b815260040161080590615955565b600d5460055460405163382dab6f60e21b81526001600160a01b039091169063e0b6adbc9061335a90339060040161577a565b60206040518083038186803b15801561337257600080fd5b505afa158015613386573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506133aa9190810190614e2e565b106133c75760405162461bcd60e51b815260040161080590615935565b6000806133d26146c2565b6001600160a01b031663b4d6cb4087876040518363ffffffff1660e01b81526004016133ff92919061583d565b604080518083038186803b15801561341657600080fd5b505afa15801561342a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061344e9190810190614d53565b9150915081801561345d575080155b6134795760405162461bcd60e51b815260040161080590615a35565b61348387866110f1565b8611156134a25760405162461bcd60e51b8152600401610805906159e5565b60006134b9600c548861489c90919063ffffffff16565b905060006134cd888363ffffffff61318c16565b90506134d76146c2565b6001600160a01b031663b3b467326040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561351157600080fd5b505af1158015613525573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506135499190810190614e2e565b945061355361495e565b604051806101200160405280878152602001336001600160a01b031681526020018b81526020018981526020018a8152602001881515815260200160008152602001600081526020014281525090506135ab81613a5f565b60055460405163170cc48160e21b81529192506001600160a01b031690635c331204906135dc908490600401615a75565b600060405180830381600087803b1580156135f657600080fd5b505af115801561360a573d6000803e3d6000fd5b5050505061361883896146d1565b861561380e57613626611d51565b6001600160a01b031663867904b43361363d611e1a565b6001600160a01b031663654a60ac8c87631c1554d160e21b6040518463ffffffff1660e01b81526004016136739392919061586b565b60206040518083038186803b15801561368b57600080fd5b505afa15801561369f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506136c39190810190614e2e565b6040518363ffffffff1660e01b81526004016136e09291906157cb565b600060405180830381600087803b1580156136fa57600080fd5b505af115801561370e573d6000803e3d6000fd5b5050505061371a6146c2565b6001600160a01b031663e31f27c1898b6040518363ffffffff1660e01b815260040161374792919061583d565b600060405180830381600087803b15801561376157600080fd5b505af1158015613775573d6000803e3d6000fd5b5050506000898152600960205260409020546001600160a01b0316159050613809576000888152600960205260409081902054905163db454a5160e01b81526001600160a01b039091169063db454a51906137d69033908d906004016157cb565b600060405180830381600087803b1580156137f057600080fd5b505af1158015613804573d6000803e3d6000fd5b505050505b6138ed565b60008881526008602052604090205461382690614607565b6001600160a01b031663867904b433846040518363ffffffff1660e01b81526004016138539291906157cb565b600060405180830381600087803b15801561386d57600080fd5b505af1158015613881573d6000803e3d6000fd5b5050505061388d6146c2565b6001600160a01b031663eb94bbde898b6040518363ffffffff1660e01b81526004016138ba92919061583d565b600060405180830381600087803b1580156138d457600080fd5b505af11580156138e8573d6000803e3d6000fd5b505050505b336001600160a01b03167f604952b18be5fed608cbdd28101dc57bd667055c9678ec6d44fb1d8e4c7c172a878b8d8c8860405161392e959493929190615ac2565b60405180910390a25050505050949350505050565b61394b611e1a565b6001600160a01b0316632528f0fe6004546040518263ffffffff1660e01b81526004016139789190615821565b60206040518083038186803b15801561399057600080fd5b505afa1580156139a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506139c89190810190614d35565b156123825760405162461bcd60e51b8152600401610805906159d5565b6000611d686b53797374656d53746174757360a01b61460e565b60008160e0015111613a235760405162461bcd60e51b815260040161080590615a45565b42613a3e600e54836101000151611e3590919063ffffffff16565b1115613a5c5760405162461bcd60e51b815260040161080590615905565b50565b613a6761495e565b8190506000806000808560a00151613b0557613a816146c2565b6001600160a01b03166303f048b08760e001516040518263ffffffff1660e01b8152600401613ab09190615821565b60806040518083038186803b158015613ac857600080fd5b505afa158015613adc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613b009190810190614e8c565b613b92565b613b0d6146c2565b6001600160a01b031663af07aa9d87606001518860e001516040518363ffffffff1660e01b8152600401613b4292919061583d565b60806040518083038186803b158015613b5a57600080fd5b505afa158015613b6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613b929190810190614e8c565b93509350935093506000808760a00151613c2257613bae6146c2565b6001600160a01b031663ba1c5e806040518163ffffffff1660e01b8152600401604080518083038186803b158015613be557600080fd5b505afa158015613bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613c1d9190810190614e4c565b613cba565b613c2a6146c2565b606089015160009081526008602052604090819020549051630ee81f7960e41b81526001600160a01b03929092169163ee81f79091613c6b91600401615821565b604080518083038186803b158015613c8257600080fd5b505afa158015613c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613cba9190810190614e4c565b915091508015613cdc5760405162461bcd60e51b8152600401610805906159a5565b6000613d79736e0bff12512a94f3b1ecebe08203fe7f8f8fae6463907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b158015613d2557600080fd5b505af4158015613d39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613d5d9190810190614e2e565b613d6d428863ffffffff61318c16565b9063ffffffff61468816565b90506000613d9d613d90858463ffffffff611e6316565b889063ffffffff611e3516565b905060008a60e00151600014613dd657613dd1613dc0838b63ffffffff61318c16565b60808d01519063ffffffff611e6316565b613dd9565b60005b90508a60a00151613e4e57613dec6146c2565b6001600160a01b031663f53037b6836040518263ffffffff1660e01b8152600401613e179190615821565b600060405180830381600087803b158015613e3157600080fd5b505af1158015613e45573d6000803e3d6000fd5b50505050613eba565b613e566146c2565b6001600160a01b031663246206398c60600151846040518363ffffffff1660e01b8152600401613e8792919061583d565b600060405180830381600087803b158015613ea157600080fd5b505af1158015613eb5573d6000803e3d6000fd5b505050505b60c08b0151613ecf908263ffffffff611e3516565b60c08b015260e08a01869052600554604051631137390760e21b81526001600160a01b03909116906344dce41c90613f0b908d90600401615a75565b600060405180830381600087803b158015613f2557600080fd5b505af1158015613f39573d6000803e3d6000fd5b50505050505050505050505050919050565b6000828152600860205260409020548190613f6590614607565b6001600160a01b03166370a08231856040518263ffffffff1660e01b8152600401613f90919061576c565b60206040518083038186803b158015613fa857600080fd5b505afa158015613fbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250613fe09190810190614e2e565b101561075e5760405162461bcd60e51b815260040161080590615a55565b60008061401c8360c001518460800151611e3590919063ffffffff16565b6080840151604085015193509091506140336145f0565b6001600160a01b031663d6f32e068686606001516040518363ffffffff1660e01b81526004016140649291906157f4565b60206040518083038186803b15801561407c57600080fd5b505afa158015614090573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506140b49190810190614d35565b156140d15760405162461bcd60e51b815260040161080590615a65565b60608401516000908152600860205260409020546140ee90614607565b6001600160a01b0316639dc29fac86846040518363ffffffff1660e01b815260040161411b9291906157f4565b600060405180830381600087803b15801561413557600080fd5b505af1158015614149573d6000803e3d6000fd5b505050508360a00151156142675761415f6146c2565b6001600160a01b0316635246f2b9856060015186608001516040518363ffffffff1660e01b815260040161419492919061583d565b600060405180830381600087803b1580156141ae57600080fd5b505af11580156141c2573d6000803e3d6000fd5b5050505060608401516000908152600960205260409020546001600160a01b03161561426257606084015160009081526009602052604090819020546080860151915163f3fef3a360e01b81526001600160a01b039091169163f3fef3a39161422f918a916004016157f4565b600060405180830381600087803b15801561424957600080fd5b505af115801561425d573d6000803e3d6000fd5b505050505b6142d7565b61426f6146c2565b6001600160a01b031663e50a31b3856060015186608001516040518363ffffffff1660e01b81526004016142a492919061583d565b600060405180830381600087803b1580156142be57600080fd5b505af11580156142d2573d6000803e3d6000fd5b505050505b6142e98460c0015185606001516146d1565b600060808501819052604080860182905260c0860182905260e0860191909152426101008601526005549051631137390760e21b81526001600160a01b03909116906344dce41c9061433f908790600401615a75565b600060405180830381600087803b15801561435957600080fd5b505af115801561436d573d6000803e3d6000fd5b50505050846001600160a01b0316866001600160a01b03167f697721ed1b9d4866cb1aaa0692f62bb3abc1b01c2dafeaad053ffd4532aa7dbb866000015184876040516143bc9392919061586b565b60405180910390a350509392505050565b6143d561495e565b508181158015906143ea575060008360c00151115b156144475760008360c0015183116144025782614408565b8360c001515b60c0850151909150614420908263ffffffff61318c16565b60c0830152614435838263ffffffff61318c16565b92506144458185606001516146d1565b505b8115611e5d576080830151614462908363ffffffff61318c16565b608082015260a08101511561457f576144796146c2565b6001600160a01b0316635246f2b98260600151846040518363ffffffff1660e01b81526004016144aa92919061583d565b600060405180830381600087803b1580156144c457600080fd5b505af11580156144d8573d6000803e3d6000fd5b5050505060608101516000908152600960205260409020546001600160a01b03161561457a5760608101516000908152600960209081526040918290205490830151915163f3fef3a360e01b81526001600160a01b039091169163f3fef3a391614547919086906004016157cb565b600060405180830381600087803b15801561456157600080fd5b505af1158015614575573d6000803e3d6000fd5b505050505b611e5d565b6145876146c2565b6001600160a01b031663e50a31b38260600151846040518363ffffffff1660e01b81526004016145b892919061583d565b600060405180830381600087803b1580156145d257600080fd5b505af11580156145e6573d6000803e3d6000fd5b5050505092915050565b6000611d686822bc31b430b733b2b960b91b61460e565b6000611e5d825b60008181526003602090815260408083205490516001600160a01b03909116918215159161463e91869101615741565b604051602081830303815290604052906129145760405162461bcd60e51b81526004016108059190615894565b6000611d686e466c657869626c6553746f7261676560881b61460e565b60008261469757506000611e5d565b828202828482816146a457fe5b0414611e5a5760405162461bcd60e51b815260040161080590615a05565b6006546001600160a01b031690565b8115610ec957631c1554d160e21b8114614776576146ed611e1a565b6001600160a01b031663654a60ac8284631c1554d160e21b6040518463ffffffff1660e01b81526004016147239392919061586b565b60206040518083038186803b15801561473b57600080fd5b505afa15801561474f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506147739190810190614e2e565b91505b61477e611d51565b6001600160a01b031663867904b46147946148e6565b6001600160a01b031663eb1edd616040518163ffffffff1660e01b815260040160206040518083038186803b1580156147cc57600080fd5b505afa1580156147e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506148049190810190614c02565b846040518363ffffffff1660e01b81526004016148229291906157f4565b600060405180830381600087803b15801561483c57600080fd5b505af1158015614850573d6000803e3d6000fd5b5050505061485c6148e6565b6001600160a01b03166322bf55ef836040518263ffffffff1660e01b8152600401610e969190615821565b60006111938383670de0b6b3a76400006148fb565b60006111938383670de0b6b3a7640000614933565b60008082116148d25760405162461bcd60e51b815260040161080590615995565b60008284816148dd57fe5b04949350505050565b6000611d6866119959541bdbdb60ca1b61460e565b6000806149158461318087600a870263ffffffff61468816565b90506005600a825b061061492757600a015b600a9004949350505050565b600080600a830461494a868663ffffffff61468816565b8161495157fe5b0490506005600a8261491d565b6040518061012001604052806000815260200160006001600160a01b031681526020016000815260200160008019168152602001600081526020016000151581526020016000815260200160008152602001600081525090565b8035611e5d81615bb1565b8051611e5d81615bb1565b60008083601f8401126149e057600080fd5b50813567ffffffffffffffff8111156149f857600080fd5b602083019150836020820283011115614a1057600080fd5b9250929050565b8035611e5d81615bc5565b8051611e5d81615bc5565b8035611e5d81615bce565b8051611e5d81615bce565b60006101208284031215614a5657600080fd5b614a61610120615b0e565b90506000614a6f8484614a2d565b8252506020614a80848483016149b8565b6020830152506040614a9484828501614a2d565b6040830152506060614aa884828501614a2d565b6060830152506080614abc84828501614a2d565b60808301525060a0614ad084828501614a17565b60a08301525060c0614ae484828501614a2d565b60c08301525060e0614af884828501614a2d565b60e083015250610100614b0d84828501614a2d565b6101008301525092915050565b60006101208284031215614b2d57600080fd5b614b38610120615b0e565b90506000614b468484614a38565b8252506020614b57848483016149c3565b6020830152506040614b6b84828501614a38565b6040830152506060614b7f84828501614a38565b6060830152506080614b9384828501614a38565b60808301525060a0614ba784828501614a22565b60a08301525060c0614bbb84828501614a38565b60c08301525060e0614bcf84828501614a38565b60e083015250610100614b0d84828501614a38565b600060208284031215614bf657600080fd5b60006106c184846149b8565b600060208284031215614c1457600080fd5b60006106c184846149c3565b60008060408385031215614c3357600080fd5b6000614c3f85856149b8565b9250506020614c5085828601614a2d565b9150509250929050565b600080600060608486031215614c6f57600080fd5b6000614c7b86866149b8565b9350506020614c8c86828701614a2d565b9250506040614c9d86828701614a2d565b9150509250925092565b60008060008060408587031215614cbd57600080fd5b843567ffffffffffffffff811115614cd457600080fd5b614ce0878288016149ce565b9450945050602085013567ffffffffffffffff811115614cff57600080fd5b614d0b878288016149ce565b95989497509550505050565b600060208284031215614d2957600080fd5b60006106c18484614a17565b600060208284031215614d4757600080fd5b60006106c18484614a22565b60008060408385031215614d6657600080fd5b6000614d728585614a22565b9250506020614c5085828601614a22565b600060208284031215614d9557600080fd5b60006106c18484614a2d565b60008060408385031215614db457600080fd5b6000614dc08585614a2d565b9250506020614c50858286016149b8565b60008060408385031215614de457600080fd5b6000614c3f8585614a2d565b60006101208284031215614e0357600080fd5b60006106c18484614a43565b60006101208284031215614e2257600080fd5b60006106c18484614b1a565b600060208284031215614e4057600080fd5b60006106c18484614a38565b60008060408385031215614e5f57600080fd5b6000614d728585614a38565b600080600060608486031215614e8057600080fd5b6000614c7b8686614a2d565b60008060008060808587031215614ea257600080fd5b6000614eae8787614a38565b9450506020614ebf87828801614a38565b9350506040614ed087828801614a38565b9250506060614ee187828801614a38565b91505092959194509250565b6000614ef98383614f7b565b505060200190565b614f0a81615b69565b82525050565b614f0a81615b4d565b6000614f2482615b3b565b614f2e8185615b3f565b9350614f3983615b35565b8060005b83811015614f67578151614f518882614eed565b9750614f5c83615b35565b925050600101614f3d565b509495945050505050565b614f0a81615b58565b614f0a81610bb7565b614f0a614f9082610bb7565b610bb7565b614f0a81615b70565b6000614fa982615b3b565b614fb38185615b3f565b9350614fc3818560208601615b7b565b614fcc81615ba7565b9093019392505050565b6000614fe3601b83615b3f565b7f496e707574206172726179206c656e677468206d69736d617463680000000000815260200192915050565b600061501c601683615b3f565b754d7573742062652067726561746572207468616e203160501b815260200192915050565b600061504e600e83615b3f565b6d43726174696f20746f6f206c6f7760901b815260200192915050565b6000615078601583615b3f565b74086c2dcdcdee840c8e4c2ee40e8d0d2e640daeac6d605b1b815260200192915050565b60006150a9603583615b3f565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000615100601983615b3f565b7f416c6c6f77616e6365206e6f74206869676820656e6f75676800000000000000815260200192915050565b6000615139601d83615b3f565b7f4c6f616e20726563656e746c7920696e74657261637465642077697468000000815260200192915050565b6000615172601e83615b3f565b7f5061796d656e74206d7573742062652067726561746572207468616e20300000815260200192915050565b60006151ab601b83615b3f565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b60006151e4601283615b3f565b7113585e081b1bd85b9cc8195e18d95959195960721b815260200192915050565b6000615212601e83615b3f565b7f43726174696f2061626f7665206c69717569646174696f6e20726174696f0000815260200192915050565b600061524b601d83615b3f565b7f4e6f7420656e6f75676820636f6c6c61746572616c20746f206f70656e000000815260200192915050565b6000615284601883615b3f565b7f43757272656e6379207261746520697320696e76616c69640000000000000000815260200192915050565b60006152bd602083615b3f565b7f57616974696e672073656373206f7220736574746c656d656e74206f77696e67815260200192915050565b60006152f6601e83615b3f565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b600061532f601a83615b3f565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b6000615368601183615b48565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b6000615395601183615b3f565b7014985d195cc8185c99481a5b9d985b1a59607a1b815260200192915050565b60006153c2601383615b3f565b7213dc195b9a5b99c81a5cc8191a5cd8589b1959606a1b815260200192915050565b60006153f1600a83615b3f565b6926b0bc1018903437bab960b11b815260200192915050565b6000615417601a83615b3f565b7f436f6c6c61746572616c207261746520697320696e76616c6964000000000000815260200192915050565b6000615450601b83615b3f565b7f45786365656473206d617820626f72726f77696e6720706f7765720000000000815260200192915050565b6000615489602f83615b3f565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b60006154da602183615b3f565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b600061551d601f83615b3f565b7f4e6f7420616c6c6f77656420746f20697373756520746869732070796e746800815260200192915050565b6000615556601e83615b3f565b7f4465706f736974206d7573742062652067726561746572207468616e20300000815260200192915050565b600061558f601a83615b3f565b7f44656274206c696d6974206f7220696e76616c69642072617465000000000000815260200192915050565b60006155c8601983615b48565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b6000615601601383615b3f565b72131bd85b88191bd95cc81b9bdd08195e1a5cdd606a1b815260200192915050565b6000615630601883615b3f565b7f4e6f7420656e6f7567682070796e74682062616c616e63650000000000000000815260200192915050565b6000615669601b83615b3f565b7f57616974696e67206f7220736574746c656d656e74206f77696e670000000000815260200192915050565b80516101208301906156a78482614f7b565b5060208201516156ba6020850182614f10565b5060408201516156cd6040850182614f7b565b5060608201516156e06060850182614f7b565b5060808201516156f36080850182614f7b565b5060a082015161570660a0850182614f72565b5060c082015161571960c0850182614f7b565b5060e082015161572c60e0850182614f7b565b50610100820151610c7c610100850182614f7b565b600061574c8261535b565b91506157588284614f84565b50602001919050565b600061574c826155bb565b60208101611e5d8284614f10565b60208101611e5d8284614f01565b604081016157968285614f01565b6111936020830184614f10565b606081016157b18286614f01565b6157be6020830185614f10565b6106c16040830184614f7b565b604081016157d98285614f01565b6111936020830184614f7b565b604081016157968285614f10565b604081016157d98285614f10565b602080825281016111938184614f19565b60208101611e5d8284614f72565b60208101611e5d8284614f7b565b604081016157968285614f7b565b604081016157d98285614f7b565b604081016158598285614f7b565b81810360208301526106c18184614f9e565b606081016158798286614f7b565b6157be6020830185614f7b565b60208101611e5d8284614f95565b602080825281016111938184614f9e565b60208082528101611e5d81614fd6565b60208082528101611e5d8161500f565b60208082528101611e5d81615041565b60208082528101611e5d8161506b565b60208082528101611e5d8161509c565b60208082528101611e5d816150f3565b60208082528101611e5d8161512c565b60208082528101611e5d81615165565b60208082528101611e5d8161519e565b60208082528101611e5d816151d7565b60208082528101611e5d81615205565b60208082528101611e5d8161523e565b60208082528101611e5d81615277565b60208082528101611e5d816152b0565b60208082528101611e5d816152e9565b60208082528101611e5d81615322565b60208082528101611e5d81615388565b60208082528101611e5d816153b5565b60208082528101611e5d816153e4565b60208082528101611e5d8161540a565b60208082528101611e5d81615443565b60208082528101611e5d8161547c565b60208082528101611e5d816154cd565b60208082528101611e5d81615510565b60208082528101611e5d81615549565b60208082528101611e5d81615582565b60208082528101611e5d816155f4565b60208082528101611e5d81615623565b60208082528101611e5d8161565c565b6101208101611e5d8284615695565b60808101615a928287614f7b565b615a9f6020830186614f01565b615aac6040830185614f7b565b615ab96060830184614f7b565b95945050505050565b60a08101615ad08288614f7b565b615add6020830187614f7b565b615aea6040830186614f7b565b615af76060830185614f7b565b615b046080830184614f7b565b9695505050505050565b60405181810167ffffffffffffffff81118282101715615b2d57600080fd5b604052919050565b60200190565b5190565b90815260200190565b919050565b6000611e5d82615b5d565b151590565b6001600160a01b031690565b6000611e5d825b6000611e5d82615b4d565b60005b83811015615b96578181015183820152602001615b7e565b83811115610c7c5750506000910152565b601f01601f191690565b615bba81615b4d565b8114613a5c57600080fd5b615bba81615b58565b615bba81610bb756fea365627a7a72315820dac7714ef2ab70337423ed3c553ca7094d75c689995b757354be01dc503d16a66c6578706572696d656e74616cf564736f6c63430005100040

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

00000000000000000000000062d0a4428f97fd398840dcd1c321f757430983ee000000000000000000000000918153d6e806df9d4d33664d1cc580416171f7200000000000000000000000005d20d931cc3b02195d2484b7fd80bbb4d14d2a9f0000000000000000000000007015cd1e78ba1428d103b0c2513077b2826b64fc705553440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010a741a46278000000000000000000000000000000000000000000000000003635c9adc5dea00000

-----Decoded View---------------
Arg [0] : _state (address): 0x62D0A4428f97fD398840DCd1C321f757430983EE
Arg [1] : _owner (address): 0x918153D6e806dF9d4D33664D1cC580416171f720
Arg [2] : _manager (address): 0x5D20d931CC3B02195D2484B7Fd80bBB4D14D2A9F
Arg [3] : _resolver (address): 0x7015cd1E78bA1428d103B0C2513077b2826b64fc
Arg [4] : _collateralKey (bytes32): 0x7055534400000000000000000000000000000000000000000000000000000000
Arg [5] : _minCratio (uint256): 1200000000000000000
Arg [6] : _minCollateral (uint256): 1000000000000000000000

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 00000000000000000000000062d0a4428f97fd398840dcd1c321f757430983ee
Arg [1] : 000000000000000000000000918153d6e806df9d4d33664d1cc580416171f720
Arg [2] : 0000000000000000000000005d20d931cc3b02195d2484b7fd80bbb4d14d2a9f
Arg [3] : 0000000000000000000000007015cd1e78ba1428d103b0c2513077b2826b64fc
Arg [4] : 7055534400000000000000000000000000000000000000000000000000000000
Arg [5] : 00000000000000000000000000000000000000000000000010a741a462780000
Arg [6] : 00000000000000000000000000000000000000000000003635c9adc5dea00000


Libraries Used


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.