Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
AragonFundraisingController
Compiler Version
v0.4.24+commit.e67f0147
Contract Source Code (Solidity)
/** *Submitted for verification at Etherscan.io on 2020-02-10 */ // File: @aragon/os/contracts/common/UnstructuredStorage.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; library UnstructuredStorage { function getStorageBool(bytes32 position) internal view returns (bool data) { assembly { data := sload(position) } } function getStorageAddress(bytes32 position) internal view returns (address data) { assembly { data := sload(position) } } function getStorageBytes32(bytes32 position) internal view returns (bytes32 data) { assembly { data := sload(position) } } function getStorageUint256(bytes32 position) internal view returns (uint256 data) { assembly { data := sload(position) } } function setStorageBool(bytes32 position, bool data) internal { assembly { sstore(position, data) } } function setStorageAddress(bytes32 position, address data) internal { assembly { sstore(position, data) } } function setStorageBytes32(bytes32 position, bytes32 data) internal { assembly { sstore(position, data) } } function setStorageUint256(bytes32 position, uint256 data) internal { assembly { sstore(position, data) } } } // File: @aragon/os/contracts/acl/IACL.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; interface IACL { function initialize(address permissionsCreator) external; // TODO: this should be external // See https://github.com/ethereum/solidity/issues/4832 function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool); } // File: @aragon/os/contracts/common/IVaultRecoverable.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; interface IVaultRecoverable { event RecoverToVault(address indexed vault, address indexed token, uint256 amount); function transferToVault(address token) external; function allowRecoverability(address token) external view returns (bool); function getRecoveryVault() external view returns (address); } // File: @aragon/os/contracts/kernel/IKernel.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; interface IKernelEvents { event SetApp(bytes32 indexed namespace, bytes32 indexed appId, address app); } // This should be an interface, but interfaces can't inherit yet :( contract IKernel is IKernelEvents, IVaultRecoverable { function acl() public view returns (IACL); function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool); function setApp(bytes32 namespace, bytes32 appId, address app) public; function getApp(bytes32 namespace, bytes32 appId) public view returns (address); } // File: @aragon/os/contracts/apps/AppStorage.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract AppStorage { using UnstructuredStorage for bytes32; /* Hardcoded constants to save gas bytes32 internal constant KERNEL_POSITION = keccak256("aragonOS.appStorage.kernel"); bytes32 internal constant APP_ID_POSITION = keccak256("aragonOS.appStorage.appId"); */ bytes32 internal constant KERNEL_POSITION = 0x4172f0f7d2289153072b0a6ca36959e0cbe2efc3afe50fc81636caa96338137b; bytes32 internal constant APP_ID_POSITION = 0xd625496217aa6a3453eecb9c3489dc5a53e6c67b444329ea2b2cbc9ff547639b; function kernel() public view returns (IKernel) { return IKernel(KERNEL_POSITION.getStorageAddress()); } function appId() public view returns (bytes32) { return APP_ID_POSITION.getStorageBytes32(); } function setKernel(IKernel _kernel) internal { KERNEL_POSITION.setStorageAddress(address(_kernel)); } function setAppId(bytes32 _appId) internal { APP_ID_POSITION.setStorageBytes32(_appId); } } // File: @aragon/os/contracts/acl/ACLSyntaxSugar.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract ACLSyntaxSugar { function arr() internal pure returns (uint256[]) { return new uint256[](0); } function arr(bytes32 _a) internal pure returns (uint256[] r) { return arr(uint256(_a)); } function arr(bytes32 _a, bytes32 _b) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b)); } function arr(address _a) internal pure returns (uint256[] r) { return arr(uint256(_a)); } function arr(address _a, address _b) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b)); } function arr(address _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) { return arr(uint256(_a), _b, _c); } function arr(address _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) { return arr(uint256(_a), _b, _c, _d); } function arr(address _a, uint256 _b) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b)); } function arr(address _a, address _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b), _c, _d, _e); } function arr(address _a, address _b, address _c) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b), uint256(_c)); } function arr(address _a, address _b, uint256 _c) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b), uint256(_c)); } function arr(uint256 _a) internal pure returns (uint256[] r) { r = new uint256[](1); r[0] = _a; } function arr(uint256 _a, uint256 _b) internal pure returns (uint256[] r) { r = new uint256[](2); r[0] = _a; r[1] = _b; } function arr(uint256 _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) { r = new uint256[](3); r[0] = _a; r[1] = _b; r[2] = _c; } function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) { r = new uint256[](4); r[0] = _a; r[1] = _b; r[2] = _c; r[3] = _d; } function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) { r = new uint256[](5); r[0] = _a; r[1] = _b; r[2] = _c; r[3] = _d; r[4] = _e; } } contract ACLHelpers { function decodeParamOp(uint256 _x) internal pure returns (uint8 b) { return uint8(_x >> (8 * 30)); } function decodeParamId(uint256 _x) internal pure returns (uint8 b) { return uint8(_x >> (8 * 31)); } function decodeParamsList(uint256 _x) internal pure returns (uint32 a, uint32 b, uint32 c) { a = uint32(_x); b = uint32(_x >> (8 * 4)); c = uint32(_x >> (8 * 8)); } } // File: @aragon/os/contracts/common/Uint256Helpers.sol pragma solidity ^0.4.24; library Uint256Helpers { uint256 private constant MAX_UINT64 = uint64(-1); string private constant ERROR_NUMBER_TOO_BIG = "UINT64_NUMBER_TOO_BIG"; function toUint64(uint256 a) internal pure returns (uint64) { require(a <= MAX_UINT64, ERROR_NUMBER_TOO_BIG); return uint64(a); } } // File: @aragon/os/contracts/common/TimeHelpers.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract TimeHelpers { using Uint256Helpers for uint256; /** * @dev Returns the current block number. * Using a function rather than `block.number` allows us to easily mock the block number in * tests. */ function getBlockNumber() internal view returns (uint256) { return block.number; } /** * @dev Returns the current block number, converted to uint64. * Using a function rather than `block.number` allows us to easily mock the block number in * tests. */ function getBlockNumber64() internal view returns (uint64) { return getBlockNumber().toUint64(); } /** * @dev Returns the current timestamp. * Using a function rather than `block.timestamp` allows us to easily mock it in * tests. */ function getTimestamp() internal view returns (uint256) { return block.timestamp; // solium-disable-line security/no-block-members } /** * @dev Returns the current timestamp, converted to uint64. * Using a function rather than `block.timestamp` allows us to easily mock it in * tests. */ function getTimestamp64() internal view returns (uint64) { return getTimestamp().toUint64(); } } // File: @aragon/os/contracts/common/Initializable.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract Initializable is TimeHelpers { using UnstructuredStorage for bytes32; // keccak256("aragonOS.initializable.initializationBlock") bytes32 internal constant INITIALIZATION_BLOCK_POSITION = 0xebb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e; string private constant ERROR_ALREADY_INITIALIZED = "INIT_ALREADY_INITIALIZED"; string private constant ERROR_NOT_INITIALIZED = "INIT_NOT_INITIALIZED"; modifier onlyInit { require(getInitializationBlock() == 0, ERROR_ALREADY_INITIALIZED); _; } modifier isInitialized { require(hasInitialized(), ERROR_NOT_INITIALIZED); _; } /** * @return Block number in which the contract was initialized */ function getInitializationBlock() public view returns (uint256) { return INITIALIZATION_BLOCK_POSITION.getStorageUint256(); } /** * @return Whether the contract has been initialized by the time of the current block */ function hasInitialized() public view returns (bool) { uint256 initializationBlock = getInitializationBlock(); return initializationBlock != 0 && getBlockNumber() >= initializationBlock; } /** * @dev Function to be called by top level contract after initialization has finished. */ function initialized() internal onlyInit { INITIALIZATION_BLOCK_POSITION.setStorageUint256(getBlockNumber()); } /** * @dev Function to be called by top level contract after initialization to enable the contract * at a future block number rather than immediately. */ function initializedAt(uint256 _blockNumber) internal onlyInit { INITIALIZATION_BLOCK_POSITION.setStorageUint256(_blockNumber); } } // File: @aragon/os/contracts/common/Petrifiable.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract Petrifiable is Initializable { // Use block UINT256_MAX (which should be never) as the initializable date uint256 internal constant PETRIFIED_BLOCK = uint256(-1); function isPetrified() public view returns (bool) { return getInitializationBlock() == PETRIFIED_BLOCK; } /** * @dev Function to be called by top level contract to prevent being initialized. * Useful for freezing base contracts when they're used behind proxies. */ function petrify() internal onlyInit { initializedAt(PETRIFIED_BLOCK); } } // File: @aragon/os/contracts/common/Autopetrified.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract Autopetrified is Petrifiable { constructor() public { // Immediately petrify base (non-proxy) instances of inherited contracts on deploy. // This renders them uninitializable (and unusable without a proxy). petrify(); } } // File: @aragon/os/contracts/common/ConversionHelpers.sol pragma solidity ^0.4.24; library ConversionHelpers { string private constant ERROR_IMPROPER_LENGTH = "CONVERSION_IMPROPER_LENGTH"; function dangerouslyCastUintArrayToBytes(uint256[] memory _input) internal pure returns (bytes memory output) { // Force cast the uint256[] into a bytes array, by overwriting its length // Note that the bytes array doesn't need to be initialized as we immediately overwrite it // with the input and a new length. The input becomes invalid from this point forward. uint256 byteLength = _input.length * 32; assembly { output := _input mstore(output, byteLength) } } function dangerouslyCastBytesToUintArray(bytes memory _input) internal pure returns (uint256[] memory output) { // Force cast the bytes array into a uint256[], by overwriting its length // Note that the uint256[] doesn't need to be initialized as we immediately overwrite it // with the input and a new length. The input becomes invalid from this point forward. uint256 intsLength = _input.length / 32; require(_input.length == intsLength * 32, ERROR_IMPROPER_LENGTH); assembly { output := _input mstore(output, intsLength) } } } // File: @aragon/os/contracts/common/ReentrancyGuard.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract ReentrancyGuard { using UnstructuredStorage for bytes32; /* Hardcoded constants to save gas bytes32 internal constant REENTRANCY_MUTEX_POSITION = keccak256("aragonOS.reentrancyGuard.mutex"); */ bytes32 private constant REENTRANCY_MUTEX_POSITION = 0xe855346402235fdd185c890e68d2c4ecad599b88587635ee285bce2fda58dacb; string private constant ERROR_REENTRANT = "REENTRANCY_REENTRANT_CALL"; modifier nonReentrant() { // Ensure mutex is unlocked require(!REENTRANCY_MUTEX_POSITION.getStorageBool(), ERROR_REENTRANT); // Lock mutex before function call REENTRANCY_MUTEX_POSITION.setStorageBool(true); // Perform function call _; // Unlock mutex after function call REENTRANCY_MUTEX_POSITION.setStorageBool(false); } } // File: @aragon/os/contracts/lib/token/ERC20.sol // See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/a9f910d34f0ab33a1ae5e714f69f9596a02b4d91/contracts/token/ERC20/ERC20.sol pragma solidity ^0.4.24; /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function allowance(address _owner, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } // File: @aragon/os/contracts/common/EtherTokenConstant.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; // aragonOS and aragon-apps rely on address(0) to denote native ETH, in // contracts where both tokens and ETH are accepted contract EtherTokenConstant { address internal constant ETH = address(0); } // File: @aragon/os/contracts/common/IsContract.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract IsContract { /* * NOTE: this should NEVER be used for authentication * (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize). * * This is only intended to be used as a sanity check that an address is actually a contract, * RATHER THAN an address not being a contract. */ function isContract(address _target) internal view returns (bool) { if (_target == address(0)) { return false; } uint256 size; assembly { size := extcodesize(_target) } return size > 0; } } // File: @aragon/os/contracts/common/SafeERC20.sol // Inspired by AdEx (https://github.com/AdExNetwork/adex-protocol-eth/blob/b9df617829661a7518ee10f4cb6c4108659dd6d5/contracts/libs/SafeERC20.sol) // and 0x (https://github.com/0xProject/0x-monorepo/blob/737d1dc54d72872e24abce5a1dbe1b66d35fa21a/contracts/protocol/contracts/protocol/AssetProxy/ERC20Proxy.sol#L143) pragma solidity ^0.4.24; library SafeERC20 { // Before 0.5, solidity has a mismatch between `address.transfer()` and `token.transfer()`: // https://github.com/ethereum/solidity/issues/3544 bytes4 private constant TRANSFER_SELECTOR = 0xa9059cbb; string private constant ERROR_TOKEN_BALANCE_REVERTED = "SAFE_ERC_20_BALANCE_REVERTED"; string private constant ERROR_TOKEN_ALLOWANCE_REVERTED = "SAFE_ERC_20_ALLOWANCE_REVERTED"; function invokeAndCheckSuccess(address _addr, bytes memory _calldata) private returns (bool) { bool ret; assembly { let ptr := mload(0x40) // free memory pointer let success := call( gas, // forward all gas _addr, // address 0, // no value add(_calldata, 0x20), // calldata start mload(_calldata), // calldata length ptr, // write output over free memory 0x20 // uint256 return ) if gt(success, 0) { // Check number of bytes returned from last function call switch returndatasize // No bytes returned: assume success case 0 { ret := 1 } // 32 bytes returned: check if non-zero case 0x20 { // Only return success if returned data was true // Already have output in ptr ret := eq(mload(ptr), 1) } // Not sure what was returned: don't mark as success default { } } } return ret; } function staticInvoke(address _addr, bytes memory _calldata) private view returns (bool, uint256) { bool success; uint256 ret; assembly { let ptr := mload(0x40) // free memory pointer success := staticcall( gas, // forward all gas _addr, // address add(_calldata, 0x20), // calldata start mload(_calldata), // calldata length ptr, // write output over free memory 0x20 // uint256 return ) if gt(success, 0) { ret := mload(ptr) } } return (success, ret); } /** * @dev Same as a standards-compliant ERC20.transfer() that never reverts (returns false). * Note that this makes an external call to the token. */ function safeTransfer(ERC20 _token, address _to, uint256 _amount) internal returns (bool) { bytes memory transferCallData = abi.encodeWithSelector( TRANSFER_SELECTOR, _to, _amount ); return invokeAndCheckSuccess(_token, transferCallData); } /** * @dev Same as a standards-compliant ERC20.transferFrom() that never reverts (returns false). * Note that this makes an external call to the token. */ function safeTransferFrom(ERC20 _token, address _from, address _to, uint256 _amount) internal returns (bool) { bytes memory transferFromCallData = abi.encodeWithSelector( _token.transferFrom.selector, _from, _to, _amount ); return invokeAndCheckSuccess(_token, transferFromCallData); } /** * @dev Same as a standards-compliant ERC20.approve() that never reverts (returns false). * Note that this makes an external call to the token. */ function safeApprove(ERC20 _token, address _spender, uint256 _amount) internal returns (bool) { bytes memory approveCallData = abi.encodeWithSelector( _token.approve.selector, _spender, _amount ); return invokeAndCheckSuccess(_token, approveCallData); } /** * @dev Static call into ERC20.balanceOf(). * Reverts if the call fails for some reason (should never fail). */ function staticBalanceOf(ERC20 _token, address _owner) internal view returns (uint256) { bytes memory balanceOfCallData = abi.encodeWithSelector( _token.balanceOf.selector, _owner ); (bool success, uint256 tokenBalance) = staticInvoke(_token, balanceOfCallData); require(success, ERROR_TOKEN_BALANCE_REVERTED); return tokenBalance; } /** * @dev Static call into ERC20.allowance(). * Reverts if the call fails for some reason (should never fail). */ function staticAllowance(ERC20 _token, address _owner, address _spender) internal view returns (uint256) { bytes memory allowanceCallData = abi.encodeWithSelector( _token.allowance.selector, _owner, _spender ); (bool success, uint256 allowance) = staticInvoke(_token, allowanceCallData); require(success, ERROR_TOKEN_ALLOWANCE_REVERTED); return allowance; } } // File: @aragon/os/contracts/common/VaultRecoverable.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract VaultRecoverable is IVaultRecoverable, EtherTokenConstant, IsContract { using SafeERC20 for ERC20; string private constant ERROR_DISALLOWED = "RECOVER_DISALLOWED"; string private constant ERROR_VAULT_NOT_CONTRACT = "RECOVER_VAULT_NOT_CONTRACT"; string private constant ERROR_TOKEN_TRANSFER_FAILED = "RECOVER_TOKEN_TRANSFER_FAILED"; /** * @notice Send funds to recovery Vault. This contract should never receive funds, * but in case it does, this function allows one to recover them. * @param _token Token balance to be sent to recovery vault. */ function transferToVault(address _token) external { require(allowRecoverability(_token), ERROR_DISALLOWED); address vault = getRecoveryVault(); require(isContract(vault), ERROR_VAULT_NOT_CONTRACT); uint256 balance; if (_token == ETH) { balance = address(this).balance; vault.transfer(balance); } else { ERC20 token = ERC20(_token); balance = token.staticBalanceOf(this); require(token.safeTransfer(vault, balance), ERROR_TOKEN_TRANSFER_FAILED); } emit RecoverToVault(vault, _token, balance); } /** * @dev By default deriving from AragonApp makes it recoverable * @param token Token address that would be recovered * @return bool whether the app allows the recovery */ function allowRecoverability(address token) public view returns (bool) { return true; } // Cast non-implemented interface to be public so we can use it internally function getRecoveryVault() public view returns (address); } // File: @aragon/os/contracts/evmscript/IEVMScriptExecutor.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; interface IEVMScriptExecutor { function execScript(bytes script, bytes input, address[] blacklist) external returns (bytes); function executorType() external pure returns (bytes32); } // File: @aragon/os/contracts/evmscript/IEVMScriptRegistry.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract EVMScriptRegistryConstants { /* Hardcoded constants to save gas bytes32 internal constant EVMSCRIPT_REGISTRY_APP_ID = apmNamehash("evmreg"); */ bytes32 internal constant EVMSCRIPT_REGISTRY_APP_ID = 0xddbcfd564f642ab5627cf68b9b7d374fb4f8a36e941a75d89c87998cef03bd61; } interface IEVMScriptRegistry { function addScriptExecutor(IEVMScriptExecutor executor) external returns (uint id); function disableScriptExecutor(uint256 executorId) external; // TODO: this should be external // See https://github.com/ethereum/solidity/issues/4832 function getScriptExecutor(bytes script) public view returns (IEVMScriptExecutor); } // File: @aragon/os/contracts/kernel/KernelConstants.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract KernelAppIds { /* Hardcoded constants to save gas bytes32 internal constant KERNEL_CORE_APP_ID = apmNamehash("kernel"); bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = apmNamehash("acl"); bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = apmNamehash("vault"); */ bytes32 internal constant KERNEL_CORE_APP_ID = 0x3b4bf6bf3ad5000ecf0f989d5befde585c6860fea3e574a4fab4c49d1c177d9c; bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = 0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a; bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = 0x7e852e0fcfce6551c13800f1e7476f982525c2b5277ba14b24339c68416336d1; } contract KernelNamespaceConstants { /* Hardcoded constants to save gas bytes32 internal constant KERNEL_CORE_NAMESPACE = keccak256("core"); bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = keccak256("base"); bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = keccak256("app"); */ bytes32 internal constant KERNEL_CORE_NAMESPACE = 0xc681a85306374a5ab27f0bbc385296a54bcd314a1948b6cf61c4ea1bc44bb9f8; bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = 0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f; bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb; } // File: @aragon/os/contracts/evmscript/EVMScriptRunner.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; contract EVMScriptRunner is AppStorage, Initializable, EVMScriptRegistryConstants, KernelNamespaceConstants { string private constant ERROR_EXECUTOR_UNAVAILABLE = "EVMRUN_EXECUTOR_UNAVAILABLE"; string private constant ERROR_PROTECTED_STATE_MODIFIED = "EVMRUN_PROTECTED_STATE_MODIFIED"; /* This is manually crafted in assembly string private constant ERROR_EXECUTOR_INVALID_RETURN = "EVMRUN_EXECUTOR_INVALID_RETURN"; */ event ScriptResult(address indexed executor, bytes script, bytes input, bytes returnData); function getEVMScriptExecutor(bytes _script) public view returns (IEVMScriptExecutor) { return IEVMScriptExecutor(getEVMScriptRegistry().getScriptExecutor(_script)); } function getEVMScriptRegistry() public view returns (IEVMScriptRegistry) { address registryAddr = kernel().getApp(KERNEL_APP_ADDR_NAMESPACE, EVMSCRIPT_REGISTRY_APP_ID); return IEVMScriptRegistry(registryAddr); } function runScript(bytes _script, bytes _input, address[] _blacklist) internal isInitialized protectState returns (bytes) { IEVMScriptExecutor executor = getEVMScriptExecutor(_script); require(address(executor) != address(0), ERROR_EXECUTOR_UNAVAILABLE); bytes4 sig = executor.execScript.selector; bytes memory data = abi.encodeWithSelector(sig, _script, _input, _blacklist); bytes memory output; assembly { let success := delegatecall( gas, // forward all gas executor, // address add(data, 0x20), // calldata start mload(data), // calldata length 0, // don't write output (we'll handle this ourselves) 0 // don't write output ) output := mload(0x40) // free mem ptr get switch success case 0 { // If the call errored, forward its full error data returndatacopy(output, 0, returndatasize) revert(output, returndatasize) } default { switch gt(returndatasize, 0x3f) case 0 { // Need at least 0x40 bytes returned for properly ABI-encoded bytes values, // revert with "EVMRUN_EXECUTOR_INVALID_RETURN" // See remix: doing a `revert("EVMRUN_EXECUTOR_INVALID_RETURN")` always results in // this memory layout mstore(output, 0x08c379a000000000000000000000000000000000000000000000000000000000) // error identifier mstore(add(output, 0x04), 0x0000000000000000000000000000000000000000000000000000000000000020) // starting offset mstore(add(output, 0x24), 0x000000000000000000000000000000000000000000000000000000000000001e) // reason length mstore(add(output, 0x44), 0x45564d52554e5f4558454355544f525f494e56414c49445f52455455524e0000) // reason revert(output, 100) // 100 = 4 + 3 * 32 (error identifier + 3 words for the ABI encoded error) } default { // Copy result // // Needs to perform an ABI decode for the expected `bytes` return type of // `executor.execScript()` as solidity will automatically ABI encode the returned bytes as: // [ position of the first dynamic length return value = 0x20 (32 bytes) ] // [ output length (32 bytes) ] // [ output content (N bytes) ] // // Perform the ABI decode by ignoring the first 32 bytes of the return data let copysize := sub(returndatasize, 0x20) returndatacopy(output, 0x20, copysize) mstore(0x40, add(output, copysize)) // free mem ptr set } } } emit ScriptResult(address(executor), _script, _input, output); return output; } modifier protectState { address preKernel = address(kernel()); bytes32 preAppId = appId(); _; // exec require(address(kernel()) == preKernel, ERROR_PROTECTED_STATE_MODIFIED); require(appId() == preAppId, ERROR_PROTECTED_STATE_MODIFIED); } } // File: @aragon/os/contracts/apps/AragonApp.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; // Contracts inheriting from AragonApp are, by default, immediately petrified upon deployment so // that they can never be initialized. // Unless overriden, this behaviour enforces those contracts to be usable only behind an AppProxy. // ReentrancyGuard, EVMScriptRunner, and ACLSyntaxSugar are not directly used by this contract, but // are included so that they are automatically usable by subclassing contracts contract AragonApp is AppStorage, Autopetrified, VaultRecoverable, ReentrancyGuard, EVMScriptRunner, ACLSyntaxSugar { string private constant ERROR_AUTH_FAILED = "APP_AUTH_FAILED"; modifier auth(bytes32 _role) { require(canPerform(msg.sender, _role, new uint256[](0)), ERROR_AUTH_FAILED); _; } modifier authP(bytes32 _role, uint256[] _params) { require(canPerform(msg.sender, _role, _params), ERROR_AUTH_FAILED); _; } /** * @dev Check whether an action can be performed by a sender for a particular role on this app * @param _sender Sender of the call * @param _role Role on this app * @param _params Permission params for the role * @return Boolean indicating whether the sender has the permissions to perform the action. * Always returns false if the app hasn't been initialized yet. */ function canPerform(address _sender, bytes32 _role, uint256[] _params) public view returns (bool) { if (!hasInitialized()) { return false; } IKernel linkedKernel = kernel(); if (address(linkedKernel) == address(0)) { return false; } return linkedKernel.hasPermission( _sender, address(this), _role, ConversionHelpers.dangerouslyCastUintArrayToBytes(_params) ); } /** * @dev Get the recovery vault for the app * @return Recovery vault address for the app */ function getRecoveryVault() public view returns (address) { // Funds recovery via a vault is only available when used with a kernel return kernel().getRecoveryVault(); // if kernel is not set, it will revert } } // File: @aragon/os/contracts/lib/math/SafeMath.sol // See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol // Adapted to use pragma ^0.4.24 and satisfy our linter rules pragma solidity ^0.4.24; /** * @title SafeMath * @dev Math operations with safety checks that revert on error */ library SafeMath { string private constant ERROR_ADD_OVERFLOW = "MATH_ADD_OVERFLOW"; string private constant ERROR_SUB_UNDERFLOW = "MATH_SUB_UNDERFLOW"; string private constant ERROR_MUL_OVERFLOW = "MATH_MUL_OVERFLOW"; string private constant ERROR_DIV_ZERO = "MATH_DIV_ZERO"; /** * @dev Multiplies two numbers, reverts on 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, ERROR_MUL_OVERFLOW); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b > 0, ERROR_DIV_ZERO); // Solidity only automatically asserts when dividing by 0 uint256 c = _a / _b; // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b <= _a, ERROR_SUB_UNDERFLOW); uint256 c = _a - _b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 _a, uint256 _b) internal pure returns (uint256) { uint256 c = _a + _b; require(c >= _a, ERROR_ADD_OVERFLOW); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, ERROR_DIV_ZERO); return a % b; } } // File: @aragon/apps-agent/contracts/standards/ERC1271.sol pragma solidity 0.4.24; // ERC1271 on Feb 12th, 2019: https://github.com/ethereum/EIPs/blob/a97dc434930d0ccc4461c97d8c7a920dc585adf2/EIPS/eip-1271.md // Using `isValidSignature(bytes32,bytes)` even though the standard still hasn't been modified // Rationale: https://github.com/ethereum/EIPs/issues/1271#issuecomment-462719728 contract ERC1271 { bytes4 constant public ERC1271_INTERFACE_ID = 0xfb855dc9; // this.isValidSignature.selector bytes4 constant public ERC1271_RETURN_VALID_SIGNATURE = 0x20c13b0b; // TODO: Likely needs to be updated bytes4 constant public ERC1271_RETURN_INVALID_SIGNATURE = 0x00000000; /** * @dev Function must be implemented by deriving contract * @param _hash Arbitrary length data signed on the behalf of address(this) * @param _signature Signature byte array associated with _data * @return A bytes4 magic value 0x20c13b0b if the signature check passes, 0x00000000 if not * * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5) * MUST allow external calls */ function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4); function returnIsValidSignatureMagicNumber(bool isValid) internal pure returns (bytes4) { return isValid ? ERC1271_RETURN_VALID_SIGNATURE : ERC1271_RETURN_INVALID_SIGNATURE; } } contract ERC1271Bytes is ERC1271 { /** * @dev Default behavior of `isValidSignature(bytes,bytes)`, can be overloaded for custom validation * @param _data Arbitrary length data signed on the behalf of address(this) * @param _signature Signature byte array associated with _data * @return A bytes4 magic value 0x20c13b0b if the signature check passes, 0x00000000 if not * * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5) * MUST allow external calls */ function isValidSignature(bytes _data, bytes _signature) public view returns (bytes4) { return isValidSignature(keccak256(_data), _signature); } } // File: @aragon/apps-agent/contracts/SignatureValidator.sol pragma solidity 0.4.24; // Inspired by https://github.com/horizon-games/multi-token-standard/blob/319740cf2a78b8816269ae49a09c537b3fd7303b/contracts/utils/SignatureValidator.sol // This should probably be moved into aOS: https://github.com/aragon/aragonOS/pull/442 library SignatureValidator { enum SignatureMode { Invalid, // 0x00 EIP712, // 0x01 EthSign, // 0x02 ERC1271, // 0x03 NMode // 0x04, to check if mode is specified, leave at the end } // bytes4(keccak256("isValidSignature(bytes,bytes)") bytes4 public constant ERC1271_RETURN_VALID_SIGNATURE = 0x20c13b0b; uint256 internal constant ERC1271_ISVALIDSIG_MAX_GAS = 250000; string private constant ERROR_INVALID_LENGTH_POP_BYTE = "SIGVAL_INVALID_LENGTH_POP_BYTE"; /// @dev Validates that a hash was signed by a specified signer. /// @param hash Hash which was signed. /// @param signer Address of the signer. /// @param signature ECDSA signature along with the mode (0 = Invalid, 1 = EIP712, 2 = EthSign, 3 = ERC1271) {mode}{r}{s}{v}. /// @return Returns whether signature is from a specified user. function isValidSignature(bytes32 hash, address signer, bytes signature) internal view returns (bool) { if (signature.length == 0) { return false; } uint8 modeByte = uint8(signature[0]); if (modeByte >= uint8(SignatureMode.NMode)) { return false; } SignatureMode mode = SignatureMode(modeByte); if (mode == SignatureMode.EIP712) { return ecVerify(hash, signer, signature); } else if (mode == SignatureMode.EthSign) { return ecVerify( keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)), signer, signature ); } else if (mode == SignatureMode.ERC1271) { // Pop the mode byte before sending it down the validation chain return safeIsValidSignature(signer, hash, popFirstByte(signature)); } else { return false; } } function ecVerify(bytes32 hash, address signer, bytes memory signature) private pure returns (bool) { (bool badSig, bytes32 r, bytes32 s, uint8 v) = unpackEcSig(signature); if (badSig) { return false; } return signer == ecrecover(hash, v, r, s); } function unpackEcSig(bytes memory signature) private pure returns (bool badSig, bytes32 r, bytes32 s, uint8 v) { if (signature.length != 66) { badSig = true; return; } v = uint8(signature[65]); assembly { r := mload(add(signature, 33)) s := mload(add(signature, 65)) } // Allow signature version to be 0 or 1 if (v < 27) { v += 27; } if (v != 27 && v != 28) { badSig = true; } } function popFirstByte(bytes memory input) private pure returns (bytes memory output) { uint256 inputLength = input.length; require(inputLength > 0, ERROR_INVALID_LENGTH_POP_BYTE); output = new bytes(inputLength - 1); if (output.length == 0) { return output; } uint256 inputPointer; uint256 outputPointer; assembly { inputPointer := add(input, 0x21) outputPointer := add(output, 0x20) } memcpy(outputPointer, inputPointer, output.length); } function safeIsValidSignature(address validator, bytes32 hash, bytes memory signature) private view returns (bool) { bytes memory data = abi.encodeWithSelector(ERC1271(validator).isValidSignature.selector, hash, signature); bytes4 erc1271Return = safeBytes4StaticCall(validator, data, ERC1271_ISVALIDSIG_MAX_GAS); return erc1271Return == ERC1271_RETURN_VALID_SIGNATURE; } function safeBytes4StaticCall(address target, bytes data, uint256 maxGas) private view returns (bytes4 ret) { uint256 gasLeft = gasleft(); uint256 callGas = gasLeft > maxGas ? maxGas : gasLeft; bool ok; assembly { ok := staticcall(callGas, target, add(data, 0x20), mload(data), 0, 0) } if (!ok) { return; } uint256 size; assembly { size := returndatasize } if (size != 32) { return; } assembly { let ptr := mload(0x40) // get next free memory ptr returndatacopy(ptr, 0, size) // copy return from above `staticcall` ret := mload(ptr) // read data at ptr and set it to be returned } return ret; } // From: https://github.com/Arachnid/solidity-stringutils/blob/01e955c1d6/src/strings.sol function memcpy(uint256 dest, uint256 src, uint256 len) private pure { // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } } // File: @aragon/apps-agent/contracts/standards/IERC165.sol pragma solidity 0.4.24; interface IERC165 { function supportsInterface(bytes4 interfaceId) external pure returns (bool); } // File: @aragon/os/contracts/common/DepositableStorage.sol pragma solidity 0.4.24; contract DepositableStorage { using UnstructuredStorage for bytes32; // keccak256("aragonOS.depositableStorage.depositable") bytes32 internal constant DEPOSITABLE_POSITION = 0x665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea; function isDepositable() public view returns (bool) { return DEPOSITABLE_POSITION.getStorageBool(); } function setDepositable(bool _depositable) internal { DEPOSITABLE_POSITION.setStorageBool(_depositable); } } // File: @aragon/apps-vault/contracts/Vault.sol pragma solidity 0.4.24; contract Vault is EtherTokenConstant, AragonApp, DepositableStorage { using SafeERC20 for ERC20; bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE"); string private constant ERROR_DATA_NON_ZERO = "VAULT_DATA_NON_ZERO"; string private constant ERROR_NOT_DEPOSITABLE = "VAULT_NOT_DEPOSITABLE"; string private constant ERROR_DEPOSIT_VALUE_ZERO = "VAULT_DEPOSIT_VALUE_ZERO"; string private constant ERROR_TRANSFER_VALUE_ZERO = "VAULT_TRANSFER_VALUE_ZERO"; string private constant ERROR_SEND_REVERTED = "VAULT_SEND_REVERTED"; string private constant ERROR_VALUE_MISMATCH = "VAULT_VALUE_MISMATCH"; string private constant ERROR_TOKEN_TRANSFER_FROM_REVERTED = "VAULT_TOKEN_TRANSFER_FROM_REVERT"; string private constant ERROR_TOKEN_TRANSFER_REVERTED = "VAULT_TOKEN_TRANSFER_REVERTED"; event VaultTransfer(address indexed token, address indexed to, uint256 amount); event VaultDeposit(address indexed token, address indexed sender, uint256 amount); /** * @dev On a normal send() or transfer() this fallback is never executed as it will be * intercepted by the Proxy (see aragonOS#281) */ function () external payable isInitialized { require(msg.data.length == 0, ERROR_DATA_NON_ZERO); _deposit(ETH, msg.value); } /** * @notice Initialize Vault app * @dev As an AragonApp it needs to be initialized in order for roles (`auth` and `authP`) to work */ function initialize() external onlyInit { initialized(); setDepositable(true); } /** * @notice Deposit `_value` `_token` to the vault * @param _token Address of the token being transferred * @param _value Amount of tokens being transferred */ function deposit(address _token, uint256 _value) external payable isInitialized { _deposit(_token, _value); } /** * @notice Transfer `_value` `_token` from the Vault to `_to` * @param _token Address of the token being transferred * @param _to Address of the recipient of tokens * @param _value Amount of tokens being transferred */ /* solium-disable-next-line function-order */ function transfer(address _token, address _to, uint256 _value) external authP(TRANSFER_ROLE, arr(_token, _to, _value)) { require(_value > 0, ERROR_TRANSFER_VALUE_ZERO); if (_token == ETH) { require(_to.send(_value), ERROR_SEND_REVERTED); } else { require(ERC20(_token).safeTransfer(_to, _value), ERROR_TOKEN_TRANSFER_REVERTED); } emit VaultTransfer(_token, _to, _value); } function balance(address _token) public view returns (uint256) { if (_token == ETH) { return address(this).balance; } else { return ERC20(_token).staticBalanceOf(address(this)); } } /** * @dev Disable recovery escape hatch, as it could be used * maliciously to transfer funds away from the vault */ function allowRecoverability(address) public view returns (bool) { return false; } function _deposit(address _token, uint256 _value) internal { require(isDepositable(), ERROR_NOT_DEPOSITABLE); require(_value > 0, ERROR_DEPOSIT_VALUE_ZERO); if (_token == ETH) { // Deposit is implicit in this case require(msg.value == _value, ERROR_VALUE_MISMATCH); } else { require( ERC20(_token).safeTransferFrom(msg.sender, address(this), _value), ERROR_TOKEN_TRANSFER_FROM_REVERTED ); } emit VaultDeposit(_token, msg.sender, _value); } } // File: @aragon/os/contracts/common/IForwarder.sol /* * SPDX-License-Identitifer: MIT */ pragma solidity ^0.4.24; interface IForwarder { function isForwarder() external pure returns (bool); // TODO: this should be external // See https://github.com/ethereum/solidity/issues/4832 function canForward(address sender, bytes evmCallScript) public view returns (bool); // TODO: this should be external // See https://github.com/ethereum/solidity/issues/4832 function forward(bytes evmCallScript) public; } // File: @aragon/apps-agent/contracts/Agent.sol /* * SPDX-License-Identitifer: GPL-3.0-or-later */ pragma solidity 0.4.24; contract Agent is IERC165, ERC1271Bytes, IForwarder, IsContract, Vault { /* Hardcoded constants to save gas bytes32 public constant EXECUTE_ROLE = keccak256("EXECUTE_ROLE"); bytes32 public constant SAFE_EXECUTE_ROLE = keccak256("SAFE_EXECUTE_ROLE"); bytes32 public constant ADD_PROTECTED_TOKEN_ROLE = keccak256("ADD_PROTECTED_TOKEN_ROLE"); bytes32 public constant REMOVE_PROTECTED_TOKEN_ROLE = keccak256("REMOVE_PROTECTED_TOKEN_ROLE"); bytes32 public constant ADD_PRESIGNED_HASH_ROLE = keccak256("ADD_PRESIGNED_HASH_ROLE"); bytes32 public constant DESIGNATE_SIGNER_ROLE = keccak256("DESIGNATE_SIGNER_ROLE"); bytes32 public constant RUN_SCRIPT_ROLE = keccak256("RUN_SCRIPT_ROLE"); */ bytes32 public constant EXECUTE_ROLE = 0xcebf517aa4440d1d125e0355aae64401211d0848a23c02cc5d29a14822580ba4; bytes32 public constant SAFE_EXECUTE_ROLE = 0x0a1ad7b87f5846153c6d5a1f761d71c7d0cfd122384f56066cd33239b7933694; bytes32 public constant ADD_PROTECTED_TOKEN_ROLE = 0x6eb2a499556bfa2872f5aa15812b956cc4a71b4d64eb3553f7073c7e41415aaa; bytes32 public constant REMOVE_PROTECTED_TOKEN_ROLE = 0x71eee93d500f6f065e38b27d242a756466a00a52a1dbcd6b4260f01a8640402a; bytes32 public constant ADD_PRESIGNED_HASH_ROLE = 0x0b29780bb523a130b3b01f231ef49ed2fa2781645591a0b0a44ca98f15a5994c; bytes32 public constant DESIGNATE_SIGNER_ROLE = 0x23ce341656c3f14df6692eebd4757791e33662b7dcf9970c8308303da5472b7c; bytes32 public constant RUN_SCRIPT_ROLE = 0xb421f7ad7646747f3051c50c0b8e2377839296cd4973e27f63821d73e390338f; uint256 public constant PROTECTED_TOKENS_CAP = 10; bytes4 private constant ERC165_INTERFACE_ID = 0x01ffc9a7; string private constant ERROR_TARGET_PROTECTED = "AGENT_TARGET_PROTECTED"; string private constant ERROR_PROTECTED_TOKENS_MODIFIED = "AGENT_PROTECTED_TOKENS_MODIFIED"; string private constant ERROR_PROTECTED_BALANCE_LOWERED = "AGENT_PROTECTED_BALANCE_LOWERED"; string private constant ERROR_TOKENS_CAP_REACHED = "AGENT_TOKENS_CAP_REACHED"; string private constant ERROR_TOKEN_NOT_ERC20 = "AGENT_TOKEN_NOT_ERC20"; string private constant ERROR_TOKEN_ALREADY_PROTECTED = "AGENT_TOKEN_ALREADY_PROTECTED"; string private constant ERROR_TOKEN_NOT_PROTECTED = "AGENT_TOKEN_NOT_PROTECTED"; string private constant ERROR_DESIGNATED_TO_SELF = "AGENT_DESIGNATED_TO_SELF"; string private constant ERROR_CAN_NOT_FORWARD = "AGENT_CAN_NOT_FORWARD"; mapping (bytes32 => bool) public isPresigned; address public designatedSigner; address[] public protectedTokens; event SafeExecute(address indexed sender, address indexed target, bytes data); event Execute(address indexed sender, address indexed target, uint256 ethValue, bytes data); event AddProtectedToken(address indexed token); event RemoveProtectedToken(address indexed token); event PresignHash(address indexed sender, bytes32 indexed hash); event SetDesignatedSigner(address indexed sender, address indexed oldSigner, address indexed newSigner); /** * @notice Execute '`@radspec(_target, _data)`' on `_target``_ethValue == 0 ? '' : ' (Sending' + @tokenAmount(0x0000000000000000000000000000000000000000, _ethValue) + ')'` * @param _target Address where the action is being executed * @param _ethValue Amount of ETH from the contract that is sent with the action * @param _data Calldata for the action * @return Exits call frame forwarding the return data of the executed call (either error or success data) */ function execute(address _target, uint256 _ethValue, bytes _data) external // This function MUST always be external as the function performs a low level return, exiting the Agent app execution context authP(EXECUTE_ROLE, arr(_target, _ethValue, uint256(_getSig(_data)))) // bytes4 casted as uint256 sets the bytes as the LSBs { bool result = _target.call.value(_ethValue)(_data); if (result) { emit Execute(msg.sender, _target, _ethValue, _data); } assembly { let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize) // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas. // if the call returned error data, forward it switch result case 0 { revert(ptr, returndatasize) } default { return(ptr, returndatasize) } } } /** * @notice Execute '`@radspec(_target, _data)`' on `_target` ensuring that protected tokens can't be spent * @param _target Address where the action is being executed * @param _data Calldata for the action * @return Exits call frame forwarding the return data of the executed call (either error or success data) */ function safeExecute(address _target, bytes _data) external // This function MUST always be external as the function performs a low level return, exiting the Agent app execution context authP(SAFE_EXECUTE_ROLE, arr(_target, uint256(_getSig(_data)))) // bytes4 casted as uint256 sets the bytes as the LSBs { uint256 protectedTokensLength = protectedTokens.length; address[] memory protectedTokens_ = new address[](protectedTokensLength); uint256[] memory balances = new uint256[](protectedTokensLength); for (uint256 i = 0; i < protectedTokensLength; i++) { address token = protectedTokens[i]; require(_target != token, ERROR_TARGET_PROTECTED); // we copy the protected tokens array to check whether the storage array has been modified during the underlying call protectedTokens_[i] = token; // we copy the balances to check whether they have been modified during the underlying call balances[i] = balance(token); } bool result = _target.call(_data); bytes32 ptr; uint256 size; assembly { size := returndatasize ptr := mload(0x40) mstore(0x40, add(ptr, returndatasize)) returndatacopy(ptr, 0, returndatasize) } if (result) { // if the underlying call has succeeded, we check that the protected tokens // and their balances have not been modified and return the call's return data require(protectedTokens.length == protectedTokensLength, ERROR_PROTECTED_TOKENS_MODIFIED); for (uint256 j = 0; j < protectedTokensLength; j++) { require(protectedTokens[j] == protectedTokens_[j], ERROR_PROTECTED_TOKENS_MODIFIED); require(balance(protectedTokens[j]) >= balances[j], ERROR_PROTECTED_BALANCE_LOWERED); } emit SafeExecute(msg.sender, _target, _data); assembly { return(ptr, size) } } else { // if the underlying call has failed, we revert and forward returned error data assembly { revert(ptr, size) } } } /** * @notice Add `_token.symbol(): string` to the list of protected tokens * @param _token Address of the token to be protected */ function addProtectedToken(address _token) external authP(ADD_PROTECTED_TOKEN_ROLE, arr(_token)) { require(protectedTokens.length < PROTECTED_TOKENS_CAP, ERROR_TOKENS_CAP_REACHED); require(_isERC20(_token), ERROR_TOKEN_NOT_ERC20); require(!_tokenIsProtected(_token), ERROR_TOKEN_ALREADY_PROTECTED); _addProtectedToken(_token); } /** * @notice Remove `_token.symbol(): string` from the list of protected tokens * @param _token Address of the token to be unprotected */ function removeProtectedToken(address _token) external authP(REMOVE_PROTECTED_TOKEN_ROLE, arr(_token)) { require(_tokenIsProtected(_token), ERROR_TOKEN_NOT_PROTECTED); _removeProtectedToken(_token); } /** * @notice Pre-sign hash `_hash` * @param _hash Hash that will be considered signed regardless of the signature checked with 'isValidSignature()' */ function presignHash(bytes32 _hash) external authP(ADD_PRESIGNED_HASH_ROLE, arr(_hash)) { isPresigned[_hash] = true; emit PresignHash(msg.sender, _hash); } /** * @notice Set `_designatedSigner` as the designated signer of the app, which will be able to sign messages on behalf of the app * @param _designatedSigner Address that will be able to sign messages on behalf of the app */ function setDesignatedSigner(address _designatedSigner) external authP(DESIGNATE_SIGNER_ROLE, arr(_designatedSigner)) { // Prevent an infinite loop by setting the app itself as its designated signer. // An undetectable loop can be created by setting a different contract as the // designated signer which calls back into `isValidSignature`. // Given that `isValidSignature` is always called with just 50k gas, the max // damage of the loop is wasting 50k gas. require(_designatedSigner != address(this), ERROR_DESIGNATED_TO_SELF); address oldDesignatedSigner = designatedSigner; designatedSigner = _designatedSigner; emit SetDesignatedSigner(msg.sender, oldDesignatedSigner, _designatedSigner); } // Forwarding fns /** * @notice Tells whether the Agent app is a forwarder or not * @dev IForwarder interface conformance * @return Always true */ function isForwarder() external pure returns (bool) { return true; } /** * @notice Execute the script as the Agent app * @dev IForwarder interface conformance. Forwards any token holder action. * @param _evmScript Script being executed */ function forward(bytes _evmScript) public { require(canForward(msg.sender, _evmScript), ERROR_CAN_NOT_FORWARD); bytes memory input = ""; // no input address[] memory blacklist = new address[](0); // no addr blacklist, can interact with anything runScript(_evmScript, input, blacklist); // We don't need to emit an event here as EVMScriptRunner will emit ScriptResult if successful } /** * @notice Tells whether `_sender` can forward actions or not * @dev IForwarder interface conformance * @param _sender Address of the account intending to forward an action * @return True if the given address can run scripts, false otherwise */ function canForward(address _sender, bytes _evmScript) public view returns (bool) { // Note that `canPerform()` implicitly does an initialization check itself return canPerform(_sender, RUN_SCRIPT_ROLE, arr(_getScriptACLParam(_evmScript))); } // ERC-165 conformance /** * @notice Tells whether this contract supports a given ERC-165 interface * @param _interfaceId Interface bytes to check * @return True if this contract supports the interface */ function supportsInterface(bytes4 _interfaceId) external pure returns (bool) { return _interfaceId == ERC1271_INTERFACE_ID || _interfaceId == ERC165_INTERFACE_ID; } // ERC-1271 conformance /** * @notice Tells whether a signature is seen as valid by this contract through ERC-1271 * @param _hash Arbitrary length data signed on the behalf of address (this) * @param _signature Signature byte array associated with _data * @return The ERC-1271 magic value if the signature is valid */ function isValidSignature(bytes32 _hash, bytes _signature) public view returns (bytes4) { // Short-circuit in case the hash was presigned. Optimization as performing calls // and ecrecover is more expensive than an SLOAD. if (isPresigned[_hash]) { return returnIsValidSignatureMagicNumber(true); } bool isValid; if (designatedSigner == address(0)) { isValid = false; } else { isValid = SignatureValidator.isValidSignature(_hash, designatedSigner, _signature); } return returnIsValidSignatureMagicNumber(isValid); } // Getters function getProtectedTokensLength() public view isInitialized returns (uint256) { return protectedTokens.length; } // Internal fns function _addProtectedToken(address _token) internal { protectedTokens.push(_token); emit AddProtectedToken(_token); } function _removeProtectedToken(address _token) internal { protectedTokens[_protectedTokenIndex(_token)] = protectedTokens[protectedTokens.length - 1]; protectedTokens.length--; emit RemoveProtectedToken(_token); } function _isERC20(address _token) internal view returns (bool) { if (!isContract(_token)) { return false; } // Throwaway sanity check to make sure the token's `balanceOf()` does not error (for now) balance(_token); return true; } function _protectedTokenIndex(address _token) internal view returns (uint256) { for (uint i = 0; i < protectedTokens.length; i++) { if (protectedTokens[i] == _token) { return i; } } revert(ERROR_TOKEN_NOT_PROTECTED); } function _tokenIsProtected(address _token) internal view returns (bool) { for (uint256 i = 0; i < protectedTokens.length; i++) { if (protectedTokens[i] == _token) { return true; } } return false; } function _getScriptACLParam(bytes _evmScript) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(_evmScript))); } function _getSig(bytes _data) internal pure returns (bytes4 sig) { if (_data.length < 4) { return; } assembly { sig := mload(add(_data, 0x20)) } } } // File: @aragon/apps-shared-minime/contracts/ITokenController.sol pragma solidity ^0.4.24; /// @dev The token controller contract must implement these functions interface ITokenController { /// @notice Called when `_owner` sends ether to the MiniMe Token contract /// @param _owner The address that sent the ether to create tokens /// @return True if the ether is accepted, false if it throws function proxyPayment(address _owner) external payable returns(bool); /// @notice Notifies the controller about a token transfer allowing the /// controller to react if desired /// @param _from The origin of the transfer /// @param _to The destination of the transfer /// @param _amount The amount of the transfer /// @return False if the controller does not authorize the transfer function onTransfer(address _from, address _to, uint _amount) external returns(bool); /// @notice Notifies the controller about an approval allowing the /// controller to react if desired /// @param _owner The address that calls `approve()` /// @param _spender The spender in the `approve()` call /// @param _amount The amount in the `approve()` call /// @return False if the controller does not authorize the approval function onApprove(address _owner, address _spender, uint _amount) external returns(bool); } // File: @aragon/apps-shared-minime/contracts/MiniMeToken.sol pragma solidity ^0.4.24; /* Copyright 2016, Jordi Baylina This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /// @title MiniMeToken Contract /// @author Jordi Baylina /// @dev This token contract's goal is to make it easy for anyone to clone this /// token using the token distribution at a given block, this will allow DAO's /// and DApps to upgrade their features in a decentralized manner without /// affecting the original token /// @dev It is ERC20 compliant, but still needs to under go further testing. contract Controlled { /// @notice The address of the controller is the only address that can call /// a function with this modifier modifier onlyController { require(msg.sender == controller); _; } address public controller; function Controlled() public { controller = msg.sender;} /// @notice Changes the controller of the contract /// @param _newController The new controller of the contract function changeController(address _newController) onlyController public { controller = _newController; } } contract ApproveAndCallFallBack { function receiveApproval( address from, uint256 _amount, address _token, bytes _data ) public; } /// @dev The actual token contract, the default controller is the msg.sender /// that deploys the contract, so usually this token will be deployed by a /// token controller contract, which Giveth will call a "Campaign" contract MiniMeToken is Controlled { string public name; //The Token's name: e.g. DigixDAO Tokens uint8 public decimals; //Number of decimals of the smallest unit string public symbol; //An identifier: e.g. REP string public version = "MMT_0.1"; //An arbitrary versioning scheme /// @dev `Checkpoint` is the structure that attaches a block number to a /// given value, the block number attached is the one that last changed the /// value struct Checkpoint { // `fromBlock` is the block number that the value was generated from uint128 fromBlock; // `value` is the amount of tokens at a specific block number uint128 value; } // `parentToken` is the Token address that was cloned to produce this token; // it will be 0x0 for a token that was not cloned MiniMeToken public parentToken; // `parentSnapShotBlock` is the block number from the Parent Token that was // used to determine the initial distribution of the Clone Token uint public parentSnapShotBlock; // `creationBlock` is the block number that the Clone Token was created uint public creationBlock; // `balances` is the map that tracks the balance of each address, in this // contract when the balance changes the block number that the change // occurred is also included in the map mapping (address => Checkpoint[]) balances; // `allowed` tracks any extra transfer rights as in all ERC20 tokens mapping (address => mapping (address => uint256)) allowed; // Tracks the history of the `totalSupply` of the token Checkpoint[] totalSupplyHistory; // Flag that determines if the token is transferable or not. bool public transfersEnabled; // The factory used to create new clone tokens MiniMeTokenFactory public tokenFactory; //////////////// // Constructor //////////////// /// @notice Constructor to create a MiniMeToken /// @param _tokenFactory The address of the MiniMeTokenFactory contract that /// will create the Clone token contracts, the token factory needs to be /// deployed first /// @param _parentToken Address of the parent token, set to 0x0 if it is a /// new token /// @param _parentSnapShotBlock Block of the parent token that will /// determine the initial distribution of the clone token, set to 0 if it /// is a new token /// @param _tokenName Name of the new token /// @param _decimalUnits Number of decimals of the new token /// @param _tokenSymbol Token Symbol for the new token /// @param _transfersEnabled If true, tokens will be able to be transferred function MiniMeToken( MiniMeTokenFactory _tokenFactory, MiniMeToken _parentToken, uint _parentSnapShotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) public { tokenFactory = _tokenFactory; name = _tokenName; // Set the name decimals = _decimalUnits; // Set the decimals symbol = _tokenSymbol; // Set the symbol parentToken = _parentToken; parentSnapShotBlock = _parentSnapShotBlock; transfersEnabled = _transfersEnabled; creationBlock = block.number; } /////////////////// // ERC20 Methods /////////////////// /// @notice Send `_amount` tokens to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _amount The amount of tokens to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _amount) public returns (bool success) { require(transfersEnabled); return doTransfer(msg.sender, _to, _amount); } /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it /// is approved by `_from` /// @param _from The address holding the tokens being transferred /// @param _to The address of the recipient /// @param _amount The amount of tokens to be transferred /// @return True if the transfer was successful function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) { // The controller of this contract can move tokens around at will, // this is important to recognize! Confirm that you trust the // controller of this contract, which in most situations should be // another open source smart contract or 0x0 if (msg.sender != controller) { require(transfersEnabled); // The standard ERC 20 transferFrom functionality if (allowed[_from][msg.sender] < _amount) return false; allowed[_from][msg.sender] -= _amount; } return doTransfer(_from, _to, _amount); } /// @dev This is the actual transfer function in the token contract, it can /// only be called by other functions in this contract. /// @param _from The address holding the tokens being transferred /// @param _to The address of the recipient /// @param _amount The amount of tokens to be transferred /// @return True if the transfer was successful function doTransfer(address _from, address _to, uint _amount) internal returns(bool) { if (_amount == 0) { return true; } require(parentSnapShotBlock < block.number); // Do not allow transfer to 0x0 or the token contract itself require((_to != 0) && (_to != address(this))); // If the amount being transfered is more than the balance of the // account the transfer returns false var previousBalanceFrom = balanceOfAt(_from, block.number); if (previousBalanceFrom < _amount) { return false; } // Alerts the token controller of the transfer if (isContract(controller)) { // Adding the ` == true` makes the linter shut up so... require(ITokenController(controller).onTransfer(_from, _to, _amount) == true); } // First update the balance array with the new value for the address // sending the tokens updateValueAtNow(balances[_from], previousBalanceFrom - _amount); // Then update the balance array with the new value for the address // receiving the tokens var previousBalanceTo = balanceOfAt(_to, block.number); require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow updateValueAtNow(balances[_to], previousBalanceTo + _amount); // An event to make the transfer easy to find on the blockchain Transfer(_from, _to, _amount); return true; } /// @param _owner The address that's balance is being requested /// @return The balance of `_owner` at the current block function balanceOf(address _owner) public constant returns (uint256 balance) { return balanceOfAt(_owner, block.number); } /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on /// its behalf. This is a modified version of the ERC20 approve function /// to be a little bit safer /// @param _spender The address of the account able to transfer the tokens /// @param _amount The amount of tokens to be approved for transfer /// @return True if the approval was successful function approve(address _spender, uint256 _amount) public returns (bool success) { require(transfersEnabled); // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender,0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); // Alerts the token controller of the approve function call if (isContract(controller)) { // Adding the ` == true` makes the linter shut up so... require(ITokenController(controller).onApprove(msg.sender, _spender, _amount) == true); } allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } /// @dev This function makes it easy to read the `allowed[]` map /// @param _owner The address of the account that owns the token /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens of _owner that _spender is allowed /// to spend function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on /// its behalf, and then a function is triggered in the contract that is /// being approved, `_spender`. This allows users to use their tokens to /// interact with contracts in one function call instead of two /// @param _spender The address of the contract able to transfer the tokens /// @param _amount The amount of tokens to be approved for transfer /// @return True if the function call was successful function approveAndCall(ApproveAndCallFallBack _spender, uint256 _amount, bytes _extraData) public returns (bool success) { require(approve(_spender, _amount)); _spender.receiveApproval( msg.sender, _amount, this, _extraData ); return true; } /// @dev This function makes it easy to get the total number of tokens /// @return The total number of tokens function totalSupply() public constant returns (uint) { return totalSupplyAt(block.number); } //////////////// // Query balance and totalSupply in History //////////////// /// @dev Queries the balance of `_owner` at a specific `_blockNumber` /// @param _owner The address from which the balance will be retrieved /// @param _blockNumber The block number when the balance is queried /// @return The balance at `_blockNumber` function balanceOfAt(address _owner, uint _blockNumber) public constant returns (uint) { // These next few lines are used when the balance of the token is // requested before a check point was ever created for this token, it // requires that the `parentToken.balanceOfAt` be queried at the // genesis block for that token as this contains initial balance of // this token if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock)); } else { // Has no parent return 0; } // This will return the expected balance during normal situations } else { return getValueAt(balances[_owner], _blockNumber); } } /// @notice Total amount of tokens at a specific `_blockNumber`. /// @param _blockNumber The block number when the totalSupply is queried /// @return The total amount of tokens at `_blockNumber` function totalSupplyAt(uint _blockNumber) public constant returns(uint) { // These next few lines are used when the totalSupply of the token is // requested before a check point was ever created for this token, it // requires that the `parentToken.totalSupplyAt` be queried at the // genesis block for this token as that contains totalSupply of this // token at this block number. if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock)); } else { return 0; } // This will return the expected totalSupply during normal situations } else { return getValueAt(totalSupplyHistory, _blockNumber); } } //////////////// // Clone Token Method //////////////// /// @notice Creates a new clone token with the initial distribution being /// this token at `_snapshotBlock` /// @param _cloneTokenName Name of the clone token /// @param _cloneDecimalUnits Number of decimals of the smallest unit /// @param _cloneTokenSymbol Symbol of the clone token /// @param _snapshotBlock Block when the distribution of the parent token is /// copied to set the initial distribution of the new clone token; /// if the block is zero than the actual block, the current block is used /// @param _transfersEnabled True if transfers are allowed in the clone /// @return The address of the new MiniMeToken Contract function createCloneToken( string _cloneTokenName, uint8 _cloneDecimalUnits, string _cloneTokenSymbol, uint _snapshotBlock, bool _transfersEnabled ) public returns(MiniMeToken) { uint256 snapshot = _snapshotBlock == 0 ? block.number - 1 : _snapshotBlock; MiniMeToken cloneToken = tokenFactory.createCloneToken( this, snapshot, _cloneTokenName, _cloneDecimalUnits, _cloneTokenSymbol, _transfersEnabled ); cloneToken.changeController(msg.sender); // An event to make the token easy to find on the blockchain NewCloneToken(address(cloneToken), snapshot); return cloneToken; } //////////////// // Generate and destroy tokens //////////////// /// @notice Generates `_amount` tokens that are assigned to `_owner` /// @param _owner The address that will be assigned the new tokens /// @param _amount The quantity of tokens generated /// @return True if the tokens are generated correctly function generateTokens(address _owner, uint _amount) onlyController public returns (bool) { uint curTotalSupply = totalSupply(); require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow uint previousBalanceTo = balanceOf(_owner); require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount); updateValueAtNow(balances[_owner], previousBalanceTo + _amount); Transfer(0, _owner, _amount); return true; } /// @notice Burns `_amount` tokens from `_owner` /// @param _owner The address that will lose the tokens /// @param _amount The quantity of tokens to burn /// @return True if the tokens are burned correctly function destroyTokens(address _owner, uint _amount) onlyController public returns (bool) { uint curTotalSupply = totalSupply(); require(curTotalSupply >= _amount); uint previousBalanceFrom = balanceOf(_owner); require(previousBalanceFrom >= _amount); updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount); updateValueAtNow(balances[_owner], previousBalanceFrom - _amount); Transfer(_owner, 0, _amount); return true; } //////////////// // Enable tokens transfers //////////////// /// @notice Enables token holders to transfer their tokens freely if true /// @param _transfersEnabled True if transfers are allowed in the clone function enableTransfers(bool _transfersEnabled) onlyController public { transfersEnabled = _transfersEnabled; } //////////////// // Internal helper functions to query and set a value in a snapshot array //////////////// /// @dev `getValueAt` retrieves the number of tokens at a given block number /// @param checkpoints The history of values being queried /// @param _block The block number to retrieve the value at /// @return The number of tokens being queried function getValueAt(Checkpoint[] storage checkpoints, uint _block) constant internal returns (uint) { if (checkpoints.length == 0) return 0; // Shortcut for the actual value if (_block >= checkpoints[checkpoints.length-1].fromBlock) return checkpoints[checkpoints.length-1].value; if (_block < checkpoints[0].fromBlock) return 0; // Binary search of the value in the array uint min = 0; uint max = checkpoints.length-1; while (max > min) { uint mid = (max + min + 1) / 2; if (checkpoints[mid].fromBlock<=_block) { min = mid; } else { max = mid-1; } } return checkpoints[min].value; } /// @dev `updateValueAtNow` used to update the `balances` map and the /// `totalSupplyHistory` /// @param checkpoints The history of data being updated /// @param _value The new number of tokens function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value) internal { if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) { Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++]; newCheckPoint.fromBlock = uint128(block.number); newCheckPoint.value = uint128(_value); } else { Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length - 1]; oldCheckPoint.value = uint128(_value); } } /// @dev Internal function to determine if an address is a contract /// @param _addr The address being queried /// @return True if `_addr` is a contract function isContract(address _addr) constant internal returns(bool) { uint size; if (_addr == 0) return false; assembly { size := extcodesize(_addr) } return size>0; } /// @dev Helper function to return a min betwen the two uints function min(uint a, uint b) pure internal returns (uint) { return a < b ? a : b; } /// @notice The fallback function: If the contract's controller has not been /// set to 0, then the `proxyPayment` method is called which relays the /// ether and creates tokens as described in the token controller contract function () external payable { require(isContract(controller)); // Adding the ` == true` makes the linter shut up so... require(ITokenController(controller).proxyPayment.value(msg.value)(msg.sender) == true); } ////////// // Safety Methods ////////// /// @notice This method can be used by the controller to extract mistakenly /// sent tokens to this contract. /// @param _token The address of the token contract that you want to recover /// set to 0 in case you want to extract ether. function claimTokens(address _token) onlyController public { if (_token == 0x0) { controller.transfer(this.balance); return; } MiniMeToken token = MiniMeToken(_token); uint balance = token.balanceOf(this); token.transfer(controller, balance); ClaimedTokens(_token, controller, balance); } //////////////// // Events //////////////// event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); event Transfer(address indexed _from, address indexed _to, uint256 _amount); event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock); event Approval( address indexed _owner, address indexed _spender, uint256 _amount ); } //////////////// // MiniMeTokenFactory //////////////// /// @dev This contract is used to generate clone contracts from a contract. /// In solidity this is the way to create a contract from a contract of the /// same class contract MiniMeTokenFactory { /// @notice Update the DApp by creating a new token with new functionalities /// the msg.sender becomes the controller of this clone token /// @param _parentToken Address of the token being cloned /// @param _snapshotBlock Block of the parent token that will /// determine the initial distribution of the clone token /// @param _tokenName Name of the new token /// @param _decimalUnits Number of decimals of the new token /// @param _tokenSymbol Token Symbol for the new token /// @param _transfersEnabled If true, tokens will be able to be transferred /// @return The address of the new token contract function createCloneToken( MiniMeToken _parentToken, uint _snapshotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) public returns (MiniMeToken) { MiniMeToken newToken = new MiniMeToken( this, _parentToken, _snapshotBlock, _tokenName, _decimalUnits, _tokenSymbol, _transfersEnabled ); newToken.changeController(msg.sender); return newToken; } } // File: @aragon/apps-token-manager/contracts/TokenManager.sol /* * SPDX-License-Identitifer: GPL-3.0-or-later */ /* solium-disable function-order */ pragma solidity 0.4.24; contract TokenManager is ITokenController, IForwarder, AragonApp { using SafeMath for uint256; bytes32 public constant MINT_ROLE = keccak256("MINT_ROLE"); bytes32 public constant ISSUE_ROLE = keccak256("ISSUE_ROLE"); bytes32 public constant ASSIGN_ROLE = keccak256("ASSIGN_ROLE"); bytes32 public constant REVOKE_VESTINGS_ROLE = keccak256("REVOKE_VESTINGS_ROLE"); bytes32 public constant BURN_ROLE = keccak256("BURN_ROLE"); uint256 public constant MAX_VESTINGS_PER_ADDRESS = 50; string private constant ERROR_CALLER_NOT_TOKEN = "TM_CALLER_NOT_TOKEN"; string private constant ERROR_NO_VESTING = "TM_NO_VESTING"; string private constant ERROR_TOKEN_CONTROLLER = "TM_TOKEN_CONTROLLER"; string private constant ERROR_MINT_RECEIVER_IS_TM = "TM_MINT_RECEIVER_IS_TM"; string private constant ERROR_VESTING_TO_TM = "TM_VESTING_TO_TM"; string private constant ERROR_TOO_MANY_VESTINGS = "TM_TOO_MANY_VESTINGS"; string private constant ERROR_WRONG_CLIFF_DATE = "TM_WRONG_CLIFF_DATE"; string private constant ERROR_VESTING_NOT_REVOKABLE = "TM_VESTING_NOT_REVOKABLE"; string private constant ERROR_REVOKE_TRANSFER_FROM_REVERTED = "TM_REVOKE_TRANSFER_FROM_REVERTED"; string private constant ERROR_CAN_NOT_FORWARD = "TM_CAN_NOT_FORWARD"; string private constant ERROR_BALANCE_INCREASE_NOT_ALLOWED = "TM_BALANCE_INC_NOT_ALLOWED"; string private constant ERROR_ASSIGN_TRANSFER_FROM_REVERTED = "TM_ASSIGN_TRANSFER_FROM_REVERTED"; struct TokenVesting { uint256 amount; uint64 start; uint64 cliff; uint64 vesting; bool revokable; } // Note that we COMPLETELY trust this MiniMeToken to not be malicious for proper operation of this contract MiniMeToken public token; uint256 public maxAccountTokens; // We are mimicing an array in the inner mapping, we use a mapping instead to make app upgrade more graceful mapping (address => mapping (uint256 => TokenVesting)) internal vestings; mapping (address => uint256) public vestingsLengths; // Other token specific events can be watched on the token address directly (avoids duplication) event NewVesting(address indexed receiver, uint256 vestingId, uint256 amount); event RevokeVesting(address indexed receiver, uint256 vestingId, uint256 nonVestedAmount); modifier onlyToken() { require(msg.sender == address(token), ERROR_CALLER_NOT_TOKEN); _; } modifier vestingExists(address _holder, uint256 _vestingId) { // TODO: it's not checking for gaps that may appear because of deletes in revokeVesting function require(_vestingId < vestingsLengths[_holder], ERROR_NO_VESTING); _; } /** * @notice Initialize Token Manager for `_token.symbol(): string`, whose tokens are `transferable ? 'not' : ''` transferable`_maxAccountTokens > 0 ? ' and limited to a maximum of ' + @tokenAmount(_token, _maxAccountTokens, false) + ' per account' : ''` * @param _token MiniMeToken address for the managed token (Token Manager instance must be already set as the token controller) * @param _transferable whether the token can be transferred by holders * @param _maxAccountTokens Maximum amount of tokens an account can have (0 for infinite tokens) */ function initialize( MiniMeToken _token, bool _transferable, uint256 _maxAccountTokens ) external onlyInit { initialized(); require(_token.controller() == address(this), ERROR_TOKEN_CONTROLLER); token = _token; maxAccountTokens = _maxAccountTokens == 0 ? uint256(-1) : _maxAccountTokens; if (token.transfersEnabled() != _transferable) { token.enableTransfers(_transferable); } } /** * @notice Mint `@tokenAmount(self.token(): address, _amount, false)` tokens for `_receiver` * @param _receiver The address receiving the tokens, cannot be the Token Manager itself (use `issue()` instead) * @param _amount Number of tokens minted */ function mint(address _receiver, uint256 _amount) external authP(MINT_ROLE, arr(_receiver, _amount)) { require(_receiver != address(this), ERROR_MINT_RECEIVER_IS_TM); _mint(_receiver, _amount); } /** * @notice Mint `@tokenAmount(self.token(): address, _amount, false)` tokens for the Token Manager * @param _amount Number of tokens minted */ function issue(uint256 _amount) external authP(ISSUE_ROLE, arr(_amount)) { _mint(address(this), _amount); } /** * @notice Assign `@tokenAmount(self.token(): address, _amount, false)` tokens to `_receiver` from the Token Manager's holdings * @param _receiver The address receiving the tokens * @param _amount Number of tokens transferred */ function assign(address _receiver, uint256 _amount) external authP(ASSIGN_ROLE, arr(_receiver, _amount)) { _assign(_receiver, _amount); } /** * @notice Burn `@tokenAmount(self.token(): address, _amount, false)` tokens from `_holder` * @param _holder Holder of tokens being burned * @param _amount Number of tokens being burned */ function burn(address _holder, uint256 _amount) external authP(BURN_ROLE, arr(_holder, _amount)) { // minime.destroyTokens() never returns false, only reverts on failure token.destroyTokens(_holder, _amount); } /** * @notice Assign `@tokenAmount(self.token(): address, _amount, false)` tokens to `_receiver` from the Token Manager's holdings with a `_revokable : 'revokable' : ''` vesting starting at `@formatDate(_start)`, cliff at `@formatDate(_cliff)` (first portion of tokens transferable), and completed vesting at `@formatDate(_vested)` (all tokens transferable) * @param _receiver The address receiving the tokens, cannot be Token Manager itself * @param _amount Number of tokens vested * @param _start Date the vesting calculations start * @param _cliff Date when the initial portion of tokens are transferable * @param _vested Date when all tokens are transferable * @param _revokable Whether the vesting can be revoked by the Token Manager */ function assignVested( address _receiver, uint256 _amount, uint64 _start, uint64 _cliff, uint64 _vested, bool _revokable ) external authP(ASSIGN_ROLE, arr(_receiver, _amount)) returns (uint256) { require(_receiver != address(this), ERROR_VESTING_TO_TM); require(vestingsLengths[_receiver] < MAX_VESTINGS_PER_ADDRESS, ERROR_TOO_MANY_VESTINGS); require(_start <= _cliff && _cliff <= _vested, ERROR_WRONG_CLIFF_DATE); uint256 vestingId = vestingsLengths[_receiver]++; vestings[_receiver][vestingId] = TokenVesting( _amount, _start, _cliff, _vested, _revokable ); _assign(_receiver, _amount); emit NewVesting(_receiver, vestingId, _amount); return vestingId; } /** * @notice Revoke vesting #`_vestingId` from `_holder`, returning unvested tokens to the Token Manager * @param _holder Address whose vesting to revoke * @param _vestingId Numeric id of the vesting */ function revokeVesting(address _holder, uint256 _vestingId) external authP(REVOKE_VESTINGS_ROLE, arr(_holder)) vestingExists(_holder, _vestingId) { TokenVesting storage v = vestings[_holder][_vestingId]; require(v.revokable, ERROR_VESTING_NOT_REVOKABLE); uint256 nonVested = _calculateNonVestedTokens( v.amount, getTimestamp(), v.start, v.cliff, v.vesting ); // To make vestingIds immutable over time, we just zero out the revoked vesting // Clearing this out also allows the token transfer back to the Token Manager to succeed delete vestings[_holder][_vestingId]; // transferFrom always works as controller // onTransfer hook always allows if transfering to token controller require(token.transferFrom(_holder, address(this), nonVested), ERROR_REVOKE_TRANSFER_FROM_REVERTED); emit RevokeVesting(_holder, _vestingId, nonVested); } // ITokenController fns // `onTransfer()`, `onApprove()`, and `proxyPayment()` are callbacks from the MiniMe token // contract and are only meant to be called through the managed MiniMe token that gets assigned // during initialization. /* * @dev Notifies the controller about a token transfer allowing the controller to decide whether * to allow it or react if desired (only callable from the token). * Initialization check is implicitly provided by `onlyToken()`. * @param _from The origin of the transfer * @param _to The destination of the transfer * @param _amount The amount of the transfer * @return False if the controller does not authorize the transfer */ function onTransfer(address _from, address _to, uint256 _amount) external onlyToken returns (bool) { return _isBalanceIncreaseAllowed(_to, _amount) && _transferableBalance(_from, getTimestamp()) >= _amount; } /** * @dev Notifies the controller about an approval allowing the controller to react if desired * Initialization check is implicitly provided by `onlyToken()`. * @return False if the controller does not authorize the approval */ function onApprove(address, address, uint) external onlyToken returns (bool) { return true; } /** * @dev Called when ether is sent to the MiniMe Token contract * Initialization check is implicitly provided by `onlyToken()`. * @return True if the ether is accepted, false for it to throw */ function proxyPayment(address) external payable onlyToken returns (bool) { return false; } // Forwarding fns function isForwarder() external pure returns (bool) { return true; } /** * @notice Execute desired action as a token holder * @dev IForwarder interface conformance. Forwards any token holder action. * @param _evmScript Script being executed */ function forward(bytes _evmScript) public { require(canForward(msg.sender, _evmScript), ERROR_CAN_NOT_FORWARD); bytes memory input = new bytes(0); // TODO: Consider input for this // Add the managed token to the blacklist to disallow a token holder from executing actions // on the token controller's (this contract) behalf address[] memory blacklist = new address[](1); blacklist[0] = address(token); runScript(_evmScript, input, blacklist); } function canForward(address _sender, bytes) public view returns (bool) { return hasInitialized() && token.balanceOf(_sender) > 0; } // Getter fns function getVesting( address _recipient, uint256 _vestingId ) public view vestingExists(_recipient, _vestingId) returns ( uint256 amount, uint64 start, uint64 cliff, uint64 vesting, bool revokable ) { TokenVesting storage tokenVesting = vestings[_recipient][_vestingId]; amount = tokenVesting.amount; start = tokenVesting.start; cliff = tokenVesting.cliff; vesting = tokenVesting.vesting; revokable = tokenVesting.revokable; } function spendableBalanceOf(address _holder) public view isInitialized returns (uint256) { return _transferableBalance(_holder, getTimestamp()); } function transferableBalance(address _holder, uint256 _time) public view isInitialized returns (uint256) { return _transferableBalance(_holder, _time); } /** * @dev Disable recovery escape hatch for own token, * as the it has the concept of issuing tokens without assigning them */ function allowRecoverability(address _token) public view returns (bool) { return _token != address(token); } // Internal fns function _assign(address _receiver, uint256 _amount) internal { require(_isBalanceIncreaseAllowed(_receiver, _amount), ERROR_BALANCE_INCREASE_NOT_ALLOWED); // Must use transferFrom() as transfer() does not give the token controller full control require(token.transferFrom(address(this), _receiver, _amount), ERROR_ASSIGN_TRANSFER_FROM_REVERTED); } function _mint(address _receiver, uint256 _amount) internal { require(_isBalanceIncreaseAllowed(_receiver, _amount), ERROR_BALANCE_INCREASE_NOT_ALLOWED); token.generateTokens(_receiver, _amount); // minime.generateTokens() never returns false } function _isBalanceIncreaseAllowed(address _receiver, uint256 _inc) internal view returns (bool) { // Max balance doesn't apply to the token manager itself if (_receiver == address(this)) { return true; } return token.balanceOf(_receiver).add(_inc) <= maxAccountTokens; } /** * @dev Calculate amount of non-vested tokens at a specifc time * @param tokens The total amount of tokens vested * @param time The time at which to check * @param start The date vesting started * @param cliff The cliff period * @param vested The fully vested date * @return The amount of non-vested tokens of a specific grant * transferableTokens * | _/-------- vestedTokens rect * | _/ * | _/ * | _/ * | _/ * | / * | .| * | . | * | . | * | . | * | . | * | . | * +===+===========+---------+----------> time * Start Cliff Vested */ function _calculateNonVestedTokens( uint256 tokens, uint256 time, uint256 start, uint256 cliff, uint256 vested ) private pure returns (uint256) { // Shortcuts for before cliff and after vested cases. if (time >= vested) { return 0; } if (time < cliff) { return tokens; } // Interpolate all vested tokens. // As before cliff the shortcut returns 0, we can just calculate a value // in the vesting rect (as shown in above's figure) // vestedTokens = tokens * (time - start) / (vested - start) // In assignVesting we enforce start <= cliff <= vested // Here we shortcut time >= vested and time < cliff, // so no division by 0 is possible uint256 vestedTokens = tokens.mul(time.sub(start)) / vested.sub(start); // tokens - vestedTokens return tokens.sub(vestedTokens); } function _transferableBalance(address _holder, uint256 _time) internal view returns (uint256) { uint256 transferable = token.balanceOf(_holder); // This check is not strictly necessary for the current version of this contract, as // Token Managers now cannot assign vestings to themselves. // However, this was a possibility in the past, so in case there were vestings assigned to // themselves, this will still return the correct value (entire balance, as the Token // Manager does not have a spending limit on its own balance). if (_holder != address(this)) { uint256 vestingsCount = vestingsLengths[_holder]; for (uint256 i = 0; i < vestingsCount; i++) { TokenVesting storage v = vestings[_holder][i]; uint256 nonTransferable = _calculateNonVestedTokens( v.amount, _time, v.start, v.cliff, v.vesting ); transferable = transferable.sub(nonTransferable); } } return transferable; } } // File: @ablack/fundraising-bancor-formula/contracts/interfaces/IBancorFormula.sol pragma solidity 0.4.24; /* Bancor Formula interface */ contract IBancorFormula { function calculatePurchaseReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _depositAmount) public view returns (uint256); function calculateSaleReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _sellAmount) public view returns (uint256); function calculateCrossConnectorReturn(uint256 _fromConnectorBalance, uint32 _fromConnectorWeight, uint256 _toConnectorBalance, uint32 _toConnectorWeight, uint256 _amount) public view returns (uint256); } // File: @ablack/fundraising-bancor-formula/contracts/utility/Utils.sol pragma solidity 0.4.24; /* Utilities & Common Modifiers */ contract Utils { /** constructor */ constructor() public { } // verifies that an amount is greater than zero modifier greaterThanZero(uint256 _amount) { require(_amount > 0); _; } // validates an address - currently only checks that it isn't null modifier validAddress(address _address) { require(_address != address(0)); _; } // verifies that the address is different than this contract address modifier notThis(address _address) { require(_address != address(this)); _; } } // File: @ablack/fundraising-bancor-formula/contracts/BancorFormula.sol pragma solidity 0.4.24; contract BancorFormula is IBancorFormula, Utils { using SafeMath for uint256; string public version = '0.3'; uint256 private constant ONE = 1; uint32 private constant MAX_WEIGHT = 1000000; uint8 private constant MIN_PRECISION = 32; uint8 private constant MAX_PRECISION = 127; /** Auto-generated via 'PrintIntScalingFactors.py' */ uint256 private constant FIXED_1 = 0x080000000000000000000000000000000; uint256 private constant FIXED_2 = 0x100000000000000000000000000000000; uint256 private constant MAX_NUM = 0x200000000000000000000000000000000; /** Auto-generated via 'PrintLn2ScalingFactors.py' */ uint256 private constant LN2_NUMERATOR = 0x3f80fe03f80fe03f80fe03f80fe03f8; uint256 private constant LN2_DENOMINATOR = 0x5b9de1d10bf4103d647b0955897ba80; /** Auto-generated via 'PrintFunctionOptimalLog.py' and 'PrintFunctionOptimalExp.py' */ uint256 private constant OPT_LOG_MAX_VAL = 0x15bf0a8b1457695355fb8ac404e7a79e3; uint256 private constant OPT_EXP_MAX_VAL = 0x800000000000000000000000000000000; /** Auto-generated via 'PrintFunctionConstructor.py' */ uint256[128] private maxExpArray; constructor() public { // maxExpArray[ 0] = 0x6bffffffffffffffffffffffffffffffff; // maxExpArray[ 1] = 0x67ffffffffffffffffffffffffffffffff; // maxExpArray[ 2] = 0x637fffffffffffffffffffffffffffffff; // maxExpArray[ 3] = 0x5f6fffffffffffffffffffffffffffffff; // maxExpArray[ 4] = 0x5b77ffffffffffffffffffffffffffffff; // maxExpArray[ 5] = 0x57b3ffffffffffffffffffffffffffffff; // maxExpArray[ 6] = 0x5419ffffffffffffffffffffffffffffff; // maxExpArray[ 7] = 0x50a2ffffffffffffffffffffffffffffff; // maxExpArray[ 8] = 0x4d517fffffffffffffffffffffffffffff; // maxExpArray[ 9] = 0x4a233fffffffffffffffffffffffffffff; // maxExpArray[ 10] = 0x47165fffffffffffffffffffffffffffff; // maxExpArray[ 11] = 0x4429afffffffffffffffffffffffffffff; // maxExpArray[ 12] = 0x415bc7ffffffffffffffffffffffffffff; // maxExpArray[ 13] = 0x3eab73ffffffffffffffffffffffffffff; // maxExpArray[ 14] = 0x3c1771ffffffffffffffffffffffffffff; // maxExpArray[ 15] = 0x399e96ffffffffffffffffffffffffffff; // maxExpArray[ 16] = 0x373fc47fffffffffffffffffffffffffff; // maxExpArray[ 17] = 0x34f9e8ffffffffffffffffffffffffffff; // maxExpArray[ 18] = 0x32cbfd5fffffffffffffffffffffffffff; // maxExpArray[ 19] = 0x30b5057fffffffffffffffffffffffffff; // maxExpArray[ 20] = 0x2eb40f9fffffffffffffffffffffffffff; // maxExpArray[ 21] = 0x2cc8340fffffffffffffffffffffffffff; // maxExpArray[ 22] = 0x2af09481ffffffffffffffffffffffffff; // maxExpArray[ 23] = 0x292c5bddffffffffffffffffffffffffff; // maxExpArray[ 24] = 0x277abdcdffffffffffffffffffffffffff; // maxExpArray[ 25] = 0x25daf6657fffffffffffffffffffffffff; // maxExpArray[ 26] = 0x244c49c65fffffffffffffffffffffffff; // maxExpArray[ 27] = 0x22ce03cd5fffffffffffffffffffffffff; // maxExpArray[ 28] = 0x215f77c047ffffffffffffffffffffffff; // maxExpArray[ 29] = 0x1fffffffffffffffffffffffffffffffff; // maxExpArray[ 30] = 0x1eaefdbdabffffffffffffffffffffffff; // maxExpArray[ 31] = 0x1d6bd8b2ebffffffffffffffffffffffff; maxExpArray[ 32] = 0x1c35fedd14ffffffffffffffffffffffff; maxExpArray[ 33] = 0x1b0ce43b323fffffffffffffffffffffff; maxExpArray[ 34] = 0x19f0028ec1ffffffffffffffffffffffff; maxExpArray[ 35] = 0x18ded91f0e7fffffffffffffffffffffff; maxExpArray[ 36] = 0x17d8ec7f0417ffffffffffffffffffffff; maxExpArray[ 37] = 0x16ddc6556cdbffffffffffffffffffffff; maxExpArray[ 38] = 0x15ecf52776a1ffffffffffffffffffffff; maxExpArray[ 39] = 0x15060c256cb2ffffffffffffffffffffff; maxExpArray[ 40] = 0x1428a2f98d72ffffffffffffffffffffff; maxExpArray[ 41] = 0x13545598e5c23fffffffffffffffffffff; maxExpArray[ 42] = 0x1288c4161ce1dfffffffffffffffffffff; maxExpArray[ 43] = 0x11c592761c666fffffffffffffffffffff; maxExpArray[ 44] = 0x110a688680a757ffffffffffffffffffff; maxExpArray[ 45] = 0x1056f1b5bedf77ffffffffffffffffffff; maxExpArray[ 46] = 0x0faadceceeff8bffffffffffffffffffff; maxExpArray[ 47] = 0x0f05dc6b27edadffffffffffffffffffff; maxExpArray[ 48] = 0x0e67a5a25da4107fffffffffffffffffff; maxExpArray[ 49] = 0x0dcff115b14eedffffffffffffffffffff; maxExpArray[ 50] = 0x0d3e7a392431239fffffffffffffffffff; maxExpArray[ 51] = 0x0cb2ff529eb71e4fffffffffffffffffff; maxExpArray[ 52] = 0x0c2d415c3db974afffffffffffffffffff; maxExpArray[ 53] = 0x0bad03e7d883f69bffffffffffffffffff; maxExpArray[ 54] = 0x0b320d03b2c343d5ffffffffffffffffff; maxExpArray[ 55] = 0x0abc25204e02828dffffffffffffffffff; maxExpArray[ 56] = 0x0a4b16f74ee4bb207fffffffffffffffff; maxExpArray[ 57] = 0x09deaf736ac1f569ffffffffffffffffff; maxExpArray[ 58] = 0x0976bd9952c7aa957fffffffffffffffff; maxExpArray[ 59] = 0x09131271922eaa606fffffffffffffffff; maxExpArray[ 60] = 0x08b380f3558668c46fffffffffffffffff; maxExpArray[ 61] = 0x0857ddf0117efa215bffffffffffffffff; maxExpArray[ 62] = 0x07ffffffffffffffffffffffffffffffff; maxExpArray[ 63] = 0x07abbf6f6abb9d087fffffffffffffffff; maxExpArray[ 64] = 0x075af62cbac95f7dfa7fffffffffffffff; maxExpArray[ 65] = 0x070d7fb7452e187ac13fffffffffffffff; maxExpArray[ 66] = 0x06c3390ecc8af379295fffffffffffffff; maxExpArray[ 67] = 0x067c00a3b07ffc01fd6fffffffffffffff; maxExpArray[ 68] = 0x0637b647c39cbb9d3d27ffffffffffffff; maxExpArray[ 69] = 0x05f63b1fc104dbd39587ffffffffffffff; maxExpArray[ 70] = 0x05b771955b36e12f7235ffffffffffffff; maxExpArray[ 71] = 0x057b3d49dda84556d6f6ffffffffffffff; maxExpArray[ 72] = 0x054183095b2c8ececf30ffffffffffffff; maxExpArray[ 73] = 0x050a28be635ca2b888f77fffffffffffff; maxExpArray[ 74] = 0x04d5156639708c9db33c3fffffffffffff; maxExpArray[ 75] = 0x04a23105873875bd52dfdfffffffffffff; maxExpArray[ 76] = 0x0471649d87199aa990756fffffffffffff; maxExpArray[ 77] = 0x04429a21a029d4c1457cfbffffffffffff; maxExpArray[ 78] = 0x0415bc6d6fb7dd71af2cb3ffffffffffff; maxExpArray[ 79] = 0x03eab73b3bbfe282243ce1ffffffffffff; maxExpArray[ 80] = 0x03c1771ac9fb6b4c18e229ffffffffffff; maxExpArray[ 81] = 0x0399e96897690418f785257fffffffffff; maxExpArray[ 82] = 0x0373fc456c53bb779bf0ea9fffffffffff; maxExpArray[ 83] = 0x034f9e8e490c48e67e6ab8bfffffffffff; maxExpArray[ 84] = 0x032cbfd4a7adc790560b3337ffffffffff; maxExpArray[ 85] = 0x030b50570f6e5d2acca94613ffffffffff; maxExpArray[ 86] = 0x02eb40f9f620fda6b56c2861ffffffffff; maxExpArray[ 87] = 0x02cc8340ecb0d0f520a6af58ffffffffff; maxExpArray[ 88] = 0x02af09481380a0a35cf1ba02ffffffffff; maxExpArray[ 89] = 0x0292c5bdd3b92ec810287b1b3fffffffff; maxExpArray[ 90] = 0x0277abdcdab07d5a77ac6d6b9fffffffff; maxExpArray[ 91] = 0x025daf6654b1eaa55fd64df5efffffffff; maxExpArray[ 92] = 0x0244c49c648baa98192dce88b7ffffffff; maxExpArray[ 93] = 0x022ce03cd5619a311b2471268bffffffff; maxExpArray[ 94] = 0x0215f77c045fbe885654a44a0fffffffff; maxExpArray[ 95] = 0x01ffffffffffffffffffffffffffffffff; maxExpArray[ 96] = 0x01eaefdbdaaee7421fc4d3ede5ffffffff; maxExpArray[ 97] = 0x01d6bd8b2eb257df7e8ca57b09bfffffff; maxExpArray[ 98] = 0x01c35fedd14b861eb0443f7f133fffffff; maxExpArray[ 99] = 0x01b0ce43b322bcde4a56e8ada5afffffff; maxExpArray[100] = 0x019f0028ec1fff007f5a195a39dfffffff; maxExpArray[101] = 0x018ded91f0e72ee74f49b15ba527ffffff; maxExpArray[102] = 0x017d8ec7f04136f4e5615fd41a63ffffff; maxExpArray[103] = 0x016ddc6556cdb84bdc8d12d22e6fffffff; maxExpArray[104] = 0x015ecf52776a1155b5bd8395814f7fffff; maxExpArray[105] = 0x015060c256cb23b3b3cc3754cf40ffffff; maxExpArray[106] = 0x01428a2f98d728ae223ddab715be3fffff; maxExpArray[107] = 0x013545598e5c23276ccf0ede68034fffff; maxExpArray[108] = 0x01288c4161ce1d6f54b7f61081194fffff; maxExpArray[109] = 0x011c592761c666aa641d5a01a40f17ffff; maxExpArray[110] = 0x0110a688680a7530515f3e6e6cfdcdffff; maxExpArray[111] = 0x01056f1b5bedf75c6bcb2ce8aed428ffff; maxExpArray[112] = 0x00faadceceeff8a0890f3875f008277fff; maxExpArray[113] = 0x00f05dc6b27edad306388a600f6ba0bfff; maxExpArray[114] = 0x00e67a5a25da41063de1495d5b18cdbfff; maxExpArray[115] = 0x00dcff115b14eedde6fc3aa5353f2e4fff; maxExpArray[116] = 0x00d3e7a3924312399f9aae2e0f868f8fff; maxExpArray[117] = 0x00cb2ff529eb71e41582cccd5a1ee26fff; maxExpArray[118] = 0x00c2d415c3db974ab32a51840c0b67edff; maxExpArray[119] = 0x00bad03e7d883f69ad5b0a186184e06bff; maxExpArray[120] = 0x00b320d03b2c343d4829abd6075f0cc5ff; maxExpArray[121] = 0x00abc25204e02828d73c6e80bcdb1a95bf; maxExpArray[122] = 0x00a4b16f74ee4bb2040a1ec6c15fbbf2df; maxExpArray[123] = 0x009deaf736ac1f569deb1b5ae3f36c130f; maxExpArray[124] = 0x00976bd9952c7aa957f5937d790ef65037; maxExpArray[125] = 0x009131271922eaa6064b73a22d0bd4f2bf; maxExpArray[126] = 0x008b380f3558668c46c91c49a2f8e967b9; maxExpArray[127] = 0x00857ddf0117efa215952912839f6473e6; } /** @dev given a token supply, connector balance, weight and a deposit amount (in the connector token), calculates the return for a given conversion (in the main token) Formula: Return = _supply * ((1 + _depositAmount / _connectorBalance) ^ (_connectorWeight / 1000000) - 1) @param _supply token total supply @param _connectorBalance total connector balance @param _connectorWeight connector weight, represented in ppm, 1-1000000 @param _depositAmount deposit amount, in connector token @return purchase return amount */ function calculatePurchaseReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _depositAmount) public view returns (uint256) { // validate input require(_supply > 0 && _connectorBalance > 0 && _connectorWeight > 0 && _connectorWeight <= MAX_WEIGHT); // special case for 0 deposit amount if (_depositAmount == 0) return 0; // special case if the weight = 100% if (_connectorWeight == MAX_WEIGHT) return _supply.mul(_depositAmount) / _connectorBalance; uint256 result; uint8 precision; uint256 baseN = _depositAmount.add(_connectorBalance); (result, precision) = power(baseN, _connectorBalance, _connectorWeight, MAX_WEIGHT); uint256 temp = _supply.mul(result) >> precision; return temp - _supply; } /** @dev given a token supply, connector balance, weight and a sell amount (in the main token), calculates the return for a given conversion (in the connector token) Formula: Return = _connectorBalance * (1 - (1 - _sellAmount / _supply) ^ (1 / (_connectorWeight / 1000000))) @param _supply token total supply @param _connectorBalance total connector @param _connectorWeight constant connector Weight, represented in ppm, 1-1000000 @param _sellAmount sell amount, in the token itself @return sale return amount */ function calculateSaleReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _sellAmount) public view returns (uint256) { // validate input require(_supply > 0 && _connectorBalance > 0 && _connectorWeight > 0 && _connectorWeight <= MAX_WEIGHT && _sellAmount <= _supply); // special case for 0 sell amount if (_sellAmount == 0) return 0; // special case for selling the entire supply if (_sellAmount == _supply) return _connectorBalance; // special case if the weight = 100% if (_connectorWeight == MAX_WEIGHT) return _connectorBalance.mul(_sellAmount) / _supply; uint256 result; uint8 precision; uint256 baseD = _supply - _sellAmount; (result, precision) = power(_supply, baseD, MAX_WEIGHT, _connectorWeight); uint256 temp1 = _connectorBalance.mul(result); uint256 temp2 = _connectorBalance << precision; return (temp1 - temp2) / result; } /** @dev given two connector balances/weights and a sell amount (in the first connector token), calculates the return for a conversion from the first connector token to the second connector token (in the second connector token) Formula: Return = _toConnectorBalance * (1 - (_fromConnectorBalance / (_fromConnectorBalance + _amount)) ^ (_fromConnectorWeight / _toConnectorWeight)) @param _fromConnectorBalance input connector balance @param _fromConnectorWeight input connector weight, represented in ppm, 1-1000000 @param _toConnectorBalance output connector balance @param _toConnectorWeight output connector weight, represented in ppm, 1-1000000 @param _amount input connector amount @return second connector amount */ function calculateCrossConnectorReturn(uint256 _fromConnectorBalance, uint32 _fromConnectorWeight, uint256 _toConnectorBalance, uint32 _toConnectorWeight, uint256 _amount) public view returns (uint256) { // validate input require(_fromConnectorBalance > 0 && _fromConnectorWeight > 0 && _fromConnectorWeight <= MAX_WEIGHT && _toConnectorBalance > 0 && _toConnectorWeight > 0 && _toConnectorWeight <= MAX_WEIGHT); // special case for equal weights if (_fromConnectorWeight == _toConnectorWeight) return _toConnectorBalance.mul(_amount) / _fromConnectorBalance.add(_amount); uint256 result; uint8 precision; uint256 baseN = _fromConnectorBalance.add(_amount); (result, precision) = power(baseN, _fromConnectorBalance, _fromConnectorWeight, _toConnectorWeight); uint256 temp1 = _toConnectorBalance.mul(result); uint256 temp2 = _toConnectorBalance << precision; return (temp1 - temp2) / result; } /** General Description: Determine a value of precision. Calculate an integer approximation of (_baseN / _baseD) ^ (_expN / _expD) * 2 ^ precision. Return the result along with the precision used. Detailed Description: Instead of calculating "base ^ exp", we calculate "e ^ (log(base) * exp)". The value of "log(base)" is represented with an integer slightly smaller than "log(base) * 2 ^ precision". The larger "precision" is, the more accurately this value represents the real value. However, the larger "precision" is, the more bits are required in order to store this value. And the exponentiation function, which takes "x" and calculates "e ^ x", is limited to a maximum exponent (maximum value of "x"). This maximum exponent depends on the "precision" used, and it is given by "maxExpArray[precision] >> (MAX_PRECISION - precision)". Hence we need to determine the highest precision which can be used for the given input, before calling the exponentiation function. This allows us to compute "base ^ exp" with maximum accuracy and without exceeding 256 bits in any of the intermediate computations. This functions assumes that "_expN < 2 ^ 256 / log(MAX_NUM - 1)", otherwise the multiplication should be replaced with a "safeMul". */ function power(uint256 _baseN, uint256 _baseD, uint32 _expN, uint32 _expD) internal view returns (uint256, uint8) { require(_baseN < MAX_NUM); uint256 baseLog; uint256 base = _baseN * FIXED_1 / _baseD; if (base < OPT_LOG_MAX_VAL) { baseLog = optimalLog(base); } else { baseLog = generalLog(base); } uint256 baseLogTimesExp = baseLog * _expN / _expD; if (baseLogTimesExp < OPT_EXP_MAX_VAL) { return (optimalExp(baseLogTimesExp), MAX_PRECISION); } else { uint8 precision = findPositionInMaxExpArray(baseLogTimesExp); return (generalExp(baseLogTimesExp >> (MAX_PRECISION - precision), precision), precision); } } /** Compute log(x / FIXED_1) * FIXED_1. This functions assumes that "x >= FIXED_1", because the output would be negative otherwise. */ function generalLog(uint256 x) internal pure returns (uint256) { uint256 res = 0; // If x >= 2, then we compute the integer part of log2(x), which is larger than 0. if (x >= FIXED_2) { uint8 count = floorLog2(x / FIXED_1); x >>= count; // now x < 2 res = count * FIXED_1; } // If x > 1, then we compute the fraction part of log2(x), which is larger than 0. if (x > FIXED_1) { for (uint8 i = MAX_PRECISION; i > 0; --i) { x = (x * x) / FIXED_1; // now 1 < x < 4 if (x >= FIXED_2) { x >>= 1; // now 1 < x < 2 res += ONE << (i - 1); } } } return res * LN2_NUMERATOR / LN2_DENOMINATOR; } /** Compute the largest integer smaller than or equal to the binary logarithm of the input. */ function floorLog2(uint256 _n) internal pure returns (uint8) { uint8 res = 0; if (_n < 256) { // At most 8 iterations while (_n > 1) { _n >>= 1; res += 1; } } else { // Exactly 8 iterations for (uint8 s = 128; s > 0; s >>= 1) { if (_n >= (ONE << s)) { _n >>= s; res |= s; } } } return res; } /** The global "maxExpArray" is sorted in descending order, and therefore the following statements are equivalent: - This function finds the position of [the smallest value in "maxExpArray" larger than or equal to "x"] - This function finds the highest position of [a value in "maxExpArray" larger than or equal to "x"] */ function findPositionInMaxExpArray(uint256 _x) internal view returns (uint8) { uint8 lo = MIN_PRECISION; uint8 hi = MAX_PRECISION; while (lo + 1 < hi) { uint8 mid = (lo + hi) / 2; if (maxExpArray[mid] >= _x) lo = mid; else hi = mid; } if (maxExpArray[hi] >= _x) return hi; if (maxExpArray[lo] >= _x) return lo; require(false); return 0; } /** This function can be auto-generated by the script 'PrintFunctionGeneralExp.py'. It approximates "e ^ x" via maclaurin summation: "(x^0)/0! + (x^1)/1! + ... + (x^n)/n!". It returns "e ^ (x / 2 ^ precision) * 2 ^ precision", that is, the result is upshifted for accuracy. The global "maxExpArray" maps each "precision" to "((maximumExponent + 1) << (MAX_PRECISION - precision)) - 1". The maximum permitted value for "x" is therefore given by "maxExpArray[precision] >> (MAX_PRECISION - precision)". */ function generalExp(uint256 _x, uint8 _precision) internal pure returns (uint256) { uint256 xi = _x; uint256 res = 0; xi = (xi * _x) >> _precision; res += xi * 0x3442c4e6074a82f1797f72ac0000000; // add x^02 * (33! / 02!) xi = (xi * _x) >> _precision; res += xi * 0x116b96f757c380fb287fd0e40000000; // add x^03 * (33! / 03!) xi = (xi * _x) >> _precision; res += xi * 0x045ae5bdd5f0e03eca1ff4390000000; // add x^04 * (33! / 04!) xi = (xi * _x) >> _precision; res += xi * 0x00defabf91302cd95b9ffda50000000; // add x^05 * (33! / 05!) xi = (xi * _x) >> _precision; res += xi * 0x002529ca9832b22439efff9b8000000; // add x^06 * (33! / 06!) xi = (xi * _x) >> _precision; res += xi * 0x00054f1cf12bd04e516b6da88000000; // add x^07 * (33! / 07!) xi = (xi * _x) >> _precision; res += xi * 0x0000a9e39e257a09ca2d6db51000000; // add x^08 * (33! / 08!) xi = (xi * _x) >> _precision; res += xi * 0x000012e066e7b839fa050c309000000; // add x^09 * (33! / 09!) xi = (xi * _x) >> _precision; res += xi * 0x000001e33d7d926c329a1ad1a800000; // add x^10 * (33! / 10!) xi = (xi * _x) >> _precision; res += xi * 0x0000002bee513bdb4a6b19b5f800000; // add x^11 * (33! / 11!) xi = (xi * _x) >> _precision; res += xi * 0x00000003a9316fa79b88eccf2a00000; // add x^12 * (33! / 12!) xi = (xi * _x) >> _precision; res += xi * 0x0000000048177ebe1fa812375200000; // add x^13 * (33! / 13!) xi = (xi * _x) >> _precision; res += xi * 0x0000000005263fe90242dcbacf00000; // add x^14 * (33! / 14!) xi = (xi * _x) >> _precision; res += xi * 0x000000000057e22099c030d94100000; // add x^15 * (33! / 15!) xi = (xi * _x) >> _precision; res += xi * 0x0000000000057e22099c030d9410000; // add x^16 * (33! / 16!) xi = (xi * _x) >> _precision; res += xi * 0x00000000000052b6b54569976310000; // add x^17 * (33! / 17!) xi = (xi * _x) >> _precision; res += xi * 0x00000000000004985f67696bf748000; // add x^18 * (33! / 18!) xi = (xi * _x) >> _precision; res += xi * 0x000000000000003dea12ea99e498000; // add x^19 * (33! / 19!) xi = (xi * _x) >> _precision; res += xi * 0x00000000000000031880f2214b6e000; // add x^20 * (33! / 20!) xi = (xi * _x) >> _precision; res += xi * 0x000000000000000025bcff56eb36000; // add x^21 * (33! / 21!) xi = (xi * _x) >> _precision; res += xi * 0x000000000000000001b722e10ab1000; // add x^22 * (33! / 22!) xi = (xi * _x) >> _precision; res += xi * 0x0000000000000000001317c70077000; // add x^23 * (33! / 23!) xi = (xi * _x) >> _precision; res += xi * 0x00000000000000000000cba84aafa00; // add x^24 * (33! / 24!) xi = (xi * _x) >> _precision; res += xi * 0x00000000000000000000082573a0a00; // add x^25 * (33! / 25!) xi = (xi * _x) >> _precision; res += xi * 0x00000000000000000000005035ad900; // add x^26 * (33! / 26!) xi = (xi * _x) >> _precision; res += xi * 0x000000000000000000000002f881b00; // add x^27 * (33! / 27!) xi = (xi * _x) >> _precision; res += xi * 0x0000000000000000000000001b29340; // add x^28 * (33! / 28!) xi = (xi * _x) >> _precision; res += xi * 0x00000000000000000000000000efc40; // add x^29 * (33! / 29!) xi = (xi * _x) >> _precision; res += xi * 0x0000000000000000000000000007fe0; // add x^30 * (33! / 30!) xi = (xi * _x) >> _precision; res += xi * 0x0000000000000000000000000000420; // add x^31 * (33! / 31!) xi = (xi * _x) >> _precision; res += xi * 0x0000000000000000000000000000021; // add x^32 * (33! / 32!) xi = (xi * _x) >> _precision; res += xi * 0x0000000000000000000000000000001; // add x^33 * (33! / 33!) return res / 0x688589cc0e9505e2f2fee5580000000 + _x + (ONE << _precision); // divide by 33! and then add x^1 / 1! + x^0 / 0! } /** Return log(x / FIXED_1) * FIXED_1 Input range: FIXED_1 <= x <= LOG_EXP_MAX_VAL - 1 Auto-generated via 'PrintFunctionOptimalLog.py' Detailed description: - Rewrite the input as a product of natural exponents and a single residual r, such that 1 < r < 2 - The natural logarithm of each (pre-calculated) exponent is the degree of the exponent - The natural logarithm of r is calculated via Taylor series for log(1 + x), where x = r - 1 - The natural logarithm of the input is calculated by summing up the intermediate results above - For example: log(250) = log(e^4 * e^1 * e^0.5 * 1.021692859) = 4 + 1 + 0.5 + log(1 + 0.021692859) */ function optimalLog(uint256 x) internal pure returns (uint256) { uint256 res = 0; uint256 y; uint256 z; uint256 w; if (x >= 0xd3094c70f034de4b96ff7d5b6f99fcd8) {res += 0x40000000000000000000000000000000; x = x * FIXED_1 / 0xd3094c70f034de4b96ff7d5b6f99fcd8;} // add 1 / 2^1 if (x >= 0xa45af1e1f40c333b3de1db4dd55f29a7) {res += 0x20000000000000000000000000000000; x = x * FIXED_1 / 0xa45af1e1f40c333b3de1db4dd55f29a7;} // add 1 / 2^2 if (x >= 0x910b022db7ae67ce76b441c27035c6a1) {res += 0x10000000000000000000000000000000; x = x * FIXED_1 / 0x910b022db7ae67ce76b441c27035c6a1;} // add 1 / 2^3 if (x >= 0x88415abbe9a76bead8d00cf112e4d4a8) {res += 0x08000000000000000000000000000000; x = x * FIXED_1 / 0x88415abbe9a76bead8d00cf112e4d4a8;} // add 1 / 2^4 if (x >= 0x84102b00893f64c705e841d5d4064bd3) {res += 0x04000000000000000000000000000000; x = x * FIXED_1 / 0x84102b00893f64c705e841d5d4064bd3;} // add 1 / 2^5 if (x >= 0x8204055aaef1c8bd5c3259f4822735a2) {res += 0x02000000000000000000000000000000; x = x * FIXED_1 / 0x8204055aaef1c8bd5c3259f4822735a2;} // add 1 / 2^6 if (x >= 0x810100ab00222d861931c15e39b44e99) {res += 0x01000000000000000000000000000000; x = x * FIXED_1 / 0x810100ab00222d861931c15e39b44e99;} // add 1 / 2^7 if (x >= 0x808040155aabbbe9451521693554f733) {res += 0x00800000000000000000000000000000; x = x * FIXED_1 / 0x808040155aabbbe9451521693554f733;} // add 1 / 2^8 z = y = x - FIXED_1; w = y * y / FIXED_1; res += z * (0x100000000000000000000000000000000 - y) / 0x100000000000000000000000000000000; z = z * w / FIXED_1; // add y^01 / 01 - y^02 / 02 res += z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y) / 0x200000000000000000000000000000000; z = z * w / FIXED_1; // add y^03 / 03 - y^04 / 04 res += z * (0x099999999999999999999999999999999 - y) / 0x300000000000000000000000000000000; z = z * w / FIXED_1; // add y^05 / 05 - y^06 / 06 res += z * (0x092492492492492492492492492492492 - y) / 0x400000000000000000000000000000000; z = z * w / FIXED_1; // add y^07 / 07 - y^08 / 08 res += z * (0x08e38e38e38e38e38e38e38e38e38e38e - y) / 0x500000000000000000000000000000000; z = z * w / FIXED_1; // add y^09 / 09 - y^10 / 10 res += z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y) / 0x600000000000000000000000000000000; z = z * w / FIXED_1; // add y^11 / 11 - y^12 / 12 res += z * (0x089d89d89d89d89d89d89d89d89d89d89 - y) / 0x700000000000000000000000000000000; z = z * w / FIXED_1; // add y^13 / 13 - y^14 / 14 res += z * (0x088888888888888888888888888888888 - y) / 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16 return res; } /** Return e ^ (x / FIXED_1) * FIXED_1 Input range: 0 <= x <= OPT_EXP_MAX_VAL - 1 Auto-generated via 'PrintFunctionOptimalExp.py' Detailed description: - Rewrite the input as a sum of binary exponents and a single residual r, as small as possible - The exponentiation of each binary exponent is given (pre-calculated) - The exponentiation of r is calculated via Taylor series for e^x, where x = r - The exponentiation of the input is calculated by multiplying the intermediate results above - For example: e^5.521692859 = e^(4 + 1 + 0.5 + 0.021692859) = e^4 * e^1 * e^0.5 * e^0.021692859 */ function optimalExp(uint256 x) internal pure returns (uint256) { uint256 res = 0; uint256 y; uint256 z; z = y = x % 0x10000000000000000000000000000000; // get the input modulo 2^(-3) z = z * y / FIXED_1; res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!) z = z * y / FIXED_1; res += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!) z = z * y / FIXED_1; res += z * 0x0168244fdac78000; // add y^04 * (20! / 04!) z = z * y / FIXED_1; res += z * 0x004807432bc18000; // add y^05 * (20! / 05!) z = z * y / FIXED_1; res += z * 0x000c0135dca04000; // add y^06 * (20! / 06!) z = z * y / FIXED_1; res += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!) z = z * y / FIXED_1; res += z * 0x000036e0f639b800; // add y^08 * (20! / 08!) z = z * y / FIXED_1; res += z * 0x00000618fee9f800; // add y^09 * (20! / 09!) z = z * y / FIXED_1; res += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!) z = z * y / FIXED_1; res += z * 0x0000000e30dce400; // add y^11 * (20! / 11!) z = z * y / FIXED_1; res += z * 0x000000012ebd1300; // add y^12 * (20! / 12!) z = z * y / FIXED_1; res += z * 0x0000000017499f00; // add y^13 * (20! / 13!) z = z * y / FIXED_1; res += z * 0x0000000001a9d480; // add y^14 * (20! / 14!) z = z * y / FIXED_1; res += z * 0x00000000001c6380; // add y^15 * (20! / 15!) z = z * y / FIXED_1; res += z * 0x000000000001c638; // add y^16 * (20! / 16!) z = z * y / FIXED_1; res += z * 0x0000000000001ab8; // add y^17 * (20! / 17!) z = z * y / FIXED_1; res += z * 0x000000000000017c; // add y^18 * (20! / 18!) z = z * y / FIXED_1; res += z * 0x0000000000000014; // add y^19 * (20! / 19!) z = z * y / FIXED_1; res += z * 0x0000000000000001; // add y^20 * (20! / 20!) res = res / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0! if ((x & 0x010000000000000000000000000000000) != 0) res = res * 0x1c3d6a24ed82218787d624d3e5eba95f9 / 0x18ebef9eac820ae8682b9793ac6d1e776; // multiply by e^2^(-3) if ((x & 0x020000000000000000000000000000000) != 0) res = res * 0x18ebef9eac820ae8682b9793ac6d1e778 / 0x1368b2fc6f9609fe7aceb46aa619baed4; // multiply by e^2^(-2) if ((x & 0x040000000000000000000000000000000) != 0) res = res * 0x1368b2fc6f9609fe7aceb46aa619baed5 / 0x0bc5ab1b16779be3575bd8f0520a9f21f; // multiply by e^2^(-1) if ((x & 0x080000000000000000000000000000000) != 0) res = res * 0x0bc5ab1b16779be3575bd8f0520a9f21e / 0x0454aaa8efe072e7f6ddbab84b40a55c9; // multiply by e^2^(+0) if ((x & 0x100000000000000000000000000000000) != 0) res = res * 0x0454aaa8efe072e7f6ddbab84b40a55c5 / 0x00960aadc109e7a3bf4578099615711ea; // multiply by e^2^(+1) if ((x & 0x200000000000000000000000000000000) != 0) res = res * 0x00960aadc109e7a3bf4578099615711d7 / 0x0002bf84208204f5977f9a8cf01fdce3d; // multiply by e^2^(+2) if ((x & 0x400000000000000000000000000000000) != 0) res = res * 0x0002bf84208204f5977f9a8cf01fdc307 / 0x0000003c6ab775dd0b95b4cbee7e65d11; // multiply by e^2^(+3) return res; } } // File: @ablack/fundraising-shared-interfaces/contracts/IAragonFundraisingController.sol pragma solidity 0.4.24; contract IAragonFundraisingController { function openTrading() external; function updateTappedAmount(address _token) external; function collateralsToBeClaimed(address _collateral) public view returns (uint256); function balanceOf(address _who, address _token) public view returns (uint256); } // File: @ablack/fundraising-batched-bancor-market-maker/contracts/BatchedBancorMarketMaker.sol pragma solidity 0.4.24; contract BatchedBancorMarketMaker is EtherTokenConstant, IsContract, AragonApp { using SafeERC20 for ERC20; using SafeMath for uint256; /** Hardcoded constants to save gas bytes32 public constant OPEN_ROLE = keccak256("OPEN_ROLE"); bytes32 public constant UPDATE_FORMULA_ROLE = keccak256("UPDATE_FORMULA_ROLE"); bytes32 public constant UPDATE_BENEFICIARY_ROLE = keccak256("UPDATE_BENEFICIARY_ROLE"); bytes32 public constant UPDATE_FEES_ROLE = keccak256("UPDATE_FEES_ROLE"); bytes32 public constant ADD_COLLATERAL_TOKEN_ROLE = keccak256("ADD_COLLATERAL_TOKEN_ROLE"); bytes32 public constant REMOVE_COLLATERAL_TOKEN_ROLE = keccak256("REMOVE_COLLATERAL_TOKEN_ROLE"); bytes32 public constant UPDATE_COLLATERAL_TOKEN_ROLE = keccak256("UPDATE_COLLATERAL_TOKEN_ROLE"); bytes32 public constant OPEN_BUY_ORDER_ROLE = keccak256("OPEN_BUY_ORDER_ROLE"); bytes32 public constant OPEN_SELL_ORDER_ROLE = keccak256("OPEN_SELL_ORDER_ROLE"); */ bytes32 public constant OPEN_ROLE = 0xefa06053e2ca99a43c97c4a4f3d8a394ee3323a8ff237e625fba09fe30ceb0a4; bytes32 public constant UPDATE_FORMULA_ROLE = 0xbfb76d8d43f55efe58544ea32af187792a7bdb983850d8fed33478266eec3cbb; bytes32 public constant UPDATE_BENEFICIARY_ROLE = 0xf7ea2b80c7b6a2cab2c11d2290cb005c3748397358a25e17113658c83b732593; bytes32 public constant UPDATE_FEES_ROLE = 0x5f9be2932ed3a723f295a763be1804c7ebfd1a41c1348fb8bdf5be1c5cdca822; bytes32 public constant ADD_COLLATERAL_TOKEN_ROLE = 0x217b79cb2bc7760defc88529853ef81ab33ae5bb315408ce9f5af09c8776662d; bytes32 public constant REMOVE_COLLATERAL_TOKEN_ROLE = 0x2044e56de223845e4be7d0a6f4e9a29b635547f16413a6d1327c58d9db438ee2; bytes32 public constant UPDATE_COLLATERAL_TOKEN_ROLE = 0xe0565c2c43e0d841e206bb36a37f12f22584b4652ccee6f9e0c071b697a2e13d; bytes32 public constant OPEN_BUY_ORDER_ROLE = 0xa589c8f284b76fc8d510d9d553485c47dbef1b0745ae00e0f3fd4e28fcd77ea7; bytes32 public constant OPEN_SELL_ORDER_ROLE = 0xd68ba2b769fa37a2a7bd4bed9241b448bc99eca41f519ef037406386a8f291c0; uint256 public constant PCT_BASE = 10 ** 18; // 0% = 0; 1% = 10 ** 16; 100% = 10 ** 18 uint32 public constant PPM = 1000000; string private constant ERROR_CONTRACT_IS_EOA = "MM_CONTRACT_IS_EOA"; string private constant ERROR_INVALID_BENEFICIARY = "MM_INVALID_BENEFICIARY"; string private constant ERROR_INVALID_BATCH_BLOCKS = "MM_INVALID_BATCH_BLOCKS"; string private constant ERROR_INVALID_PERCENTAGE = "MM_INVALID_PERCENTAGE"; string private constant ERROR_INVALID_RESERVE_RATIO = "MM_INVALID_RESERVE_RATIO"; string private constant ERROR_INVALID_TM_SETTING = "MM_INVALID_TM_SETTING"; string private constant ERROR_INVALID_COLLATERAL = "MM_INVALID_COLLATERAL"; string private constant ERROR_INVALID_COLLATERAL_VALUE = "MM_INVALID_COLLATERAL_VALUE"; string private constant ERROR_INVALID_BOND_AMOUNT = "MM_INVALID_BOND_AMOUNT"; string private constant ERROR_ALREADY_OPEN = "MM_ALREADY_OPEN"; string private constant ERROR_NOT_OPEN = "MM_NOT_OPEN"; string private constant ERROR_COLLATERAL_ALREADY_WHITELISTED = "MM_COLLATERAL_ALREADY_WHITELISTED"; string private constant ERROR_COLLATERAL_NOT_WHITELISTED = "MM_COLLATERAL_NOT_WHITELISTED"; string private constant ERROR_NOTHING_TO_CLAIM = "MM_NOTHING_TO_CLAIM"; string private constant ERROR_BATCH_NOT_OVER = "MM_BATCH_NOT_OVER"; string private constant ERROR_BATCH_CANCELLED = "MM_BATCH_CANCELLED"; string private constant ERROR_BATCH_NOT_CANCELLED = "MM_BATCH_NOT_CANCELLED"; string private constant ERROR_SLIPPAGE_EXCEEDS_LIMIT = "MM_SLIPPAGE_EXCEEDS_LIMIT"; string private constant ERROR_INSUFFICIENT_POOL_BALANCE = "MM_INSUFFICIENT_POOL_BALANCE"; string private constant ERROR_TRANSFER_FROM_FAILED = "MM_TRANSFER_FROM_FAILED"; struct Collateral { bool whitelisted; uint256 virtualSupply; uint256 virtualBalance; uint32 reserveRatio; uint256 slippage; } struct MetaBatch { bool initialized; uint256 realSupply; uint256 buyFeePct; uint256 sellFeePct; IBancorFormula formula; mapping(address => Batch) batches; } struct Batch { bool initialized; bool cancelled; uint256 supply; uint256 balance; uint32 reserveRatio; uint256 slippage; uint256 totalBuySpend; uint256 totalBuyReturn; uint256 totalSellSpend; uint256 totalSellReturn; mapping(address => uint256) buyers; mapping(address => uint256) sellers; } IAragonFundraisingController public controller; TokenManager public tokenManager; ERC20 public token; Vault public reserve; address public beneficiary; IBancorFormula public formula; uint256 public batchBlocks; uint256 public buyFeePct; uint256 public sellFeePct; bool public isOpen; uint256 public tokensToBeMinted; mapping(address => uint256) public collateralsToBeClaimed; mapping(address => Collateral) public collaterals; mapping(uint256 => MetaBatch) public metaBatches; event UpdateBeneficiary (address indexed beneficiary); event UpdateFormula (address indexed formula); event UpdateFees (uint256 buyFeePct, uint256 sellFeePct); event NewMetaBatch (uint256 indexed id, uint256 supply, uint256 buyFeePct, uint256 sellFeePct, address formula); event NewBatch ( uint256 indexed id, address indexed collateral, uint256 supply, uint256 balance, uint32 reserveRatio, uint256 slippage) ; event CancelBatch (uint256 indexed id, address indexed collateral); event AddCollateralToken ( address indexed collateral, uint256 virtualSupply, uint256 virtualBalance, uint32 reserveRatio, uint256 slippage ); event RemoveCollateralToken (address indexed collateral); event UpdateCollateralToken ( address indexed collateral, uint256 virtualSupply, uint256 virtualBalance, uint32 reserveRatio, uint256 slippage ); event Open (); event OpenBuyOrder (address indexed buyer, uint256 indexed batchId, address indexed collateral, uint256 fee, uint256 value); event OpenSellOrder (address indexed seller, uint256 indexed batchId, address indexed collateral, uint256 amount); event ClaimBuyOrder (address indexed buyer, uint256 indexed batchId, address indexed collateral, uint256 amount); event ClaimSellOrder (address indexed seller, uint256 indexed batchId, address indexed collateral, uint256 fee, uint256 value); event ClaimCancelledBuyOrder (address indexed buyer, uint256 indexed batchId, address indexed collateral, uint256 value); event ClaimCancelledSellOrder(address indexed seller, uint256 indexed batchId, address indexed collateral, uint256 amount); event UpdatePricing ( uint256 indexed batchId, address indexed collateral, uint256 totalBuySpend, uint256 totalBuyReturn, uint256 totalSellSpend, uint256 totalSellReturn ); /***** external function *****/ /** * @notice Initialize market maker * @param _controller The address of the controller contract * @param _tokenManager The address of the [bonded token] token manager contract * @param _reserve The address of the reserve [pool] contract * @param _beneficiary The address of the beneficiary [to whom fees are to be sent] * @param _formula The address of the BancorFormula [computation] contract * @param _batchBlocks The number of blocks batches are to last * @param _buyFeePct The fee to be deducted from buy orders [in PCT_BASE] * @param _sellFeePct The fee to be deducted from sell orders [in PCT_BASE] */ function initialize( IAragonFundraisingController _controller, TokenManager _tokenManager, IBancorFormula _formula, Vault _reserve, address _beneficiary, uint256 _batchBlocks, uint256 _buyFeePct, uint256 _sellFeePct ) external onlyInit { initialized(); require(isContract(_controller), ERROR_CONTRACT_IS_EOA); require(isContract(_tokenManager), ERROR_CONTRACT_IS_EOA); require(isContract(_formula), ERROR_CONTRACT_IS_EOA); require(isContract(_reserve), ERROR_CONTRACT_IS_EOA); require(_beneficiaryIsValid(_beneficiary), ERROR_INVALID_BENEFICIARY); require(_batchBlocks > 0, ERROR_INVALID_BATCH_BLOCKS); require(_feeIsValid(_buyFeePct) && _feeIsValid(_sellFeePct), ERROR_INVALID_PERCENTAGE); require(_tokenManagerSettingIsValid(_tokenManager), ERROR_INVALID_TM_SETTING); controller = _controller; tokenManager = _tokenManager; token = ERC20(tokenManager.token()); formula = _formula; reserve = _reserve; beneficiary = _beneficiary; batchBlocks = _batchBlocks; buyFeePct = _buyFeePct; sellFeePct = _sellFeePct; } /* generic settings related function */ /** * @notice Open market making [enabling users to open buy and sell orders] */ function open() external auth(OPEN_ROLE) { require(!isOpen, ERROR_ALREADY_OPEN); _open(); } /** * @notice Update formula to `_formula` * @param _formula The address of the new BancorFormula [computation] contract */ function updateFormula(IBancorFormula _formula) external auth(UPDATE_FORMULA_ROLE) { require(isContract(_formula), ERROR_CONTRACT_IS_EOA); _updateFormula(_formula); } /** * @notice Update beneficiary to `_beneficiary` * @param _beneficiary The address of the new beneficiary [to whom fees are to be sent] */ function updateBeneficiary(address _beneficiary) external auth(UPDATE_BENEFICIARY_ROLE) { require(_beneficiaryIsValid(_beneficiary), ERROR_INVALID_BENEFICIARY); _updateBeneficiary(_beneficiary); } /** * @notice Update fees deducted from buy and sell orders to respectively `@formatPct(_buyFeePct)`% and `@formatPct(_sellFeePct)`% * @param _buyFeePct The new fee to be deducted from buy orders [in PCT_BASE] * @param _sellFeePct The new fee to be deducted from sell orders [in PCT_BASE] */ function updateFees(uint256 _buyFeePct, uint256 _sellFeePct) external auth(UPDATE_FEES_ROLE) { require(_feeIsValid(_buyFeePct) && _feeIsValid(_sellFeePct), ERROR_INVALID_PERCENTAGE); _updateFees(_buyFeePct, _sellFeePct); } /* collateral tokens related functions */ /** * @notice Add `_collateral.symbol(): string` as a whitelisted collateral token * @param _collateral The address of the collateral token to be whitelisted * @param _virtualSupply The virtual supply to be used for that collateral token [in wei] * @param _virtualBalance The virtual balance to be used for that collateral token [in wei] * @param _reserveRatio The reserve ratio to be used for that collateral token [in PPM] * @param _slippage The price slippage below which each batch is to be kept for that collateral token [in PCT_BASE] */ function addCollateralToken(address _collateral, uint256 _virtualSupply, uint256 _virtualBalance, uint32 _reserveRatio, uint256 _slippage) external auth(ADD_COLLATERAL_TOKEN_ROLE) { require(isContract(_collateral) || _collateral == ETH, ERROR_INVALID_COLLATERAL); require(!_collateralIsWhitelisted(_collateral), ERROR_COLLATERAL_ALREADY_WHITELISTED); require(_reserveRatioIsValid(_reserveRatio), ERROR_INVALID_RESERVE_RATIO); _addCollateralToken(_collateral, _virtualSupply, _virtualBalance, _reserveRatio, _slippage); } /** * @notice Remove `_collateral.symbol(): string` as a whitelisted collateral token * @param _collateral The address of the collateral token to be un-whitelisted */ function removeCollateralToken(address _collateral) external auth(REMOVE_COLLATERAL_TOKEN_ROLE) { require(_collateralIsWhitelisted(_collateral), ERROR_COLLATERAL_NOT_WHITELISTED); _removeCollateralToken(_collateral); } /** * @notice Update `_collateral.symbol(): string` collateralization settings * @param _collateral The address of the collateral token whose collateralization settings are to be updated * @param _virtualSupply The new virtual supply to be used for that collateral token [in wei] * @param _virtualBalance The new virtual balance to be used for that collateral token [in wei] * @param _reserveRatio The new reserve ratio to be used for that collateral token [in PPM] * @param _slippage The new price slippage below which each batch is to be kept for that collateral token [in PCT_BASE] */ function updateCollateralToken(address _collateral, uint256 _virtualSupply, uint256 _virtualBalance, uint32 _reserveRatio, uint256 _slippage) external auth(UPDATE_COLLATERAL_TOKEN_ROLE) { require(_collateralIsWhitelisted(_collateral), ERROR_COLLATERAL_NOT_WHITELISTED); require(_reserveRatioIsValid(_reserveRatio), ERROR_INVALID_RESERVE_RATIO); _updateCollateralToken(_collateral, _virtualSupply, _virtualBalance, _reserveRatio, _slippage); } /* market making related functions */ /** * @notice Open a buy order worth `@tokenAmount(_collateral, _value)` * @param _buyer The address of the buyer * @param _collateral The address of the collateral token to be spent * @param _value The amount of collateral token to be spent */ function openBuyOrder(address _buyer, address _collateral, uint256 _value) external payable auth(OPEN_BUY_ORDER_ROLE) { require(isOpen, ERROR_NOT_OPEN); require(_collateralIsWhitelisted(_collateral), ERROR_COLLATERAL_NOT_WHITELISTED); require(!_batchIsCancelled(_currentBatchId(), _collateral), ERROR_BATCH_CANCELLED); require(_collateralValueIsValid(_buyer, _collateral, _value, msg.value), ERROR_INVALID_COLLATERAL_VALUE); _openBuyOrder(_buyer, _collateral, _value); } /** * @notice Open a sell order worth `@tokenAmount(self.token(): address, _amount)` against `_collateral.symbol(): string` * @param _seller The address of the seller * @param _collateral The address of the collateral token to be returned * @param _amount The amount of bonded token to be spent */ function openSellOrder(address _seller, address _collateral, uint256 _amount) external auth(OPEN_SELL_ORDER_ROLE) { require(isOpen, ERROR_NOT_OPEN); require(_collateralIsWhitelisted(_collateral), ERROR_COLLATERAL_NOT_WHITELISTED); require(!_batchIsCancelled(_currentBatchId(), _collateral), ERROR_BATCH_CANCELLED); require(_bondAmountIsValid(_seller, _amount), ERROR_INVALID_BOND_AMOUNT); _openSellOrder(_seller, _collateral, _amount); } /** * @notice Claim the results of `_buyer`'s `_collateral.symbol(): string` buy orders from batch #`_batchId` * @param _buyer The address of the user whose buy orders are to be claimed * @param _batchId The id of the batch in which buy orders are to be claimed * @param _collateral The address of the collateral token against which buy orders are to be claimed */ function claimBuyOrder(address _buyer, uint256 _batchId, address _collateral) external nonReentrant isInitialized { require(_collateralIsWhitelisted(_collateral), ERROR_COLLATERAL_NOT_WHITELISTED); require(_batchIsOver(_batchId), ERROR_BATCH_NOT_OVER); require(!_batchIsCancelled(_batchId, _collateral), ERROR_BATCH_CANCELLED); require(_userIsBuyer(_batchId, _collateral, _buyer), ERROR_NOTHING_TO_CLAIM); _claimBuyOrder(_buyer, _batchId, _collateral); } /** * @notice Claim the results of `_seller`'s `_collateral.symbol(): string` sell orders from batch #`_batchId` * @param _seller The address of the user whose sell orders are to be claimed * @param _batchId The id of the batch in which sell orders are to be claimed * @param _collateral The address of the collateral token against which sell orders are to be claimed */ function claimSellOrder(address _seller, uint256 _batchId, address _collateral) external nonReentrant isInitialized { require(_collateralIsWhitelisted(_collateral), ERROR_COLLATERAL_NOT_WHITELISTED); require(_batchIsOver(_batchId), ERROR_BATCH_NOT_OVER); require(!_batchIsCancelled(_batchId, _collateral), ERROR_BATCH_CANCELLED); require(_userIsSeller(_batchId, _collateral, _seller), ERROR_NOTHING_TO_CLAIM); _claimSellOrder(_seller, _batchId, _collateral); } /** * @notice Claim the investments of `_buyer`'s `_collateral.symbol(): string` buy orders from cancelled batch #`_batchId` * @param _buyer The address of the user whose cancelled buy orders are to be claimed * @param _batchId The id of the batch in which cancelled buy orders are to be claimed * @param _collateral The address of the collateral token against which cancelled buy orders are to be claimed */ function claimCancelledBuyOrder(address _buyer, uint256 _batchId, address _collateral) external nonReentrant isInitialized { require(_batchIsCancelled(_batchId, _collateral), ERROR_BATCH_NOT_CANCELLED); require(_userIsBuyer(_batchId, _collateral, _buyer), ERROR_NOTHING_TO_CLAIM); _claimCancelledBuyOrder(_buyer, _batchId, _collateral); } /** * @notice Claim the investments of `_seller`'s `_collateral.symbol(): string` sell orders from cancelled batch #`_batchId` * @param _seller The address of the user whose cancelled sell orders are to be claimed * @param _batchId The id of the batch in which cancelled sell orders are to be claimed * @param _collateral The address of the collateral token against which cancelled sell orders are to be claimed */ function claimCancelledSellOrder(address _seller, uint256 _batchId, address _collateral) external nonReentrant isInitialized { require(_batchIsCancelled(_batchId, _collateral), ERROR_BATCH_NOT_CANCELLED); require(_userIsSeller(_batchId, _collateral, _seller), ERROR_NOTHING_TO_CLAIM); _claimCancelledSellOrder(_seller, _batchId, _collateral); } /***** public view functions *****/ function getCurrentBatchId() public view isInitialized returns (uint256) { return _currentBatchId(); } function getCollateralToken(address _collateral) public view isInitialized returns (bool, uint256, uint256, uint32, uint256) { Collateral storage collateral = collaterals[_collateral]; return (collateral.whitelisted, collateral.virtualSupply, collateral.virtualBalance, collateral.reserveRatio, collateral.slippage); } function getBatch(uint256 _batchId, address _collateral) public view isInitialized returns (bool, bool, uint256, uint256, uint32, uint256, uint256, uint256, uint256, uint256) { Batch storage batch = metaBatches[_batchId].batches[_collateral]; return ( batch.initialized, batch.cancelled, batch.supply, batch.balance, batch.reserveRatio, batch.slippage, batch.totalBuySpend, batch.totalBuyReturn, batch.totalSellSpend, batch.totalSellReturn ); } function getStaticPricePPM(uint256 _supply, uint256 _balance, uint32 _reserveRatio) public view isInitialized returns (uint256) { return _staticPricePPM(_supply, _balance, _reserveRatio); } /***** internal functions *****/ /* computation functions */ function _staticPricePPM(uint256 _supply, uint256 _balance, uint32 _reserveRatio) internal pure returns (uint256) { return uint256(PPM).mul(uint256(PPM)).mul(_balance).div(_supply.mul(uint256(_reserveRatio))); } function _currentBatchId() internal view returns (uint256) { return (block.number.div(batchBlocks)).mul(batchBlocks); } /* check functions */ function _beneficiaryIsValid(address _beneficiary) internal pure returns (bool) { return _beneficiary != address(0); } function _feeIsValid(uint256 _fee) internal pure returns (bool) { return _fee < PCT_BASE; } function _reserveRatioIsValid(uint32 _reserveRatio) internal pure returns (bool) { return _reserveRatio <= PPM; } function _tokenManagerSettingIsValid(TokenManager _tokenManager) internal view returns (bool) { return _tokenManager.maxAccountTokens() == uint256(-1); } function _collateralValueIsValid(address _buyer, address _collateral, uint256 _value, uint256 _msgValue) internal view returns (bool) { if (_value == 0) { return false; } if (_collateral == ETH) { return _msgValue == _value; } return ( _msgValue == 0 && controller.balanceOf(_buyer, _collateral) >= _value && ERC20(_collateral).allowance(_buyer, address(this)) >= _value ); } function _bondAmountIsValid(address _seller, uint256 _amount) internal view returns (bool) { return _amount != 0 && tokenManager.spendableBalanceOf(_seller) >= _amount; } function _collateralIsWhitelisted(address _collateral) internal view returns (bool) { return collaterals[_collateral].whitelisted; } function _batchIsOver(uint256 _batchId) internal view returns (bool) { return _batchId < _currentBatchId(); } function _batchIsCancelled(uint256 _batchId, address _collateral) internal view returns (bool) { return metaBatches[_batchId].batches[_collateral].cancelled; } function _userIsBuyer(uint256 _batchId, address _collateral, address _user) internal view returns (bool) { Batch storage batch = metaBatches[_batchId].batches[_collateral]; return batch.buyers[_user] > 0; } function _userIsSeller(uint256 _batchId, address _collateral, address _user) internal view returns (bool) { Batch storage batch = metaBatches[_batchId].batches[_collateral]; return batch.sellers[_user] > 0; } function _poolBalanceIsSufficient(address _collateral) internal view returns (bool) { return controller.balanceOf(address(reserve), _collateral) >= collateralsToBeClaimed[_collateral]; } function _slippageIsValid(Batch storage _batch, address _collateral) internal view returns (bool) { uint256 staticPricePPM = _staticPricePPM(_batch.supply, _batch.balance, _batch.reserveRatio); uint256 maximumSlippage = _batch.slippage; // if static price is zero let's consider that every slippage is valid if (staticPricePPM == 0) { return true; } return _buySlippageIsValid(_batch, staticPricePPM, maximumSlippage) && _sellSlippageIsValid(_batch, staticPricePPM, maximumSlippage); } function _buySlippageIsValid(Batch storage _batch, uint256 _startingPricePPM, uint256 _maximumSlippage) internal view returns (bool) { /** * NOTE * the case where starting price is zero is handled * in the meta function _slippageIsValid() */ /** * NOTE * slippage is valid if: * totalBuyReturn >= totalBuySpend / (startingPrice * (1 + maxSlippage)) * totalBuyReturn >= totalBuySpend / ((startingPricePPM / PPM) * (1 + maximumSlippage / PCT_BASE)) * totalBuyReturn >= totalBuySpend / ((startingPricePPM / PPM) * (1 + maximumSlippage / PCT_BASE)) * totalBuyReturn >= totalBuySpend / ((startingPricePPM / PPM) * (PCT + maximumSlippage) / PCT_BASE) * totalBuyReturn * startingPrice * ( PCT + maximumSlippage) >= totalBuySpend * PCT_BASE * PPM */ if ( _batch.totalBuyReturn.mul(_startingPricePPM).mul(PCT_BASE.add(_maximumSlippage)) >= _batch.totalBuySpend.mul(PCT_BASE).mul(uint256(PPM)) ) { return true; } return false; } function _sellSlippageIsValid(Batch storage _batch, uint256 _startingPricePPM, uint256 _maximumSlippage) internal view returns (bool) { /** * NOTE * the case where starting price is zero is handled * in the meta function _slippageIsValid() */ // if allowed sell slippage >= 100% // then any sell slippage is valid if (_maximumSlippage >= PCT_BASE) { return true; } /** * NOTE * slippage is valid if * totalSellReturn >= startingPrice * (1 - maxSlippage) * totalBuySpend * totalSellReturn >= (startingPricePPM / PPM) * (1 - maximumSlippage / PCT_BASE) * totalBuySpend * totalSellReturn >= (startingPricePPM / PPM) * (PCT_BASE - maximumSlippage) * totalBuySpend / PCT_BASE * totalSellReturn * PCT_BASE * PPM = startingPricePPM * (PCT_BASE - maximumSlippage) * totalBuySpend */ if ( _batch.totalSellReturn.mul(PCT_BASE).mul(uint256(PPM)) >= _startingPricePPM.mul(PCT_BASE.sub(_maximumSlippage)).mul(_batch.totalSellSpend) ) { return true; } return false; } /* initialization functions */ function _currentBatch(address _collateral) internal returns (uint256, Batch storage) { uint256 batchId = _currentBatchId(); MetaBatch storage metaBatch = metaBatches[batchId]; Batch storage batch = metaBatch.batches[_collateral]; if (!metaBatch.initialized) { /** * NOTE * all collateral batches should be initialized with the same supply to * avoid price manipulation between different collaterals in the same meta-batch * we don't need to do the same with collateral balances as orders against one collateral * can't affect the pool's balance against another collateral and tap is a step-function * of the meta-batch duration */ /** * NOTE * realSupply(metaBatch) = totalSupply(metaBatchInitialization) + tokensToBeMinted(metaBatchInitialization) * 1. buy and sell orders incoming during the current meta-batch and affecting totalSupply or tokensToBeMinted * should not be taken into account in the price computation [they are already a part of the batched pricing computation] * 2. the only way for totalSupply to be modified during a meta-batch [outside of incoming buy and sell orders] * is for buy orders from previous meta-batches to be claimed [and tokens to be minted]: * as such totalSupply(metaBatch) + tokenToBeMinted(metaBatch) will always equal totalSupply(metaBatchInitialization) + tokenToBeMinted(metaBatchInitialization) */ metaBatch.realSupply = token.totalSupply().add(tokensToBeMinted); metaBatch.buyFeePct = buyFeePct; metaBatch.sellFeePct = sellFeePct; metaBatch.formula = formula; metaBatch.initialized = true; emit NewMetaBatch(batchId, metaBatch.realSupply, metaBatch.buyFeePct, metaBatch.sellFeePct, metaBatch.formula); } if (!batch.initialized) { /** * NOTE * supply(batch) = realSupply(metaBatch) + virtualSupply(batchInitialization) * virtualSupply can technically be updated during a batch: the on-going batch will still use * its value at the time of initialization [it's up to the updater to act wisely] */ /** * NOTE * balance(batch) = poolBalance(batchInitialization) - collateralsToBeClaimed(batchInitialization) + virtualBalance(metaBatchInitialization) * 1. buy and sell orders incoming during the current batch and affecting poolBalance or collateralsToBeClaimed * should not be taken into account in the price computation [they are already a part of the batched price computation] * 2. the only way for poolBalance to be modified during a batch [outside of incoming buy and sell orders] * is for sell orders from previous meta-batches to be claimed [and collateral to be transfered] as the tap is a step-function of the meta-batch duration: * as such poolBalance(batch) - collateralsToBeClaimed(batch) will always equal poolBalance(batchInitialization) - collateralsToBeClaimed(batchInitialization) * 3. virtualBalance can technically be updated during a batch: the on-going batch will still use * its value at the time of initialization [it's up to the updater to act wisely] */ controller.updateTappedAmount(_collateral); batch.supply = metaBatch.realSupply.add(collaterals[_collateral].virtualSupply); batch.balance = controller.balanceOf(address(reserve), _collateral).add(collaterals[_collateral].virtualBalance).sub(collateralsToBeClaimed[_collateral]); batch.reserveRatio = collaterals[_collateral].reserveRatio; batch.slippage = collaterals[_collateral].slippage; batch.initialized = true; emit NewBatch(batchId, _collateral, batch.supply, batch.balance, batch.reserveRatio, batch.slippage); } return (batchId, batch); } /* state modifiying functions */ function _open() internal { isOpen = true; emit Open(); } function _updateBeneficiary(address _beneficiary) internal { beneficiary = _beneficiary; emit UpdateBeneficiary(_beneficiary); } function _updateFormula(IBancorFormula _formula) internal { formula = _formula; emit UpdateFormula(address(_formula)); } function _updateFees(uint256 _buyFeePct, uint256 _sellFeePct) internal { buyFeePct = _buyFeePct; sellFeePct = _sellFeePct; emit UpdateFees(_buyFeePct, _sellFeePct); } function _cancelCurrentBatch(address _collateral) internal { (uint256 batchId, Batch storage batch) = _currentBatch(_collateral); if (!batch.cancelled) { batch.cancelled = true; // bought bonds are cancelled but sold bonds are due back // bought collaterals are cancelled but sold collaterals are due back tokensToBeMinted = tokensToBeMinted.sub(batch.totalBuyReturn).add(batch.totalSellSpend); collateralsToBeClaimed[_collateral] = collateralsToBeClaimed[_collateral].add(batch.totalBuySpend).sub(batch.totalSellReturn); emit CancelBatch(batchId, _collateral); } } function _addCollateralToken(address _collateral, uint256 _virtualSupply, uint256 _virtualBalance, uint32 _reserveRatio, uint256 _slippage) internal { collaterals[_collateral].whitelisted = true; collaterals[_collateral].virtualSupply = _virtualSupply; collaterals[_collateral].virtualBalance = _virtualBalance; collaterals[_collateral].reserveRatio = _reserveRatio; collaterals[_collateral].slippage = _slippage; emit AddCollateralToken(_collateral, _virtualSupply, _virtualBalance, _reserveRatio, _slippage); } function _removeCollateralToken(address _collateral) internal { _cancelCurrentBatch(_collateral); Collateral storage collateral = collaterals[_collateral]; delete collateral.whitelisted; delete collateral.virtualSupply; delete collateral.virtualBalance; delete collateral.reserveRatio; delete collateral.slippage; emit RemoveCollateralToken(_collateral); } function _updateCollateralToken( address _collateral, uint256 _virtualSupply, uint256 _virtualBalance, uint32 _reserveRatio, uint256 _slippage ) internal { collaterals[_collateral].virtualSupply = _virtualSupply; collaterals[_collateral].virtualBalance = _virtualBalance; collaterals[_collateral].reserveRatio = _reserveRatio; collaterals[_collateral].slippage = _slippage; emit UpdateCollateralToken(_collateral, _virtualSupply, _virtualBalance, _reserveRatio, _slippage); } function _openBuyOrder(address _buyer, address _collateral, uint256 _value) internal { (uint256 batchId, Batch storage batch) = _currentBatch(_collateral); // deduct fee uint256 fee = _value.mul(metaBatches[batchId].buyFeePct).div(PCT_BASE); uint256 value = _value.sub(fee); // collect fee and collateral if (fee > 0) { _transfer(_buyer, beneficiary, _collateral, fee); } _transfer(_buyer, address(reserve), _collateral, value); // save batch uint256 deprecatedBuyReturn = batch.totalBuyReturn; uint256 deprecatedSellReturn = batch.totalSellReturn; // update batch batch.totalBuySpend = batch.totalBuySpend.add(value); batch.buyers[_buyer] = batch.buyers[_buyer].add(value); // update pricing _updatePricing(batch, batchId, _collateral); // update the amount of tokens to be minted and collaterals to be claimed tokensToBeMinted = tokensToBeMinted.sub(deprecatedBuyReturn).add(batch.totalBuyReturn); collateralsToBeClaimed[_collateral] = collateralsToBeClaimed[_collateral].sub(deprecatedSellReturn).add(batch.totalSellReturn); // sanity checks require(_slippageIsValid(batch, _collateral), ERROR_SLIPPAGE_EXCEEDS_LIMIT); emit OpenBuyOrder(_buyer, batchId, _collateral, fee, value); } function _openSellOrder(address _seller, address _collateral, uint256 _amount) internal { (uint256 batchId, Batch storage batch) = _currentBatch(_collateral); // burn bonds tokenManager.burn(_seller, _amount); // save batch uint256 deprecatedBuyReturn = batch.totalBuyReturn; uint256 deprecatedSellReturn = batch.totalSellReturn; // update batch batch.totalSellSpend = batch.totalSellSpend.add(_amount); batch.sellers[_seller] = batch.sellers[_seller].add(_amount); // update pricing _updatePricing(batch, batchId, _collateral); // update the amount of tokens to be minted and collaterals to be claimed tokensToBeMinted = tokensToBeMinted.sub(deprecatedBuyReturn).add(batch.totalBuyReturn); collateralsToBeClaimed[_collateral] = collateralsToBeClaimed[_collateral].sub(deprecatedSellReturn).add(batch.totalSellReturn); // sanity checks require(_slippageIsValid(batch, _collateral), ERROR_SLIPPAGE_EXCEEDS_LIMIT); require(_poolBalanceIsSufficient(_collateral), ERROR_INSUFFICIENT_POOL_BALANCE); emit OpenSellOrder(_seller, batchId, _collateral, _amount); } function _claimBuyOrder(address _buyer, uint256 _batchId, address _collateral) internal { Batch storage batch = metaBatches[_batchId].batches[_collateral]; uint256 buyReturn = (batch.buyers[_buyer].mul(batch.totalBuyReturn)).div(batch.totalBuySpend); batch.buyers[_buyer] = 0; if (buyReturn > 0) { tokensToBeMinted = tokensToBeMinted.sub(buyReturn); tokenManager.mint(_buyer, buyReturn); } emit ClaimBuyOrder(_buyer, _batchId, _collateral, buyReturn); } function _claimSellOrder(address _seller, uint256 _batchId, address _collateral) internal { Batch storage batch = metaBatches[_batchId].batches[_collateral]; uint256 saleReturn = (batch.sellers[_seller].mul(batch.totalSellReturn)).div(batch.totalSellSpend); uint256 fee = saleReturn.mul(metaBatches[_batchId].sellFeePct).div(PCT_BASE); uint256 value = saleReturn.sub(fee); batch.sellers[_seller] = 0; if (value > 0) { collateralsToBeClaimed[_collateral] = collateralsToBeClaimed[_collateral].sub(saleReturn); reserve.transfer(_collateral, _seller, value); } if (fee > 0) { reserve.transfer(_collateral, beneficiary, fee); } emit ClaimSellOrder(_seller, _batchId, _collateral, fee, value); } function _claimCancelledBuyOrder(address _buyer, uint256 _batchId, address _collateral) internal { Batch storage batch = metaBatches[_batchId].batches[_collateral]; uint256 value = batch.buyers[_buyer]; batch.buyers[_buyer] = 0; if (value > 0) { collateralsToBeClaimed[_collateral] = collateralsToBeClaimed[_collateral].sub(value); reserve.transfer(_collateral, _buyer, value); } emit ClaimCancelledBuyOrder(_buyer, _batchId, _collateral, value); } function _claimCancelledSellOrder(address _seller, uint256 _batchId, address _collateral) internal { Batch storage batch = metaBatches[_batchId].batches[_collateral]; uint256 amount = batch.sellers[_seller]; batch.sellers[_seller] = 0; if (amount > 0) { tokensToBeMinted = tokensToBeMinted.sub(amount); tokenManager.mint(_seller, amount); } emit ClaimCancelledSellOrder(_seller, _batchId, _collateral, amount); } function _updatePricing(Batch storage batch, uint256 _batchId, address _collateral) internal { // the situation where there are no buy nor sell orders can't happen [keep commented] // if (batch.totalSellSpend == 0 && batch.totalBuySpend == 0) // return; // static price is the current exact price in collateral // per token according to the initial state of the batch // [expressed in PPM for precision sake] uint256 staticPricePPM = _staticPricePPM(batch.supply, batch.balance, batch.reserveRatio); // [NOTE] // if staticPrice is zero then resultOfSell [= 0] <= batch.totalBuySpend // so totalSellReturn will be zero and totalBuyReturn will be // computed normally along the formula // 1. we want to find out if buy orders are worth more sell orders [or vice-versa] // 2. we thus check the return of sell orders at the current exact price // 3. if the return of sell orders is larger than the pending buys, // there are more sells than buys [and vice-versa] uint256 resultOfSell = batch.totalSellSpend.mul(staticPricePPM).div(uint256(PPM)); if (resultOfSell > batch.totalBuySpend) { // >> sell orders are worth more than buy orders // 1. first we execute all pending buy orders at the current exact // price because there is at least one sell order for each buy order // 2. then the final sell return is the addition of this first // matched return with the remaining bonding curve return // the number of tokens bought as a result of all buy orders matched at the // current exact price [which is less than the total amount of tokens to be sold] batch.totalBuyReturn = batch.totalBuySpend.mul(uint256(PPM)).div(staticPricePPM); // the number of tokens left over to be sold along the curve which is the difference // between the original total sell order and the result of all the buy orders uint256 remainingSell = batch.totalSellSpend.sub(batch.totalBuyReturn); // the amount of collateral generated by selling tokens left over to be sold // along the bonding curve in the batch initial state [as if the buy orders // never existed and the sell order was just smaller than originally thought] uint256 remainingSellReturn = metaBatches[_batchId].formula.calculateSaleReturn(batch.supply, batch.balance, batch.reserveRatio, remainingSell); // the total result of all sells is the original amount of buys which were matched // plus the remaining sells which were executed along the bonding curve batch.totalSellReturn = batch.totalBuySpend.add(remainingSellReturn); } else { // >> buy orders are worth more than sell orders // 1. first we execute all pending sell orders at the current exact // price because there is at least one buy order for each sell order // 2. then the final buy return is the addition of this first // matched return with the remaining bonding curve return // the number of collaterals bought as a result of all sell orders matched at the // current exact price [which is less than the total amount of collateral to be spent] batch.totalSellReturn = resultOfSell; // the number of collaterals left over to be spent along the curve which is the difference // between the original total buy order and the result of all the sell orders uint256 remainingBuy = batch.totalBuySpend.sub(resultOfSell); // the amount of tokens generated by selling collaterals left over to be spent // along the bonding curve in the batch initial state [as if the sell orders // never existed and the buy order was just smaller than originally thought] uint256 remainingBuyReturn = metaBatches[_batchId].formula.calculatePurchaseReturn(batch.supply, batch.balance, batch.reserveRatio, remainingBuy); // the total result of all buys is the original amount of buys which were matched // plus the remaining buys which were executed along the bonding curve batch.totalBuyReturn = batch.totalSellSpend.add(remainingBuyReturn); } emit UpdatePricing(_batchId, _collateral, batch.totalBuySpend, batch.totalBuyReturn, batch.totalSellSpend, batch.totalSellReturn); } function _transfer(address _from, address _to, address _collateralToken, uint256 _amount) internal { if (_collateralToken == ETH) { _to.transfer(_amount); } else { require(ERC20(_collateralToken).safeTransferFrom(_from, _to, _amount), ERROR_TRANSFER_FROM_FAILED); } } } // File: @ablack/fundraising-shared-interfaces/contracts/IPresale.sol pragma solidity 0.4.24; contract IPresale { function open() external; function close() external; function contribute(address _contributor, uint256 _value) external payable; function refund(address _contributor, uint256 _vestedPurchaseId) external; function contributionToTokens(uint256 _value) public view returns (uint256); function contributionToken() public view returns (address); } // File: @ablack/fundraising-shared-interfaces/contracts/ITap.sol pragma solidity 0.4.24; contract ITap { function updateBeneficiary(address _beneficiary) external; function updateMaximumTapRateIncreasePct(uint256 _maximumTapRateIncreasePct) external; function updateMaximumTapFloorDecreasePct(uint256 _maximumTapFloorDecreasePct) external; function addTappedToken(address _token, uint256 _rate, uint256 _floor) external; function updateTappedToken(address _token, uint256 _rate, uint256 _floor) external; function resetTappedToken(address _token) external; function updateTappedAmount(address _token) external; function withdraw(address _token) external; function getMaximumWithdrawal(address _token) public view returns (uint256); function rates(address _token) public view returns (uint256); } // File: contracts/AragonFundraisingController.sol pragma solidity 0.4.24; contract AragonFundraisingController is EtherTokenConstant, IsContract, IAragonFundraisingController, AragonApp { using SafeERC20 for ERC20; using SafeMath for uint256; /** Hardcoded constants to save gas bytes32 public constant UPDATE_BENEFICIARY_ROLE = keccak256("UPDATE_BENEFICIARY_ROLE"); bytes32 public constant UPDATE_FEES_ROLE = keccak256("UPDATE_FEES_ROLE"); bytes32 public constant ADD_COLLATERAL_TOKEN_ROLE = keccak256("ADD_COLLATERAL_TOKEN_ROLE"); bytes32 public constant REMOVE_COLLATERAL_TOKEN_ROLE = keccak256("REMOVE_COLLATERAL_TOKEN_ROLE"); bytes32 public constant UPDATE_COLLATERAL_TOKEN_ROLE = keccak256("UPDATE_COLLATERAL_TOKEN_ROLE"); bytes32 public constant UPDATE_MAXIMUM_TAP_RATE_INCREASE_PCT_ROLE = keccak256("UPDATE_MAXIMUM_TAP_RATE_INCREASE_PCT_ROLE"); bytes32 public constant UPDATE_MAXIMUM_TAP_FLOOR_DECREASE_PCT_ROLE = keccak256("UPDATE_MAXIMUM_TAP_FLOOR_DECREASE_PCT_ROLE"); bytes32 public constant ADD_TOKEN_TAP_ROLE = keccak256("ADD_TOKEN_TAP_ROLE"); bytes32 public constant UPDATE_TOKEN_TAP_ROLE = keccak256("UPDATE_TOKEN_TAP_ROLE"); bytes32 public constant OPEN_PRESALE_ROLE = keccak256("OPEN_PRESALE_ROLE"); bytes32 public constant OPEN_TRADING_ROLE = keccak256("OPEN_TRADING_ROLE"); bytes32 public constant CONTRIBUTE_ROLE = keccak256("CONTRIBUTE_ROLE"); bytes32 public constant OPEN_BUY_ORDER_ROLE = keccak256("OPEN_BUY_ORDER_ROLE"); bytes32 public constant OPEN_SELL_ORDER_ROLE = keccak256("OPEN_SELL_ORDER_ROLE"); bytes32 public constant WITHDRAW_ROLE = keccak256("WITHDRAW_ROLE"); */ bytes32 public constant UPDATE_BENEFICIARY_ROLE = 0xf7ea2b80c7b6a2cab2c11d2290cb005c3748397358a25e17113658c83b732593; bytes32 public constant UPDATE_FEES_ROLE = 0x5f9be2932ed3a723f295a763be1804c7ebfd1a41c1348fb8bdf5be1c5cdca822; bytes32 public constant ADD_COLLATERAL_TOKEN_ROLE = 0x217b79cb2bc7760defc88529853ef81ab33ae5bb315408ce9f5af09c8776662d; bytes32 public constant REMOVE_COLLATERAL_TOKEN_ROLE = 0x2044e56de223845e4be7d0a6f4e9a29b635547f16413a6d1327c58d9db438ee2; bytes32 public constant UPDATE_COLLATERAL_TOKEN_ROLE = 0xe0565c2c43e0d841e206bb36a37f12f22584b4652ccee6f9e0c071b697a2e13d; bytes32 public constant UPDATE_MAXIMUM_TAP_RATE_INCREASE_PCT_ROLE = 0x5d94de7e429250eee4ff97e30ab9f383bea3cd564d6780e0a9e965b1add1d207; bytes32 public constant UPDATE_MAXIMUM_TAP_FLOOR_DECREASE_PCT_ROLE = 0x57c9c67896cf0a4ffe92cbea66c2f7c34380af06bf14215dabb078cf8a6d99e1; bytes32 public constant ADD_TOKEN_TAP_ROLE = 0xbc9cb5e3f7ce81c4fd021d86a4bcb193dee9df315b540808c3ed59a81e596207; bytes32 public constant UPDATE_TOKEN_TAP_ROLE = 0xdb8c88bedbc61ea0f92e1ce46da0b7a915affbd46d1c76c4bbac9a209e4a8416; bytes32 public constant OPEN_PRESALE_ROLE = 0xf323aa41eef4850a8ae7ebd047d4c89f01ce49c781f3308be67303db9cdd48c2; bytes32 public constant OPEN_TRADING_ROLE = 0x26ce034204208c0bbca4c8a793d17b99e546009b1dd31d3c1ef761f66372caf6; bytes32 public constant CONTRIBUTE_ROLE = 0x9ccaca4edf2127f20c425fdd86af1ba178b9e5bee280cd70d88ac5f6874c4f07; bytes32 public constant OPEN_BUY_ORDER_ROLE = 0xa589c8f284b76fc8d510d9d553485c47dbef1b0745ae00e0f3fd4e28fcd77ea7; bytes32 public constant OPEN_SELL_ORDER_ROLE = 0xd68ba2b769fa37a2a7bd4bed9241b448bc99eca41f519ef037406386a8f291c0; bytes32 public constant WITHDRAW_ROLE = 0x5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec; uint256 public constant TO_RESET_CAP = 10; string private constant ERROR_CONTRACT_IS_EOA = "FUNDRAISING_CONTRACT_IS_EOA"; string private constant ERROR_INVALID_TOKENS = "FUNDRAISING_INVALID_TOKENS"; IPresale public presale; BatchedBancorMarketMaker public marketMaker; Agent public reserve; ITap public tap; address[] public toReset; /***** external functions *****/ /** * @notice Initialize Aragon Fundraising controller * @param _presale The address of the presale contract * @param _marketMaker The address of the market maker contract * @param _reserve The address of the reserve [pool] contract * @param _tap The address of the tap contract * @param _toReset The addresses of the tokens whose tap timestamps are to be reset [when presale is closed and trading is open] */ function initialize( IPresale _presale, BatchedBancorMarketMaker _marketMaker, Agent _reserve, ITap _tap, address[] _toReset ) external onlyInit { require(isContract(_presale), ERROR_CONTRACT_IS_EOA); require(isContract(_marketMaker), ERROR_CONTRACT_IS_EOA); require(isContract(_reserve), ERROR_CONTRACT_IS_EOA); require(isContract(_tap), ERROR_CONTRACT_IS_EOA); require(_toReset.length < TO_RESET_CAP, ERROR_INVALID_TOKENS); initialized(); presale = _presale; marketMaker = _marketMaker; reserve = _reserve; tap = _tap; for (uint256 i = 0; i < _toReset.length; i++) { require(_tokenIsContractOrETH(_toReset[i]), ERROR_INVALID_TOKENS); toReset.push(_toReset[i]); } } /* generic settings related function */ /** * @notice Update beneficiary to `_beneficiary` * @param _beneficiary The address of the new beneficiary */ function updateBeneficiary(address _beneficiary) external auth(UPDATE_BENEFICIARY_ROLE) { marketMaker.updateBeneficiary(_beneficiary); tap.updateBeneficiary(_beneficiary); } /** * @notice Update fees deducted from buy and sell orders to respectively `@formatPct(_buyFeePct)`% and `@formatPct(_sellFeePct)`% * @param _buyFeePct The new fee to be deducted from buy orders [in PCT_BASE] * @param _sellFeePct The new fee to be deducted from sell orders [in PCT_BASE] */ function updateFees(uint256 _buyFeePct, uint256 _sellFeePct) external auth(UPDATE_FEES_ROLE) { marketMaker.updateFees(_buyFeePct, _sellFeePct); } /* presale related functions */ /** * @notice Open presale */ function openPresale() external auth(OPEN_PRESALE_ROLE) { presale.open(); } /** * @notice Close presale and open trading */ function closePresale() external isInitialized { presale.close(); } /** * @notice Contribute to the presale up to `@tokenAmount(self.contributionToken(): address, _value)` * @param _value The amount of contribution token to be spent */ function contribute(uint256 _value) external payable auth(CONTRIBUTE_ROLE) { presale.contribute.value(msg.value)(msg.sender, _value); } /** * @notice Refund `_contributor`'s presale contribution #`_vestedPurchaseId` * @param _contributor The address of the contributor whose presale contribution is to be refunded * @param _vestedPurchaseId The id of the contribution to be refunded */ function refund(address _contributor, uint256 _vestedPurchaseId) external isInitialized { presale.refund(_contributor, _vestedPurchaseId); } /* market making related functions */ /** * @notice Open trading [enabling users to open buy and sell orders] */ function openTrading() external auth(OPEN_TRADING_ROLE) { for (uint256 i = 0; i < toReset.length; i++) { if (tap.rates(toReset[i]) != uint256(0)) { tap.resetTappedToken(toReset[i]); } } marketMaker.open(); } /** * @notice Open a buy order worth `@tokenAmount(_collateral, _value)` * @param _collateral The address of the collateral token to be spent * @param _value The amount of collateral token to be spent */ function openBuyOrder(address _collateral, uint256 _value) external payable auth(OPEN_BUY_ORDER_ROLE) { marketMaker.openBuyOrder.value(msg.value)(msg.sender, _collateral, _value); } /** * @notice Open a sell order worth `@tokenAmount(self.token(): address, _amount)` against `_collateral.symbol(): string` * @param _collateral The address of the collateral token to be returned * @param _amount The amount of bonded token to be spent */ function openSellOrder(address _collateral, uint256 _amount) external auth(OPEN_SELL_ORDER_ROLE) { marketMaker.openSellOrder(msg.sender, _collateral, _amount); } /** * @notice Claim the results of `_collateral.symbol(): string` buy orders from batch #`_batchId` * @param _buyer The address of the user whose buy orders are to be claimed * @param _batchId The id of the batch in which buy orders are to be claimed * @param _collateral The address of the collateral token against which buy orders are to be claimed */ function claimBuyOrder(address _buyer, uint256 _batchId, address _collateral) external isInitialized { marketMaker.claimBuyOrder(_buyer, _batchId, _collateral); } /** * @notice Claim the results of `_collateral.symbol(): string` sell orders from batch #`_batchId` * @param _seller The address of the user whose sell orders are to be claimed * @param _batchId The id of the batch in which sell orders are to be claimed * @param _collateral The address of the collateral token against which sell orders are to be claimed */ function claimSellOrder(address _seller, uint256 _batchId, address _collateral) external isInitialized { marketMaker.claimSellOrder(_seller, _batchId, _collateral); } /* collateral tokens related functions */ /** * @notice Add `_collateral.symbol(): string` as a whitelisted collateral token * @param _collateral The address of the collateral token to be whitelisted * @param _virtualSupply The virtual supply to be used for that collateral token [in wei] * @param _virtualBalance The virtual balance to be used for that collateral token [in wei] * @param _reserveRatio The reserve ratio to be used for that collateral token [in PPM] * @param _slippage The price slippage below which each market making batch is to be kept for that collateral token [in PCT_BASE] * @param _rate The rate at which that token is to be tapped [in wei / block] * @param _floor The floor above which the reserve [pool] balance for that token is to be kept [in wei] */ function addCollateralToken( address _collateral, uint256 _virtualSupply, uint256 _virtualBalance, uint32 _reserveRatio, uint256 _slippage, uint256 _rate, uint256 _floor ) external auth(ADD_COLLATERAL_TOKEN_ROLE) { marketMaker.addCollateralToken(_collateral, _virtualSupply, _virtualBalance, _reserveRatio, _slippage); if (_collateral != ETH) { reserve.addProtectedToken(_collateral); } if (_rate > 0) { tap.addTappedToken(_collateral, _rate, _floor); } } /** * @notice Re-add `_collateral.symbol(): string` as a whitelisted collateral token [if it has been un-whitelisted in the past] * @param _collateral The address of the collateral token to be whitelisted * @param _virtualSupply The virtual supply to be used for that collateral token [in wei] * @param _virtualBalance The virtual balance to be used for that collateral token [in wei] * @param _reserveRatio The reserve ratio to be used for that collateral token [in PPM] * @param _slippage The price slippage below which each market making batch is to be kept for that collateral token [in PCT_BASE] */ function reAddCollateralToken( address _collateral, uint256 _virtualSupply, uint256 _virtualBalance, uint32 _reserveRatio, uint256 _slippage ) external auth(ADD_COLLATERAL_TOKEN_ROLE) { marketMaker.addCollateralToken(_collateral, _virtualSupply, _virtualBalance, _reserveRatio, _slippage); } /** * @notice Remove `_collateral.symbol(): string` as a whitelisted collateral token * @param _collateral The address of the collateral token to be un-whitelisted */ function removeCollateralToken(address _collateral) external auth(REMOVE_COLLATERAL_TOKEN_ROLE) { marketMaker.removeCollateralToken(_collateral); // the token should still be tapped to avoid being locked // the token should still be protected to avoid being spent } /** * @notice Update `_collateral.symbol(): string` collateralization settings * @param _collateral The address of the collateral token whose collateralization settings are to be updated * @param _virtualSupply The new virtual supply to be used for that collateral token [in wei] * @param _virtualBalance The new virtual balance to be used for that collateral token [in wei] * @param _reserveRatio The new reserve ratio to be used for that collateral token [in PPM] * @param _slippage The new price slippage below which each market making batch is to be kept for that collateral token [in PCT_BASE] */ function updateCollateralToken( address _collateral, uint256 _virtualSupply, uint256 _virtualBalance, uint32 _reserveRatio, uint256 _slippage ) external auth(UPDATE_COLLATERAL_TOKEN_ROLE) { marketMaker.updateCollateralToken(_collateral, _virtualSupply, _virtualBalance, _reserveRatio, _slippage); } /* tap related functions */ /** * @notice Update maximum tap rate increase percentage to `@formatPct(_maximumTapRateIncreasePct)`% * @param _maximumTapRateIncreasePct The new maximum tap rate increase percentage to be allowed [in PCT_BASE] */ function updateMaximumTapRateIncreasePct(uint256 _maximumTapRateIncreasePct) external auth(UPDATE_MAXIMUM_TAP_RATE_INCREASE_PCT_ROLE) { tap.updateMaximumTapRateIncreasePct(_maximumTapRateIncreasePct); } /** * @notice Update maximum tap floor decrease percentage to `@formatPct(_maximumTapFloorDecreasePct)`% * @param _maximumTapFloorDecreasePct The new maximum tap floor decrease percentage to be allowed [in PCT_BASE] */ function updateMaximumTapFloorDecreasePct(uint256 _maximumTapFloorDecreasePct) external auth(UPDATE_MAXIMUM_TAP_FLOOR_DECREASE_PCT_ROLE) { tap.updateMaximumTapFloorDecreasePct(_maximumTapFloorDecreasePct); } /** * @notice Add tap for `_token.symbol(): string` with a rate of `@tokenAmount(_token, _rate)` per block and a floor of `@tokenAmount(_token, _floor)` * @param _token The address of the token to be tapped * @param _rate The rate at which that token is to be tapped [in wei / block] * @param _floor The floor above which the reserve [pool] balance for that token is to be kept [in wei] */ function addTokenTap(address _token, uint256 _rate, uint256 _floor) external auth(ADD_TOKEN_TAP_ROLE) { tap.addTappedToken(_token, _rate, _floor); } /** * @notice Update tap for `_token.symbol(): string` with a rate of about `@tokenAmount(_token, 4 * 60 * 24 * 30 * _rate)` per month and a floor of `@tokenAmount(_token, _floor)` * @param _token The address of the token whose tap is to be updated * @param _rate The new rate at which that token is to be tapped [in wei / block] * @param _floor The new floor above which the reserve [pool] balance for that token is to be kept [in wei] */ function updateTokenTap(address _token, uint256 _rate, uint256 _floor) external auth(UPDATE_TOKEN_TAP_ROLE) { tap.updateTappedToken(_token, _rate, _floor); } /** * @notice Update tapped amount for `_token.symbol(): string` * @param _token The address of the token whose tapped amount is to be updated */ function updateTappedAmount(address _token) external { tap.updateTappedAmount(_token); } /** * @notice Transfer about `@tokenAmount(_token, self.getMaximumWithdrawal(_token): uint256)` from the reserve to the beneficiary * @param _token The address of the token to be transfered from the reserve to the beneficiary */ function withdraw(address _token) external auth(WITHDRAW_ROLE) { tap.withdraw(_token); } /***** public view functions *****/ function token() public view isInitialized returns (address) { return marketMaker.token(); } function contributionToken() public view isInitialized returns (address) { return presale.contributionToken(); } function getMaximumWithdrawal(address _token) public view isInitialized returns (uint256) { return tap.getMaximumWithdrawal(_token); } function collateralsToBeClaimed(address _collateral) public view isInitialized returns (uint256) { return marketMaker.collateralsToBeClaimed(_collateral); } function balanceOf(address _who, address _token) public view isInitialized returns (uint256) { uint256 balance = _token == ETH ? _who.balance : ERC20(_token).staticBalanceOf(_who); if (_who == address(reserve)) { return balance.sub(tap.getMaximumWithdrawal(_token)); } else { return balance; } } /***** internal functions *****/ function _tokenIsContractOrETH(address _token) internal view returns (bool) { return isContract(_token) || _token == ETH; } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"constant":false,"inputs":[{"name":"_maximumTapRateIncreasePct","type":"uint256"}],"name":"updateMaximumTapRateIncreasePct","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"hasInitialized","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_beneficiary","type":"address"}],"name":"updateBeneficiary","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"TO_RESET_CAP","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"OPEN_TRADING_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"OPEN_PRESALE_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"marketMaker","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_script","type":"bytes"}],"name":"getEVMScriptExecutor","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"OPEN_BUY_ORDER_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UPDATE_COLLATERAL_TOKEN_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getRecoveryVault","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"_rate","type":"uint256"},{"name":"_floor","type":"uint256"}],"name":"addTokenTap","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_contributor","type":"address"},{"name":"_vestedPurchaseId","type":"uint256"}],"name":"refund","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UPDATE_BENEFICIARY_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_collateral","type":"address"}],"name":"collateralsToBeClaimed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"contributionToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_seller","type":"address"},{"name":"_batchId","type":"uint256"},{"name":"_collateral","type":"address"}],"name":"claimSellOrder","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"ADD_COLLATERAL_TOKEN_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UPDATE_FEES_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_collateral","type":"address"},{"name":"_virtualSupply","type":"uint256"},{"name":"_virtualBalance","type":"uint256"},{"name":"_reserveRatio","type":"uint32"},{"name":"_slippage","type":"uint256"}],"name":"reAddCollateralToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"closePresale","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_buyFeePct","type":"uint256"},{"name":"_sellFeePct","type":"uint256"}],"name":"updateFees","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_buyer","type":"address"},{"name":"_batchId","type":"uint256"},{"name":"_collateral","type":"address"}],"name":"claimBuyOrder","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_collateral","type":"address"},{"name":"_amount","type":"uint256"}],"name":"openSellOrder","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"token","type":"address"}],"name":"allowRecoverability","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"appId","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"updateTappedAmount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_collateral","type":"address"},{"name":"_virtualSupply","type":"uint256"},{"name":"_virtualBalance","type":"uint256"},{"name":"_reserveRatio","type":"uint32"},{"name":"_slippage","type":"uint256"}],"name":"updateCollateralToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getInitializationBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ADD_TOKEN_TAP_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"openPresale","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_collateral","type":"address"}],"name":"removeCollateralToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_collateral","type":"address"},{"name":"_virtualSupply","type":"uint256"},{"name":"_virtualBalance","type":"uint256"},{"name":"_reserveRatio","type":"uint32"},{"name":"_slippage","type":"uint256"},{"name":"_rate","type":"uint256"},{"name":"_floor","type":"uint256"}],"name":"addCollateralToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"transferToVault","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_sender","type":"address"},{"name":"_role","type":"bytes32"},{"name":"_params","type":"uint256[]"}],"name":"canPerform","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRIBUTE_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getEVMScriptRegistry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"UPDATE_TOKEN_TAP_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"REMOVE_COLLATERAL_TOKEN_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"_rate","type":"uint256"},{"name":"_floor","type":"uint256"}],"name":"updateTokenTap","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UPDATE_MAXIMUM_TAP_RATE_INCREASE_PCT_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"contribute","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"openTrading","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"UPDATE_MAXIMUM_TAP_FLOOR_DECREASE_PCT_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"reserve","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"toReset","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"OPEN_SELL_ORDER_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_maximumTapFloorDecreasePct","type":"uint256"}],"name":"updateMaximumTapFloorDecreasePct","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_collateral","type":"address"},{"name":"_value","type":"uint256"}],"name":"openBuyOrder","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"kernel","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isPetrified","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"WITHDRAW_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_token","type":"address"}],"name":"getMaximumWithdrawal","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_token","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_presale","type":"address"},{"name":"_marketMaker","type":"address"},{"name":"_reserve","type":"address"},{"name":"_tap","type":"address"},{"name":"_toReset","type":"address[]"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tap","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"presale","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"executor","type":"address"},{"indexed":false,"name":"script","type":"bytes"},{"indexed":false,"name":"input","type":"bytes"},{"indexed":false,"name":"returnData","type":"bytes"}],"name":"ScriptResult","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"vault","type":"address"},{"indexed":true,"name":"token","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"RecoverToVault","type":"event"}]
Contract Creation Code
6080604052620000176401000000006200001d810204565b6200023b565b6200003064010000000062000125810204565b60408051808201909152601881527f494e49545f414c52454144595f494e495449414c495a45440000000000000000602082015290156200010c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015620000d0578181015183820152602001620000b6565b50505050905090810190601f168015620000fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506200012360001964010000000062000154810204565b565b60006200014f60008051602062003e8f833981519152640100000000620037f76200023382021704565b905090565b6200016764010000000062000125810204565b60408051808201909152601881527f494e49545f414c52454144595f494e495449414c495a454400000000000000006020820152901562000206576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252838181518152602001915080519060200190808383600083811015620000d0578181015183820152602001620000b6565b506200023060008051602062003e8f8339815191528264010000000062003bd46200023782021704565b50565b5490565b9055565b613c44806200024b6000396000f3006080604052600436106102be5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166307e18bc881146102c35780630803fac0146102dd5780630aaffd2a146103065780630d304791146103275780630f97e2fe1461034e5780631c196659146103635780631f21f9af146103785780632914b9bd146103a95780632cd4a270146104025780633017dbed1461041757806332f0a3b51461042c5780633b3fadb614610441578063410085df1461046857806341644f8c1461048c5780634afe6c47146104a15780634bedf9a8146104c257806351cff8d9146104d75780635e6f6c77146104f8578063608bac051461052357806360e14b6014610538578063628b95b51461054d57806363cea450146105805780636db794371461059557806378ea6103146105b05780637b0d772e146105db5780637e7db6e1146105ff57806380afdea814610620578063846a0a89146106355780638a9b1e2d146106565780638b3dd749146106895780638b4886341461069e5780638dd98312146106b357806394f9059f146106c857806397ff256a146106e95780639d4941d814610722578063a1658fad14610743578063a2b96b6f146107aa578063a479e508146107bf578063b0d88a40146107d4578063b6e9c826146107e9578063b8fd61a8146107fe578063c102b1b514610825578063c1cbbca71461083a578063c9567bf914610845578063cc77491b1461085a578063cd3293de1461086f578063cf6adb4014610884578063cf9d82f21461089c578063d21bd820146108b1578063d441e2b7146108c9578063d4aae0c4146108e0578063de4796ed146108f5578063e02023a11461090a578063e2a5aec51461091f578063f7888aec14610940578063f8453e7c14610967578063fc0c546a146109a6578063fd221031146109bb578063fdea8e0b146109d0575b600080fd5b3480156102cf57600080fd5b506102db6004356109e5565b005b3480156102e957600080fd5b506102f2610b5a565b604080519115158252519081900360200190f35b34801561031257600080fd5b506102db600160a060020a0360043516610b83565b34801561033357600080fd5b5061033c610d1e565b60408051918252519081900360200190f35b34801561035a57600080fd5b5061033c610d23565b34801561036f57600080fd5b5061033c610d47565b34801561038457600080fd5b5061038d610d6b565b60408051600160a060020a039092168252519081900360200190f35b3480156103b557600080fd5b506040805160206004803580820135601f810184900484028501840190955284845261038d943694929360249392840191908190840183828082843750949750610d7a9650505050505050565b34801561040e57600080fd5b5061033c610e79565b34801561042357600080fd5b5061033c610e9d565b34801561043857600080fd5b5061038d610ec1565b34801561044d57600080fd5b506102db600160a060020a0360043516602435604435610f52565b34801561047457600080fd5b506102db600160a060020a036004351660243561109a565b34801561049857600080fd5b5061033c611182565b3480156104ad57600080fd5b5061033c600160a060020a03600435166111a6565b3480156104ce57600080fd5b5061038d61128d565b3480156104e357600080fd5b506102db600160a060020a0360043516611377565b34801561050457600080fd5b506102db600160a060020a036004358116906024359060443516611493565b34801561052f57600080fd5b5061033c6115a3565b34801561054457600080fd5b5061033c6115c7565b34801561055957600080fd5b506102db600160a060020a036004351660243560443563ffffffff606435166084356115eb565b34801561058c57600080fd5b506102db611748565b3480156105a157600080fd5b506102db600435602435611839565b3480156105bc57600080fd5b506102db600160a060020a03600435811690602435906044351661195b565b3480156105e757600080fd5b506102db600160a060020a0360043516602435611a4e565b34801561060b57600080fd5b506102f2600160a060020a0360043516611b77565b34801561062c57600080fd5b5061033c611b7d565b34801561064157600080fd5b506102db600160a060020a0360043516611bad565b34801561066257600080fd5b506102db600160a060020a036004351660243560443563ffffffff60643516608435611c2f565b34801561069557600080fd5b5061033c611d6c565b3480156106aa57600080fd5b5061033c611d97565b3480156106bf57600080fd5b506102db611dbb565b3480156106d457600080fd5b506102db600160a060020a0360043516611eca565b3480156106f557600080fd5b506102db600160a060020a036004351660243560443563ffffffff6064351660843560a43560c435611fe6565b34801561072e57600080fd5b506102db600160a060020a036004351661226a565b34801561074f57600080fd5b5060408051602060046044358181013583810280860185019096528085526102f2958335600160a060020a03169560248035963696956064959394920192918291850190849080828437509497506124f99650505050505050565b3480156107b657600080fd5b5061033c612662565b3480156107cb57600080fd5b5061038d612686565b3480156107e057600080fd5b5061033c61273b565b3480156107f557600080fd5b5061033c61275f565b34801561080a57600080fd5b506102db600160a060020a0360043516602435604435612783565b34801561083157600080fd5b5061033c6128ad565b6102db6004356128d1565b34801561085157600080fd5b506102db6129f1565b34801561086657600080fd5b5061033c612c8b565b34801561087b57600080fd5b5061038d612caf565b34801561089057600080fd5b5061038d600435612cbe565b3480156108a857600080fd5b5061033c612ce6565b3480156108bd57600080fd5b506102db600435612d0a565b6102db600160a060020a0360043516602435612e25565b3480156108ec57600080fd5b5061038d612f51565b34801561090157600080fd5b506102f2612f7c565b34801561091657600080fd5b5061033c612f8f565b34801561092b57600080fd5b5061033c600160a060020a0360043516612fb3565b34801561094c57600080fd5b5061033c600160a060020a036004358116906024351661309a565b34801561097357600080fd5b506102db600160a060020a0360048035821691602480358216926044358316926064351691608435908101910135613224565b3480156109b257600080fd5b5061038d6136ea565b3480156109c757600080fd5b5061038d6137d5565b3480156109dc57600080fd5b5061038d6137e4565b604080516000808252602082019092527f5d94de7e429250eee4ff97e30ab9f383bea3cd564d6780e0a9e965b1add1d20791610a279133918491905b506124f9565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515610ad75760405160e560020a62461bcd0281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610a9c578181015183820152602001610a84565b50505050905090810190601f168015610ac95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600354604080517f07e18bc8000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a03909216916307e18bc89160248082019260009290919082900301818387803b158015610b3e57600080fd5b505af1158015610b52573d6000803e3d6000fd5b505050505050565b600080610b65611d6c565b90508015801590610b7d575080610b7a6137f3565b10155b91505090565b604080516000808252602082019092527ff7ea2b80c7b6a2cab2c11d2290cb005c3748397358a25e17113658c83b73259391610bc3913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515610c375760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f0aaffd2a000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015291519190921691630aaffd2a91602480830192600092919082900301818387803b158015610c9f57600080fd5b505af1158015610cb3573d6000803e3d6000fd5b5050600354604080517f0aaffd2a000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301529151919092169350630aaffd2a9250602480830192600092919082900301818387803b158015610b3e57600080fd5b600a81565b7f26ce034204208c0bbca4c8a793d17b99e546009b1dd31d3c1ef761f66372caf681565b7ff323aa41eef4850a8ae7ebd047d4c89f01ce49c781f3308be67303db9cdd48c281565b600154600160a060020a031681565b6000610d84612686565b600160a060020a03166304bf2a7f836040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610dfb578181015183820152602001610de3565b50505050905090810190601f168015610e285780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b158015610e4757600080fd5b505af1158015610e5b573d6000803e3d6000fd5b505050506040513d6020811015610e7157600080fd5b505192915050565b7fa589c8f284b76fc8d510d9d553485c47dbef1b0745ae00e0f3fd4e28fcd77ea781565b7fe0565c2c43e0d841e206bb36a37f12f22584b4652ccee6f9e0c071b697a2e13d81565b6000610ecb612f51565b600160a060020a03166332f0a3b56040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b505050506040513d6020811015610f4b57600080fd5b5051905090565b604080516000808252602082019092527fbc9cb5e3f7ce81c4fd021d86a4bcb193dee9df315b540808c3ed59a81e59620791610f92913391849190610a21565b60408051808201909152600f8152600080516020613bd983398151915260208201529015156110065760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517fb897b628000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015260248201879052604482018690529151919092169163b897b62891606480830192600092919082900301818387803b15801561107c57600080fd5b505af1158015611090573d6000803e3d6000fd5b5050505050505050565b6110a2610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156111165760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060008054604080517f410085df000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152602482018690529151919092169263410085df926044808201939182900301818387803b158015610b3e57600080fd5b7ff7ea2b80c7b6a2cab2c11d2290cb005c3748397358a25e17113658c83b73259381565b60006111b0610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156112245760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f4afe6c47000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015291519190921691634afe6c479160248083019260209291908290030181600087803b158015610e4757600080fd5b6000611297610b5a565b6040805180820190915260148152600080516020613bf9833981519152602082015290151561130b5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b506000809054906101000a9004600160a060020a0316600160a060020a0316634bedf9a86040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610f2157600080fd5b604080516000808252602082019092527f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec916113b7913391849190610a21565b60408051808201909152600f8152600080516020613bd9833981519152602082015290151561142b5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517f51cff8d9000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152915191909216916351cff8d991602480830192600092919082900301818387803b158015610b3e57600080fd5b61149b610b5a565b6040805180820190915260148152600080516020613bf9833981519152602082015290151561150f5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f5e6f6c77000000000000000000000000000000000000000000000000000000008152600160a060020a03868116600483015260248201869052848116604483015291519190921691635e6f6c7791606480830192600092919082900301818387803b15801561158657600080fd5b505af115801561159a573d6000803e3d6000fd5b50505050505050565b7f217b79cb2bc7760defc88529853ef81ab33ae5bb315408ce9f5af09c8776662d81565b7f5f9be2932ed3a723f295a763be1804c7ebfd1a41c1348fb8bdf5be1c5cdca82281565b604080516000808252602082019092527f217b79cb2bc7760defc88529853ef81ab33ae5bb315408ce9f5af09c8776662d9161162b913391849190610a21565b60408051808201909152600f8152600080516020613bd9833981519152602082015290151561169f5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517ffd531e03000000000000000000000000000000000000000000000000000000008152600160a060020a038981166004830152602482018990526044820188905263ffffffff87166064830152608482018690529151919092169163fd531e039160a480830192600092919082900301818387803b15801561172857600080fd5b505af115801561173c573d6000803e3d6000fd5b50505050505050505050565b611750610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156117c45760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060008054604080517f43d726d60000000000000000000000000000000000000000000000000000000081529051600160a060020a03909216926343d726d69260048084019382900301818387803b15801561181f57600080fd5b505af1158015611833573d6000803e3d6000fd5b50505050565b604080516000808252602082019092527f5f9be2932ed3a723f295a763be1804c7ebfd1a41c1348fb8bdf5be1c5cdca82291611879913391849190610a21565b60408051808201909152600f8152600080516020613bd983398151915260208201529015156118ed5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f6db7943700000000000000000000000000000000000000000000000000000000815260048101869052602481018590529051600160a060020a0390921691636db794379160448082019260009290919082900301818387803b15801561158657600080fd5b611963610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156119d75760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f78ea6103000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152602482018690528481166044830152915191909216916378ea610391606480830192600092919082900301818387803b15801561158657600080fd5b604080516000808252602082019092527fd68ba2b769fa37a2a7bd4bed9241b448bc99eca41f519ef037406386a8f291c091611a8e913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515611b025760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f0f1ff5ea000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a0386811660248301526044820186905291519190921691630f1ff5ea91606480830192600092919082900301818387803b15801561158657600080fd5b50600190565b6000611ba87fd625496217aa6a3453eecb9c3489dc5a53e6c67b444329ea2b2cbc9ff547639b6137f7565b905090565b600354604080517f846a0a89000000000000000000000000000000000000000000000000000000008152600160a060020a0384811660048301529151919092169163846a0a8991602480830192600092919082900301818387803b158015611c1457600080fd5b505af1158015611c28573d6000803e3d6000fd5b5050505050565b604080516000808252602082019092527fe0565c2c43e0d841e206bb36a37f12f22584b4652ccee6f9e0c071b697a2e13d91611c6f913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515611ce35760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f8a9b1e2d000000000000000000000000000000000000000000000000000000008152600160a060020a038981166004830152602482018990526044820188905263ffffffff871660648301526084820186905291519190921691638a9b1e2d9160a480830192600092919082900301818387803b15801561172857600080fd5b6000611ba87febb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e6137f7565b7fbc9cb5e3f7ce81c4fd021d86a4bcb193dee9df315b540808c3ed59a81e59620781565b604080516000808252602082019092527ff323aa41eef4850a8ae7ebd047d4c89f01ce49c781f3308be67303db9cdd48c291611dfb913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515611e6f5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060008054604080517ffcfff16f0000000000000000000000000000000000000000000000000000000081529051600160a060020a039092169263fcfff16f9260048084019382900301818387803b158015611c1457600080fd5b604080516000808252602082019092527f2044e56de223845e4be7d0a6f4e9a29b635547f16413a6d1327c58d9db438ee291611f0a913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515611f7e5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f94f9059f000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152915191909216916394f9059f91602480830192600092919082900301818387803b158015610b3e57600080fd5b604080516000808252602082019092527f217b79cb2bc7760defc88529853ef81ab33ae5bb315408ce9f5af09c8776662d91612026913391849190610a21565b60408051808201909152600f8152600080516020613bd9833981519152602082015290151561209a5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517ffd531e03000000000000000000000000000000000000000000000000000000008152600160a060020a038b81166004830152602482018b9052604482018a905263ffffffff89166064830152608482018890529151919092169163fd531e039160a480830192600092919082900301818387803b15801561212357600080fd5b505af1158015612137573d6000803e3d6000fd5b50505050600160a060020a038816156121ca57600254604080517f6298e902000000000000000000000000000000000000000000000000000000008152600160a060020a038b8116600483015291519190921691636298e90291602480830192600092919082900301818387803b1580156121b157600080fd5b505af11580156121c5573d6000803e3d6000fd5b505050505b600083111561109057600354604080517fb897b628000000000000000000000000000000000000000000000000000000008152600160a060020a038b8116600483015260248201879052604482018690529151919092169163b897b62891606480830192600092919082900301818387803b15801561224857600080fd5b505af115801561225c573d6000803e3d6000fd5b505050505050505050505050565b600080600061227884611b77565b60408051808201909152601281527f5245434f5645525f444953414c4c4f574544000000000000000000000000000060208201529015156122fe5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50612307610ec1565b9250612312836137ff565b60408051808201909152601a81527f5245434f5645525f5641554c545f4e4f545f434f4e545241435400000000000060208201529015156123985760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600160a060020a03841615156123e95760405130319250600160a060020a0384169083156108fc029084906000818181858888f193505050501580156123e3573d6000803e3d6000fd5b506124a8565b5082612404600160a060020a0382163063ffffffff61382c16565b9150612420600160a060020a038216848463ffffffff61394116565b60408051808201909152601d81527f5245434f5645525f544f4b454e5f5452414e534645525f4641494c454400000060208201529015156124a65760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b505b83600160a060020a031683600160a060020a03167f596caf56044b55fb8c4ca640089bbc2b63cae3e978b851f5745cbb7c5b288e02846040518082815260200191505060405180910390a350505050565b600080612504610b5a565b1515612513576000915061265a565b61251b612f51565b9050600160a060020a0381161515612536576000915061265a565b80600160a060020a031663fdef9106863087612551886139cc565b6040517c010000000000000000000000000000000000000000000000000000000063ffffffff8716028152600160a060020a03808616600483019081529085166024830152604482018490526080606483019081528351608484015283519192909160a490910190602085019080838360005b838110156125dc5781810151838201526020016125c4565b50505050905090810190601f1680156126095780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15801561262b57600080fd5b505af115801561263f573d6000803e3d6000fd5b505050506040513d602081101561265557600080fd5b505191505b509392505050565b7f9ccaca4edf2127f20c425fdd86af1ba178b9e5bee280cd70d88ac5f6874c4f0781565b600080612691612f51565b604080517fbe00bbd80000000000000000000000000000000000000000000000000000000081527fd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb60048201527fddbcfd564f642ab5627cf68b9b7d374fb4f8a36e941a75d89c87998cef03bd6160248201529051600160a060020a03929092169163be00bbd8916044808201926020929091908290030181600087803b158015610e4757600080fd5b7fdb8c88bedbc61ea0f92e1ce46da0b7a915affbd46d1c76c4bbac9a209e4a841681565b7f2044e56de223845e4be7d0a6f4e9a29b635547f16413a6d1327c58d9db438ee281565b604080516000808252602082019092527fdb8c88bedbc61ea0f92e1ce46da0b7a915affbd46d1c76c4bbac9a209e4a8416916127c3913391849190610a21565b60408051808201909152600f8152600080516020613bd983398151915260208201529015156128375760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517ff30a00ce000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015260248201879052604482018690529151919092169163f30a00ce91606480830192600092919082900301818387803b15801561107c57600080fd5b7f5d94de7e429250eee4ff97e30ab9f383bea3cd564d6780e0a9e965b1add1d20781565b604080516000808252602082019092527f9ccaca4edf2127f20c425fdd86af1ba178b9e5bee280cd70d88ac5f6874c4f0791612911913391849190610a21565b60408051808201909152600f8152600080516020613bd983398151915260208201529015156129855760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060008054604080517f8418cd99000000000000000000000000000000000000000000000000000000008152336004820152602481018690529051600160a060020a0390921692638418cd99923492604480820193929182900301818588803b15801561158657600080fd5b604080516000808252602082019092527f26ce034204208c0bbca4c8a793d17b99e546009b1dd31d3c1ef761f66372caf690612a31903390839085610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515612aa55760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600091505b600454821015612c1f5760035460048054600092600160a060020a03169163a8734f0b9186908110612ad957fe5b6000918252602080832090910154604080517c010000000000000000000000000000000000000000000000000000000063ffffffff8716028152600160a060020a0390921660048301525160248083019491928390030190829087803b158015612b4257600080fd5b505af1158015612b56573d6000803e3d6000fd5b505050506040513d6020811015612b6c57600080fd5b505114612c145760035460048054600160a060020a0390921691639cbbba88919085908110612b9757fe5b6000918252602082200154604080517c010000000000000000000000000000000000000000000000000000000063ffffffff8616028152600160a060020a039092166004830152516024808301939282900301818387803b158015612bfb57600080fd5b505af1158015612c0f573d6000803e3d6000fd5b505050505b600190910190612aab565b600160009054906101000a9004600160a060020a0316600160a060020a031663fcfff16f6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401600060405180830381600087803b158015610b3e57600080fd5b7f57c9c67896cf0a4ffe92cbea66c2f7c34380af06bf14215dabb078cf8a6d99e181565b600254600160a060020a031681565b6004805482908110612ccc57fe5b600091825260209091200154600160a060020a0316905081565b7fd68ba2b769fa37a2a7bd4bed9241b448bc99eca41f519ef037406386a8f291c081565b604080516000808252602082019092527f57c9c67896cf0a4ffe92cbea66c2f7c34380af06bf14215dabb078cf8a6d99e191612d4a913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515612dbe5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517fd21bd820000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a039092169163d21bd8209160248082019260009290919082900301818387803b158015610b3e57600080fd5b604080516000808252602082019092527fa589c8f284b76fc8d510d9d553485c47dbef1b0745ae00e0f3fd4e28fcd77ea791612e65913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515612ed95760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f3fae9bfb000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a0386811660248301526044820186905291519190921691633fae9bfb91349160648082019260009290919082900301818588803b15801561107c57600080fd5b6000611ba87f4172f0f7d2289153072b0a6ca36959e0cbe2efc3afe50fc81636caa96338137b6137f7565b6000600019612f89611d6c565b14905090565b7f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec81565b6000612fbd610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156130315760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517fe2a5aec5000000000000000000000000000000000000000000000000000000008152600160a060020a0385811660048301529151919092169163e2a5aec59160248083019260209291908290030181600087803b158015610e4757600080fd5b6000806130a5610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156131195760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600160a060020a0383161561314757613142600160a060020a0384168563ffffffff61382c16565b613153565b83600160a060020a0316315b600254909150600160a060020a038581169116141561321957600354604080517fe2a5aec5000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152915161321293929092169163e2a5aec5916024808201926020929091908290030181600087803b1580156131d957600080fd5b505af11580156131ed573d6000803e3d6000fd5b505050506040513d602081101561320357600080fd5b5051829063ffffffff6139d616565b915061321d565b8091505b5092915050565b600061322e611d6c565b60408051808201909152601881527f494e49545f414c52454144595f494e495449414c495a45440000000000000000602082015290156132b35760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b506132bd876137ff565b60408051808201909152601b81527f46554e4452414953494e475f434f4e54524143545f49535f454f41000000000060208201529015156133435760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5061334d866137ff565b60408051808201909152601b81527f46554e4452414953494e475f434f4e54524143545f49535f454f41000000000060208201529015156133d35760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b506133dd856137ff565b60408051808201909152601b81527f46554e4452414953494e475f434f4e54524143545f49535f454f41000000000060208201529015156134635760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5061346d846137ff565b60408051808201909152601b81527f46554e4452414953494e475f434f4e54524143545f49535f454f41000000000060208201529015156134f35760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060408051808201909152601a81527f46554e4452414953494e475f494e56414c49445f544f4b454e530000000000006020820152600a831061357b5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50613584613a6a565b5060008054600160a060020a0380891673ffffffffffffffffffffffffffffffffffffffff19928316178355600180548983169084161790556002805488831690841617905560038054918716919092161790555b8181101561159a576136058383838181106135f057fe5b90506020020135600160a060020a0316613b32565b60408051808201909152601a81527f46554e4452414953494e475f494e56414c49445f544f4b454e53000000000000602082015290151561368b5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600483838381811061369a57fe5b8354600181810186556000958652602095869020909101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03969093029490940135949094161790915550016135d9565b60006136f4610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156137685760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600160009054906101000a9004600160a060020a0316600160a060020a031663fc0c546a6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610f2157600080fd5b600354600160a060020a031681565b600054600160a060020a031681565b4390565b5490565b5490565b600080600160a060020a038316151561381b5760009150613826565b823b90506000811191505b50919050565b60408051600160a060020a0383166024808301919091528251808303909101815260449091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f70a082310000000000000000000000000000000000000000000000000000000017905260009081806138ac8684613b55565b60408051808201909152601c81527f534146455f4552435f32305f42414c414e43455f524556455254454400000000602082015291935091508215156139375760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5095945050505050565b60408051600160a060020a038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526000906139c38582613b86565b95945050505050565b8051602002815290565b60408051808201909152601281527f4d4154485f5355425f554e444552464c4f5700000000000000000000000000006020820152600090819084841115613a625760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b505050900390565b613a72611d6c565b60408051808201909152601881527f494e49545f414c52454144595f494e495449414c495a4544000000000000000060208201529015613af75760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50613b30613b036137f3565b7febb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e9063ffffffff613bd416565b565b6000613b3d826137ff565b80613b4f5750600160a060020a038216155b92915050565b6000806000806040516020818751602089018a5afa92506000831115613b7a57805191505b50909590945092505050565b6000806040516020818551602087016000895af16000811115613bca573d8015613bb75760208114613bc057613bc8565b60019350613bc8565b600183511493505b505b5090949350505050565b905556004150505f415554485f4641494c45440000000000000000000000000000000000494e49545f4e4f545f494e495449414c495a4544000000000000000000000000a165627a7a7230582027ecbd82ecc3a0a937a5951feb66c0e8c7ae59220178f7c631b9a3a850f7d2450029ebb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e
Deployed Bytecode
0x6080604052600436106102be5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166307e18bc881146102c35780630803fac0146102dd5780630aaffd2a146103065780630d304791146103275780630f97e2fe1461034e5780631c196659146103635780631f21f9af146103785780632914b9bd146103a95780632cd4a270146104025780633017dbed1461041757806332f0a3b51461042c5780633b3fadb614610441578063410085df1461046857806341644f8c1461048c5780634afe6c47146104a15780634bedf9a8146104c257806351cff8d9146104d75780635e6f6c77146104f8578063608bac051461052357806360e14b6014610538578063628b95b51461054d57806363cea450146105805780636db794371461059557806378ea6103146105b05780637b0d772e146105db5780637e7db6e1146105ff57806380afdea814610620578063846a0a89146106355780638a9b1e2d146106565780638b3dd749146106895780638b4886341461069e5780638dd98312146106b357806394f9059f146106c857806397ff256a146106e95780639d4941d814610722578063a1658fad14610743578063a2b96b6f146107aa578063a479e508146107bf578063b0d88a40146107d4578063b6e9c826146107e9578063b8fd61a8146107fe578063c102b1b514610825578063c1cbbca71461083a578063c9567bf914610845578063cc77491b1461085a578063cd3293de1461086f578063cf6adb4014610884578063cf9d82f21461089c578063d21bd820146108b1578063d441e2b7146108c9578063d4aae0c4146108e0578063de4796ed146108f5578063e02023a11461090a578063e2a5aec51461091f578063f7888aec14610940578063f8453e7c14610967578063fc0c546a146109a6578063fd221031146109bb578063fdea8e0b146109d0575b600080fd5b3480156102cf57600080fd5b506102db6004356109e5565b005b3480156102e957600080fd5b506102f2610b5a565b604080519115158252519081900360200190f35b34801561031257600080fd5b506102db600160a060020a0360043516610b83565b34801561033357600080fd5b5061033c610d1e565b60408051918252519081900360200190f35b34801561035a57600080fd5b5061033c610d23565b34801561036f57600080fd5b5061033c610d47565b34801561038457600080fd5b5061038d610d6b565b60408051600160a060020a039092168252519081900360200190f35b3480156103b557600080fd5b506040805160206004803580820135601f810184900484028501840190955284845261038d943694929360249392840191908190840183828082843750949750610d7a9650505050505050565b34801561040e57600080fd5b5061033c610e79565b34801561042357600080fd5b5061033c610e9d565b34801561043857600080fd5b5061038d610ec1565b34801561044d57600080fd5b506102db600160a060020a0360043516602435604435610f52565b34801561047457600080fd5b506102db600160a060020a036004351660243561109a565b34801561049857600080fd5b5061033c611182565b3480156104ad57600080fd5b5061033c600160a060020a03600435166111a6565b3480156104ce57600080fd5b5061038d61128d565b3480156104e357600080fd5b506102db600160a060020a0360043516611377565b34801561050457600080fd5b506102db600160a060020a036004358116906024359060443516611493565b34801561052f57600080fd5b5061033c6115a3565b34801561054457600080fd5b5061033c6115c7565b34801561055957600080fd5b506102db600160a060020a036004351660243560443563ffffffff606435166084356115eb565b34801561058c57600080fd5b506102db611748565b3480156105a157600080fd5b506102db600435602435611839565b3480156105bc57600080fd5b506102db600160a060020a03600435811690602435906044351661195b565b3480156105e757600080fd5b506102db600160a060020a0360043516602435611a4e565b34801561060b57600080fd5b506102f2600160a060020a0360043516611b77565b34801561062c57600080fd5b5061033c611b7d565b34801561064157600080fd5b506102db600160a060020a0360043516611bad565b34801561066257600080fd5b506102db600160a060020a036004351660243560443563ffffffff60643516608435611c2f565b34801561069557600080fd5b5061033c611d6c565b3480156106aa57600080fd5b5061033c611d97565b3480156106bf57600080fd5b506102db611dbb565b3480156106d457600080fd5b506102db600160a060020a0360043516611eca565b3480156106f557600080fd5b506102db600160a060020a036004351660243560443563ffffffff6064351660843560a43560c435611fe6565b34801561072e57600080fd5b506102db600160a060020a036004351661226a565b34801561074f57600080fd5b5060408051602060046044358181013583810280860185019096528085526102f2958335600160a060020a03169560248035963696956064959394920192918291850190849080828437509497506124f99650505050505050565b3480156107b657600080fd5b5061033c612662565b3480156107cb57600080fd5b5061038d612686565b3480156107e057600080fd5b5061033c61273b565b3480156107f557600080fd5b5061033c61275f565b34801561080a57600080fd5b506102db600160a060020a0360043516602435604435612783565b34801561083157600080fd5b5061033c6128ad565b6102db6004356128d1565b34801561085157600080fd5b506102db6129f1565b34801561086657600080fd5b5061033c612c8b565b34801561087b57600080fd5b5061038d612caf565b34801561089057600080fd5b5061038d600435612cbe565b3480156108a857600080fd5b5061033c612ce6565b3480156108bd57600080fd5b506102db600435612d0a565b6102db600160a060020a0360043516602435612e25565b3480156108ec57600080fd5b5061038d612f51565b34801561090157600080fd5b506102f2612f7c565b34801561091657600080fd5b5061033c612f8f565b34801561092b57600080fd5b5061033c600160a060020a0360043516612fb3565b34801561094c57600080fd5b5061033c600160a060020a036004358116906024351661309a565b34801561097357600080fd5b506102db600160a060020a0360048035821691602480358216926044358316926064351691608435908101910135613224565b3480156109b257600080fd5b5061038d6136ea565b3480156109c757600080fd5b5061038d6137d5565b3480156109dc57600080fd5b5061038d6137e4565b604080516000808252602082019092527f5d94de7e429250eee4ff97e30ab9f383bea3cd564d6780e0a9e965b1add1d20791610a279133918491905b506124f9565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515610ad75760405160e560020a62461bcd0281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610a9c578181015183820152602001610a84565b50505050905090810190601f168015610ac95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600354604080517f07e18bc8000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a03909216916307e18bc89160248082019260009290919082900301818387803b158015610b3e57600080fd5b505af1158015610b52573d6000803e3d6000fd5b505050505050565b600080610b65611d6c565b90508015801590610b7d575080610b7a6137f3565b10155b91505090565b604080516000808252602082019092527ff7ea2b80c7b6a2cab2c11d2290cb005c3748397358a25e17113658c83b73259391610bc3913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515610c375760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f0aaffd2a000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015291519190921691630aaffd2a91602480830192600092919082900301818387803b158015610c9f57600080fd5b505af1158015610cb3573d6000803e3d6000fd5b5050600354604080517f0aaffd2a000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301529151919092169350630aaffd2a9250602480830192600092919082900301818387803b158015610b3e57600080fd5b600a81565b7f26ce034204208c0bbca4c8a793d17b99e546009b1dd31d3c1ef761f66372caf681565b7ff323aa41eef4850a8ae7ebd047d4c89f01ce49c781f3308be67303db9cdd48c281565b600154600160a060020a031681565b6000610d84612686565b600160a060020a03166304bf2a7f836040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610dfb578181015183820152602001610de3565b50505050905090810190601f168015610e285780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b158015610e4757600080fd5b505af1158015610e5b573d6000803e3d6000fd5b505050506040513d6020811015610e7157600080fd5b505192915050565b7fa589c8f284b76fc8d510d9d553485c47dbef1b0745ae00e0f3fd4e28fcd77ea781565b7fe0565c2c43e0d841e206bb36a37f12f22584b4652ccee6f9e0c071b697a2e13d81565b6000610ecb612f51565b600160a060020a03166332f0a3b56040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b505050506040513d6020811015610f4b57600080fd5b5051905090565b604080516000808252602082019092527fbc9cb5e3f7ce81c4fd021d86a4bcb193dee9df315b540808c3ed59a81e59620791610f92913391849190610a21565b60408051808201909152600f8152600080516020613bd983398151915260208201529015156110065760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517fb897b628000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015260248201879052604482018690529151919092169163b897b62891606480830192600092919082900301818387803b15801561107c57600080fd5b505af1158015611090573d6000803e3d6000fd5b5050505050505050565b6110a2610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156111165760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060008054604080517f410085df000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152602482018690529151919092169263410085df926044808201939182900301818387803b158015610b3e57600080fd5b7ff7ea2b80c7b6a2cab2c11d2290cb005c3748397358a25e17113658c83b73259381565b60006111b0610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156112245760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f4afe6c47000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015291519190921691634afe6c479160248083019260209291908290030181600087803b158015610e4757600080fd5b6000611297610b5a565b6040805180820190915260148152600080516020613bf9833981519152602082015290151561130b5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b506000809054906101000a9004600160a060020a0316600160a060020a0316634bedf9a86040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610f2157600080fd5b604080516000808252602082019092527f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec916113b7913391849190610a21565b60408051808201909152600f8152600080516020613bd9833981519152602082015290151561142b5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517f51cff8d9000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152915191909216916351cff8d991602480830192600092919082900301818387803b158015610b3e57600080fd5b61149b610b5a565b6040805180820190915260148152600080516020613bf9833981519152602082015290151561150f5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f5e6f6c77000000000000000000000000000000000000000000000000000000008152600160a060020a03868116600483015260248201869052848116604483015291519190921691635e6f6c7791606480830192600092919082900301818387803b15801561158657600080fd5b505af115801561159a573d6000803e3d6000fd5b50505050505050565b7f217b79cb2bc7760defc88529853ef81ab33ae5bb315408ce9f5af09c8776662d81565b7f5f9be2932ed3a723f295a763be1804c7ebfd1a41c1348fb8bdf5be1c5cdca82281565b604080516000808252602082019092527f217b79cb2bc7760defc88529853ef81ab33ae5bb315408ce9f5af09c8776662d9161162b913391849190610a21565b60408051808201909152600f8152600080516020613bd9833981519152602082015290151561169f5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517ffd531e03000000000000000000000000000000000000000000000000000000008152600160a060020a038981166004830152602482018990526044820188905263ffffffff87166064830152608482018690529151919092169163fd531e039160a480830192600092919082900301818387803b15801561172857600080fd5b505af115801561173c573d6000803e3d6000fd5b50505050505050505050565b611750610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156117c45760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060008054604080517f43d726d60000000000000000000000000000000000000000000000000000000081529051600160a060020a03909216926343d726d69260048084019382900301818387803b15801561181f57600080fd5b505af1158015611833573d6000803e3d6000fd5b50505050565b604080516000808252602082019092527f5f9be2932ed3a723f295a763be1804c7ebfd1a41c1348fb8bdf5be1c5cdca82291611879913391849190610a21565b60408051808201909152600f8152600080516020613bd983398151915260208201529015156118ed5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f6db7943700000000000000000000000000000000000000000000000000000000815260048101869052602481018590529051600160a060020a0390921691636db794379160448082019260009290919082900301818387803b15801561158657600080fd5b611963610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156119d75760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f78ea6103000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152602482018690528481166044830152915191909216916378ea610391606480830192600092919082900301818387803b15801561158657600080fd5b604080516000808252602082019092527fd68ba2b769fa37a2a7bd4bed9241b448bc99eca41f519ef037406386a8f291c091611a8e913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515611b025760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f0f1ff5ea000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a0386811660248301526044820186905291519190921691630f1ff5ea91606480830192600092919082900301818387803b15801561158657600080fd5b50600190565b6000611ba87fd625496217aa6a3453eecb9c3489dc5a53e6c67b444329ea2b2cbc9ff547639b6137f7565b905090565b600354604080517f846a0a89000000000000000000000000000000000000000000000000000000008152600160a060020a0384811660048301529151919092169163846a0a8991602480830192600092919082900301818387803b158015611c1457600080fd5b505af1158015611c28573d6000803e3d6000fd5b5050505050565b604080516000808252602082019092527fe0565c2c43e0d841e206bb36a37f12f22584b4652ccee6f9e0c071b697a2e13d91611c6f913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515611ce35760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f8a9b1e2d000000000000000000000000000000000000000000000000000000008152600160a060020a038981166004830152602482018990526044820188905263ffffffff871660648301526084820186905291519190921691638a9b1e2d9160a480830192600092919082900301818387803b15801561172857600080fd5b6000611ba87febb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e6137f7565b7fbc9cb5e3f7ce81c4fd021d86a4bcb193dee9df315b540808c3ed59a81e59620781565b604080516000808252602082019092527ff323aa41eef4850a8ae7ebd047d4c89f01ce49c781f3308be67303db9cdd48c291611dfb913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515611e6f5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060008054604080517ffcfff16f0000000000000000000000000000000000000000000000000000000081529051600160a060020a039092169263fcfff16f9260048084019382900301818387803b158015611c1457600080fd5b604080516000808252602082019092527f2044e56de223845e4be7d0a6f4e9a29b635547f16413a6d1327c58d9db438ee291611f0a913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515611f7e5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f94f9059f000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152915191909216916394f9059f91602480830192600092919082900301818387803b158015610b3e57600080fd5b604080516000808252602082019092527f217b79cb2bc7760defc88529853ef81ab33ae5bb315408ce9f5af09c8776662d91612026913391849190610a21565b60408051808201909152600f8152600080516020613bd9833981519152602082015290151561209a5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517ffd531e03000000000000000000000000000000000000000000000000000000008152600160a060020a038b81166004830152602482018b9052604482018a905263ffffffff89166064830152608482018890529151919092169163fd531e039160a480830192600092919082900301818387803b15801561212357600080fd5b505af1158015612137573d6000803e3d6000fd5b50505050600160a060020a038816156121ca57600254604080517f6298e902000000000000000000000000000000000000000000000000000000008152600160a060020a038b8116600483015291519190921691636298e90291602480830192600092919082900301818387803b1580156121b157600080fd5b505af11580156121c5573d6000803e3d6000fd5b505050505b600083111561109057600354604080517fb897b628000000000000000000000000000000000000000000000000000000008152600160a060020a038b8116600483015260248201879052604482018690529151919092169163b897b62891606480830192600092919082900301818387803b15801561224857600080fd5b505af115801561225c573d6000803e3d6000fd5b505050505050505050505050565b600080600061227884611b77565b60408051808201909152601281527f5245434f5645525f444953414c4c4f574544000000000000000000000000000060208201529015156122fe5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50612307610ec1565b9250612312836137ff565b60408051808201909152601a81527f5245434f5645525f5641554c545f4e4f545f434f4e545241435400000000000060208201529015156123985760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600160a060020a03841615156123e95760405130319250600160a060020a0384169083156108fc029084906000818181858888f193505050501580156123e3573d6000803e3d6000fd5b506124a8565b5082612404600160a060020a0382163063ffffffff61382c16565b9150612420600160a060020a038216848463ffffffff61394116565b60408051808201909152601d81527f5245434f5645525f544f4b454e5f5452414e534645525f4641494c454400000060208201529015156124a65760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b505b83600160a060020a031683600160a060020a03167f596caf56044b55fb8c4ca640089bbc2b63cae3e978b851f5745cbb7c5b288e02846040518082815260200191505060405180910390a350505050565b600080612504610b5a565b1515612513576000915061265a565b61251b612f51565b9050600160a060020a0381161515612536576000915061265a565b80600160a060020a031663fdef9106863087612551886139cc565b6040517c010000000000000000000000000000000000000000000000000000000063ffffffff8716028152600160a060020a03808616600483019081529085166024830152604482018490526080606483019081528351608484015283519192909160a490910190602085019080838360005b838110156125dc5781810151838201526020016125c4565b50505050905090810190601f1680156126095780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15801561262b57600080fd5b505af115801561263f573d6000803e3d6000fd5b505050506040513d602081101561265557600080fd5b505191505b509392505050565b7f9ccaca4edf2127f20c425fdd86af1ba178b9e5bee280cd70d88ac5f6874c4f0781565b600080612691612f51565b604080517fbe00bbd80000000000000000000000000000000000000000000000000000000081527fd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb60048201527fddbcfd564f642ab5627cf68b9b7d374fb4f8a36e941a75d89c87998cef03bd6160248201529051600160a060020a03929092169163be00bbd8916044808201926020929091908290030181600087803b158015610e4757600080fd5b7fdb8c88bedbc61ea0f92e1ce46da0b7a915affbd46d1c76c4bbac9a209e4a841681565b7f2044e56de223845e4be7d0a6f4e9a29b635547f16413a6d1327c58d9db438ee281565b604080516000808252602082019092527fdb8c88bedbc61ea0f92e1ce46da0b7a915affbd46d1c76c4bbac9a209e4a8416916127c3913391849190610a21565b60408051808201909152600f8152600080516020613bd983398151915260208201529015156128375760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517ff30a00ce000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015260248201879052604482018690529151919092169163f30a00ce91606480830192600092919082900301818387803b15801561107c57600080fd5b7f5d94de7e429250eee4ff97e30ab9f383bea3cd564d6780e0a9e965b1add1d20781565b604080516000808252602082019092527f9ccaca4edf2127f20c425fdd86af1ba178b9e5bee280cd70d88ac5f6874c4f0791612911913391849190610a21565b60408051808201909152600f8152600080516020613bd983398151915260208201529015156129855760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060008054604080517f8418cd99000000000000000000000000000000000000000000000000000000008152336004820152602481018690529051600160a060020a0390921692638418cd99923492604480820193929182900301818588803b15801561158657600080fd5b604080516000808252602082019092527f26ce034204208c0bbca4c8a793d17b99e546009b1dd31d3c1ef761f66372caf690612a31903390839085610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515612aa55760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600091505b600454821015612c1f5760035460048054600092600160a060020a03169163a8734f0b9186908110612ad957fe5b6000918252602080832090910154604080517c010000000000000000000000000000000000000000000000000000000063ffffffff8716028152600160a060020a0390921660048301525160248083019491928390030190829087803b158015612b4257600080fd5b505af1158015612b56573d6000803e3d6000fd5b505050506040513d6020811015612b6c57600080fd5b505114612c145760035460048054600160a060020a0390921691639cbbba88919085908110612b9757fe5b6000918252602082200154604080517c010000000000000000000000000000000000000000000000000000000063ffffffff8616028152600160a060020a039092166004830152516024808301939282900301818387803b158015612bfb57600080fd5b505af1158015612c0f573d6000803e3d6000fd5b505050505b600190910190612aab565b600160009054906101000a9004600160a060020a0316600160a060020a031663fcfff16f6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401600060405180830381600087803b158015610b3e57600080fd5b7f57c9c67896cf0a4ffe92cbea66c2f7c34380af06bf14215dabb078cf8a6d99e181565b600254600160a060020a031681565b6004805482908110612ccc57fe5b600091825260209091200154600160a060020a0316905081565b7fd68ba2b769fa37a2a7bd4bed9241b448bc99eca41f519ef037406386a8f291c081565b604080516000808252602082019092527f57c9c67896cf0a4ffe92cbea66c2f7c34380af06bf14215dabb078cf8a6d99e191612d4a913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515612dbe5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517fd21bd820000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a039092169163d21bd8209160248082019260009290919082900301818387803b158015610b3e57600080fd5b604080516000808252602082019092527fa589c8f284b76fc8d510d9d553485c47dbef1b0745ae00e0f3fd4e28fcd77ea791612e65913391849190610a21565b60408051808201909152600f8152600080516020613bd98339815191526020820152901515612ed95760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600154604080517f3fae9bfb000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a0386811660248301526044820186905291519190921691633fae9bfb91349160648082019260009290919082900301818588803b15801561107c57600080fd5b6000611ba87f4172f0f7d2289153072b0a6ca36959e0cbe2efc3afe50fc81636caa96338137b6137f7565b6000600019612f89611d6c565b14905090565b7f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec81565b6000612fbd610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156130315760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600354604080517fe2a5aec5000000000000000000000000000000000000000000000000000000008152600160a060020a0385811660048301529151919092169163e2a5aec59160248083019260209291908290030181600087803b158015610e4757600080fd5b6000806130a5610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156131195760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600160a060020a0383161561314757613142600160a060020a0384168563ffffffff61382c16565b613153565b83600160a060020a0316315b600254909150600160a060020a038581169116141561321957600354604080517fe2a5aec5000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152915161321293929092169163e2a5aec5916024808201926020929091908290030181600087803b1580156131d957600080fd5b505af11580156131ed573d6000803e3d6000fd5b505050506040513d602081101561320357600080fd5b5051829063ffffffff6139d616565b915061321d565b8091505b5092915050565b600061322e611d6c565b60408051808201909152601881527f494e49545f414c52454144595f494e495449414c495a45440000000000000000602082015290156132b35760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b506132bd876137ff565b60408051808201909152601b81527f46554e4452414953494e475f434f4e54524143545f49535f454f41000000000060208201529015156133435760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5061334d866137ff565b60408051808201909152601b81527f46554e4452414953494e475f434f4e54524143545f49535f454f41000000000060208201529015156133d35760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b506133dd856137ff565b60408051808201909152601b81527f46554e4452414953494e475f434f4e54524143545f49535f454f41000000000060208201529015156134635760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5061346d846137ff565b60408051808201909152601b81527f46554e4452414953494e475f434f4e54524143545f49535f454f41000000000060208201529015156134f35760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5060408051808201909152601a81527f46554e4452414953494e475f494e56414c49445f544f4b454e530000000000006020820152600a831061357b5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50613584613a6a565b5060008054600160a060020a0380891673ffffffffffffffffffffffffffffffffffffffff19928316178355600180548983169084161790556002805488831690841617905560038054918716919092161790555b8181101561159a576136058383838181106135f057fe5b90506020020135600160a060020a0316613b32565b60408051808201909152601a81527f46554e4452414953494e475f494e56414c49445f544f4b454e53000000000000602082015290151561368b5760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600483838381811061369a57fe5b8354600181810186556000958652602095869020909101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03969093029490940135949094161790915550016135d9565b60006136f4610b5a565b6040805180820190915260148152600080516020613bf983398151915260208201529015156137685760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50600160009054906101000a9004600160a060020a0316600160a060020a031663fc0c546a6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610f2157600080fd5b600354600160a060020a031681565b600054600160a060020a031681565b4390565b5490565b5490565b600080600160a060020a038316151561381b5760009150613826565b823b90506000811191505b50919050565b60408051600160a060020a0383166024808301919091528251808303909101815260449091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f70a082310000000000000000000000000000000000000000000000000000000017905260009081806138ac8684613b55565b60408051808201909152601c81527f534146455f4552435f32305f42414c414e43455f524556455254454400000000602082015291935091508215156139375760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b5095945050505050565b60408051600160a060020a038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526000906139c38582613b86565b95945050505050565b8051602002815290565b60408051808201909152601281527f4d4154485f5355425f554e444552464c4f5700000000000000000000000000006020820152600090819084841115613a625760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b505050900390565b613a72611d6c565b60408051808201909152601881527f494e49545f414c52454144595f494e495449414c495a4544000000000000000060208201529015613af75760405160e560020a62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610a9c578181015183820152602001610a84565b50613b30613b036137f3565b7febb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e9063ffffffff613bd416565b565b6000613b3d826137ff565b80613b4f5750600160a060020a038216155b92915050565b6000806000806040516020818751602089018a5afa92506000831115613b7a57805191505b50909590945092505050565b6000806040516020818551602087016000895af16000811115613bca573d8015613bb75760208114613bc057613bc8565b60019350613bc8565b600183511493505b505b5090949350505050565b905556004150505f415554485f4641494c45440000000000000000000000000000000000494e49545f4e4f545f494e495449414c495a4544000000000000000000000000a165627a7a7230582027ecbd82ecc3a0a937a5951feb66c0e8c7ae59220178f7c631b9a3a850f7d2450029
Deployed Bytecode Sourcemap
186317:18661:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;201218:216;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;201218:216:0;;;;;;;10148:211;;8:9:-1;5:2;;;30:1;27;20:12;5:2;10148:211:0;;;;;;;;;;;;;;;;;;;;;;192519:196;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;192519:196:0;-1:-1:-1;;;;;192519:196:0;;;;;190368:41;;8:9:-1;5:2;;;30:1;27;20:12;5:2;190368:41:0;;;;;;;;;;;;;;;;;;;;189656:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;189656:135:0;;;;189514;;8:9:-1;5:2;;;30:1;27;20:12;5:2;189514:135:0;;;;190633:43;;8:9:-1;5:2;;;30:1;27;20:12;5:2;190633:43:0;;;;;;;;-1:-1:-1;;;;;190633:43:0;;;;;;;;;;;;;;27655:181;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;27655:181:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;27655:181:0;;-1:-1:-1;27655:181:0;;-1:-1:-1;;;;;;;27655:181:0;189940:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;189940:135:0;;;;188804;;8:9:-1;5:2;;;30:1;27;20:12;5:2;188804:135:0;;;;33773:232;;8:9:-1;5:2;;;30:1;27;20:12;5:2;33773:232:0;;;;202337:162;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;202337:162:0;-1:-1:-1;;;;;202337:162:0;;;;;;;;;194176:154;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;194176:154:0;-1:-1:-1;;;;;194176:154:0;;;;;;;188236:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;188236:135:0;;;;204247:170;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;204247:170:0;-1:-1:-1;;;;;204247:170:0;;;;;203957:126;;8:9:-1;5:2;;;30:1;27;20:12;5:2;203957:126:0;;;;203690:102;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;203690:102:0;-1:-1:-1;;;;;203690:102:0;;;;;196656:180;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;196656:180:0;-1:-1:-1;;;;;196656:180:0;;;;;;;;;;;;;188520:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;188520:135:0;;;;188378;;8:9:-1;5:2;;;30:1;27;20:12;5:2;188378:135:0;;;;199011:376;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;199011:376:0;-1:-1:-1;;;;;199011:376:0;;;;;;;;;;;;;;;193457:81;;8:9:-1;5:2;;;30:1;27;20:12;5:2;193457:81:0;;;;193044:159;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;193044:159:0;;;;;;;196072:176;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;196072:176:0;-1:-1:-1;;;;;196072:176:0;;;;;;;;;;;;;195493:175;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;195493:175:0;-1:-1:-1;;;;;195493:175:0;;;;;;;23998:101;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;23998:101:0;-1:-1:-1;;;;;23998:101:0;;;;;3643:108;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3643:108:0;;;;203329:102;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;203329:102:0;-1:-1:-1;;;;;203329:102:0;;;;;200552:386;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;200552:386:0;-1:-1:-1;;;;;200552:386:0;;;;;;;;;;;;;;;9894:139;;8:9:-1;5:2;;;30:1;27;20:12;5:2;9894:139:0;;;;189230:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;189230:135:0;;;;193296:89;;8:9:-1;5:2;;;30:1;27;20:12;5:2;193296:89:0;;;;199586:297;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;199586:297:0;-1:-1:-1;;;;;199586:297:0;;;;;197720:620;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;197720:620:0;-1:-1:-1;;;;;197720:620:0;;;;;;;;;;;;;;;;;;;23152:639;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;23152:639:0;-1:-1:-1;;;;;23152:639:0;;;;;33139:512;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;33139:512:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;33139:512:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;33139:512:0;;-1:-1:-1;33139:512:0;;-1:-1:-1;;;;;;;33139:512:0;189798:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;189798:135:0;;;;27844:234;;8:9:-1;5:2;;;30:1;27;20:12;5:2;27844:234:0;;;;189372:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;189372:135:0;;;;188662;;8:9:-1;5:2;;;30:1;27;20:12;5:2;188662:135:0;;;;202982:171;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;202982:171:0;-1:-1:-1;;;;;202982:171:0;;;;;;;;;188946:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;188946:135:0;;;;193736:149;;;;;;194474:284;;8:9:-1;5:2;;;30:1;27;20:12;5:2;194474:284:0;;;;189088:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;189088:135:0;;;;190683:39;;8:9:-1;5:2;;;30:1;27;20:12;5:2;190683:39:0;;;;190771;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;190771:39:0;;;;;190082:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;190082:135:0;;;;201683:221;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;201683:221:0;;;;;195003:195;;-1:-1:-1;;;;;195003:195:0;;;;;;;3517:118;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3517:118:0;;;;11262:119;;8:9:-1;5:2;;;30:1;27;20:12;5:2;11262:119:0;;;;190224:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;190224:135:0;;;;204091:148;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;204091:148:0;-1:-1:-1;;;;;204091:148:0;;;;;204425:364;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;204425:364:0;-1:-1:-1;;;;;204425:364:0;;;;;;;;;;191337:994;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;191337:994:0;-1:-1:-1;;;;;191337:994:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;203843:106;;8:9:-1;5:2;;;30:1;27;20:12;5:2;203843:106:0;;;;190729:35;;8:9:-1;5:2;;;30:1;27;20:12;5:2;190729:35:0;;;;190587:39;;8:9:-1;5:2;;;30:1;27;20:12;5:2;190587:39:0;;;;201218:216;32501:16;;;32515:1;32501:16;;;;;;;;;189015:66;;32471:47;;32482:10;;189015:66;;32501:16;;;32471:10;:47::i;:::-;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;201363:3:0;;:63;;;;;;;;;;;;;;-1:-1:-1;;;;;201363:3:0;;;;:35;;:63;;;;;:3;;:63;;;;;;;;:3;;:63;;;5:2:-1;;;;30:1;27;20:12;5:2;201363:63:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;201363:63:0;;;;201218:216;;:::o;10148:211::-;10195:4;10212:27;10242:24;:22;:24::i;:::-;10212:54;-1:-1:-1;10284:24:0;;;;;:67;;;10332:19;10312:16;:14;:16::i;:::-;:39;;10284:67;10277:74;;10148:211;;:::o;192519:196::-;32501:16;;;32515:1;32501:16;;;;;;;;;188305:66;;32471:47;;32482:10;;188305:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;192618:11:0;;:43;;;;;;-1:-1:-1;;;;;192618:43:0;;;;;;;;;:11;;;;;:29;;:43;;;;;:11;;:43;;;;;;;:11;;:43;;;5:2:-1;;;;30:1;27;20:12;5:2;192618:43:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;-1:-1;;192672:3:0;;:35;;;;;;-1:-1:-1;;;;;192672:35:0;;;;;;;;;:3;;;;;-1:-1:-1;192672:21:0;;-1:-1:-1;192672:35:0;;;;;:3;;:35;;;;;;;:3;;:35;;;5:2:-1;;;;30:1;27;20:12;190368:41:0;190407:2;190368:41;:::o;189656:135::-;189725:66;189656:135;:::o;189514:::-;189583:66;189514:135;:::o;190633:43::-;;;-1:-1:-1;;;;;190633:43:0;;:::o;27655:181::-;27721:18;27778:22;:20;:22::i;:::-;-1:-1:-1;;;;;27778:40:0;;27819:7;27778:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;27778:49:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;27778:49:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;27778:49:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;27778:49:0;;27655:181;-1:-1:-1;;27655:181:0:o;189940:135::-;190009:66;189940:135;:::o;188804:::-;188873:66;188804:135;:::o;33773:232::-;33822:7;33930:8;:6;:8::i;:::-;-1:-1:-1;;;;;33930:25:0;;:27;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;33930:27:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;33930:27:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;33930:27:0;;-1:-1:-1;33773:232:0;:::o;202337:162::-;32501:16;;;32515:1;32501:16;;;;;;;;;189299:66;;32471:47;;32482:10;;189299:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;202450:3:0;;:41;;;;;;-1:-1:-1;;;;;202450:41:0;;;;;;;;;;;;;;;;;;;;;:3;;;;;:18;;:41;;;;;:3;;:41;;;;;;;:3;;:41;;;5:2:-1;;;;30:1;27;20:12;5:2;202450:41:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;202450:41:0;;;;202337:162;;;;:::o;194176:154::-;9743:16;:14;:16::i;:::-;9761:21;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;9761:21:0;;;;;9735:48;;;;;;-1:-1:-1;;;;;9735:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9735:48:0;-1:-1:-1;194275:7:0;;;:47;;;;;;-1:-1:-1;;;;;194275:47:0;;;;;;;;;;;;;;;:7;;;;;:14;;:47;;;;;;;;;;;:7;;:47;;;5:2:-1;;;;30:1;27;20:12;188236:135:0;188305:66;188236:135;:::o;204247:170::-;204335:7;9743:16;:14;:16::i;:::-;9761:21;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;9761:21:0;;;;;9735:48;;;;;;-1:-1:-1;;;;;9735:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9735:48:0;-1:-1:-1;204362:11:0;;:47;;;;;;-1:-1:-1;;;;;204362:47:0;;;;;;;;;:11;;;;;:34;;:47;;;;;;;;;;;;;;:11;;:47;;;5:2:-1;;;;30:1;27;20:12;203957:126:0;204021:7;9743:16;:14;:16::i;:::-;9761:21;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;9761:21:0;;;;;9735:48;;;;;;-1:-1:-1;;;;;9735:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9735:48:0;;204048:7;;;;;;;;;-1:-1:-1;;;;;204048:7:0;-1:-1:-1;;;;;204048:25:0;;:27;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;203690:102:0;32501:16;;;32515:1;32501:16;;;;;;;;;190293:66;;32471:47;;32482:10;;190293:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;203764:3:0;;:20;;;;;;-1:-1:-1;;;;;203764:20:0;;;;;;;;;:3;;;;;:12;;:20;;;;;:3;;:20;;;;;;;:3;;:20;;;5:2:-1;;;;30:1;27;20:12;196656:180:0;9743:16;:14;:16::i;:::-;9761:21;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;9761:21:0;;;;;9735:48;;;;;;-1:-1:-1;;;;;9735:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9735:48:0;-1:-1:-1;196770:11:0;;:58;;;;;;-1:-1:-1;;;;;196770:58:0;;;;;;;;;;;;;;;;;;;;;;:11;;;;;:26;;:58;;;;;:11;;:58;;;;;;;:11;;:58;;;5:2:-1;;;;30:1;27;20:12;5:2;196770:58:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;196770:58:0;;;;196656:180;;;:::o;188520:135::-;188589:66;188520:135;:::o;188378:::-;188447:66;188378:135;:::o;199011:376::-;32501:16;;;32515:1;32501:16;;;;;;;;;188589:66;;32471:47;;32482:10;;188589:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;199277:11:0;;:102;;;;;;-1:-1:-1;;;;;199277:102:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:11;;;;;:30;;:102;;;;;:11;;:102;;;;;;;:11;;:102;;;5:2:-1;;;;30:1;27;20:12;5:2;199277:102:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;199277:102:0;;;;199011:376;;;;;;:::o;193457:81::-;9743:16;:14;:16::i;:::-;9761:21;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;9761:21:0;;;;;9735:48;;;;;;-1:-1:-1;;;;;9735:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9735:48:0;-1:-1:-1;193515:7:0;;;:15;;;;;;;;-1:-1:-1;;;;;193515:7:0;;;;:13;;:15;;;;;;;;;;:7;;:15;;;5:2:-1;;;;30:1;27;20:12;5:2;193515:15:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;193515:15:0;;;;193457:81::o;193044:159::-;32501:16;;;32515:1;32501:16;;;;;;;;;188447:66;;32471:47;;32482:10;;188447:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;193148:11:0;;:47;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;193148:11:0;;;;:22;;:47;;;;;:11;;:47;;;;;;;;:11;;:47;;;5:2:-1;;;;30:1;27;20:12;196072:176:0;9743:16;:14;:16::i;:::-;9761:21;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;9761:21:0;;;;;9735:48;;;;;;-1:-1:-1;;;;;9735:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9735:48:0;-1:-1:-1;196184:11:0;;:56;;;;;;-1:-1:-1;;;;;196184:56:0;;;;;;;;;;;;;;;;;;;;;;:11;;;;;:25;;:56;;;;;:11;;:56;;;;;;;:11;;:56;;;5:2:-1;;;;30:1;27;20:12;195493:175:0;32501:16;;;32515:1;32501:16;;;;;;;;;190151:66;;32471:47;;32482:10;;190151:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;195601:11:0;;:59;;;;;;195627:10;195601:59;;;;-1:-1:-1;;;;;195601:59:0;;;;;;;;;;;;;;;:11;;;;;:25;;:59;;;;;:11;;:59;;;;;;;:11;;:59;;;5:2:-1;;;;30:1;27;20:12;23998:101:0;-1:-1:-1;24087:4:0;;23998:101::o;3643:108::-;3681:7;3708:35;3442:66;3708:33;:35::i;:::-;3701:42;;3643:108;:::o;203329:102::-;203393:3;;:30;;;;;;-1:-1:-1;;;;;203393:30:0;;;;;;;;;:3;;;;;:22;;:30;;;;;:3;;:30;;;;;;;:3;;:30;;;5:2:-1;;;;30:1;27;20:12;5:2;203393:30:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;203393:30:0;;;;203329:102;:::o;200552:386::-;32501:16;;;32515:1;32501:16;;;;;;;;;188873:66;;32471:47;;32482:10;;188873:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;200825:11:0;;:105;;;;;;-1:-1:-1;;;;;200825:105:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:11;;;;;:33;;:105;;;;;:11;;:105;;;;;;;:11;;:105;;;5:2:-1;;;;30:1;27;20:12;9894:139:0;9949:7;9976:49;9340:66;9976:47;:49::i;189230:135::-;189299:66;189230:135;:::o;193296:89::-;32501:16;;;32515:1;32501:16;;;;;;;;;189583:66;;32471:47;;32482:10;;189583:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;193363:7:0;;;:14;;;;;;;;-1:-1:-1;;;;;193363:7:0;;;;:12;;:14;;;;;;;;;;:7;;:14;;;5:2:-1;;;;30:1;27;20:12;199586:297:0;32501:16;;;32515:1;32501:16;;;;;;;;;188731:66;;32471:47;;32482:10;;188731:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;199693:11:0;;:46;;;;;;-1:-1:-1;;;;;199693:46:0;;;;;;;;;:11;;;;;:33;;:46;;;;;:11;;:46;;;;;;;:11;;:46;;;5:2:-1;;;;30:1;27;20:12;197720:620:0;32501:16;;;32515:1;32501:16;;;;;;;;;188589:66;;32471:47;;32482:10;;188589:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;198033:11:0;;:102;;;;;;-1:-1:-1;;;;;198033:102:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:11;;;;;:30;;:102;;;;;:11;;:102;;;;;;;:11;;:102;;;5:2:-1;;;;30:1;27;20:12;5:2;198033:102:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;-1:-1;;;;;;;;;198150:18:0;;;198146:89;;198185:7;;:38;;;;;;-1:-1:-1;;;;;198185:38:0;;;;;;;;;:7;;;;;:25;;:38;;;;;:7;;:38;;;;;;;:7;;:38;;;5:2:-1;;;;30:1;27;20:12;5:2;198185:38:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;198185:38:0;;;;198146:89;198257:1;198249:5;:9;198245:88;;;198275:3;;:46;;;;;;-1:-1:-1;;;;;198275:46:0;;;;;;;;;;;;;;;;;;;;;:3;;;;;:18;;:46;;;;;:3;;:46;;;;;;;:3;;:46;;;5:2:-1;;;;30:1;27;20:12;5:2;198275:46:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;198275:46:0;;;;197720:620;;;;;;;;:::o;23152:639::-;23278:13;23388:15;23550:11;23221:27;23241:6;23221:19;:27::i;:::-;23250:16;;;;;;;;;;;;;;;;;;23213:54;;;;;;-1:-1:-1;;;;;23213:54:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;23213:54:0;;23294:18;:16;:18::i;:::-;23278:34;;23331:17;23342:5;23331:10;:17::i;:::-;23350:24;;;;;;;;;;;;;;;;;;23323:52;;;;;;-1:-1:-1;;;;;23323:52:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;23323:52:0;-1:-1:-1;;;;;;23418:13:0;;;23414:314;;;23494:23;;23466:4;23458:21;;-1:-1:-1;;;;;;23494:14:0;;;:23;;;;;23458:21;;23494:23;;;;23458:21;23494:14;:23;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;23494:23:0;23414:314;;;-1:-1:-1;23570:6:0;23602:27;-1:-1:-1;;;;;23602:21:0;;23624:4;23602:27;:21;:27;:::i;:::-;23592:37;-1:-1:-1;23652:34:0;-1:-1:-1;;;;;23652:18:0;;23671:5;23592:37;23652:34;:18;:34;:::i;:::-;23688:27;;;;;;;;;;;;;;;;;;23644:72;;;;;;-1:-1:-1;;;;;23644:72:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;23644:72:0;;23414:314;23767:6;-1:-1:-1;;;;;23745:38:0;23760:5;-1:-1:-1;;;;;23745:38:0;;23775:7;23745:38;;;;;;;;;;;;;;;;;;23152:639;;;;:::o;33139:512::-;33231:4;33322:20;33253:16;:14;:16::i;:::-;33252:17;33248:62;;;33293:5;33286:12;;;;33248:62;33345:8;:6;:8::i;:::-;33322:31;-1:-1:-1;;;;;;33368:35:0;;;33364:80;;;33427:5;33420:12;;;;33364:80;33463:12;-1:-1:-1;;;;;33463:26:0;;33504:7;33534:4;33554:5;33574:58;33624:7;33574:49;:58::i;:::-;33463:180;;;;;;;;;-1:-1:-1;;;;;33463:180:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;33463:180:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;33463:180:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;33463:180:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;33463:180:0;;-1:-1:-1;33139:512:0;;;;;;;:::o;189798:135::-;189867:66;189798:135;:::o;27844:234::-;27897:18;27928:20;27951:8;:6;:8::i;:::-;:69;;;;;;26879:66;27951:69;;;;24967:66;27951:69;;;;;;-1:-1:-1;;;;;27951:15:0;;;;;;;:69;;;;;;;;;;;;;;;;:15;:69;;;5:2:-1;;;;30:1;27;20:12;189372:135:0;189441:66;189372:135;:::o;188662:::-;188731:66;188662:135;:::o;202982:171::-;32501:16;;;32515:1;32501:16;;;;;;;;;189441:66;;32471:47;;32482:10;;189441:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;203101:3:0;;:44;;;;;;-1:-1:-1;;;;;203101:44:0;;;;;;;;;;;;;;;;;;;;;:3;;;;;:21;;:44;;;;;:3;;:44;;;;;;;:3;;:44;;;5:2:-1;;;;30:1;27;20:12;188946:135:0;189015:66;188946:135;:::o;193736:149::-;32501:16;;;32515:1;32501:16;;;;;;;;;189867:66;;32471:47;;32482:10;;189867:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;193822:7:0;;;:55;;;;;;193858:10;193822:55;;;;;;;;;;;;-1:-1:-1;;;;;193822:7:0;;;;:18;;193847:9;;193822:55;;;;;:7;:55;;;;;;193847:9;193822:7;:55;;;5:2:-1;;;;30:1;27;20:12;194474:284:0;32501:16;;;194546:9;32501:16;;;;;;;;;189725:66;;32471:47;;32482:10;;189725:66;;194546:9;32501:16;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;;194558:1;194546:13;;194541:179;194565:7;:14;194561:18;;194541:179;;;194605:3;;194615:7;:10;;194638:1;;-1:-1:-1;;;;;194605:3:0;;:9;;194623:1;;194615:10;;;;;;;;;;;;;;;;;;194605:21;;;;;;;;;;-1:-1:-1;;;;;194615:10:0;;;194605:21;;;;;;;;;;;;;;;;;;;;;;;5:2:-1;;;;30:1;27;20:12;5:2;194605:21:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;194605:21:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;194605:21:0;:35;194601:108;;194661:3;;194682:7;:10;;-1:-1:-1;;;;;194661:3:0;;;;:20;;194682:7;194690:1;;194682:10;;;;;;;;;;;;;;;194661:32;;;;;;;;;;-1:-1:-1;;;;;194682:10:0;;;194661:32;;;;;;;;;;194682:10;194661:32;;;;;194682:10;194661:32;;;;5:2:-1;;;;30:1;27;20:12;5:2;194661:32:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;194661:32:0;;;;194601:108;194581:3;;;;;194541:179;;;194732:11;;;;;;;;;-1:-1:-1;;;;;194732:11:0;-1:-1:-1;;;;;194732:16:0;;:18;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;189088:135:0;189157:66;189088:135;:::o;190683:39::-;;;-1:-1:-1;;;;;190683:39:0;;:::o;190771:::-;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;190771:39:0;;-1:-1:-1;190771:39:0;:::o;190082:135::-;190151:66;190082:135;:::o;201683:221::-;32501:16;;;32515:1;32501:16;;;;;;;;;189157:66;;32471:47;;32482:10;;189157:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;201831:3:0;;:65;;;;;;;;;;;;;;-1:-1:-1;;;;;201831:3:0;;;;:36;;:65;;;;;:3;;:65;;;;;;;;:3;;:65;;;5:2:-1;;;;30:1;27;20:12;195003:195:0;32501:16;;;32515:1;32501:16;;;;;;;;;190009:66;;32471:47;;32482:10;;190009:66;;32501:16;;;32471:47;32520:17;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;32520:17:0;;;;;32463:75;;;;;;-1:-1:-1;;;;;32463:75:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;32463:75:0;-1:-1:-1;195116:11:0;;:74;;;;;;195158:10;195116:74;;;;-1:-1:-1;;;;;195116:74:0;;;;;;;;;;;;;;;:11;;;;;:24;;195147:9;;195116:74;;;;;:11;;:74;;;;;;;;195147:9;195116:11;:74;;;5:2:-1;;;;30:1;27;20:12;3517:118:0;3556:7;3591:35;3325:66;3591:33;:35::i;11262:119::-;11306:4;-1:-1:-1;;11330:24:0;:22;:24::i;:::-;:43;11323:50;;11262:119;:::o;190224:135::-;190293:66;190224:135;:::o;204091:148::-;204172:7;9743:16;:14;:16::i;:::-;9761:21;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;9761:21:0;;;;;9735:48;;;;;;-1:-1:-1;;;;;9735:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9735:48:0;-1:-1:-1;204199:3:0;;:32;;;;;;-1:-1:-1;;;;;204199:32:0;;;;;;;;;:3;;;;;:24;;:32;;;;;;;;;;;;;;:3;;:32;;;5:2:-1;;;;30:1;27;20:12;204425:364:0;204509:7;204529:15;9743:16;:14;:16::i;:::-;9761:21;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;9761:21:0;;;;;9735:48;;;;;;-1:-1:-1;;;;;9735:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9735:48:0;-1:-1:-1;;;;;;204547:13:0;;;:66;;204578:35;-1:-1:-1;;;;;204578:29:0;;204608:4;204578:35;:29;:35;:::i;:::-;204547:66;;;204563:4;-1:-1:-1;;;;;204563:12:0;;204547:66;204646:7;;204529:84;;-1:-1:-1;;;;;;204630:24:0;;;204646:7;;204630:24;204626:156;;;204690:3;;:32;;;;;;-1:-1:-1;;;;;204690:32:0;;;;;;;;;204678:45;;204690:3;;;;;:24;;:32;;;;;;;;;;;;;;;:3;;:32;;;5:2:-1;;;;30:1;27;20:12;5:2;204690:32:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;204690:32:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;204690:32:0;204678:7;;:45;:11;:45;:::i;:::-;204671:52;;;;204626:156;204763:7;204756:14;;204626:156;204425:364;;;;;:::o;191337:994::-;192151:9;9616:24;:22;:24::i;:::-;9647:25;;;;;;;;;;;;;;;;;;9616:29;9608:65;;;;-1:-1:-1;;;;;9608:65:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9608:65:0;;191644:20;191655:8;191644:10;:20::i;:::-;191676:21;;;;;;;;;;;;;;;;;;191636:62;;;;;;-1:-1:-1;;;;;191636:62:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;191636:62:0;;191717:24;191728:12;191717:10;:24::i;:::-;191749:21;;;;;;;;;;;;;;;;;;191709:62;;;;;;-1:-1:-1;;;;;191709:62:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;191709:62:0;;191790:20;191801:8;191790:10;:20::i;:::-;191822:21;;;;;;;;;;;;;;;;;;191782:62;;;;;;-1:-1:-1;;;;;191782:62:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;191782:62:0;;191863:16;191874:4;191863:10;:16::i;:::-;191895:21;;;;;;;;;;;;;;;;;;191855:62;;;;;;-1:-1:-1;;;;;191855:62:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;191855:62:0;-1:-1:-1;191968:20:0;;;;;;;;;;;;;;;;;190407:2;191936:30;;191928:61;;;;-1:-1:-1;;;;;191928:61:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;191928:61:0;;192002:13;:11;:13::i;:::-;-1:-1:-1;192028:7:0;:18;;-1:-1:-1;;;;;192028:18:0;;;-1:-1:-1;;192028:18:0;;;;;;;192057:26;;;;;;;;;;;192094:7;:18;;;;;;;;;;;192123:3;:10;;;;;;;;;;;;192146:178;192166:19;;;192146:178;;;192215:34;192237:8;;192246:1;192237:11;;;;;;;;;;;;;-1:-1:-1;;;;;192237:11:0;192215:21;:34::i;:::-;192251:20;;;;;;;;;;;;;;;;;;192207:65;;;;;;-1:-1:-1;;;;;192207:65:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;192207:65:0;-1:-1:-1;192287:7:0;192300:8;;192309:1;192300:11;;;;;;;27:10:-1;;39:1;23:18;;;45:23;;-1:-1;192287:25:0;;;192300:11;192287:25;;;;;;;;;-1:-1:-1;;192287:25:0;-1:-1:-1;;;;;192300:11:0;;;;;;;;;;;;;192287:25;;;;-1:-1:-1;192187:3:0;192146:178;;203843:106;203895:7;9743:16;:14;:16::i;:::-;9761:21;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;9761:21:0;;;;;9735:48;;;;;;-1:-1:-1;;;;;9735:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9735:48:0;;203922:11;;;;;;;;;-1:-1:-1;;;;;203922:11:0;-1:-1:-1;;;;;203922:17:0;;:19;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;190729:35:0;;;-1:-1:-1;;;;;190729:35:0;;:::o;190587:39::-;;;-1:-1:-1;;;;;190587:39:0;;:::o;7931:96::-;8007:12;7931:96;:::o;459:136::-;571:15;;561:27::o;603:136::-;715:15;;705:27::o;16385:252::-;16445:4;;-1:-1:-1;;;;;16466:21:0;;;16462:66;;;16511:5;16504:12;;;;16462:66;16594:7;16582:20;16574:28;;16628:1;16621:4;:8;16614:15;;16385:252;;;;;:::o;21369:413::-;21500:94;;;-1:-1:-1;;;;;21500:94:0;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;21500:94:0;;;;;;;;25:18:-1;;61:17;;21500:94:0;182:15:-1;21537:25:0;179:29:-1;160:49;;21447:7:0;;;;21646:39;21537:6;21500:94;21646:12;:39::i;:::-;21713:28;;;;;;;;;;;;;;;;;21607:78;;-1:-1:-1;21607:78:0;-1:-1:-1;21696:46:0;;;;;;;-1:-1:-1;;;;;21696:46:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;21696:46:0;-1:-1:-1;21762:12:0;21369:413;-1:-1:-1;;;;;21369:413:0:o;19851:311::-;19984:105;;;-1:-1:-1;;;;;19984:105:0;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;19984:105:0;;;;;;;;25:18:-1;;61:17;;19984:105:0;182:15:-1;20021:17:0;179:29:-1;160:49;;19935:4:0;;20107:47;20129:6;19984:105;20107:21;:47::i;:::-;20100:54;19851:311;-1:-1:-1;;;;;19851:311:0:o;12286:548::-;12707:13;;12723:2;12707:18;12790:26;;12707:6;12745:82::o;35799:177::-;35897:19;;;;;;;;;;;;;;;;;35859:7;;;;35887:8;;;;35879:38;;;;-1:-1:-1;;;;;35879:38:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;35879:38:0;-1:-1:-1;;;35940:7:0;;;35799:177::o;10475:125::-;9616:24;:22;:24::i;:::-;9647:25;;;;;;;;;;;;;;;;;;9616:29;9608:65;;;;-1:-1:-1;;;;;9608:65:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;9608:65:0;;10527;10575:16;:14;:16::i;:::-;9340:66;;10527:65;:47;:65;:::i;:::-;10475:125::o;204838:137::-;204908:4;204932:18;204943:6;204932:10;:18::i;:::-;:35;;;-1:-1:-1;;;;;;204954:13:0;;;204932:35;204925:42;204838:137;-1:-1:-1;;204838:137:0:o;18869:798::-;18979:4;18985:7;19010:12;19033:11;19096:4;19090:11;19478:4;19406:3;19354:9;19348:16;19306:4;19295:9;19291:20;19241:5;19183:3;19154:378;19143:389;;19563:1;19554:7;19551:14;19548:2;;;19598:3;19592:10;19585:17;;19548:2;-1:-1:-1;19646:7:0;;19655:3;;-1:-1:-1;18869:798:0;-1:-1:-1;;;18869:798:0:o;17480:1381::-;17585:4;17607:8;17667:4;17661:11;18098:4;18026:3;17974:9;17968:16;17926:4;17915:9;17911:20;17860:1;17810:5;17752:3;17729:423;18183:1;18174:7;18171:14;18168:2;;;18287:14;18375:57;;;;18514:4;18509:197;;;;18280:527;;18375:57;18412:1;18405:8;;18375:57;;18509:197;18685:1;18679:3;18673:10;18670:17;18663:24;;18280:527;;18168:2;-1:-1:-1;18850:3:0;;17480:1381;-1:-1:-1;;;;17480:1381:0:o;1128:121::-;1218:22;;1216:26::o
Swarm Source
bzzr://27ecbd82ecc3a0a937a5951feb66c0e8c7ae59220178f7c631b9a3a850f7d245
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.