My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Name:
CollateralEth
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 optimistic.etherscan.io on 2021-12-15 */ /* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: CollateralEth.sol * * Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/CollateralEth.sol * Docs: https://docs.synthetix.io/contracts/CollateralEth * * Contract Dependencies: * - Collateral * - IAddressResolver * - ICollateralEth * - ICollateralLoan * - MixinResolver * - MixinSystemSettings * - Owned * - ReentrancyGuard * Libraries: * - Address * - SafeDecimalMath * - SafeERC20 * - SafeMath * * MIT License * =========== * * Copyright (c) 2021 Synthetix * * 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.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see `ERC20Detailed`. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a `Transfer` event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through `transferFrom`. This is * zero by default. * * This value changes when `approve` or `transferFrom` are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * > Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an `Approval` event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a `Transfer` event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to `approve`. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @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; } } /** * @dev Collection of functions related to the address type, */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * > It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } } /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // https://docs.synthetix.io/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.synthetix.io/contracts/source/interfaces/iaddressresolver interface IAddressResolver { function getAddress(bytes32 name) external view returns (address); function getSynth(bytes32 key) external view returns (address); function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address); } // https://docs.synthetix.io/contracts/source/interfaces/isynth interface ISynth { // Views function currencyKey() external view returns (bytes32); function transferableSynths(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 Synthetix function burn(address account, uint amount) external; function issue(address account, uint amount) external; } // https://docs.synthetix.io/contracts/source/interfaces/iissuer interface IIssuer { // Views function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availableSynthCount() external view returns (uint); function availableSynths(uint index) external view returns (ISynth); function canBurnSynths(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 lastIssueEvent(address account) external view returns (uint); function maxIssuableSynths(address issuer) external view returns (uint maxIssuable); function minimumStakeTime() external view returns (uint); function remainingIssuableSynths(address issuer) external view returns ( uint maxIssuable, uint alreadyIssued, uint totalSystemDebt ); function synths(bytes32 currencyKey) external view returns (ISynth); function getSynths(bytes32[] calldata currencyKeys) external view returns (ISynth[] memory); function synthsByAddress(address synthAddress) external view returns (bytes32); function totalIssuedSynths(bytes32 currencyKey, bool excludeOtherCollateral) external view returns (uint); function transferableSynthetixAndAnyRateIsInvalid(address account, uint balance) external view returns (uint transferable, bool anyRateIsInvalid); // Restricted: used internally to Synthetix function issueSynths(address from, uint amount) external; function issueSynthsOnBehalf( address issueFor, address from, uint amount ) external; function issueMaxSynths(address from) external; function issueMaxSynthsOnBehalf(address issueFor, address from) external; function burnSynths(address from, uint amount) external; function burnSynthsOnBehalf( address burnForAddress, address from, uint amount ) external; function burnSynthsToTarget(address from) external; function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external; function burnForRedemption( address deprecatedSynthProxy, address account, uint balance ) external; function liquidateDelinquentAccount( address account, uint susdAmount, address liquidator ) external returns (uint totalRedeemed, uint amountToLiquidate); } // Inheritance // Internal references // https://docs.synthetix.io/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 getSynth(bytes32 key) external view returns (address) { IIssuer issuer = IIssuer(repository["Issuer"]); require(address(issuer) != address(0), "Cannot find Issuer address"); return address(issuer.synths(key)); } /* ========== EVENTS ========== */ event AddressImported(bytes32 name, address destination); } // Internal references // https://docs.synthetix.io/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.synthetix.io/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.synthetix.io/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_CROSS_DOMAIN_RELAY_GAS_LIMIT = "crossDomainRelayGasLimit"; bytes32 internal constant SETTING_ETHER_WRAPPER_MAX_ETH = "etherWrapperMaxETH"; bytes32 internal constant SETTING_ETHER_WRAPPER_MINT_FEE_RATE = "etherWrapperMintFeeRate"; bytes32 internal constant SETTING_ETHER_WRAPPER_BURN_FEE_RATE = "etherWrapperBurnFeeRate"; bytes32 internal constant SETTING_WRAPPER_MAX_TOKEN_AMOUNT = "wrapperMaxTokens"; bytes32 internal constant SETTING_WRAPPER_MINT_FEE_RATE = "wrapperMintFeeRate"; bytes32 internal constant SETTING_WRAPPER_BURN_FEE_RATE = "wrapperBurnFeeRate"; bytes32 internal constant SETTING_MIN_CRATIO = "minCratio"; bytes32 internal constant SETTING_NEW_COLLATERAL_MANAGER = "newCollateralManager"; bytes32 internal constant SETTING_INTERACTION_DELAY = "interactionDelay"; bytes32 internal constant SETTING_COLLAPSE_FEE_RATE = "collapseFeeRate"; bytes32 internal constant SETTING_ATOMIC_MAX_VOLUME_PER_BLOCK = "atomicMaxVolumePerBlock"; bytes32 internal constant SETTING_ATOMIC_TWAP_WINDOW = "atomicTwapWindow"; bytes32 internal constant SETTING_ATOMIC_EQUIVALENT_FOR_DEX_PRICING = "atomicEquivalentForDexPricing"; bytes32 internal constant SETTING_ATOMIC_EXCHANGE_FEE_RATE = "atomicExchangeFeeRate"; bytes32 internal constant SETTING_ATOMIC_PRICE_BUFFER = "atomicPriceBuffer"; bytes32 internal constant SETTING_ATOMIC_VOLATILITY_CONSIDERATION_WINDOW = "atomicVolConsiderationWindow"; bytes32 internal constant SETTING_ATOMIC_VOLATILITY_UPDATE_THRESHOLD = "atomicVolUpdateThreshold"; bytes32 internal constant CONTRACT_FLEXIBLESTORAGE = "FlexibleStorage"; enum CrossDomainMessageGasLimits {Deposit, Escrow, Reward, Withdrawal, Relay} 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 if (gasLimitType == CrossDomainMessageGasLimits.Relay) { return SETTING_CROSS_DOMAIN_RELAY_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 getEtherWrapperMaxETH() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ETHER_WRAPPER_MAX_ETH); } function getEtherWrapperMintFeeRate() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ETHER_WRAPPER_MINT_FEE_RATE); } function getEtherWrapperBurnFeeRate() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ETHER_WRAPPER_BURN_FEE_RATE); } function getWrapperMaxTokenAmount(address wrapper) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_WRAPPER_MAX_TOKEN_AMOUNT, wrapper)) ); } function getWrapperMintFeeRate(address wrapper) internal view returns (int) { return flexibleStorage().getIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_WRAPPER_MINT_FEE_RATE, wrapper)) ); } function getWrapperBurnFeeRate(address wrapper) internal view returns (int) { return flexibleStorage().getIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_WRAPPER_BURN_FEE_RATE, wrapper)) ); } function getMinCratio(address collateral) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_MIN_CRATIO, collateral)) ); } function getNewCollateralManager(address collateral) internal view returns (address) { return flexibleStorage().getAddressValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_NEW_COLLATERAL_MANAGER, collateral)) ); } function getInteractionDelay(address collateral) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_INTERACTION_DELAY, collateral)) ); } function getCollapseFeeRate(address collateral) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_COLLAPSE_FEE_RATE, collateral)) ); } function getAtomicMaxVolumePerBlock() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ATOMIC_MAX_VOLUME_PER_BLOCK); } function getAtomicTwapWindow() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ATOMIC_TWAP_WINDOW); } function getAtomicEquivalentForDexPricing(bytes32 currencyKey) internal view returns (address) { return flexibleStorage().getAddressValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_EQUIVALENT_FOR_DEX_PRICING, currencyKey)) ); } function getAtomicExchangeFeeRate(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_EXCHANGE_FEE_RATE, currencyKey)) ); } function getAtomicPriceBuffer(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_PRICE_BUFFER, currencyKey)) ); } function getAtomicVolatilityConsiderationWindow(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_VOLATILITY_CONSIDERATION_WINDOW, currencyKey)) ); } function getAtomicVolatilityUpdateThreshold(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_VOLATILITY_UPDATE_THRESHOLD, currencyKey)) ); } } 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 synth that was borowed bytes32 currency; // Amount of synths 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; } } // Libraries // https://docs.synthetix.io/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; } // Computes `a - b`, setting the value to 0 if b > a. function floorsub(uint a, uint b) internal pure returns (uint) { return b >= a ? 0 : a - b; } /* ---------- Utilities ---------- */ /* * Absolute value of the input, returned as a signed number. */ function signedAbs(int x) internal pure returns (int) { return x < 0 ? -x : x; } /* * Absolute value of the input, returned as an unsigned number. */ function abs(int x) internal pure returns (uint) { return uint(signedAbs(x)); } } interface ICollateralUtil { function getCollateralRatio(ICollateralLoan.Loan calldata loan, bytes32 collateralKey) external view returns (uint cratio); function maxLoan( uint amount, bytes32 currency, uint minCratio, bytes32 collateralKey ) external view returns (uint max); function liquidationAmount( ICollateralLoan.Loan calldata loan, uint minCratio, bytes32 collateralKey ) external view returns (uint amount); function collateralRedeemed( bytes32 currency, uint amount, bytes32 collateralKey ) external view returns (uint collateral); } interface ICollateralManager { // Manager information function hasCollateral(address collateral) external view returns (bool); function isSynthManaged(bytes32 currencyKey) external view returns (bool); // State information function long(bytes32 synth) external view returns (uint amount); function short(bytes32 synth) external view returns (uint amount); function totalLong() external view returns (uint susdValue, bool anyRateIsInvalid); function totalShort() external view returns (uint susdValue, bool anyRateIsInvalid); function getBorrowRate() external view returns (uint borrowRate, bool anyRateIsInvalid); function getShortRate(bytes32 synth) 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 areSynthsAndCurrenciesSet(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys) external view returns (bool); function areShortableSynthsSet(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys) 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 addSynths(bytes32[] calldata synthNamesInResolver, bytes32[] calldata synthKeys) external; function removeSynths(bytes32[] calldata synths, bytes32[] calldata synthKeys) external; function addShortableSynths(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys) external; function removeShortableSynths(bytes32[] calldata synths) external; // State mutative function incrementLongs(bytes32 synth, uint amount) external; function decrementLongs(bytes32 synth, uint amount) external; function incrementShorts(bytes32 synth, uint amount) external; function decrementShorts(bytes32 synth, uint amount) external; function accrueInterest( uint interestIndex, bytes32 currency, bool isShort ) external returns (uint difference, uint index); function updateBorrowRatesCollateral(uint rate) external; function updateShortRatesCollateral(bytes32 currency, uint rate) external; } // https://docs.synthetix.io/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 requireExchangeBetweenSynthsAllowed(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view; function requireSynthActive(bytes32 currencyKey) external view; function requireSynthsActive(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 synthExchangeSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason); function synthSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason); function getSynthExchangeSuspensions(bytes32[] calldata synths) external view returns (bool[] memory exchangeSuspensions, uint256[] memory reasons); function getSynthSuspensions(bytes32[] calldata synths) external view returns (bool[] memory suspensions, uint256[] memory reasons); // Restricted functions function suspendSynth(bytes32 currencyKey, uint256 reason) external; function updateAccessControl( bytes32 section, address account, bool canSuspend, bool canResume ) external; } // https://docs.synthetix.io/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 Synthetix function appendAccountIssuanceRecord( address account, uint lockedAmount, uint debtEntryIndex ) external; function recordFeePaid(uint sUSDAmount) external; function setRewardsToDistribute(uint amount) external; } // https://docs.synthetix.io/contracts/source/interfaces/iexchangerates interface IExchangeRates { // Structs struct RateAndUpdatedTime { uint216 rate; uint40 time; } // 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 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 effectiveAtomicValueAndRates( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external view returns ( uint value, uint systemValue, uint systemSourceRate, uint systemDestinationRate ); 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 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 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); function synthTooVolatileForAtomicExchange(bytes32 currencyKey) external view returns (bool); } interface IVirtualSynth { // 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 synth() external view returns (ISynth); // Mutative functions function settle(address account) external; } // https://docs.synthetix.io/contracts/source/interfaces/iexchanger interface IExchanger { // Views function calculateAmountAfterSettlement( address from, bytes32 currencyKey, uint amount, uint refunded ) external view returns (uint amountAfterSettlement); function isSynthRateInvalid(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 exchangeForAddress, address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress, bool virtualSynth, address rewardAddress, bytes32 trackingCode ) external returns (uint amountReceived, IVirtualSynth vSynth); function exchangeAtomically( address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress, bytes32 trackingCode ) external returns (uint amountReceived); function settle(address from, bytes32 currencyKey) external returns ( uint reclaimed, uint refunded, uint numEntries ); function resetLastExchangeRate(bytes32[] calldata currencyKeys) external; function suspendSynthWithInvalidRate(bytes32 currencyKey) external; } // https://docs.synthetix.io/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; using SafeERC20 for IERC20; /* ========== CONSTANTS ========== */ bytes32 private constant sUSD = "sUSD"; // ========== STATE VARIABLES ========== // The synth corresponding to the collateral. bytes32 public collateralKey; // Stores open loans. mapping(uint => Loan) public loans; ICollateralManager public manager; // The synths that this contract can issue. bytes32[] public synths; // Map from currency key to synth contract name. mapping(bytes32 => bytes32) public synthsByKey; // 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; 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_SYNTHSUSD = "SynthsUSD"; bytes32 private constant CONTRACT_COLLATERALUTIL = "CollateralUtil"; /* ========== CONSTRUCTOR ========== */ constructor( address _owner, ICollateralManager _manager, address _resolver, bytes32 _collateralKey, uint _minCratio, uint _minCollateral ) public Owned(_owner) MixinSystemSettings(_resolver) { manager = _manager; 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[](6); newAddresses[0] = CONTRACT_FEEPOOL; newAddresses[1] = CONTRACT_EXRATES; newAddresses[2] = CONTRACT_EXCHANGER; newAddresses[3] = CONTRACT_SYSTEMSTATUS; newAddresses[4] = CONTRACT_SYNTHSUSD; newAddresses[5] = CONTRACT_COLLATERALUTIL; bytes32[] memory combined = combineArrays(existingAddresses, newAddresses); addresses = combineArrays(combined, synths); } /* ---------- Related Contracts ---------- */ function _systemStatus() internal view returns (ISystemStatus) { return ISystemStatus(requireAndGetAddress(CONTRACT_SYSTEMSTATUS)); } function _synth(bytes32 synthName) internal view returns (ISynth) { return ISynth(requireAndGetAddress(synthName)); } function _synthsUSD() internal view returns (ISynth) { return ISynth(requireAndGetAddress(CONTRACT_SYNTHSUSD)); } 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 _collateralUtil() internal view returns (ICollateralUtil) { return ICollateralUtil(requireAndGetAddress(CONTRACT_COLLATERALUTIL)); } /* ---------- Public Views ---------- */ function collateralRatio(uint id) public view returns (uint cratio) { Loan memory loan = loans[id]; return _collateralUtil().getCollateralRatio(loan, collateralKey); } function liquidationAmount(uint id) public view returns (uint liqAmount) { Loan memory loan = loans[id]; return _collateralUtil().liquidationAmount(loan, minCratio, collateralKey); } // The maximum number of synths issuable for this amount of collateral function maxLoan(uint amount, bytes32 currency) public view returns (uint max) { return _collateralUtil().maxLoan(amount, currency, minCratio, collateralKey); } function areSynthsAndCurrenciesSet(bytes32[] calldata _synthNamesInResolver, bytes32[] calldata _synthKeys) external view returns (bool) { if (synths.length != _synthNamesInResolver.length) { return false; } for (uint i = 0; i < _synthNamesInResolver.length; i++) { bytes32 synthName = _synthNamesInResolver[i]; if (synths[i] != synthName) { return false; } if (synthsByKey[_synthKeys[i]] != synths[i]) { return false; } } return true; } /* ---------- SETTERS ---------- */ function setMinCollateral(uint _minCollateral) external onlyOwner { minCollateral = _minCollateral; emit MinCollateralUpdated(minCollateral); } function setIssueFeeRate(uint _issueFeeRate) external onlyOwner { issueFeeRate = _issueFeeRate; emit IssueFeeRateUpdated(issueFeeRate); } function setCanOpenLoans(bool _canOpenLoans) external onlyOwner { canOpenLoans = _canOpenLoans; emit CanOpenLoansUpdated(canOpenLoans); } /* ---------- UTILITIES ---------- */ // Check the account has enough of the synth to make the payment function _checkSynthBalance( address payer, bytes32 key, uint amount ) internal view { require(IERC20(address(_synth(synthsByKey[key]))).balanceOf(payer) >= amount, "Not enough balance"); } // We set the interest index to 0 to indicate the loan has been closed. function _checkLoanAvailable(Loan memory loan) internal view { _isLoanOpen(loan.interestIndex); require(loan.lastInteraction.add(getInteractionDelay(address(this))) <= block.timestamp, "Recently interacted"); } function _isLoanOpen(uint interestIndex) internal pure { require(interestIndex != 0, "Loan is closed"); } /* ========== MUTATIVE FUNCTIONS ========== */ /* ---------- Synths ---------- */ function addSynths(bytes32[] calldata _synthNamesInResolver, bytes32[] calldata _synthKeys) external onlyOwner { require(_synthNamesInResolver.length == _synthKeys.length, "Array length mismatch"); for (uint i = 0; i < _synthNamesInResolver.length; i++) { bytes32 synthName = _synthNamesInResolver[i]; synths.push(synthName); synthsByKey[_synthKeys[i]] = synthName; } // ensure cache has the latest rebuildCache(); } /* ---------- Rewards Contracts ---------- */ function addRewardsContracts(address rewardsContract, bytes32 synth) external onlyOwner { shortingRewards[synth] = rewardsContract; } /* ---------- LOAN INTERACTIONS ---------- */ function _open( uint collateral, uint amount, bytes32 currency, bool short ) internal rateIsValid issuanceIsActive returns (uint id) { // 0. Check if able to open loans. require(canOpenLoans, "Open disabled"); // 1. We can only issue certain synths. require(synthsByKey[currency] > 0, "Not allowed to issue"); // 2. Make sure the synth rate is not invalid. require(!_exchangeRates().rateIsInvalid(currency), "Invalid rate"); // 3. Collateral >= minimum collateral size. require(collateral >= minCollateral, "Not enough collateral"); // 4. Check we haven't hit the debt cap for non snx collateral. (bool canIssue, bool anyRateIsInvalid) = manager.exceedsDebtLimit(amount, currency); // 5. Check if we've hit the debt cap or any rate is invalid. require(canIssue && !anyRateIsInvalid, "Debt limit or invalid rate"); // 6. Require requested loan < max loan. require(amount <= maxLoan(collateral, currency), "Exceed max borrow 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. loans[id] = 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. _accrueInterest(loans[id]); // 12. Pay the minting fees to the fee pool. _payFees(issueFee, currency); // 13. If its short, convert back to sUSD, otherwise issue the loan. if (short) { _synthsUSD().issue(msg.sender, _exchangeRates().effectiveValue(currency, loanAmountMinusFee, sUSD)); manager.incrementShorts(currency, amount); if (shortingRewards[currency] != address(0)) { IShortingRewards(shortingRewards[currency]).enrol(msg.sender, amount); } } else { _synth(synthsByKey[currency]).issue(msg.sender, loanAmountMinusFee); manager.incrementLongs(currency, amount); } // 14. Emit event for the newly opened loan. emit LoanCreated(msg.sender, id, amount, collateral, currency, issueFee); } function _close(address borrower, uint id) internal rateIsValid issuanceIsActive returns (uint amount, uint collateral) { // 0. Get the loan and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, borrower); // 1. Check loan is open and last interaction time. _checkLoanAvailable(loan); // 2. Record loan as closed. (amount, collateral) = _closeLoan(borrower, borrower, loan); // 3. Emit the event for the closed loan. emit LoanClosed(borrower, id); } function _closeByLiquidation( address borrower, address liquidator, Loan storage loan ) internal returns (uint amount, uint collateral) { (amount, collateral) = _closeLoan(borrower, liquidator, loan); // Emit the event for the loan closed by liquidation. emit LoanClosedByLiquidation(borrower, loan.id, liquidator, amount, collateral); } function _closeLoan( address borrower, address liquidator, Loan storage loan ) internal returns (uint amount, uint collateral) { // 0. Work out the total amount owing on the loan. uint total = loan.amount.add(loan.accruedInterest); // 1. Store this for the event. amount = loan.amount; // 2. Return collateral to the child class so it knows how much to transfer. collateral = loan.collateral; // 3. Check that the liquidator has enough synths. _checkSynthBalance(liquidator, loan.currency, total); // 4. Burn the synths. _synth(synthsByKey[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. _recordLoanAsClosed(loan); } function _closeLoanByRepayment(address borrower, uint id) internal returns (uint amount, uint collateral) { // 0. Get the loan. Loan storage loan = loans[id]; // 1. Repay the loan with its collateral. (amount, collateral) = _repayWithCollateral(borrower, id, loan.amount); // 2. Pay the service fee for collapsing the loan. uint serviceFee = amount.multiplyDecimalRound(getCollapseFeeRate(address(this))); _payFees(serviceFee, sUSD); collateral = collateral.sub(serviceFee); // 3. Record loan as closed. _recordLoanAsClosed(loan); // 4. Emit the event for the loan closed by repayment. emit LoanClosedByRepayment(borrower, id, amount, collateral); } function _deposit( address account, uint id, uint amount ) internal rateIsValid issuanceIsActive returns (uint, uint) { // 0. They sent some value > 0 require(amount > 0, "Deposit must be above 0"); // 1. Get the loan. // Owner is not important here, as it is a donation to the collateral of the loan Loan storage loan = loans[id]; // 2. Check loan hasn't been closed or liquidated. _isLoanOpen(loan.interestIndex); // 3. Accrue interest on the loan. _accrueInterest(loan); // 4. Add the collateral. loan.collateral = loan.collateral.add(amount); // 5. Emit the event for the deposited collateral. emit CollateralDeposited(account, id, amount, loan.collateral); return (loan.amount, loan.collateral); } function _withdraw(uint id, uint amount) internal rateIsValid issuanceIsActive returns (uint, uint) { // 0. Get the loan and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, msg.sender); // 1. Subtract the collateral. loan.collateral = loan.collateral.sub(amount); // 2. Check that the new amount does not put them under the minimum c ratio. _checkLoanRatio(loan); // 3. Emit the event for the withdrawn collateral. emit CollateralWithdrawn(msg.sender, id, amount, loan.collateral); return (loan.amount, loan.collateral); } function _liquidate( address borrower, uint id, uint payment ) internal rateIsValid issuanceIsActive returns (uint collateralLiquidated) { require(payment > 0, "Payment must be above 0"); // 0. Get the loan and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, borrower); // 1. Check they have enough balance to make the payment. _checkSynthBalance(msg.sender, loan.currency, payment); // 2. Check they are eligible for liquidation. // Note: this will revert if collateral is 0, however that should only be possible if the loan amount is 0. require(_collateralUtil().getCollateralRatio(loan, collateralKey) < minCratio, "Cratio above liq ratio"); // 3. Determine how much needs to be liquidated to fix their c ratio. uint liqAmount = _collateralUtil().liquidationAmount(loan, minCratio, collateralKey); // 4. Only allow them to liquidate enough to fix the c ratio. uint amountToLiquidate = liqAmount < payment ? liqAmount : payment; // 5. Work out the total amount owing on the loan. uint amountOwing = loan.amount.add(loan.accruedInterest); // 6. If its greater than the amount owing, we need to close the loan. if (amountToLiquidate >= amountOwing) { (, collateralLiquidated) = _closeByLiquidation(borrower, msg.sender, loan); return collateralLiquidated; } // 7. Check they have enough balance to liquidate the loan. _checkSynthBalance(msg.sender, loan.currency, amountToLiquidate); // 8. Process the payment to workout interest/principal split. _processPayment(loan, amountToLiquidate); // 9. Work out how much collateral to redeem. collateralLiquidated = _collateralUtil().collateralRedeemed(loan.currency, amountToLiquidate, collateralKey); loan.collateral = loan.collateral.sub(collateralLiquidated); // 10. Burn the synths from the liquidator. _synth(synthsByKey[loan.currency]).burn(msg.sender, amountToLiquidate); // 11. Emit the event for the partial liquidation. emit LoanPartiallyLiquidated(borrower, id, msg.sender, amountToLiquidate, collateralLiquidated); } function _repay( address borrower, address repayer, uint id, uint payment ) internal rateIsValid issuanceIsActive returns (uint, uint) { // 0. Get the loan. // Owner is not important here, as it is a donation to repay the loan. Loan storage loan = loans[id]; // 1. Check loan is open and last interaction time. _checkLoanAvailable(loan); // 2. Check the spender has enough synths to make the repayment _checkSynthBalance(repayer, loan.currency, payment); // 3. Accrue interest on the loan. _accrueInterest(loan); // 4. Process the payment. _processPayment(loan, payment); // 5. Burn synths from the payer _synth(synthsByKey[loan.currency]).burn(repayer, payment); // 6. Update the last interaction time. loan.lastInteraction = block.timestamp; // 7. Emit the event the repayment. emit LoanRepaymentMade(borrower, repayer, id, payment, loan.amount); // 8. Return the loan amount and collateral after repaying. return (loan.amount, loan.collateral); } function _repayWithCollateral( address borrower, uint id, uint payment ) internal rateIsValid issuanceIsActive returns (uint amount, uint collateral) { // 0. Get the loan to repay and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, borrower); // 1. Check loan is open and last interaction time. _checkLoanAvailable(loan); // 2. Repay the accrued interest. payment = payment.add(loan.accruedInterest); // 3. Make sure they are not overpaying. require(payment <= loan.amount.add(loan.accruedInterest), "Payment too high"); // 4. Get the expected amount for the exchange from borrowed synth -> sUSD. (uint expectedAmount, uint fee, ) = _exchanger().getAmountsForExchange(payment, loan.currency, sUSD); // 5. Reduce the collateral by the amount repaid (minus the exchange fees). loan.collateral = loan.collateral.sub(expectedAmount); // 6. Process the payment and pay the exchange fees if needed. _processPayment(loan, payment); _payFees(fee, sUSD); // 7. Update the last interaction time. loan.lastInteraction = block.timestamp; // 8. Emit the event for the collateral repayment. emit LoanRepaymentMade(borrower, borrower, id, payment, loan.amount); // 9. Return the amount repaid and the remaining collateral. return (payment, loan.collateral); } function _draw(uint id, uint amount) internal rateIsValid issuanceIsActive returns (uint, uint) { // 0. Get the loan and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, msg.sender); // 1. Check last interaction time. _checkLoanAvailable(loan); // 2. Add the requested amount. loan.amount = loan.amount.add(amount); // 3. If it is below the minimum, don't allow this draw. _checkLoanRatio(loan); // 4. This fee is denominated in the currency of the loan uint issueFee = amount.multiplyDecimalRound(issueFeeRate); // 5. Calculate the minting fee and subtract it from the draw amount uint amountMinusFee = amount.sub(issueFee); // 6. If its short, issue the synths. if (loan.short) { manager.incrementShorts(loan.currency, amount); _synthsUSD().issue(msg.sender, _exchangeRates().effectiveValue(loan.currency, amountMinusFee, sUSD)); if (shortingRewards[loan.currency] != address(0)) { IShortingRewards(shortingRewards[loan.currency]).enrol(msg.sender, amount); } } else { manager.incrementLongs(loan.currency, amount); _synth(synthsByKey[loan.currency]).issue(msg.sender, amountMinusFee); } // 7. Pay the minting fees to the fee pool _payFees(issueFee, loan.currency); // 8. Update the last interaction time. loan.lastInteraction = block.timestamp; // 9. Emit the event for the draw down. emit LoanDrawnDown(msg.sender, id, amount); return (loan.amount, loan.collateral); } // Update the cumulative interest rate for the currency that was interacted with. function _accrueInterest(Loan storage loan) internal { (uint differential, uint newIndex) = manager.accrueInterest(loan.interestIndex, loan.currency, loan.short); // If the loan was just opened, don't record any interest. Otherwise multiply by the amount outstanding. uint interest = loan.interestIndex == 0 ? 0 : loan.amount.multiplyDecimal(differential); // Update the loan. loan.accruedInterest = loan.accruedInterest.add(interest); loan.interestIndex = newIndex; } // Works out the amount of interest and principal after a repayment is made. function _processPayment(Loan storage loan, uint payment) internal { require(payment > 0, "Payment must be above 0"); if (loan.accruedInterest > 0) { uint interestPaid = payment > loan.accruedInterest ? loan.accruedInterest : payment; loan.accruedInterest = loan.accruedInterest.sub(interestPaid); payment = payment.sub(interestPaid); _payFees(interestPaid, loan.currency); } // If there is more payment left after the interest, pay down the principal. if (payment > 0) { loan.amount = loan.amount.sub(payment); // And get the manager to reduce the total long/short balance. if (loan.short) { manager.decrementShorts(loan.currency, payment); if (shortingRewards[loan.currency] != address(0)) { IShortingRewards(shortingRewards[loan.currency]).withdraw(loan.account, payment); } } else { manager.decrementLongs(loan.currency, payment); } } } // Take an amount of fees in a certain synth and convert it to sUSD before paying the fee pool. function _payFees(uint amount, bytes32 synth) internal { if (amount > 0) { if (synth != sUSD) { amount = _exchangeRates().effectiveValue(synth, amount, sUSD); } _synthsUSD().issue(_feePool().FEE_ADDRESS(), amount); _feePool().recordFeePaid(amount); } } function _recordLoanAsClosed(Loan storage loan) internal { loan.amount = 0; loan.collateral = 0; loan.accruedInterest = 0; loan.interestIndex = 0; loan.lastInteraction = block.timestamp; } function _getLoanAndAccrueInterest(uint id, address owner) internal returns (Loan storage loan) { loan = loans[id]; // Make sure the loan is open and it is the borrower. _isLoanOpen(loan.interestIndex); require(loan.account == owner, "Must be borrower"); _accrueInterest(loan); } function _checkLoanRatio(Loan storage loan) internal view { if (loan.amount == 0) { return; } require(collateralRatio(loan.id) > minCratio, "Cratio too low"); } // ========== MODIFIERS ========== modifier rateIsValid() { _requireRateIsValid(); _; } function _requireRateIsValid() private view { require(!_exchangeRates().rateIsInvalid(collateralKey), "Invalid rate"); } modifier issuanceIsActive() { _requireIssuanceIsActive(); _; } function _requireIssuanceIsActive() private view { _systemStatus().requireIssuanceActive(); } // ========== EVENTS ========== // Setters event MinCollateralUpdated(uint minCollateral); event IssueFeeRateUpdated(uint issueFeeRate); 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 ); event LoanClosedByRepayment(address indexed account, uint id, uint amountRepaid, uint collateralAfter); } /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier * available, which can be aplied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. */ contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor () internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } } interface ICollateralEth { function open(uint amount, bytes32 currency) external payable returns (uint id); function close(uint id) external returns (uint amount, uint collateral); function deposit(address borrower, uint id) external payable returns (uint principal, uint collateral); function withdraw(uint id, uint amount) external returns (uint principal, uint collateral); function repay( address borrower, uint id, uint amount ) external returns (uint principal, uint collateral); function draw(uint id, uint amount) external returns (uint principal, uint collateral); function liquidate( address borrower, uint id, uint amount ) external; function claim(uint amount) external; } // Inheritance // This contract handles the payable aspects of eth loans. contract CollateralEth is Collateral, ICollateralEth, ReentrancyGuard { mapping(address => uint) public pendingWithdrawals; constructor( address _owner, ICollateralManager _manager, address _resolver, bytes32 _collateralKey, uint _minCratio, uint _minCollateral ) public Collateral(_owner, _manager, _resolver, _collateralKey, _minCratio, _minCollateral) {} function open(uint amount, bytes32 currency) external payable returns (uint id) { id = _open(msg.value, amount, currency, false); } function close(uint id) external returns (uint amount, uint collateral) { (amount, collateral) = _close(msg.sender, id); pendingWithdrawals[msg.sender] = pendingWithdrawals[msg.sender].add(collateral); } function deposit(address borrower, uint id) external payable returns (uint principal, uint collateral) { (principal, collateral) = _deposit(borrower, id, msg.value); } function withdraw(uint id, uint amount) external returns (uint principal, uint collateral) { (principal, collateral) = _withdraw(id, amount); pendingWithdrawals[msg.sender] = pendingWithdrawals[msg.sender].add(amount); } function repay( address borrower, uint id, uint amount ) external returns (uint principal, uint collateral) { (principal, collateral) = _repay(borrower, msg.sender, id, amount); } function draw(uint id, uint amount) external returns (uint principal, uint collateral) { (principal, collateral) = _draw(id, amount); } function liquidate( address borrower, uint id, uint amount ) external { uint collateralLiquidated = _liquidate(borrower, id, amount); pendingWithdrawals[msg.sender] = pendingWithdrawals[msg.sender].add(collateralLiquidated); } function claim(uint amount) external nonReentrant { // If they try to withdraw more than their total balance, it will fail on the safe sub. pendingWithdrawals[msg.sender] = pendingWithdrawals[msg.sender].sub(amount); // solhint-disable avoid-low-level-calls (bool success, ) = msg.sender.call.value(amount)(""); require(success, "Transfer failed"); } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract ICollateralManager","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":"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":"amountRepaid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralAfter","type":"uint256"}],"name":"LoanClosedByRepayment","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":"uint256","name":"minCollateral","type":"uint256"}],"name":"MinCollateralUpdated","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":"address","name":"rewardsContract","type":"address"},{"internalType":"bytes32","name":"synth","type":"bytes32"}],"name":"addRewardsContracts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32[]","name":"_synthNamesInResolver","type":"bytes32[]"},{"internalType":"bytes32[]","name":"_synthKeys","type":"bytes32[]"}],"name":"addSynths","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32[]","name":"_synthNamesInResolver","type":"bytes32[]"},{"internalType":"bytes32[]","name":"_synthKeys","type":"bytes32[]"}],"name":"areSynthsAndCurrenciesSet","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":"amount","type":"uint256"}],"name":"claim","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"close","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"}],"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":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"collateralRatio","outputs":[{"internalType":"uint256","name":"cratio","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"draw","outputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","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":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"liquidationAmount","outputs":[{"internalType":"uint256","name":"liqAmount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"loans","outputs":[{"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"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"manager","outputs":[{"internalType":"contract ICollateralManager","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":"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":"amount","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"}],"name":"open","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"pendingWithdrawals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"}],"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":"_issueFeeRate","type":"uint256"}],"name":"setIssueFeeRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_minCollateral","type":"uint256"}],"name":"setMinCollateral","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":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"synths","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"synthsByKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080604052600d805460ff191660011790553480156200001e57600080fd5b506040516200476938038062004769833981016040819052620000419162000150565b8585858585858380876001600160a01b0381166200007c5760405162461bcd60e51b8152600401620000739062000261565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000c99184906200023b565b60405180910390a150600280546001600160a01b039283166001600160a01b0319918216179091556006805498909216971696909617909555600492909255600a55600b5550506001600e5550620002e295505050505050565b80516200013081620002b2565b92915050565b80516200013081620002cc565b80516200013081620002d7565b60008060008060008060c087890312156200016a57600080fd5b600062000178898962000123565b96505060206200018b89828a0162000143565b95505060406200019e89828a0162000123565b9450506060620001b189828a0162000136565b9350506080620001c489828a0162000136565b92505060a0620001d789828a0162000136565b9150509295509295509295565b620001ef81620002a5565b82525050565b620001ef816200027c565b60006200020f60198362000273565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b604081016200024b8285620001e4565b6200025a6020830184620001f5565b9392505050565b60208082528101620001308162000200565b90815260200190565b6000620001308262000299565b90565b600062000130826200027c565b6001600160a01b031690565b600062000130826200028c565b620002bd816200027c565b8114620002c957600080fd5b50565b620002bd8162000289565b620002bd816200028c565b61447780620002f26000396000f3fe60806040526004361061020f5760003560e01c806372e18b6a11610118578063925ead11116100a0578063ba2de9bc1161006f578063ba2de9bc146105b0578063d2b8035a146105c5578063de81eda9146105e5578063e1ec3c6814610605578063f3f437031461063a5761020f565b8063925ead1114610546578063a76cdfa51461055b578063aa2d8ce31461057b578063b562a1ab1461059b5761020f565b8063846321a4116100e7578063846321a4146104af578063899ffef4146104cf5780638cd2e0c7146104f15780638da5cb5b1461051157806390abb4d9146105265761020f565b806372e18b6a14610445578063741853601461046557806379ba50971461047a5780637e1323551461048f5761020f565b8063379607f51161019b578063441a3e701161016a578063441a3e70146103bb57806347e7ef24146103db578063481c6a75146103ee57806353a47bb7146104035780635eb2ad01146104255761020f565b8063379607f51461034657806338245377146103665780634065b81b1461038657806341c738011461039b5761020f565b80631627540c116101e25780631627540c146102af57806323d60e2e146102cf5780632af64bd3146102ef57806330edd96114610311578063361e2086146103315761020f565b806304f3bcec1461021457806306c19e3f1461023f5780630710285c1461025f5780630aebeb4e14610281575b600080fd5b34801561022057600080fd5b5061022961065a565b6040516102369190614009565b60405180910390f35b61025261024d3660046136c0565b610669565b6040516102369190613f97565b34801561026b57600080fd5b5061027f61027a36600461355b565b61067f565b005b34801561028d57600080fd5b506102a161029c366004613684565b6106c5565b604051610236929190613fb3565b3480156102bb57600080fd5b5061027f6102ca3660046134e5565b61070e565b3480156102db57600080fd5b5061027f6102ea3660046135a8565b61076c565b3480156102fb57600080fd5b5061030461083b565b6040516102369190613f89565b34801561031d57600080fd5b5061025261032c366004613684565b610953565b34801561033d57600080fd5b50610252610971565b34801561035257600080fd5b5061027f610361366004613684565b610977565b34801561037257600080fd5b50610252610381366004613684565b610a4c565b34801561039257600080fd5b50610304610a5e565b3480156103a757600080fd5b506102526103b6366004613684565b610a67565b3480156103c757600080fd5b506102a16103d63660046136c0565b610b7f565b6102a16103e9366004613521565b610bca565b3480156103fa57600080fd5b50610229610be3565b34801561040f57600080fd5b50610418610bf2565b6040516102369190613f26565b34801561043157600080fd5b5061027f610440366004613521565b610c01565b34801561045157600080fd5b506103046104603660046135a8565b610c37565b34801561047157600080fd5b5061027f610cfb565b34801561048657600080fd5b5061027f610e4d565b34801561049b57600080fd5b506102526104aa3660046136c0565b610ee9565b3480156104bb57600080fd5b5061027f6104ca366004613684565b610f2e565b3480156104db57600080fd5b506104e4610f6b565b6040516102369190613f78565b3480156104fd57600080fd5b506102a161050c36600461355b565b6110fb565b34801561051d57600080fd5b50610418611116565b34801561053257600080fd5b5061027f610541366004613618565b611125565b34801561055257600080fd5b50610252611171565b34801561056757600080fd5b5061027f610576366004613684565b611177565b34801561058757600080fd5b50610252610596366004613684565b6111b4565b3480156105a757600080fd5b50610252611278565b3480156105bc57600080fd5b5061025261127e565b3480156105d157600080fd5b506102a16105e03660046136c0565b611284565b3480156105f157600080fd5b50610418610600366004613684565b611291565b34801561061157600080fd5b50610625610620366004613684565b6112ac565b604051610236999897969594939291906141ee565b34801561064657600080fd5b506102526106553660046134e5565b611306565b6002546001600160a01b031681565b60006106783484846000611318565b9392505050565b600061068c8484846119c0565b336000908152600f60205260409020549091506106af908263ffffffff611d2716565b336000908152600f602052604090205550505050565b6000806106d23384611d4c565b336000908152600f602052604090205491935091506106f7908263ffffffff611d2716565b336000908152600f60205260409020559092909150565b610716611e42565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610761908390613f26565b60405180910390a150565b610774611e42565b82811461079c5760405162461bcd60e51b815260040161079390614048565b60405180910390fd5b60005b8381101561082c5760008585838181106107b557fe5b600780546001810182556000918252602090920293909301357fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688909101819055925082916008915086868681811061080957fe5b60209081029290920135835250810191909152604001600020555060010161079f565b50610835610cfb565b50505050565b60006060610847610f6b565b905060005b815181101561094957600082828151811061086357fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a721906108b4908590600401613f97565b60206040518083038186803b1580156108cc57600080fd5b505afa1580156108e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109049190810190613503565b6001600160a01b031614158061092f57506000818152600360205260409020546001600160a01b0316155b156109405760009350505050610950565b5060010161084c565b5060019150505b90565b6007818154811061096057fe5b600091825260209091200154905081565b600c5481565b600e805460010190819055336000908152600f60205260409020546109a2908363ffffffff611e6e16565b336000818152600f602052604080822093909355915184906109c390613f1b565b60006040518083038185875af1925050503d8060008114610a00576040519150601f19603f3d011682016040523d82523d6000602084013e610a05565b606091505b5050905080610a265760405162461bcd60e51b815260040161079390614058565b50600e548114610a485760405162461bcd60e51b815260040161079390614168565b5050565b60086020526000908152604090205481565b600d5460ff1681565b6000610a71613407565b506000828152600560208181526040928390208351610120810185528154815260018201546001600160a01b03169281019290925260028101549382019390935260038301546060820152600483015460808201529082015460ff16151560a0820152600682015460c0820152600782015460e0820152600890910154610100820152610afc611e96565b6001600160a01b031663fbfeca4082600a546004546040518463ffffffff1660e01b8152600401610b2f939291906141a5565b60206040518083038186803b158015610b4757600080fd5b505afa158015610b5b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061067891908101906136a2565b600080610b8c8484611eb7565b336000908152600f60205260409020549193509150610bb1908463ffffffff611d2716565b336000908152600f602052604090205590939092509050565b600080610bd8848434611f5c565b909590945092505050565b6006546001600160a01b031681565b6001546001600160a01b031681565b610c09611e42565b600090815260096020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b6007546000908414610c4b57506000610cf3565b60005b84811015610ced576000868683818110610c6457fe5b9050602002013590508060078381548110610c7b57fe5b906000526020600020015414610c9657600092505050610cf3565b60078281548110610ca357fe5b906000526020600020015460086000878786818110610cbe57fe5b9050602002013581526020019081526020016000205414610ce457600092505050610cf3565b50600101610c4e565b50600190505b949350505050565b6060610d05610f6b565b905060005b8151811015610a48576000828281518110610d2157fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d018384604051602001610d639190613f10565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610d8f929190613fc1565b60206040518083038186803b158015610da757600080fd5b505afa158015610dbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610ddf9190810190613503565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890610e3b9084908490613fa5565b60405180910390a15050600101610d0a565b6001546001600160a01b03163314610e775760405162461bcd60e51b815260040161079390614038565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92610eba926001600160a01b0391821692911690613f4f565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000610ef3611e96565b6001600160a01b0316638a7399758484600a546004546040518563ffffffff1660e01b8152600401610b2f94939291906142da565b92915050565b610f36611e42565b600b8190556040517fd19fe8ad9152af12b174a60210fb798db0767d63973ebb97298dc44d67a5c82d90610761908390613f97565b606080610f7661202d565b60408051600680825260e08201909252919250606091906020820160c08038833901905050905066119959541bdbdb60ca1b81600081518110610fb557fe5b6020026020010181815250506c45786368616e6765526174657360981b81600181518110610fdf57fe5b6020026020010181815250506822bc31b430b733b2b960b91b8160028151811061100557fe5b6020026020010181815250506b53797374656d53746174757360a01b8160038151811061102e57fe5b6020026020010181815250506814de5b9d1a1cd554d160ba1b8160048151811061105457fe5b6020026020010181815250506d10dbdb1b185d195c985b155d1a5b60921b8160058151811061107f57fe5b6020026020010181815250506060611097838361207e565b90506110f38160078054806020026020016040519081016040528092919081815260200182805480156110e957602002820191906000526020600020905b8154815260200190600101908083116110d5575b505050505061207e565b935050505090565b60008061110a8533868661213a565b90969095509350505050565b6000546001600160a01b031681565b61112d611e42565b600d805460ff191682151517908190556040517f261991749e1b2436706a31bde8bf184bb37fe21e303709b78d3b881afacadaa2916107619160ff90911690613f89565b600a5481565b61117f611e42565b600c8190556040517fe7bd72551c54d568cd97b00dc52d2787b5c5d4f0070d3582c1e8ba25141f799c90610761908390613f97565b60006111be613407565b506000828152600560208181526040928390208351610120810185528154815260018201546001600160a01b03169281019290925260028101549382019390935260038301546060820152600483015460808201529082015460ff16151560a0820152600682015460c0820152600782015460e0820152600890910154610100820152611249611e96565b6001600160a01b031663e99f9647826004546040518363ffffffff1660e01b8152600401610b2f929190614188565b60045481565b600b5481565b600080610bd884846122e9565b6009602052600090815260409020546001600160a01b031681565b600560208190526000918252604090912080546001820154600283015460038401546004850154958501546006860154600787015460089097015495976001600160a01b0390951696939592949360ff9092169290919089565b600f6020526000908152604090205481565b600061132261272b565b61132a6127cd565b600d5460ff1661134c5760405162461bcd60e51b815260040161079390614118565b6000838152600860205260409020546113775760405162461bcd60e51b815260040161079390614068565b61137f612821565b6001600160a01b0316632528f0fe846040518263ffffffff1660e01b81526004016113aa9190613f97565b60206040518083038186803b1580156113c257600080fd5b505afa1580156113d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113fa9190810190613636565b156114175760405162461bcd60e51b8152600401610793906140f8565b600b548510156114395760405162461bcd60e51b815260040161079390614148565b6006546040516302d35b2d60e61b815260009182916001600160a01b039091169063b4d6cb40906114709089908990600401613fb3565b604080518083038186803b15801561148757600080fd5b505afa15801561149b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114bf9190810190613654565b915091508180156114ce575080155b6114ea5760405162461bcd60e51b8152600401610793906140d8565b6114f48786610ee9565b8611156115135760405162461bcd60e51b815260040161079390614138565b600061152a600c548861283c90919063ffffffff16565b9050600061153e888363ffffffff611e6e16565b9050600660009054906101000a90046001600160a01b03166001600160a01b031663b3b467326040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561159057600080fd5b505af11580156115a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115c891908101906136a2565b60408051610120810182528281523360208083019182528284018e8152606084018d8152608085018f81528d151560a08701908152600060c0880181815260e08901828152426101008b019081528c84526005988990529a9092209851895596516001890180546001600160a01b0319166001600160a01b03909216919091179055935160028801559151600387015551600486015551918401805460ff191692151592909217909155905160068301555160078201559051600882015590955061169290612851565b61169c8288612943565b851561188f576116aa612b2f565b6001600160a01b031663867904b4336116c1612821565b6001600160a01b031663654a60ac8b86631cd554d160e21b6040518463ffffffff1660e01b81526004016116f793929190613fe1565b60206040518083038186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061174791908101906136a2565b6040518363ffffffff1660e01b8152600401611764929190613f34565b600060405180830381600087803b15801561177e57600080fd5b505af1158015611792573d6000803e3d6000fd5b505060065460405163e31f27c160e01b81526001600160a01b03909116925063e31f27c191506117c8908a908c90600401613fb3565b600060405180830381600087803b1580156117e257600080fd5b505af11580156117f6573d6000803e3d6000fd5b5050506000888152600960205260409020546001600160a01b031615905061188a576000878152600960205260409081902054905163db454a5160e01b81526001600160a01b039091169063db454a51906118579033908c90600401613f34565b600060405180830381600087803b15801561187157600080fd5b505af1158015611885573d6000803e3d6000fd5b505050505b61196b565b6000878152600860205260409020546118a790612b46565b6001600160a01b031663867904b433836040518363ffffffff1660e01b81526004016118d4929190613f34565b600060405180830381600087803b1580156118ee57600080fd5b505af1158015611902573d6000803e3d6000fd5b50506006546040516375ca5def60e11b81526001600160a01b03909116925063eb94bbde9150611938908a908c90600401613fb3565b600060405180830381600087803b15801561195257600080fd5b505af1158015611966573d6000803e3d6000fd5b505050505b336001600160a01b03167f604952b18be5fed608cbdd28101dc57bd667055c9678ec6d44fb1d8e4c7c172a868a8c8b876040516119ac9594939291906142f5565b60405180910390a250505050949350505050565b60006119ca61272b565b6119d26127cd565b600082116119f25760405162461bcd60e51b815260040161079390614178565b60006119fe8486612b51565b9050611a0f33826003015485612ba5565b600a54611a1a611e96565b6001600160a01b031663e99f9647836004546040518363ffffffff1660e01b8152600401611a499291906141d0565b60206040518083038186803b158015611a6157600080fd5b505afa158015611a75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a9991908101906136a2565b10611ab65760405162461bcd60e51b815260040161079390614158565b6000611ac0611e96565b6001600160a01b031663fbfeca4083600a546004546040518463ffffffff1660e01b8152600401611af3939291906141df565b60206040518083038186803b158015611b0b57600080fd5b505afa158015611b1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b4391908101906136a2565b90506000848210611b545784611b56565b815b90506000611b7584600601548560040154611d2790919063ffffffff16565b9050808210611b9657611b89883386612c5d565b9550610678945050505050565b611ba533856003015484612ba5565b611baf8483612cce565b611bb7611e96565b6001600160a01b0316633c4aa0f38560030154846004546040518463ffffffff1660e01b8152600401611bec93929190613fe1565b60206040518083038186803b158015611c0457600080fd5b505afa158015611c18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611c3c91908101906136a2565b6002850154909550611c54908663ffffffff611e6e16565b60028501556003840154600090815260086020526040902054611c7690612b46565b6001600160a01b0316639dc29fac33846040518363ffffffff1660e01b8152600401611ca3929190613f34565b600060405180830381600087803b158015611cbd57600080fd5b505af1158015611cd1573d6000803e3d6000fd5b50505050876001600160a01b03167fb6e43890aeea54fbe6c0ed628e78172a0ff30bbcb1d70d8b130b12c366bac4c588338589604051611d149493929190614274565b60405180910390a2505050509392505050565b6000828201838110156106785760405162461bcd60e51b815260040161079390614078565b600080611d5761272b565b611d5f6127cd565b6000611d6b8486612b51565b60408051610120810182528254815260018301546001600160a01b031660208201526002830154918101919091526003820154606082015260048201546080820152600582015460ff16151560a0820152600682015460c0820152600782015460e08201526008820154610100820152909150611de790612ebd565b611df2858683612f0a565b60405191945092506001600160a01b038616907fcab22a4e95d29d40da2ace3f6ec72b49954a9bc7b2584f8fd47bf7f357a3ed6f90611e32908790613f97565b60405180910390a2509250929050565b6000546001600160a01b03163314611e6c5760405162461bcd60e51b8152600401610793906140b8565b565b600082821115611e905760405162461bcd60e51b815260040161079390614098565b50900390565b6000611eb26d10dbdb1b185d195c985b155d1a5b60921b613170565b905090565b600080611ec261272b565b611eca6127cd565b6000611ed68533612b51565b6002810154909150611eee908563ffffffff611e6e16565b6002820155611efc816131cd565b336001600160a01b03167ffae26280bca25d80f1501a9e363c73d3845e651c9aaae54f1fc09a9dcd5f330386868460020154604051611f3d93929190613fe1565b60405180910390a28060040154816002015492509250505b9250929050565b600080611f6761272b565b611f6f6127cd565b60008311611f8f5760405162461bcd60e51b815260040161079390614128565b60008481526005602052604090206007810154611fab90613206565b611fb481612851565b6002810154611fc9908563ffffffff611d2716565b600282018190556040516001600160a01b038816917f0b1992dffc262be88559dcaf96464e9d661d8bfca7e82f2bb73e31932a82187c9161200e918991899190613fe1565b60405180910390a2806004015481600201549250925050935093915050565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b8160008151811061206f57fe5b60200260200101818152505090565b606081518351016040519080825280602002602001820160405280156120ae578160200160208202803883390190505b50905060005b83518110156120f0578381815181106120c957fe5b60200260200101518282815181106120dd57fe5b60209081029190910101526001016120b4565b5060005b82518110156121335782818151811061210957fe5b602002602001015182828651018151811061212057fe5b60209081029190910101526001016120f4565b5092915050565b60008061214561272b565b61214d6127cd565b6000848152600560208181526040928390208351610120810185528154815260018201546001600160a01b03169281019290925260028101549382019390935260038301546060820152600483015460808201529082015460ff16151560a0820152600682015460c0820152600782015460e082015260088201546101008201526121d790612ebd565b6121e686826003015486612ba5565b6121ef81612851565b6121f98185612cce565b600381015460009081526008602052604090205461221690612b46565b6001600160a01b0316639dc29fac87866040518363ffffffff1660e01b8152600401612243929190613f6a565b600060405180830381600087803b15801561225d57600080fd5b505af1158015612271573d6000803e3d6000fd5b50505050428160080181905550856001600160a01b0316876001600160a01b03167fdf10512219e869922340b1b24b21d7d79bf71f411a6391cc7c3ef5dd2fe89e7f878785600401546040516122c993929190613fe1565b60405180910390a380600401548160020154925092505094509492505050565b6000806122f461272b565b6122fc6127cd565b60006123088533612b51565b60408051610120810182528254815260018301546001600160a01b031660208201526002830154918101919091526003820154606082015260048201546080820152600582015460ff16151560a0820152600682015460c0820152600782015460e0820152600882015461010082015290915061238490612ebd565b6004810154612399908563ffffffff611d2716565b60048201556123a7816131cd565b60006123be600c548661283c90919063ffffffff16565b905060006123d2868363ffffffff611e6e16565b600584015490915060ff16156125df57600654600384015460405163e31f27c160e01b81526001600160a01b039092169163e31f27c191612417918a90600401613fb3565b600060405180830381600087803b15801561243157600080fd5b505af1158015612445573d6000803e3d6000fd5b50505050612451612b2f565b6001600160a01b031663867904b433612468612821565b6001600160a01b031663654a60ac876003015486631cd554d160e21b6040518463ffffffff1660e01b81526004016124a293929190613fe1565b60206040518083038186803b1580156124ba57600080fd5b505afa1580156124ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124f291908101906136a2565b6040518363ffffffff1660e01b815260040161250f929190613f34565b600060405180830381600087803b15801561252957600080fd5b505af115801561253d573d6000803e3d6000fd5b5050505060038301546000908152600960205260409020546001600160a01b0316156125da5760038301546000908152600960205260409081902054905163db454a5160e01b81526001600160a01b039091169063db454a51906125a79033908a90600401613f34565b600060405180830381600087803b1580156125c157600080fd5b505af11580156125d5573d6000803e3d6000fd5b505050505b6126c3565b60065460038401546040516375ca5def60e11b81526001600160a01b039092169163eb94bbde91612614918a90600401613fb3565b600060405180830381600087803b15801561262e57600080fd5b505af1158015612642573d6000803e3d6000fd5b50505060038401546000908152600860205260409020546126639150612b46565b6001600160a01b031663867904b433836040518363ffffffff1660e01b8152600401612690929190613f34565b600060405180830381600087803b1580156126aa57600080fd5b505af11580156126be573d6000803e3d6000fd5b505050505b6126d1828460030154612943565b42600884015560405133907f5754fe57f36ac0f121901d7555aba517e6608590429d86a81c662cf3583106549061270b908a908a90613fb3565b60405180910390a282600401548360020154945094505050509250929050565b612733612821565b6001600160a01b0316632528f0fe6004546040518263ffffffff1660e01b81526004016127609190613f97565b60206040518083038186803b15801561277857600080fd5b505afa15801561278c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506127b09190810190613636565b15611e6c5760405162461bcd60e51b8152600401610793906140f8565b6127d5613223565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b15801561280d57600080fd5b505afa158015610835573d6000803e3d6000fd5b6000611eb26c45786368616e6765526174657360981b613170565b60006106788383670de0b6b3a764000061323d565b600654600782015460038301546005840154604051634002a33360e11b815260009485946001600160a01b03909116936380054666936128999360ff909116906004016142b2565b6040805180830381600087803b1580156128b257600080fd5b505af11580156128c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506128ea91908101906136df565b9150915060008360070154600014612916576004840154612911908463ffffffff61327916565b612919565b60005b6006850154909150612931908263ffffffff611d2716565b60068501555060079092019190915550565b8115610a4857631cd554d160e21b81146129e85761295f612821565b6001600160a01b031663654a60ac8284631cd554d160e21b6040518463ffffffff1660e01b815260040161299593929190613fe1565b60206040518083038186803b1580156129ad57600080fd5b505afa1580156129c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506129e591908101906136a2565b91505b6129f0612b2f565b6001600160a01b031663867904b4612a066132a3565b6001600160a01b031663eb1edd616040518163ffffffff1660e01b815260040160206040518083038186803b158015612a3e57600080fd5b505afa158015612a52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a769190810190613503565b846040518363ffffffff1660e01b8152600401612a94929190613f6a565b600060405180830381600087803b158015612aae57600080fd5b505af1158015612ac2573d6000803e3d6000fd5b50505050612ace6132a3565b6001600160a01b03166322bf55ef836040518263ffffffff1660e01b8152600401612af99190613f97565b600060405180830381600087803b158015612b1357600080fd5b505af1158015612b27573d6000803e3d6000fd5b505050505050565b6000611eb26814de5b9d1a1cd554d160ba1b613170565b6000610f2882613170565b60008281526005602052604090206007810154612b6d90613206565b60018101546001600160a01b03838116911614612b9c5760405162461bcd60e51b815260040161079390614108565b610f2881612851565b6000828152600860205260409020548190612bbf90612b46565b6001600160a01b03166370a08231856040518263ffffffff1660e01b8152600401612bea9190613f26565b60206040518083038186803b158015612c0257600080fd5b505afa158015612c16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612c3a91908101906136a2565b1015612c585760405162461bcd60e51b8152600401610793906140a8565b505050565b600080612c6b858585612f0a565b8092508193505050836001600160a01b0316856001600160a01b03167f697721ed1b9d4866cb1aaa0692f62bb3abc1b01c2dafeaad053ffd4532aa7dbb85600001548585604051612cbe93929190613fe1565b60405180910390a3935093915050565b60008111612cee5760405162461bcd60e51b815260040161079390614178565b600682015415612d5057600082600601548211612d0b5781612d11565b82600601545b6006840154909150612d29908263ffffffff611e6e16565b6006840155612d3e828263ffffffff611e6e16565b9150612d4e818460030154612943565b505b8015610a48576004820154612d6b908263ffffffff611e6e16565b6004830155600582015460ff1615612e88576006546003830154604051635246f2b960e01b81526001600160a01b0390921691635246f2b991612db2918590600401613fb3565b600060405180830381600087803b158015612dcc57600080fd5b505af1158015612de0573d6000803e3d6000fd5b5050505060038201546000908152600960205260409020546001600160a01b031615612e8357600382015460009081526009602052604090819020546001840154915163f3fef3a360e01b81526001600160a01b039182169263f3fef3a392612e50929116908590600401613f34565b600060405180830381600087803b158015612e6a57600080fd5b505af1158015612e7e573d6000803e3d6000fd5b505050505b610a48565b600654600383015460405163e50a31b360e01b81526001600160a01b039092169163e50a31b391612af9918590600401613fb3565b612eca8160e00151613206565b42612ee9612ed7306132b8565b6101008401519063ffffffff611d2716565b1115612f075760405162461bcd60e51b8152600401610793906140e8565b50565b6000806000612f2a84600601548560040154611d2790919063ffffffff16565b90508360040154925083600201549150612f4985856003015483612ba5565b6003840154600090815260086020526040902054612f6690612b46565b6001600160a01b0316639dc29fac86836040518363ffffffff1660e01b8152600401612f93929190613f6a565b600060405180830381600087803b158015612fad57600080fd5b505af1158015612fc1573d6000803e3d6000fd5b50505050600584015460ff16156130df576006546003850154600480870154604051635246f2b960e01b81526001600160a01b0390941693635246f2b99361300c9390929101613fb3565b600060405180830381600087803b15801561302657600080fd5b505af115801561303a573d6000803e3d6000fd5b5050505060038401546000908152600960205260409020546001600160a01b0316156130da5760038401546000908152600960205260409081902054600480870154925163f3fef3a360e01b81526001600160a01b039092169263f3fef3a3926130a7928b929101613f6a565b600060405180830381600087803b1580156130c157600080fd5b505af11580156130d5573d6000803e3d6000fd5b505050505b61314c565b600654600385015460048087015460405163e50a31b360e01b81526001600160a01b039094169363e50a31b3936131199390929101613fb3565b600060405180830381600087803b15801561313357600080fd5b505af1158015613147573d6000803e3d6000fd5b505050505b61315e84600601548560030154612943565b6131678461338b565b50935093915050565b60008181526003602090815260408083205490516001600160a01b0390911691821515916131a091869101613ef0565b604051602081830303815290604052906121335760405162461bcd60e51b81526004016107939190614017565b60048101546131db57612f07565b600a5481546131e9906111b4565b11612f075760405162461bcd60e51b815260040161079390614028565b80612f075760405162461bcd60e51b815260040161079390614088565b6000611eb26b53797374656d53746174757360a01b613170565b600080600a8304613254868663ffffffff6133b016565b8161325b57fe5b0490506005600a82061061326d57600a015b600a9004949350505050565b6000670de0b6b3a7640000613294848463ffffffff6133b016565b8161329b57fe5b049392505050565b6000611eb266119959541bdbdb60ca1b613170565b60006132c26133ea565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b6f696e746572616374696f6e44656c617960801b85604051602001613308929190613eca565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b815260040161333b929190613fb3565b60206040518083038186803b15801561335357600080fd5b505afa158015613367573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610f2891908101906136a2565b6000600482018190556002820181905560068201819055600782015542600890910155565b6000826133bf57506000610f28565b828202828482816133cc57fe5b04146106785760405162461bcd60e51b8152600401610793906140c8565b6000611eb26e466c657869626c6553746f7261676560881b613170565b6040518061012001604052806000815260200160006001600160a01b031681526020016000815260200160008019168152602001600081526020016000151581526020016000815260200160008152602001600081525090565b8035610f288161440e565b8051610f288161440e565b60008083601f84011261348957600080fd5b50813567ffffffffffffffff8111156134a157600080fd5b602083019150836020820283011115611f5557600080fd5b8035610f2881614422565b8051610f2881614422565b8035610f288161442b565b8051610f288161442b565b6000602082840312156134f757600080fd5b6000610cf38484613461565b60006020828403121561351557600080fd5b6000610cf3848461346c565b6000806040838503121561353457600080fd5b60006135408585613461565b9250506020613551858286016134cf565b9150509250929050565b60008060006060848603121561357057600080fd5b600061357c8686613461565b935050602061358d868287016134cf565b925050604061359e868287016134cf565b9150509250925092565b600080600080604085870312156135be57600080fd5b843567ffffffffffffffff8111156135d557600080fd5b6135e187828801613477565b9450945050602085013567ffffffffffffffff81111561360057600080fd5b61360c87828801613477565b95989497509550505050565b60006020828403121561362a57600080fd5b6000610cf384846134b9565b60006020828403121561364857600080fd5b6000610cf384846134c4565b6000806040838503121561366757600080fd5b600061367385856134c4565b9250506020613551858286016134c4565b60006020828403121561369657600080fd5b6000610cf384846134cf565b6000602082840312156136b457600080fd5b6000610cf384846134da565b600080604083850312156136d357600080fd5b600061354085856134cf565b600080604083850312156136f257600080fd5b60006136fe85856134da565b9250506020613551858286016134da565b600061371b83836137ae565b505060200190565b61372c8161437b565b82525050565b61372c8161436b565b61372c6137478261436b565b6143ed565b600061375782614347565b613761818561434b565b935061376c83614341565b8060005b8381101561379a578151613784888261370f565b975061378f83614341565b925050600101613770565b509495945050505050565b61372c81614376565b61372c81610950565b61372c6137c382610950565b610950565b61372c81614382565b60006137dc82614347565b6137e6818561434b565b93506137f681856020860161438d565b6137ff816143fe565b9093019392505050565b6000613816600e8361434b565b6d43726174696f20746f6f206c6f7760901b815260200192915050565b600061384060358361434b565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b600061389760158361434b565b74082e4e4c2f240d8cadccee8d040dad2e6dac2e8c6d605b1b815260200192915050565b60006138c8600f8361434b565b6e151c985b9cd9995c8819985a5b1959608a1b815260200192915050565b60006138f360148361434b565b734e6f7420616c6c6f77656420746f20697373756560601b815260200192915050565b6000613923601b8361434b565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061395c600e8361434b565b6d131bd85b881a5cc818db1bdcd95960921b815260200192915050565b6000613986601e8361434b565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b60006139bf601183614354565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006139ec60128361434b565b714e6f7420656e6f7567682062616c616e636560701b815260200192915050565b6000613a1a602f8361434b565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b6000613a6b60218361434b565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000613aae601a8361434b565b7f44656274206c696d6974206f7220696e76616c69642072617465000000000000815260200192915050565b6000613ae760138361434b565b72149958d95b9d1b1e481a5b9d195c9858dd1959606a1b815260200192915050565b6000613b16601983614354565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b6000613b4f600c8361434b565b6b496e76616c6964207261746560a01b815260200192915050565b6000613b7760108361434b565b6f26bab9ba103132903137b93937bbb2b960811b815260200192915050565b6000610f28600083614354565b6000613bb0600d8361434b565b6c13dc195b88191a5cd8589b1959609a1b815260200192915050565b6000613bd960178361434b565b7f4465706f736974206d7573742062652061626f76652030000000000000000000815260200192915050565b6000613c1260178361434b565b7f457863656564206d617820626f72726f7720706f776572000000000000000000815260200192915050565b6000613c4b60158361434b565b74139bdd08195b9bdd59da0818dbdb1b185d195c985b605a1b815260200192915050565b6000613c7c60168361434b565b7543726174696f2061626f7665206c697120726174696f60501b815260200192915050565b6000613cae601f8361434b565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00815260200192915050565b6000613ce760178361434b565b7f5061796d656e74206d7573742062652061626f76652030000000000000000000815260200192915050565b8051610120830190613d2584826137ae565b506020820151613d386020850182613732565b506040820151613d4b60408501826137ae565b506060820151613d5e60608501826137ae565b506080820151613d7160808501826137ae565b5060a0820151613d8460a08501826137a5565b5060c0820151613d9760c08501826137ae565b5060e0820151613daa60e08501826137ae565b506101008201516108356101008501826137ae565b8054610120830190613dd0816143df565b613dda85826137ae565b50506001820154613dea816143b9565b613df76020860182613732565b50506002820154613e07816143df565b613e1460408601826137ae565b50506003820154613e24816143df565b613e3160608601826137ae565b50506004820154613e41816143df565b613e4e60808601826137ae565b50506005820154613e5e816143cc565b613e6b60a08601826137a5565b50506006820154613e7b816143df565b613e8860c08601826137ae565b50506007820154613e98816143df565b613ea560e08601826137ae565b50506008820154613eb5816143df565b613ec36101008601826137ae565b5050505050565b6000613ed682856137b7565b602082019150613ee6828461373b565b5060140192915050565b6000613efb826139b2565b9150613f0782846137b7565b50602001919050565b6000613efb82613b09565b6000610f2882613b96565b60208101610f288284613732565b60408101613f428285613723565b61067860208301846137ae565b60408101613f5d8285613732565b6106786020830184613732565b60408101613f428285613732565b60208082528101610678818461374c565b60208101610f2882846137a5565b60208101610f2882846137ae565b60408101613f5d82856137ae565b60408101613f4282856137ae565b60408101613fcf82856137ae565b8181036020830152610cf381846137d1565b60608101613fef82866137ae565b613ffc60208301856137ae565b610cf360408301846137ae565b60208101610f2882846137c8565b6020808252810161067881846137d1565b60208082528101610f2881613809565b60208082528101610f2881613833565b60208082528101610f288161388a565b60208082528101610f28816138bb565b60208082528101610f28816138e6565b60208082528101610f2881613916565b60208082528101610f288161394f565b60208082528101610f2881613979565b60208082528101610f28816139df565b60208082528101610f2881613a0d565b60208082528101610f2881613a5e565b60208082528101610f2881613aa1565b60208082528101610f2881613ada565b60208082528101610f2881613b42565b60208082528101610f2881613b6a565b60208082528101610f2881613ba3565b60208082528101610f2881613bcc565b60208082528101610f2881613c05565b60208082528101610f2881613c3e565b60208082528101610f2881613c6f565b60208082528101610f2881613ca1565b60208082528101610f2881613cda565b61014081016141978285613d13565b6106786101208301846137ae565b61016081016141b48286613d13565b6141c26101208301856137ae565b610cf36101408301846137ae565b61014081016141978285613dbf565b61016081016141b48286613dbf565b61012081016141fd828c6137ae565b61420a602083018b613732565b614217604083018a6137ae565b61422460608301896137ae565b61423160808301886137ae565b61423e60a08301876137a5565b61424b60c08301866137ae565b61425860e08301856137ae565b6142666101008301846137ae565b9a9950505050505050505050565b6080810161428282876137ae565b61428f6020830186613723565b61429c60408301856137ae565b6142a960608301846137ae565b95945050505050565b606081016142c082866137ae565b6142cd60208301856137ae565b610cf360408301846137a5565b608081016142e882876137ae565b61428f60208301866137ae565b60a0810161430382886137ae565b61431060208301876137ae565b61431d60408301866137ae565b61432a60608301856137ae565b61433760808301846137ae565b9695505050505050565b60200190565b5190565b90815260200190565b919050565b6001600160a01b031690565b60ff1690565b6000610f2882614359565b151590565b6000610f28825b6000610f288261436b565b60005b838110156143a8578181015183820152602001614390565b838111156108355750506000910152565b6000610f286143c783610950565b614359565b6000610f286143da83610950565b614365565b6000610f286137c383610950565b6000610f28826000610f2882614408565b601f01601f191690565b60601b90565b6144178161436b565b8114612f0757600080fd5b61441781614376565b6144178161095056fea365627a7a723158207ea733850eab679e1a0115a60d2318d891ec530c9063b5a96fa092a6360815b46c6578706572696d656e74616cf564736f6c634300051000400000000000000000000000003c05b1239b223c969540fefc0270227a2b00e04700000000000000000000000015e7d4972a3e477878a5867a47617122be2d1ff00000000000000000000000001cb059b7e74fd21665968c908806143e744d5f30734554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010a741a462780000000000000000000000000000000000000000000000000000016345785d8a0000
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003c05b1239b223c969540fefc0270227a2b00e04700000000000000000000000015e7d4972a3e477878a5867a47617122be2d1ff00000000000000000000000001cb059b7e74fd21665968c908806143e744d5f30734554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010a741a462780000000000000000000000000000000000000000000000000000016345785d8a0000
-----Decoded View---------------
Arg [0] : _owner (address): 0x3c05b1239b223c969540fefc0270227a2b00e047
Arg [1] : _manager (address): 0x15e7d4972a3e477878a5867a47617122be2d1ff0
Arg [2] : _resolver (address): 0x1cb059b7e74fd21665968c908806143e744d5f30
Arg [3] : _collateralKey (bytes32): 0x7345544800000000000000000000000000000000000000000000000000000000
Arg [4] : _minCratio (uint256): 1200000000000000000
Arg [5] : _minCollateral (uint256): 100000000000000000
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000003c05b1239b223c969540fefc0270227a2b00e047
Arg [1] : 00000000000000000000000015e7d4972a3e477878a5867a47617122be2d1ff0
Arg [2] : 0000000000000000000000001cb059b7e74fd21665968c908806143e744d5f30
Arg [3] : 7345544800000000000000000000000000000000000000000000000000000000
Arg [4] : 00000000000000000000000000000000000000000000000010a741a462780000
Arg [5] : 000000000000000000000000000000000000000000000000016345785d8a0000
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.