Address Details
contract
0xB0B86Dd967655728218b7b87b10051A60758af82
- Contract Name
- MintBurnWrapper
- Creator
- 0x3de721–c11bfb at 0x2824af–668f35
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- Fetching transactions...
- Transfers
- Fetching transfers...
- Gas Used
- Fetching gas used...
- Last Balance Update
- 13254104
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- MintBurnWrapper
- Optimization enabled
- true
- Compiler version
- v0.8.8+commit.dddeac2f
- Optimization runs
- 0
- EVM Version
- london
- Verified at
- 2022-08-26T02:58:00.989805Z
contracts/utils/MultiChainWrapper.sol
// SPDX-License-Identifier: GPL-3.0-or-later /** Wrap the G$ token to provide mint permissions to multichain.org router/bridge based on https://github.com/anyswap/multichain-smart-contracts/blob/1459fe6281867319af8ffb1849e5c16d242d6530/contracts/wrapper/MintBurnWrapper.sol Added onTokenTransfer Fixed: https://github.com/anyswap/multichain-smart-contracts/issues/4 https://github.com/anyswap/multichain-smart-contracts/issues/3 */ pragma solidity ^0.8; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./DAOUpgradeableContract.sol"; library TokenOperation { using Address for address; function safeMint( address token, address to, uint256 value ) internal { // mint(address,uint256) _callOptionalReturn(token, abi.encodeWithSelector(0x40c10f19, to, value)); } function safeBurnAny( address token, address from, uint256 value ) internal { // burn(address,uint256) _callOptionalReturn(token, abi.encodeWithSelector(0x9dc29fac, from, value)); } function safeBurnSelf(address token, uint256 value) internal { // burn(uint256) _callOptionalReturn(token, abi.encodeWithSelector(0x42966c68, value)); } function safeBurnFrom( address token, address from, uint256 value ) internal { // burnFrom(address,uint256) _callOptionalReturn(token, abi.encodeWithSelector(0x79cc6790, from, value)); } function _callOptionalReturn(address token, bytes memory data) private { bytes memory returndata = token.functionCall( data, "TokenOperation: low-level call failed" ); if (returndata.length > 0) { // Return data is optional require( abi.decode(returndata, (bool)), "TokenOperation: did not succeed" ); } } } interface IBridge { function Swapin( bytes32 txhash, address account, uint256 amount ) external returns (bool); function Swapout(uint256 amount, address bindaddr) external returns (bool); event LogSwapin( bytes32 indexed txhash, address indexed account, uint256 amount ); event LogSwapout( address indexed account, address indexed bindaddr, uint256 amount ); } interface IRouter { function mint(address to, uint256 amount) external returns (bool); function burn(address from, uint256 amount) external returns (bool); } //License-Identifier: GPL-3.0-or-later abstract contract PausableControl { mapping(bytes32 => bool) private _pausedRoles; bytes32 public constant PAUSE_ALL_ROLE = 0x00; event Paused(bytes32 role); event Unpaused(bytes32 role); modifier whenNotPaused(bytes32 role) { require( !paused(role) && !paused(PAUSE_ALL_ROLE), "PausableControl: paused" ); _; } modifier whenPaused(bytes32 role) { require( paused(role) || paused(PAUSE_ALL_ROLE), "PausableControl: not paused" ); _; } function paused(bytes32 role) public view virtual returns (bool) { return _pausedRoles[role]; } function _pause(bytes32 role) internal virtual whenNotPaused(role) { _pausedRoles[role] = true; emit Paused(role); } function _unpause(bytes32 role) internal virtual whenPaused(role) { _pausedRoles[role] = false; emit Unpaused(role); } } /// @dev MintBurnWrapper has the following aims: /// 1. wrap token which does not support interface `IBridge` or `IRouter` /// 2. wrap token which want to support multiple minters /// 3. add security enhancement (mint cap, pausable, etc.) contract MintBurnWrapper is IBridge, IRouter, AccessControlEnumerableUpgradeable, PausableControl, DAOUpgradeableContract { using SafeERC20 for IERC20; // access control roles bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BRIDGE_ROLE = keccak256("BRIDGE_ROLE"); bytes32 public constant ROUTER_ROLE = keccak256("ROUTER_ROLE"); // pausable control roles bytes32 public constant PAUSE_MINT_ROLE = keccak256("PAUSE_MINT_ROLE"); bytes32 public constant PAUSE_BURN_ROLE = keccak256("PAUSE_BURN_ROLE"); bytes32 public constant PAUSE_BRIDGE_ROLE = keccak256("PAUSE_BRIDGE_ROLE"); bytes32 public constant PAUSE_ROUTER_ROLE = keccak256("PAUSE_ROUTER_ROLE"); bytes32 public constant PAUSE_DEPOSIT_ROLE = keccak256("PAUSE_DEPOSIT_ROLE"); bytes32 public constant PAUSE_WITHDRAW_ROLE = keccak256("PAUSE_WITHDRAW_ROLE"); struct Supply { uint256 max; // single limit of each mint uint256 cap; // total limit of all mint uint256 total; // total minted minus burned } mapping(address => Supply) public minterSupply; uint256 public totalMintCap; // total mint cap uint256 public totalMinted; // total minted amount enum TokenType { MintBurnAny, // mint and burn(address from, uint256 amount), don't need approve MintBurnFrom, // mint and burnFrom(address from, uint256 amount), need approve MintBurnSelf, // mint and burn(uint256 amount), call transferFrom first, need approve Transfer, // transfer and transferFrom, need approve TransferDeposit // transfer and transferFrom, deposit and withdraw, need approve } address public token; // the target token this contract is wrapping TokenType public tokenType; mapping(address => uint256) public depositBalance; function initialize( address _token, TokenType _tokenType, uint256 _totalMintCap, address _admin, INameService _nameService ) external initializer { __AccessControlEnumerable_init(); require(_token != address(0), "zero token address"); require(_admin != address(0), "zero admin address"); token = _token; tokenType = _tokenType; totalMintCap = _totalMintCap; _setupRole(DEFAULT_ADMIN_ROLE, _admin); setDAO(_nameService); } function owner() external view returns (address) { return getRoleMember(DEFAULT_ADMIN_ROLE, 0); } function pause(bytes32 role) external onlyRole(DEFAULT_ADMIN_ROLE) { _pause(role); } function unpause(bytes32 role) external onlyRole(DEFAULT_ADMIN_ROLE) { _unpause(role); } function _mint(address to, uint256 amount) internal whenNotPaused(PAUSE_MINT_ROLE) { require(to != address(this), "forbid mint to address(this)"); Supply storage s = minterSupply[msg.sender]; require(amount <= s.max, "minter max exceeded"); s.total += amount; require(s.total <= s.cap, "minter cap exceeded"); totalMinted += amount; require(totalMinted <= totalMintCap, "total mint cap exceeded"); if ( tokenType == TokenType.Transfer || tokenType == TokenType.TransferDeposit ) { IERC20(token).safeTransfer(to, amount); } else { TokenOperation.safeMint(token, to, amount); } } function _burn(address from, uint256 amount) internal whenNotPaused(PAUSE_BURN_ROLE) { require(from != address(this), "forbid burn from address(this)"); // require(totalMinted >= amount, "total burn amount exceeded"); //update stats correctly, but dont fail if it tries to transfer tokens minted elsewhere as long as we burn some if (totalMinted >= amount) { totalMinted -= amount; } else { totalMinted = 0; } if (hasRole(MINTER_ROLE, msg.sender)) { Supply storage s = minterSupply[msg.sender]; if (s.total >= amount) { s.total -= amount; } else { s.total = 0; } } //handle onTokenTransfer (ERC677), assume tokens has been transfered if (from == token) { TokenOperation.safeBurnSelf(token, amount); } else if ( tokenType == TokenType.Transfer || tokenType == TokenType.TransferDeposit ) { IERC20(token).safeTransferFrom(from, address(this), amount); } else if (tokenType == TokenType.MintBurnAny) { TokenOperation.safeBurnAny(token, from, amount); } else if (tokenType == TokenType.MintBurnFrom) { TokenOperation.safeBurnFrom(token, from, amount); } else if (tokenType == TokenType.MintBurnSelf) { IERC20(token).safeTransferFrom(from, address(this), amount); TokenOperation.safeBurnSelf(token, amount); } } // impl IRouter `mint` function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) returns (bool) { _mint(to, amount); return true; } // impl IRouter `burn` function burn(address from, uint256 amount) external onlyRole(MINTER_ROLE) onlyRole(ROUTER_ROLE) whenNotPaused(PAUSE_ROUTER_ROLE) returns (bool) { _burn(from, amount); return true; } // impl IBridge `Swapin` function Swapin( bytes32 txhash, address account, uint256 amount ) external onlyRole(MINTER_ROLE) onlyRole(BRIDGE_ROLE) whenNotPaused(PAUSE_BRIDGE_ROLE) returns (bool) { _mint(account, amount); emit LogSwapin(txhash, account, amount); return true; } // impl IBridge `Swapout` function Swapout(uint256 amount, address bindaddr) external whenNotPaused(PAUSE_BRIDGE_ROLE) returns (bool) { require(bindaddr != address(0), "zero bind address"); _burn(msg.sender, amount); emit LogSwapout(msg.sender, bindaddr, amount); return true; } //impl swapout for erc677 function onTokenTransfer( address sender, uint256 amount, bytes memory data ) external whenNotPaused(PAUSE_BRIDGE_ROLE) returns (bool) { require(msg.sender == token); //verify this was called from a token transfer address bindaddr = chooseReceiver(sender, data); require(bindaddr != address(0), "zero bind address"); _burn(msg.sender, amount); //msg.sender is token, in _burn we will burn self emit LogSwapout(sender, bindaddr, amount); return true; } /** * @dev Truncate bytes array if its size is more than 20 bytes. * NOTE: Similar to the bytesToBytes32 function, make sure that _bytes is not shorter than 20 bytes. * @param _bytes to be converted to address type * @return addr included in the firsts 20 bytes of the bytes array in parameter. */ function bytesToAddress(bytes memory _bytes) internal pure returns (address addr) { assembly { addr := mload(add(_bytes, 20)) } } /** * @dev Helper function for alternative receiver feature. Chooses the actual receiver out of sender and passed data. * @param _from address of tokens sender. * @param _data passed data in the transfer message. * @return recipient of the on the other side. */ function chooseReceiver(address _from, bytes memory _data) internal pure returns (address recipient) { recipient = _from; if (_data.length > 0) { require(_data.length == 20); recipient = bytesToAddress(_data); require(recipient != address(0)); } } function deposit(uint256 amount, address to) external whenNotPaused(PAUSE_DEPOSIT_ROLE) returns (uint256) { require(tokenType == TokenType.TransferDeposit, "forbid depoist"); IERC20(token).safeTransferFrom(msg.sender, address(this), amount); depositBalance[to] += amount; return amount; } function withdraw(uint256 amount, address to) external whenNotPaused(PAUSE_WITHDRAW_ROLE) returns (uint256) { require(tokenType == TokenType.TransferDeposit, "forbid withdraw"); depositBalance[msg.sender] -= amount; IERC20(token).safeTransfer(to, amount); return amount; } function addMinter( address minter, uint256 cap, uint256 max ) external onlyRole(DEFAULT_ADMIN_ROLE) { grantRole(MINTER_ROLE, minter); minterSupply[minter].cap = cap; minterSupply[minter].max = max; } function removeMinter(address minter) external onlyRole(DEFAULT_ADMIN_ROLE) { revokeRole(MINTER_ROLE, minter); minterSupply[minter].cap = 0; minterSupply[minter].max = 0; } function setTotalMintCap(uint256 cap) external onlyRole(DEFAULT_ADMIN_ROLE) { totalMintCap = cap; } function setMinterCap(address minter, uint256 cap) external onlyRole(DEFAULT_ADMIN_ROLE) { require(hasRole(MINTER_ROLE, minter), "not minter"); minterSupply[minter].cap = cap; } function setMinterMax(address minter, uint256 max) external onlyRole(DEFAULT_ADMIN_ROLE) { require(hasRole(MINTER_ROLE, minter), "not minter"); minterSupply[minter].max = max; } function setMinterTotal( address minter, uint256 total, bool force ) external onlyRole(DEFAULT_ADMIN_ROLE) { require(force || hasRole(MINTER_ROLE, minter), "not minter"); minterSupply[minter].total = total; } }
/_openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/_openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
/_openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/_openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable { function __AccessControlEnumerable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); __AccessControlEnumerable_init_unchained(); } function __AccessControlEnumerable_init_unchained() internal initializer { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } uint256[49] private __gap; }
/_openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; }
/_openzeppelin/contracts-upgradeable/access/IAccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
/_openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
/_openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal initializer { __ERC1967Upgrade_init_unchained(); } function __ERC1967Upgrade_init_unchained() internal initializer { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; _functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
/_openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } }
/_openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal initializer { __ERC1967Upgrade_init_unchained(); __UUPSUpgradeable_init_unchained(); } function __UUPSUpgradeable_init_unchained() internal initializer { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/_openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
/_openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
/_openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
/_openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } }
/contracts/DAOStackInterfaces.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface Avatar { function nativeToken() external view returns (address); function nativeReputation() external view returns (address); function owner() external view returns (address); } interface Controller { event RegisterScheme(address indexed _sender, address indexed _scheme); event UnregisterScheme(address indexed _sender, address indexed _scheme); function genericCall( address _contract, bytes calldata _data, address _avatar, uint256 _value ) external returns (bool, bytes memory); function avatar() external view returns (address); function unregisterScheme(address _scheme, address _avatar) external returns (bool); function unregisterSelf(address _avatar) external returns (bool); function registerScheme( address _scheme, bytes32 _paramsHash, bytes4 _permissions, address _avatar ) external returns (bool); function isSchemeRegistered(address _scheme, address _avatar) external view returns (bool); function getSchemePermissions(address _scheme, address _avatar) external view returns (bytes4); function addGlobalConstraint( address _constraint, bytes32 _paramHash, address _avatar ) external returns (bool); function mintTokens( uint256 _amount, address _beneficiary, address _avatar ) external returns (bool); function externalTokenTransfer( address _token, address _recipient, uint256 _amount, address _avatar ) external returns (bool); function sendEther( uint256 _amountInWei, address payable _to, address _avatar ) external returns (bool); } interface GlobalConstraintInterface { enum CallPhase { Pre, Post, PreAndPost } function pre( address _scheme, bytes32 _params, bytes32 _method ) external returns (bool); /** * @dev when return if this globalConstraints is pre, post or both. * @return CallPhase enum indication Pre, Post or PreAndPost. */ function when() external returns (CallPhase); } interface ReputationInterface { function balanceOf(address _user) external view returns (uint256); function balanceOfAt(address _user, uint256 _blockNumber) external view returns (uint256); function getVotes(address _user) external view returns (uint256); function getVotesAt( address _user, bool _global, uint256 _blockNumber ) external view returns (uint256); function totalSupply() external view returns (uint256); function totalSupplyAt(uint256 _blockNumber) external view returns (uint256); function delegateOf(address _user) external returns (address); } interface SchemeRegistrar { function proposeScheme( Avatar _avatar, address _scheme, bytes32 _parametersHash, bytes4 _permissions, string memory _descriptionHash ) external returns (bytes32); event NewSchemeProposal( address indexed _avatar, bytes32 indexed _proposalId, address indexed _intVoteInterface, address _scheme, bytes32 _parametersHash, bytes4 _permissions, string _descriptionHash ); } interface IntVoteInterface { event NewProposal( bytes32 indexed _proposalId, address indexed _organization, uint256 _numOfChoices, address _proposer, bytes32 _paramsHash ); event ExecuteProposal( bytes32 indexed _proposalId, address indexed _organization, uint256 _decision, uint256 _totalReputation ); event VoteProposal( bytes32 indexed _proposalId, address indexed _organization, address indexed _voter, uint256 _vote, uint256 _reputation ); event CancelProposal( bytes32 indexed _proposalId, address indexed _organization ); event CancelVoting( bytes32 indexed _proposalId, address indexed _organization, address indexed _voter ); /** * @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being * generated by calculating keccak256 of a incremented counter. * @param _numOfChoices number of voting choices * @param _proposalParameters defines the parameters of the voting machine used for this proposal * @param _proposer address * @param _organization address - if this address is zero the msg.sender will be used as the organization address. * @return proposal's id. */ function propose( uint256 _numOfChoices, bytes32 _proposalParameters, address _proposer, address _organization ) external returns (bytes32); function vote( bytes32 _proposalId, uint256 _vote, uint256 _rep, address _voter ) external returns (bool); function cancelVote(bytes32 _proposalId) external; function getNumberOfChoices(bytes32 _proposalId) external view returns (uint256); function isVotable(bytes32 _proposalId) external view returns (bool); /** * @dev voteStatus returns the reputation voted for a proposal for a specific voting choice. * @param _proposalId the ID of the proposal * @param _choice the index in the * @return voted reputation for the given choice */ function voteStatus(bytes32 _proposalId, uint256 _choice) external view returns (uint256); /** * @dev isAbstainAllow returns if the voting machine allow abstain (0) * @return bool true or false */ function isAbstainAllow() external pure returns (bool); /** * @dev getAllowedRangeOfChoices returns the allowed range of choices for a voting machine. * @return min - minimum number of choices max - maximum number of choices */ function getAllowedRangeOfChoices() external pure returns (uint256 min, uint256 max); }
/contracts/Interfaces.sol
// SPDX-License-Identifier: MIT import { DataTypes } from "./utils/DataTypes.sol"; pragma solidity >=0.8.0; pragma experimental ABIEncoderV2; interface ERC20 { function balanceOf(address addr) external view returns (uint256); function transfer(address to, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function decimals() external view returns (uint8); function mint(address to, uint256 mintAmount) external returns (uint256); function totalSupply() external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); function name() external view returns (string memory); function symbol() external view returns (string memory); event Transfer(address indexed from, address indexed to, uint256 amount); event Transfer( address indexed from, address indexed to, uint256 amount, bytes data ); } interface cERC20 is ERC20 { function mint(uint256 mintAmount) external returns (uint256); function redeemUnderlying(uint256 mintAmount) external returns (uint256); function redeem(uint256 mintAmount) external returns (uint256); function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function underlying() external returns (address); } interface IGoodDollar is ERC20 { function getFees(uint256 value) external view returns (uint256, bool); function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; function renounceMinter() external; function addMinter(address minter) external; function isMinter(address minter) external view returns (bool); function transferAndCall( address to, uint256 value, bytes calldata data ) external returns (bool); function formula() external view returns (address); } interface IERC2917 is ERC20 { /// @dev This emit when interests amount per block is changed by the owner of the contract. /// It emits with the old interests amount and the new interests amount. event InterestRatePerBlockChanged(uint256 oldValue, uint256 newValue); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityIncreased(address indexed user, uint256 value); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityDecreased(address indexed user, uint256 value); /// @dev Return the current contract's interests rate per block. /// @return The amount of interests currently producing per each block. function interestsPerBlock() external view returns (uint256); /// @notice Change the current contract's interests rate. /// @dev Note the best practice will be restrict the gross product provider's contract address to call this. /// @return The true/fase to notice that the value has successfully changed or not, when it succeed, it will emite the InterestRatePerBlockChanged event. function changeInterestRatePerBlock(uint256 value) external returns (bool); /// @notice It will get the productivity of given user. /// @dev it will return 0 if user has no productivity proved in the contract. /// @return user's productivity and overall productivity. function getProductivity(address user) external view returns (uint256, uint256); /// @notice increase a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity added success. function increaseProductivity(address user, uint256 value) external returns (bool); /// @notice decrease a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity removed success. function decreaseProductivity(address user, uint256 value) external returns (bool); /// @notice take() will return the interests that callee will get at current block height. /// @dev it will always calculated by block.number, so it will change when block height changes. /// @return amount of the interests that user are able to mint() at current block height. function take() external view returns (uint256); /// @notice similar to take(), but with the block height joined to calculate return. /// @dev for instance, it returns (_amount, _block), which means at block height _block, the callee has accumulated _amount of interests. /// @return amount of interests and the block height. function takeWithBlock() external view returns (uint256, uint256); /// @notice mint the avaiable interests to callee. /// @dev once it mint, the amount of interests will transfer to callee's address. /// @return the amount of interests minted. function mint() external returns (uint256); } interface Staking { struct Staker { // The staked DAI amount uint256 stakedDAI; // The latest block number which the // staker has staked tokens uint256 lastStake; } function stakeDAI(uint256 amount) external; function withdrawStake() external; function stakers(address staker) external view returns (Staker memory); } interface Uniswap { function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function WETH() external pure returns (address); function factory() external pure returns (address); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountOut( uint256 amountI, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountsOut(uint256 amountIn, address[] memory path) external pure returns (uint256[] memory amounts); } interface UniswapFactory { function getPair(address tokenA, address tokenB) external view returns (address); } interface UniswapPair { function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function kLast() external view returns (uint256); function token0() external view returns (address); function token1() external view returns (address); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); } interface Reserve { function buy( address _buyWith, uint256 _tokenAmount, uint256 _minReturn ) external returns (uint256); } interface IIdentity { function isWhitelisted(address user) external view returns (bool); function addWhitelistedWithDID(address account, string memory did) external; function removeWhitelisted(address account) external; function addIdentityAdmin(address account) external returns (bool); function setAvatar(address _avatar) external; function isIdentityAdmin(address account) external view returns (bool); function owner() external view returns (address); event WhitelistedAdded(address user); } interface IUBIScheme { function currentDay() external view returns (uint256); function periodStart() external view returns (uint256); function hasClaimed(address claimer) external view returns (bool); } interface IFirstClaimPool { function awardUser(address user) external returns (uint256); function claimAmount() external view returns (uint256); } interface ProxyAdmin { function getProxyImplementation(address proxy) external view returns (address); function getProxyAdmin(address proxy) external view returns (address); function upgrade(address proxy, address implementation) external; function owner() external view returns (address); function transferOwnership(address newOwner) external; } /** * @dev Interface for chainlink oracles to obtain price datas */ interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestAnswer() external view returns (int256); } /** @dev interface for AAVE lending Pool */ interface ILendingPool { /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); } interface IDonationStaking { function stakeDonations() external payable; } interface INameService { function getAddress(string memory _name) external view returns (address); } interface IAaveIncentivesController { /** * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards * @param amount Amount of rewards to claim * @param to Address that will be receiving the rewards * @return Rewards claimed **/ function claimRewards( address[] calldata assets, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the total of rewards of an user, already accrued + not yet accrued * @param user The address of the user * @return The rewards **/ function getRewardsBalance(address[] calldata assets, address user) external view returns (uint256); } interface IGoodStaking { function collectUBIInterest(address recipient) external returns ( uint256, uint256, uint256 ); function iToken() external view returns (address); function currentGains( bool _returnTokenBalanceInUSD, bool _returnTokenGainsInUSD ) external view returns ( uint256, uint256, uint256, uint256, uint256 ); function getRewardEarned(address user) external view returns (uint256); function getGasCostForInterestTransfer() external view returns (uint256); function rewardsMinted( address user, uint256 rewardsPerBlock, uint256 blockStart, uint256 blockEnd ) external returns (uint256); } interface IHasRouter { function getRouter() external view returns (Uniswap); } interface IAdminWallet { function addAdmins(address payable[] memory _admins) external; function removeAdmins(address[] memory _admins) external; function owner() external view returns (address); function transferOwnership(address _owner) external; }
/contracts/utils/DAOContract.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "../DAOStackInterfaces.sol"; import "../Interfaces.sol"; /** @title Simple contract that keeps DAO contracts registery */ contract DAOContract { Controller public dao; address public avatar; INameService public nameService; function _onlyAvatar() internal view { require( address(dao.avatar()) == msg.sender, "only avatar can call this method" ); } function setDAO(INameService _ns) internal { nameService = _ns; updateAvatar(); } function updateAvatar() public { dao = Controller(nameService.getAddress("CONTROLLER")); avatar = dao.avatar(); } function nativeToken() public view returns (IGoodDollar) { return IGoodDollar(nameService.getAddress("GOODDOLLAR")); } uint256[50] private gap; }
/contracts/utils/DAOUpgradeableContract.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./DAOContract.sol"; /** @title Simple contract that adds upgradability to DAOContract */ contract DAOUpgradeableContract is Initializable, UUPSUpgradeable, DAOContract { function _authorizeUpgrade(address) internal virtual override { _onlyAvatar(); } }
/contracts/utils/DataTypes.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } enum InterestRateMode { NONE, STABLE, VARIABLE } }
Contract ABI
[{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"LogSwapin","inputs":[{"type":"bytes32","name":"txhash","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LogSwapout","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"bindaddr","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"BRIDGE_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"MINTER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_ALL_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_BRIDGE_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_BURN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_DEPOSIT_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_MINT_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_ROUTER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"PAUSE_WITHDRAW_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"ROUTER_ROLE","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"Swapin","inputs":[{"type":"bytes32","name":"txhash","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"Swapout","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"bindaddr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addMinter","inputs":[{"type":"address","name":"minter","internalType":"address"},{"type":"uint256","name":"cap","internalType":"uint256"},{"type":"uint256","name":"max","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"avatar","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"burn","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract Controller"}],"name":"dao","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"deposit","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"to","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"depositBalance","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"uint8","name":"_tokenType","internalType":"enum MintBurnWrapper.TokenType"},{"type":"uint256","name":"_totalMintCap","internalType":"uint256"},{"type":"address","name":"_admin","internalType":"address"},{"type":"address","name":"_nameService","internalType":"contract INameService"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"mint","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"max","internalType":"uint256"},{"type":"uint256","name":"cap","internalType":"uint256"},{"type":"uint256","name":"total","internalType":"uint256"}],"name":"minterSupply","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract INameService"}],"name":"nameService","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IGoodDollar"}],"name":"nativeToken","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"onTokenTransfer","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeMinter","inputs":[{"type":"address","name":"minter","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinterCap","inputs":[{"type":"address","name":"minter","internalType":"address"},{"type":"uint256","name":"cap","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinterMax","inputs":[{"type":"address","name":"minter","internalType":"address"},{"type":"uint256","name":"max","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinterTotal","inputs":[{"type":"address","name":"minter","internalType":"address"},{"type":"uint256","name":"total","internalType":"uint256"},{"type":"bool","name":"force","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTotalMintCap","inputs":[{"type":"uint256","name":"cap","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"token","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"enum MintBurnWrapper.TokenType"}],"name":"tokenType","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalMintCap","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalMinted","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateAvatar","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"withdraw","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"to","internalType":"address"}]}]
Contract Creation Code
0x60a06040523060601b60805234801561001757600080fd5b5060805160601c6133b661004b60003960008181610caa01528181610cea01528181610f5d0152610f9d01526133b66000f3fe6080604052600436106102385760003560e01c8062f714ce1461023d57806301ffc9a71461027057806303ca49f1146102a05780631296023f146102b75780631b3c90a8146102d957806323fb9eba146102f0578063248a9ca314610310578063250e0dc5146103305780632f2ff15d146103525780632f4dae9f146103725780633092afd51461039257806330d643b5146103b257806330fa738c146103d457806335e1d4871461040357806336568abe146104235780633659cfe6146104435780633e6326fc14610463578063401d1c731461049157806340c10f19146104b15780634162169f146104d157806342c83492146104f25780634f1ef286146105125780635955b592146105255780635aef7de614610547578063628d6cba146105685780636e553f651461058857806378ae8ea2146105a85780638da5cb5b146105ca5780639010d07c146105df57806391d14854146105ff578063956092121461061f578063956501bb146106775780639ac25d08146106a55780639dc29fac146106ba5780639e9e4666146106da578063a19ff680146106fa578063a217fddf146106a5578063a2309ff81461071c578063a4c0ed3614610733578063b32ad1a614610753578063b5bfddea14610775578063c8e1b4ce14610797578063ca15c873146107b7578063d5391393146107d7578063d547741f146107f9578063e1758bd814610819578063ec126c771461082e578063ed56531a1461084e578063efdaffc51461086e578063fc0c546a1461088e575b600080fd5b34801561024957600080fd5b5061025d610258366004612aec565b6108af565b6040519081526020015b60405180910390f35b34801561027c57600080fd5b5061029061028b366004612b1c565b6109a7565b6040519015158152602001610267565b3480156102ac57600080fd5b5061025d6101645481565b3480156102c357600080fd5b5061025d60008051602061336183398151915281565b3480156102e557600080fd5b506102ee6109d2565b005b3480156102fc57600080fd5b506102ee61030b366004612b46565b610b1a565b34801561031c57600080fd5b5061025d61032b366004612b72565b610b78565b34801561033c57600080fd5b5061025d6000805160206131d583398151915281565b34801561035e57600080fd5b506102ee61036d366004612aec565b610b8d565b34801561037e57600080fd5b506102ee61038d366004612b72565b610bb4565b34801561039e57600080fd5b506102ee6103ad366004612b8b565b610bcd565b3480156103be57600080fd5b5061025d60008051602061334183398151915281565b3480156103e057600080fd5b50610166546103f690600160a01b900460ff1681565b6040516102679190612bbe565b34801561040f57600080fd5b506102ee61041e366004612bf4565b610c14565b34801561042f57600080fd5b506102ee61043e366004612aec565b610c7d565b34801561044f57600080fd5b506102ee61045e366004612b8b565b610c9f565b34801561046f57600080fd5b5061013054610484906001600160a01b031681565b6040516102679190612c36565b34801561049d57600080fd5b506102ee6104ac366004612c4a565b610d68565b3480156104bd57600080fd5b506102906104cc366004612b46565b610db2565b3480156104dd57600080fd5b5061012e54610484906001600160a01b031681565b3480156104fe57600080fd5b506102ee61050d366004612c7f565b610de1565b6102ee610520366004612d8d565b610f52565b34801561053157600080fd5b5061025d6000805160206132e183398151915281565b34801561055357600080fd5b5061012f54610484906001600160a01b031681565b34801561057457600080fd5b50610290610583366004612aec565b611008565b34801561059457600080fd5b5061025d6105a3366004612aec565b6110ba565b3480156105b457600080fd5b5061025d60008051602061330183398151915281565b3480156105d657600080fd5b506104846111b2565b3480156105eb57600080fd5b506104846105fa366004612ddc565b6111c3565b34801561060b57600080fd5b5061029061061a366004612aec565b6111e2565b34801561062b57600080fd5b5061065c61063a366004612b8b565b6101636020526000908152604090208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610267565b34801561068357600080fd5b5061025d610692366004612b8b565b6101676020526000908152604090205481565b3480156106b157600080fd5b5061025d600081565b3480156106c657600080fd5b506102906106d5366004612b46565b61120d565b3480156106e657600080fd5b506102906106f5366004612b72565b61129f565b34801561070657600080fd5b5061025d60008051602061327a83398151915281565b34801561072857600080fd5b5061025d6101655481565b34801561073f57600080fd5b5061029061074e366004612dfe565b6112b4565b34801561075f57600080fd5b5061025d6000805160206131f583398151915281565b34801561078157600080fd5b5061025d60008051602061332183398151915281565b3480156107a357600080fd5b506102ee6107b2366004612b46565b61139b565b3480156107c357600080fd5b5061025d6107d2366004612b72565b6113fc565b3480156107e357600080fd5b5061025d6000805160206132c183398151915281565b34801561080557600080fd5b506102ee610814366004612aec565b611413565b34801561082557600080fd5b5061048461141d565b34801561083a57600080fd5b50610290610849366004612e56565b6114b5565b34801561085a57600080fd5b506102ee610869366004612b72565b61158c565b34801561087a57600080fd5b506102ee610889366004612b72565b6115a1565b34801561089a57600080fd5b5061016654610484906001600160a01b031681565b60006000805160206133018339815191526108c98161129f565b1580156108dd57506108db600061129f565b155b6109025760405162461bcd60e51b81526004016108f990612e8e565b60405180910390fd5b600461016654600160a01b900460ff16600481111561092357610923612ba8565b146109625760405162461bcd60e51b815260206004820152600f60248201526e666f7262696420776974686472617760881b60448201526064016108f9565b336000908152610167602052604081208054869290610982908490612ed5565b90915550506101665461099f906001600160a01b031684866115b4565b509192915050565b60006001600160e01b03198216635a05180f60e01b14806109cc57506109cc8261160a565b92915050565b6101305460405163bf40fac160e01b815260206004820152600a60248201526921a7a72a2927a62622a960b11b60448201526001600160a01b039091169063bf40fac19060640160206040518083038186803b158015610a3157600080fd5b505afa158015610a45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a699190612eec565b61012e80546001600160a01b0319166001600160a01b0392909216918217905560408051632d77bef360e11b81529051635aef7de691600480820192602092909190829003018186803b158015610abf57600080fd5b505afa158015610ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af79190612eec565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b26813361163f565b610b3e6000805160206132c1833981519152846111e2565b610b5a5760405162461bcd60e51b81526004016108f990612f09565b506001600160a01b0390911660009081526101636020526040902055565b60009081526065602052604090206001015490565b610b9782826116a3565b6000828152609760205260409020610baf90826116c0565b505050565b6000610bc0813361163f565b610bc9826116d5565b5050565b6000610bd9813361163f565b610bf16000805160206132c183398151915283611413565b506001600160a01b03166000908152610163602052604081206001810182905555565b6000610c20813361163f565b8180610c3f5750610c3f6000805160206132c1833981519152856111e2565b610c5b5760405162461bcd60e51b81526004016108f990612f09565b50506001600160a01b0390911660009081526101636020526040902060020155565b610c87828261178d565b6000828152609760205260409020610baf9082611807565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610ce85760405162461bcd60e51b81526004016108f990612f2d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610d1a61181c565b6001600160a01b031614610d405760405162461bcd60e51b81526004016108f990612f67565b610d4981611838565b60408051600080825260208201909252610d6591839190611840565b50565b6000610d74813361163f565b610d8c6000805160206132c183398151915285610b8d565b506001600160a01b03909216600090815261016360205260409020600181019190915555565b60006000805160206132c1833981519152610dcd813361163f565b610dd78484611987565b5060019392505050565b600054610100900460ff1680610dfa575060005460ff16155b610e165760405162461bcd60e51b81526004016108f990612fa1565b600054610100900460ff16158015610e38576000805461ffff19166101011790555b610e40611bd8565b6001600160a01b038616610e8b5760405162461bcd60e51b81526020600482015260126024820152717a65726f20746f6b656e206164647265737360701b60448201526064016108f9565b6001600160a01b038316610ed65760405162461bcd60e51b81526020600482015260126024820152717a65726f2061646d696e206164647265737360701b60448201526064016108f9565b61016680546001600160a01b0388166001600160a01b03198216811783558792916001600160a81b03191617600160a01b836004811115610f1957610f19612ba8565b0217905550610164849055610f2f600084611c63565b610f3882611c6d565b8015610f4a576000805461ff00191690555b505050505050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610f9b5760405162461bcd60e51b81526004016108f990612f2d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610fcd61181c565b6001600160a01b031614610ff35760405162461bcd60e51b81526004016108f990612f67565b610ffc82611838565b610bc982826001611840565b60006000805160206133618339815191526110228161129f565b1580156110365750611034600061129f565b155b6110525760405162461bcd60e51b81526004016108f990612e8e565b6001600160a01b0383166110785760405162461bcd60e51b81526004016108f990612fef565b6110823385611c91565b6040518481526001600160a01b0384169033906000805160206131b58339815191529060200160405180910390a35060019392505050565b60006000805160206131d58339815191526110d48161129f565b1580156110e857506110e6600061129f565b155b6111045760405162461bcd60e51b81526004016108f990612e8e565b600461016654600160a01b900460ff16600481111561112557611125612ba8565b146111635760405162461bcd60e51b815260206004820152600e60248201526d199bdc989a590819195c1bda5cdd60921b60448201526064016108f9565b6101665461117c906001600160a01b0316333087611f2e565b6001600160a01b03831660009081526101676020526040812080548692906111a590849061301a565b9091555093949350505050565b60006111be81806111c3565b905090565b60008281526097602052604081206111db9083611f66565b9392505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006000805160206132c1833981519152611228813361163f565b600080516020613341833981519152611241813361163f565b6000805160206132e18339815191526112598161129f565b15801561126d575061126b600061129f565b155b6112895760405162461bcd60e51b81526004016108f990612e8e565b6112938686611c91565b50600195945050505050565b600090815260c9602052604090205460ff1690565b60006000805160206133618339815191526112ce8161129f565b1580156112e257506112e0600061129f565b155b6112fe5760405162461bcd60e51b81526004016108f990612e8e565b610166546001600160a01b0316331461131657600080fd5b60006113228685611f72565b90506001600160a01b03811661134a5760405162461bcd60e51b81526004016108f990612fef565b6113543386611c91565b806001600160a01b0316866001600160a01b03166000805160206131b58339815191528760405161138791815260200190565b60405180910390a350600195945050505050565b60006113a7813361163f565b6113bf6000805160206132c1833981519152846111e2565b6113db5760405162461bcd60e51b81526004016108f990612f09565b506001600160a01b0390911660009081526101636020526040902060010155565b60008181526097602052604081206109cc90611fa2565b610c878282611fac565b6101305460405163bf40fac160e01b815260206004820152600a60248201526923a7a7a22227a62620a960b11b60448201526000916001600160a01b03169063bf40fac19060640160206040518083038186803b15801561147d57600080fd5b505afa158015611491573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111be9190612eec565b60006000805160206132c18339815191526114d0813361163f565b6000805160206133218339815191526114e9813361163f565b6000805160206133618339815191526115018161129f565b1580156115155750611513600061129f565b155b6115315760405162461bcd60e51b81526004016108f990612e8e565b61153b8686611987565b856001600160a01b0316877f05d0634fe981be85c22e2942a880821b70095d84e152c3ea3c17a4e4250d9d618760405161157791815260200190565b60405180910390a35060019695505050505050565b6000611598813361163f565b610bc982611fc9565b60006115ad813361163f565b5061016455565b610baf8363a9059cbb60e01b84846040516024016115d3929190613032565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261204e565b60006001600160e01b03198216637965db0b60e01b14806109cc57506301ffc9a760e01b6001600160e01b03198316146109cc565b61164982826111e2565b610bc957611661816001600160a01b03166014612120565b61166c836020612120565b60405160200161167d929190613077565b60408051601f198184030181529082905262461bcd60e51b82526108f9916004016130e6565b6116ac82610b78565b6116b6813361163f565b610baf83836122bb565b60006111db836001600160a01b038416612341565b806116df8161129f565b806116ef57506116ef600061129f565b6117395760405162461bcd60e51b815260206004820152601b60248201527a14185d5cd8589b1950dbdb9d1c9bdb0e881b9bdd081c185d5cd959602a1b60448201526064016108f9565b600082815260c9602052604090819020805460ff19169055517fd05bfc2250abb0f8fd265a54c53a24359c5484af63cad2e4ce87c78ab751395a906117819084815260200190565b60405180910390a15050565b6001600160a01b03811633146117fd5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016108f9565b610bc98282612390565b60006111db836001600160a01b0384166123f7565b600080516020613235833981519152546001600160a01b031690565b610d656124ea565b600061184a61181c565b9050611855846125bf565b6000835111806118625750815b15611873576118718484612652565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff1661198057805460ff191660011781556040516118ee9086906118bf908590602401612c36565b60408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b179052612652565b50805460ff191681556118ff61181c565b6001600160a01b0316826001600160a01b0316146119775760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b60648201526084016108f9565b6119808561273d565b5050505050565b6000805160206131f583398151915261199f8161129f565b1580156119b357506119b1600061129f565b155b6119cf5760405162461bcd60e51b81526004016108f990612e8e565b6001600160a01b038316301415611a275760405162461bcd60e51b815260206004820152601c60248201527b666f72626964206d696e7420746f206164647265737328746869732960201b60448201526064016108f9565b336000908152610163602052604090208054831115611a7e5760405162461bcd60e51b81526020600482015260136024820152721b5a5b9d195c881b585e08195e18d959591959606a1b60448201526064016108f9565b82816002016000828254611a92919061301a565b9091555050600181015460028201541115611ae55760405162461bcd60e51b81526020600482015260136024820152721b5a5b9d195c8818d85c08195e18d959591959606a1b60448201526064016108f9565b826101656000828254611af8919061301a565b909155505061016454610165541115611b4d5760405162461bcd60e51b81526020600482015260176024820152761d1bdd185b081b5a5b9d0818d85c08195e18d959591959604a1b60448201526064016108f9565b600361016654600160a01b900460ff166004811115611b6e57611b6e612ba8565b1480611b985750600461016654600160a01b900460ff166004811115611b9657611b96612ba8565b145b15611bba5761016654611bb5906001600160a01b031685856115b4565b611bd2565b61016654611bd2906001600160a01b0316858561277d565b50505050565b600054610100900460ff1680611bf1575060005460ff16155b611c0d5760405162461bcd60e51b81526004016108f990612fa1565b600054610100900460ff16158015611c2f576000805461ffff19166101011790555b611c376127ca565b611c3f6127ca565b611c476127ca565b611c4f6127ca565b8015610d65576000805461ff001916905550565b610b978282612834565b61013080546001600160a01b0319166001600160a01b038316179055610d656109d2565b60008051602061327a833981519152611ca98161129f565b158015611cbd5750611cbb600061129f565b155b611cd95760405162461bcd60e51b81526004016108f990612e8e565b6001600160a01b038316301415611d325760405162461bcd60e51b815260206004820152601e60248201527f666f72626964206275726e2066726f6d2061646472657373287468697329000060448201526064016108f9565b816101655410611d5a57816101656000828254611d4f9190612ed5565b90915550611d619050565b6000610165555b611d796000805160206132c1833981519152336111e2565b15611dc2573360009081526101636020526040902060028101548311611db85782816002016000828254611dad9190612ed5565b90915550611dc09050565b600060028201555b505b610166546001600160a01b0384811691161415611df05761016654610baf906001600160a01b03168361283e565b600361016654600160a01b900460ff166004811115611e1157611e11612ba8565b1480611e3b5750600461016654600160a01b900460ff166004811115611e3957611e39612ba8565b145b15611e595761016654610baf906001600160a01b0316843085611f2e565b600061016654600160a01b900460ff166004811115611e7a57611e7a612ba8565b1415611e985761016654610baf906001600160a01b0316848461285a565b600161016654600160a01b900460ff166004811115611eb957611eb9612ba8565b1415611ed75761016654610baf906001600160a01b03168484612876565b600261016654600160a01b900460ff166004811115611ef857611ef8612ba8565b1415610baf5761016654611f17906001600160a01b0316843085611f2e565b61016654610baf906001600160a01b03168361283e565b6040516001600160a01b0380851660248301528316604482015260648101829052611bd29085906323b872dd60e01b906084016115d3565b60006111db8383612892565b80518290156109cc578151601414611f8957600080fd5b5060148101516001600160a01b0381166109cc57600080fd5b60006109cc825490565b611fb582610b78565b611fbf813361163f565b610baf8383612390565b80611fd38161129f565b158015611fe75750611fe5600061129f565b155b6120035760405162461bcd60e51b81526004016108f990612e8e565b600082815260c9602052604090819020805460ff19166001179055517f0cb09dc71d57eeec2046f6854976717e4874a3cf2d6ddeddde337e5b6de6ba31906117819084815260200190565b60006120a3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166128bc9092919063ffffffff16565b805190915015610baf57808060200190518101906120c19190613119565b610baf5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108f9565b6060600061212f836002613136565b61213a90600261301a565b6001600160401b0381111561215157612151612ceb565b6040519080825280601f01601f19166020018201604052801561217b576020820181803683370190505b509050600360fc1b8160008151811061219657612196613155565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106121c5576121c5613155565b60200101906001600160f81b031916908160001a90535060006121e9846002613136565b6121f490600161301a565b90505b600181111561226c576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061222857612228613155565b1a60f81b82828151811061223e5761223e613155565b60200101906001600160f81b031916908160001a90535060049490941c936122658161316b565b90506121f7565b5083156111db5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016108f9565b6122c582826111e2565b610bc95760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556122fd3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000818152600183016020526040812054612388575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556109cc565b5060006109cc565b61239a82826111e2565b15610bc95760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081815260018301602052604081205480156124e057600061241b600183612ed5565b855490915060009061242f90600190612ed5565b905081811461249457600086600001828154811061244f5761244f613155565b906000526020600020015490508087600001848154811061247257612472613155565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806124a5576124a5613182565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506109cc565b60009150506109cc565b61012e5460408051632d77bef360e11b8152905133926001600160a01b031691635aef7de6916004808301926020929190829003018186803b15801561252f57600080fd5b505afa158015612543573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125679190612eec565b6001600160a01b0316146125bd5760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79206176617461722063616e2063616c6c2074686973206d6574686f6460448201526064016108f9565b565b803b6126235760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016108f9565b60008051602061323583398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b6126b15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016108f9565b600080846001600160a01b0316846040516126cc9190613198565b600060405180830381855af49150503d8060008114612707576040519150601f19603f3d011682016040523d82523d6000602084013e61270c565b606091505b5091509150612734828260405180606001604052806027815260200161329a602791396128d3565b95945050505050565b612746816125bf565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b610baf836340c10f198484604051602401612799929190613032565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505061290c565b600054610100900460ff16806127e3575060005460ff16155b6127ff5760405162461bcd60e51b81526004016108f990612fa1565b600054610100900460ff16158015611c4f576000805461ffff19166101011790558015610d65576000805461ff001916905550565b610bc982826122bb565b610bc9826342966c688360405160240161279991815260200190565b610baf83639dc29fac8484604051602401612799929190613032565b610baf836379cc67908484604051602401612799929190613032565b60008260000182815481106128a9576128a9613155565b9060005260206000200154905092915050565b60606128cb84846000856129a6565b949350505050565b606083156128e25750816111db565b8251156128f25782518084602001fd5b8160405162461bcd60e51b81526004016108f991906130e6565b600061293c82604051806060016040528060258152602001613255602591396001600160a01b03861691906128bc565b805190915015610baf578080602001905181019061295a9190613119565b610baf5760405162461bcd60e51b815260206004820152601f60248201527f546f6b656e4f7065726174696f6e3a20646964206e6f7420737563636565640060448201526064016108f9565b606082471015612a075760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016108f9565b6001600160a01b0385163b612a5e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108f9565b600080866001600160a01b03168587604051612a7a9190613198565b60006040518083038185875af1925050503d8060008114612ab7576040519150601f19603f3d011682016040523d82523d6000602084013e612abc565b606091505b5091509150612acc8282866128d3565b979650505050505050565b6001600160a01b0381168114610d6557600080fd5b60008060408385031215612aff57600080fd5b823591506020830135612b1181612ad7565b809150509250929050565b600060208284031215612b2e57600080fd5b81356001600160e01b0319811681146111db57600080fd5b60008060408385031215612b5957600080fd5b8235612b6481612ad7565b946020939093013593505050565b600060208284031215612b8457600080fd5b5035919050565b600060208284031215612b9d57600080fd5b81356111db81612ad7565b634e487b7160e01b600052602160045260246000fd5b6020810160058310612be057634e487b7160e01b600052602160045260246000fd5b91905290565b8015158114610d6557600080fd5b600080600060608486031215612c0957600080fd5b8335612c1481612ad7565b9250602084013591506040840135612c2b81612be6565b809150509250925092565b6001600160a01b0391909116815260200190565b600080600060608486031215612c5f57600080fd5b8335612c6a81612ad7565b95602085013595506040909401359392505050565b600080600080600060a08688031215612c9757600080fd5b8535612ca281612ad7565b9450602086013560058110612cb657600080fd5b9350604086013592506060860135612ccd81612ad7565b91506080860135612cdd81612ad7565b809150509295509295909350565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612d1257600080fd5b81356001600160401b0380821115612d2c57612d2c612ceb565b604051601f8301601f19908116603f01168101908282118183101715612d5457612d54612ceb565b81604052838152866020858801011115612d6d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060408385031215612da057600080fd5b8235612dab81612ad7565b915060208301356001600160401b03811115612dc657600080fd5b612dd285828601612d01565b9150509250929050565b60008060408385031215612def57600080fd5b50508035926020909101359150565b600080600060608486031215612e1357600080fd5b8335612e1e81612ad7565b92506020840135915060408401356001600160401b03811115612e4057600080fd5b612e4c86828701612d01565b9150509250925092565b600080600060608486031215612e6b57600080fd5b833592506020840135612e7d81612ad7565b929592945050506040919091013590565b60208082526017908201527614185d5cd8589b1950dbdb9d1c9bdb0e881c185d5cd959604a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082821015612ee757612ee7612ebf565b500390565b600060208284031215612efe57600080fd5b81516111db81612ad7565b6020808252600a90820152693737ba1036b4b73a32b960b11b604082015260600190565b6020808252602c9082015260008051602061321583398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c9082015260008051602061321583398151915260408201526b6163746976652070726f787960a01b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252601190820152707a65726f2062696e64206164647265737360781b604082015260600190565b6000821982111561302d5761302d612ebf565b500190565b6001600160a01b03929092168252602082015260400190565b60005b8381101561306657818101518382015260200161304e565b83811115611bd25750506000910152565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8152600083516130a981601785016020880161304b565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516130da81602884016020880161304b565b01602801949350505050565b602081526000825180602084015261310581604085016020870161304b565b601f01601f19169190910160400192915050565b60006020828403121561312b57600080fd5b81516111db81612be6565b600081600019048311821515161561315057613150612ebf565b500290565b634e487b7160e01b600052603260045260246000fd5b60008161317a5761317a612ebf565b506000190190565b634e487b7160e01b600052603160045260246000fd5b600082516131aa81846020870161304b565b919091019291505056fe6b616089d04950dc06c45c6dd787d657980543f89651aec47924752c7d16c888ac0c39a5c83dc0f0439e3faa066bf234104d51dfdc9693b11d7ad30f9652c454b2a18ae5d0b623b41098012c516d0bf4bef38c068c9e397da870c290888b199946756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546f6b656e4f7065726174696f6e3a206c6f772d6c6576656c2063616c6c206661696c656462d52416825983abd68b16e092b60c2eac31fd673bcce92494e063af530d9c30416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65649f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6b601d6a8ea5419a4251765936e52b2763485fede82d3c5dfd765cd67d30f4f22b5c32c5338a4841f17325e04d19d70ce58ad8cd21338b36459d998d0c6d0bc3e52ba824bfabc2bcfcdf7f0edbb486ebb05e1836c90e78047efeb949990f72e5f7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb27f8fb7f5e4c579eb0a2032178073be2893ceada4943265be25b2272b1c6a73a1a264697066735822122005e204a12756170208eb0020fb57895722ec68466ad4776a8213b3e5e2bd4d1564736f6c63430008080033
Deployed ByteCode
0x6080604052600436106102385760003560e01c8062f714ce1461023d57806301ffc9a71461027057806303ca49f1146102a05780631296023f146102b75780631b3c90a8146102d957806323fb9eba146102f0578063248a9ca314610310578063250e0dc5146103305780632f2ff15d146103525780632f4dae9f146103725780633092afd51461039257806330d643b5146103b257806330fa738c146103d457806335e1d4871461040357806336568abe146104235780633659cfe6146104435780633e6326fc14610463578063401d1c731461049157806340c10f19146104b15780634162169f146104d157806342c83492146104f25780634f1ef286146105125780635955b592146105255780635aef7de614610547578063628d6cba146105685780636e553f651461058857806378ae8ea2146105a85780638da5cb5b146105ca5780639010d07c146105df57806391d14854146105ff578063956092121461061f578063956501bb146106775780639ac25d08146106a55780639dc29fac146106ba5780639e9e4666146106da578063a19ff680146106fa578063a217fddf146106a5578063a2309ff81461071c578063a4c0ed3614610733578063b32ad1a614610753578063b5bfddea14610775578063c8e1b4ce14610797578063ca15c873146107b7578063d5391393146107d7578063d547741f146107f9578063e1758bd814610819578063ec126c771461082e578063ed56531a1461084e578063efdaffc51461086e578063fc0c546a1461088e575b600080fd5b34801561024957600080fd5b5061025d610258366004612aec565b6108af565b6040519081526020015b60405180910390f35b34801561027c57600080fd5b5061029061028b366004612b1c565b6109a7565b6040519015158152602001610267565b3480156102ac57600080fd5b5061025d6101645481565b3480156102c357600080fd5b5061025d60008051602061336183398151915281565b3480156102e557600080fd5b506102ee6109d2565b005b3480156102fc57600080fd5b506102ee61030b366004612b46565b610b1a565b34801561031c57600080fd5b5061025d61032b366004612b72565b610b78565b34801561033c57600080fd5b5061025d6000805160206131d583398151915281565b34801561035e57600080fd5b506102ee61036d366004612aec565b610b8d565b34801561037e57600080fd5b506102ee61038d366004612b72565b610bb4565b34801561039e57600080fd5b506102ee6103ad366004612b8b565b610bcd565b3480156103be57600080fd5b5061025d60008051602061334183398151915281565b3480156103e057600080fd5b50610166546103f690600160a01b900460ff1681565b6040516102679190612bbe565b34801561040f57600080fd5b506102ee61041e366004612bf4565b610c14565b34801561042f57600080fd5b506102ee61043e366004612aec565b610c7d565b34801561044f57600080fd5b506102ee61045e366004612b8b565b610c9f565b34801561046f57600080fd5b5061013054610484906001600160a01b031681565b6040516102679190612c36565b34801561049d57600080fd5b506102ee6104ac366004612c4a565b610d68565b3480156104bd57600080fd5b506102906104cc366004612b46565b610db2565b3480156104dd57600080fd5b5061012e54610484906001600160a01b031681565b3480156104fe57600080fd5b506102ee61050d366004612c7f565b610de1565b6102ee610520366004612d8d565b610f52565b34801561053157600080fd5b5061025d6000805160206132e183398151915281565b34801561055357600080fd5b5061012f54610484906001600160a01b031681565b34801561057457600080fd5b50610290610583366004612aec565b611008565b34801561059457600080fd5b5061025d6105a3366004612aec565b6110ba565b3480156105b457600080fd5b5061025d60008051602061330183398151915281565b3480156105d657600080fd5b506104846111b2565b3480156105eb57600080fd5b506104846105fa366004612ddc565b6111c3565b34801561060b57600080fd5b5061029061061a366004612aec565b6111e2565b34801561062b57600080fd5b5061065c61063a366004612b8b565b6101636020526000908152604090208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610267565b34801561068357600080fd5b5061025d610692366004612b8b565b6101676020526000908152604090205481565b3480156106b157600080fd5b5061025d600081565b3480156106c657600080fd5b506102906106d5366004612b46565b61120d565b3480156106e657600080fd5b506102906106f5366004612b72565b61129f565b34801561070657600080fd5b5061025d60008051602061327a83398151915281565b34801561072857600080fd5b5061025d6101655481565b34801561073f57600080fd5b5061029061074e366004612dfe565b6112b4565b34801561075f57600080fd5b5061025d6000805160206131f583398151915281565b34801561078157600080fd5b5061025d60008051602061332183398151915281565b3480156107a357600080fd5b506102ee6107b2366004612b46565b61139b565b3480156107c357600080fd5b5061025d6107d2366004612b72565b6113fc565b3480156107e357600080fd5b5061025d6000805160206132c183398151915281565b34801561080557600080fd5b506102ee610814366004612aec565b611413565b34801561082557600080fd5b5061048461141d565b34801561083a57600080fd5b50610290610849366004612e56565b6114b5565b34801561085a57600080fd5b506102ee610869366004612b72565b61158c565b34801561087a57600080fd5b506102ee610889366004612b72565b6115a1565b34801561089a57600080fd5b5061016654610484906001600160a01b031681565b60006000805160206133018339815191526108c98161129f565b1580156108dd57506108db600061129f565b155b6109025760405162461bcd60e51b81526004016108f990612e8e565b60405180910390fd5b600461016654600160a01b900460ff16600481111561092357610923612ba8565b146109625760405162461bcd60e51b815260206004820152600f60248201526e666f7262696420776974686472617760881b60448201526064016108f9565b336000908152610167602052604081208054869290610982908490612ed5565b90915550506101665461099f906001600160a01b031684866115b4565b509192915050565b60006001600160e01b03198216635a05180f60e01b14806109cc57506109cc8261160a565b92915050565b6101305460405163bf40fac160e01b815260206004820152600a60248201526921a7a72a2927a62622a960b11b60448201526001600160a01b039091169063bf40fac19060640160206040518083038186803b158015610a3157600080fd5b505afa158015610a45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a699190612eec565b61012e80546001600160a01b0319166001600160a01b0392909216918217905560408051632d77bef360e11b81529051635aef7de691600480820192602092909190829003018186803b158015610abf57600080fd5b505afa158015610ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af79190612eec565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b26813361163f565b610b3e6000805160206132c1833981519152846111e2565b610b5a5760405162461bcd60e51b81526004016108f990612f09565b506001600160a01b0390911660009081526101636020526040902055565b60009081526065602052604090206001015490565b610b9782826116a3565b6000828152609760205260409020610baf90826116c0565b505050565b6000610bc0813361163f565b610bc9826116d5565b5050565b6000610bd9813361163f565b610bf16000805160206132c183398151915283611413565b506001600160a01b03166000908152610163602052604081206001810182905555565b6000610c20813361163f565b8180610c3f5750610c3f6000805160206132c1833981519152856111e2565b610c5b5760405162461bcd60e51b81526004016108f990612f09565b50506001600160a01b0390911660009081526101636020526040902060020155565b610c87828261178d565b6000828152609760205260409020610baf9082611807565b306001600160a01b037f000000000000000000000000b0b86dd967655728218b7b87b10051a60758af82161415610ce85760405162461bcd60e51b81526004016108f990612f2d565b7f000000000000000000000000b0b86dd967655728218b7b87b10051a60758af826001600160a01b0316610d1a61181c565b6001600160a01b031614610d405760405162461bcd60e51b81526004016108f990612f67565b610d4981611838565b60408051600080825260208201909252610d6591839190611840565b50565b6000610d74813361163f565b610d8c6000805160206132c183398151915285610b8d565b506001600160a01b03909216600090815261016360205260409020600181019190915555565b60006000805160206132c1833981519152610dcd813361163f565b610dd78484611987565b5060019392505050565b600054610100900460ff1680610dfa575060005460ff16155b610e165760405162461bcd60e51b81526004016108f990612fa1565b600054610100900460ff16158015610e38576000805461ffff19166101011790555b610e40611bd8565b6001600160a01b038616610e8b5760405162461bcd60e51b81526020600482015260126024820152717a65726f20746f6b656e206164647265737360701b60448201526064016108f9565b6001600160a01b038316610ed65760405162461bcd60e51b81526020600482015260126024820152717a65726f2061646d696e206164647265737360701b60448201526064016108f9565b61016680546001600160a01b0388166001600160a01b03198216811783558792916001600160a81b03191617600160a01b836004811115610f1957610f19612ba8565b0217905550610164849055610f2f600084611c63565b610f3882611c6d565b8015610f4a576000805461ff00191690555b505050505050565b306001600160a01b037f000000000000000000000000b0b86dd967655728218b7b87b10051a60758af82161415610f9b5760405162461bcd60e51b81526004016108f990612f2d565b7f000000000000000000000000b0b86dd967655728218b7b87b10051a60758af826001600160a01b0316610fcd61181c565b6001600160a01b031614610ff35760405162461bcd60e51b81526004016108f990612f67565b610ffc82611838565b610bc982826001611840565b60006000805160206133618339815191526110228161129f565b1580156110365750611034600061129f565b155b6110525760405162461bcd60e51b81526004016108f990612e8e565b6001600160a01b0383166110785760405162461bcd60e51b81526004016108f990612fef565b6110823385611c91565b6040518481526001600160a01b0384169033906000805160206131b58339815191529060200160405180910390a35060019392505050565b60006000805160206131d58339815191526110d48161129f565b1580156110e857506110e6600061129f565b155b6111045760405162461bcd60e51b81526004016108f990612e8e565b600461016654600160a01b900460ff16600481111561112557611125612ba8565b146111635760405162461bcd60e51b815260206004820152600e60248201526d199bdc989a590819195c1bda5cdd60921b60448201526064016108f9565b6101665461117c906001600160a01b0316333087611f2e565b6001600160a01b03831660009081526101676020526040812080548692906111a590849061301a565b9091555093949350505050565b60006111be81806111c3565b905090565b60008281526097602052604081206111db9083611f66565b9392505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006000805160206132c1833981519152611228813361163f565b600080516020613341833981519152611241813361163f565b6000805160206132e18339815191526112598161129f565b15801561126d575061126b600061129f565b155b6112895760405162461bcd60e51b81526004016108f990612e8e565b6112938686611c91565b50600195945050505050565b600090815260c9602052604090205460ff1690565b60006000805160206133618339815191526112ce8161129f565b1580156112e257506112e0600061129f565b155b6112fe5760405162461bcd60e51b81526004016108f990612e8e565b610166546001600160a01b0316331461131657600080fd5b60006113228685611f72565b90506001600160a01b03811661134a5760405162461bcd60e51b81526004016108f990612fef565b6113543386611c91565b806001600160a01b0316866001600160a01b03166000805160206131b58339815191528760405161138791815260200190565b60405180910390a350600195945050505050565b60006113a7813361163f565b6113bf6000805160206132c1833981519152846111e2565b6113db5760405162461bcd60e51b81526004016108f990612f09565b506001600160a01b0390911660009081526101636020526040902060010155565b60008181526097602052604081206109cc90611fa2565b610c878282611fac565b6101305460405163bf40fac160e01b815260206004820152600a60248201526923a7a7a22227a62620a960b11b60448201526000916001600160a01b03169063bf40fac19060640160206040518083038186803b15801561147d57600080fd5b505afa158015611491573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111be9190612eec565b60006000805160206132c18339815191526114d0813361163f565b6000805160206133218339815191526114e9813361163f565b6000805160206133618339815191526115018161129f565b1580156115155750611513600061129f565b155b6115315760405162461bcd60e51b81526004016108f990612e8e565b61153b8686611987565b856001600160a01b0316877f05d0634fe981be85c22e2942a880821b70095d84e152c3ea3c17a4e4250d9d618760405161157791815260200190565b60405180910390a35060019695505050505050565b6000611598813361163f565b610bc982611fc9565b60006115ad813361163f565b5061016455565b610baf8363a9059cbb60e01b84846040516024016115d3929190613032565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261204e565b60006001600160e01b03198216637965db0b60e01b14806109cc57506301ffc9a760e01b6001600160e01b03198316146109cc565b61164982826111e2565b610bc957611661816001600160a01b03166014612120565b61166c836020612120565b60405160200161167d929190613077565b60408051601f198184030181529082905262461bcd60e51b82526108f9916004016130e6565b6116ac82610b78565b6116b6813361163f565b610baf83836122bb565b60006111db836001600160a01b038416612341565b806116df8161129f565b806116ef57506116ef600061129f565b6117395760405162461bcd60e51b815260206004820152601b60248201527a14185d5cd8589b1950dbdb9d1c9bdb0e881b9bdd081c185d5cd959602a1b60448201526064016108f9565b600082815260c9602052604090819020805460ff19169055517fd05bfc2250abb0f8fd265a54c53a24359c5484af63cad2e4ce87c78ab751395a906117819084815260200190565b60405180910390a15050565b6001600160a01b03811633146117fd5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016108f9565b610bc98282612390565b60006111db836001600160a01b0384166123f7565b600080516020613235833981519152546001600160a01b031690565b610d656124ea565b600061184a61181c565b9050611855846125bf565b6000835111806118625750815b15611873576118718484612652565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff1661198057805460ff191660011781556040516118ee9086906118bf908590602401612c36565b60408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b179052612652565b50805460ff191681556118ff61181c565b6001600160a01b0316826001600160a01b0316146119775760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b60648201526084016108f9565b6119808561273d565b5050505050565b6000805160206131f583398151915261199f8161129f565b1580156119b357506119b1600061129f565b155b6119cf5760405162461bcd60e51b81526004016108f990612e8e565b6001600160a01b038316301415611a275760405162461bcd60e51b815260206004820152601c60248201527b666f72626964206d696e7420746f206164647265737328746869732960201b60448201526064016108f9565b336000908152610163602052604090208054831115611a7e5760405162461bcd60e51b81526020600482015260136024820152721b5a5b9d195c881b585e08195e18d959591959606a1b60448201526064016108f9565b82816002016000828254611a92919061301a565b9091555050600181015460028201541115611ae55760405162461bcd60e51b81526020600482015260136024820152721b5a5b9d195c8818d85c08195e18d959591959606a1b60448201526064016108f9565b826101656000828254611af8919061301a565b909155505061016454610165541115611b4d5760405162461bcd60e51b81526020600482015260176024820152761d1bdd185b081b5a5b9d0818d85c08195e18d959591959604a1b60448201526064016108f9565b600361016654600160a01b900460ff166004811115611b6e57611b6e612ba8565b1480611b985750600461016654600160a01b900460ff166004811115611b9657611b96612ba8565b145b15611bba5761016654611bb5906001600160a01b031685856115b4565b611bd2565b61016654611bd2906001600160a01b0316858561277d565b50505050565b600054610100900460ff1680611bf1575060005460ff16155b611c0d5760405162461bcd60e51b81526004016108f990612fa1565b600054610100900460ff16158015611c2f576000805461ffff19166101011790555b611c376127ca565b611c3f6127ca565b611c476127ca565b611c4f6127ca565b8015610d65576000805461ff001916905550565b610b978282612834565b61013080546001600160a01b0319166001600160a01b038316179055610d656109d2565b60008051602061327a833981519152611ca98161129f565b158015611cbd5750611cbb600061129f565b155b611cd95760405162461bcd60e51b81526004016108f990612e8e565b6001600160a01b038316301415611d325760405162461bcd60e51b815260206004820152601e60248201527f666f72626964206275726e2066726f6d2061646472657373287468697329000060448201526064016108f9565b816101655410611d5a57816101656000828254611d4f9190612ed5565b90915550611d619050565b6000610165555b611d796000805160206132c1833981519152336111e2565b15611dc2573360009081526101636020526040902060028101548311611db85782816002016000828254611dad9190612ed5565b90915550611dc09050565b600060028201555b505b610166546001600160a01b0384811691161415611df05761016654610baf906001600160a01b03168361283e565b600361016654600160a01b900460ff166004811115611e1157611e11612ba8565b1480611e3b5750600461016654600160a01b900460ff166004811115611e3957611e39612ba8565b145b15611e595761016654610baf906001600160a01b0316843085611f2e565b600061016654600160a01b900460ff166004811115611e7a57611e7a612ba8565b1415611e985761016654610baf906001600160a01b0316848461285a565b600161016654600160a01b900460ff166004811115611eb957611eb9612ba8565b1415611ed75761016654610baf906001600160a01b03168484612876565b600261016654600160a01b900460ff166004811115611ef857611ef8612ba8565b1415610baf5761016654611f17906001600160a01b0316843085611f2e565b61016654610baf906001600160a01b03168361283e565b6040516001600160a01b0380851660248301528316604482015260648101829052611bd29085906323b872dd60e01b906084016115d3565b60006111db8383612892565b80518290156109cc578151601414611f8957600080fd5b5060148101516001600160a01b0381166109cc57600080fd5b60006109cc825490565b611fb582610b78565b611fbf813361163f565b610baf8383612390565b80611fd38161129f565b158015611fe75750611fe5600061129f565b155b6120035760405162461bcd60e51b81526004016108f990612e8e565b600082815260c9602052604090819020805460ff19166001179055517f0cb09dc71d57eeec2046f6854976717e4874a3cf2d6ddeddde337e5b6de6ba31906117819084815260200190565b60006120a3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166128bc9092919063ffffffff16565b805190915015610baf57808060200190518101906120c19190613119565b610baf5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108f9565b6060600061212f836002613136565b61213a90600261301a565b6001600160401b0381111561215157612151612ceb565b6040519080825280601f01601f19166020018201604052801561217b576020820181803683370190505b509050600360fc1b8160008151811061219657612196613155565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106121c5576121c5613155565b60200101906001600160f81b031916908160001a90535060006121e9846002613136565b6121f490600161301a565b90505b600181111561226c576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061222857612228613155565b1a60f81b82828151811061223e5761223e613155565b60200101906001600160f81b031916908160001a90535060049490941c936122658161316b565b90506121f7565b5083156111db5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016108f9565b6122c582826111e2565b610bc95760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556122fd3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000818152600183016020526040812054612388575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556109cc565b5060006109cc565b61239a82826111e2565b15610bc95760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081815260018301602052604081205480156124e057600061241b600183612ed5565b855490915060009061242f90600190612ed5565b905081811461249457600086600001828154811061244f5761244f613155565b906000526020600020015490508087600001848154811061247257612472613155565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806124a5576124a5613182565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506109cc565b60009150506109cc565b61012e5460408051632d77bef360e11b8152905133926001600160a01b031691635aef7de6916004808301926020929190829003018186803b15801561252f57600080fd5b505afa158015612543573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125679190612eec565b6001600160a01b0316146125bd5760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79206176617461722063616e2063616c6c2074686973206d6574686f6460448201526064016108f9565b565b803b6126235760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016108f9565b60008051602061323583398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b6126b15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016108f9565b600080846001600160a01b0316846040516126cc9190613198565b600060405180830381855af49150503d8060008114612707576040519150601f19603f3d011682016040523d82523d6000602084013e61270c565b606091505b5091509150612734828260405180606001604052806027815260200161329a602791396128d3565b95945050505050565b612746816125bf565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b610baf836340c10f198484604051602401612799929190613032565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505061290c565b600054610100900460ff16806127e3575060005460ff16155b6127ff5760405162461bcd60e51b81526004016108f990612fa1565b600054610100900460ff16158015611c4f576000805461ffff19166101011790558015610d65576000805461ff001916905550565b610bc982826122bb565b610bc9826342966c688360405160240161279991815260200190565b610baf83639dc29fac8484604051602401612799929190613032565b610baf836379cc67908484604051602401612799929190613032565b60008260000182815481106128a9576128a9613155565b9060005260206000200154905092915050565b60606128cb84846000856129a6565b949350505050565b606083156128e25750816111db565b8251156128f25782518084602001fd5b8160405162461bcd60e51b81526004016108f991906130e6565b600061293c82604051806060016040528060258152602001613255602591396001600160a01b03861691906128bc565b805190915015610baf578080602001905181019061295a9190613119565b610baf5760405162461bcd60e51b815260206004820152601f60248201527f546f6b656e4f7065726174696f6e3a20646964206e6f7420737563636565640060448201526064016108f9565b606082471015612a075760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016108f9565b6001600160a01b0385163b612a5e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108f9565b600080866001600160a01b03168587604051612a7a9190613198565b60006040518083038185875af1925050503d8060008114612ab7576040519150601f19603f3d011682016040523d82523d6000602084013e612abc565b606091505b5091509150612acc8282866128d3565b979650505050505050565b6001600160a01b0381168114610d6557600080fd5b60008060408385031215612aff57600080fd5b823591506020830135612b1181612ad7565b809150509250929050565b600060208284031215612b2e57600080fd5b81356001600160e01b0319811681146111db57600080fd5b60008060408385031215612b5957600080fd5b8235612b6481612ad7565b946020939093013593505050565b600060208284031215612b8457600080fd5b5035919050565b600060208284031215612b9d57600080fd5b81356111db81612ad7565b634e487b7160e01b600052602160045260246000fd5b6020810160058310612be057634e487b7160e01b600052602160045260246000fd5b91905290565b8015158114610d6557600080fd5b600080600060608486031215612c0957600080fd5b8335612c1481612ad7565b9250602084013591506040840135612c2b81612be6565b809150509250925092565b6001600160a01b0391909116815260200190565b600080600060608486031215612c5f57600080fd5b8335612c6a81612ad7565b95602085013595506040909401359392505050565b600080600080600060a08688031215612c9757600080fd5b8535612ca281612ad7565b9450602086013560058110612cb657600080fd5b9350604086013592506060860135612ccd81612ad7565b91506080860135612cdd81612ad7565b809150509295509295909350565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612d1257600080fd5b81356001600160401b0380821115612d2c57612d2c612ceb565b604051601f8301601f19908116603f01168101908282118183101715612d5457612d54612ceb565b81604052838152866020858801011115612d6d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060408385031215612da057600080fd5b8235612dab81612ad7565b915060208301356001600160401b03811115612dc657600080fd5b612dd285828601612d01565b9150509250929050565b60008060408385031215612def57600080fd5b50508035926020909101359150565b600080600060608486031215612e1357600080fd5b8335612e1e81612ad7565b92506020840135915060408401356001600160401b03811115612e4057600080fd5b612e4c86828701612d01565b9150509250925092565b600080600060608486031215612e6b57600080fd5b833592506020840135612e7d81612ad7565b929592945050506040919091013590565b60208082526017908201527614185d5cd8589b1950dbdb9d1c9bdb0e881c185d5cd959604a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082821015612ee757612ee7612ebf565b500390565b600060208284031215612efe57600080fd5b81516111db81612ad7565b6020808252600a90820152693737ba1036b4b73a32b960b11b604082015260600190565b6020808252602c9082015260008051602061321583398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c9082015260008051602061321583398151915260408201526b6163746976652070726f787960a01b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252601190820152707a65726f2062696e64206164647265737360781b604082015260600190565b6000821982111561302d5761302d612ebf565b500190565b6001600160a01b03929092168252602082015260400190565b60005b8381101561306657818101518382015260200161304e565b83811115611bd25750506000910152565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8152600083516130a981601785016020880161304b565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516130da81602884016020880161304b565b01602801949350505050565b602081526000825180602084015261310581604085016020870161304b565b601f01601f19169190910160400192915050565b60006020828403121561312b57600080fd5b81516111db81612be6565b600081600019048311821515161561315057613150612ebf565b500290565b634e487b7160e01b600052603260045260246000fd5b60008161317a5761317a612ebf565b506000190190565b634e487b7160e01b600052603160045260246000fd5b600082516131aa81846020870161304b565b919091019291505056fe6b616089d04950dc06c45c6dd787d657980543f89651aec47924752c7d16c888ac0c39a5c83dc0f0439e3faa066bf234104d51dfdc9693b11d7ad30f9652c454b2a18ae5d0b623b41098012c516d0bf4bef38c068c9e397da870c290888b199946756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546f6b656e4f7065726174696f6e3a206c6f772d6c6576656c2063616c6c206661696c656462d52416825983abd68b16e092b60c2eac31fd673bcce92494e063af530d9c30416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65649f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6b601d6a8ea5419a4251765936e52b2763485fede82d3c5dfd765cd67d30f4f22b5c32c5338a4841f17325e04d19d70ce58ad8cd21338b36459d998d0c6d0bc3e52ba824bfabc2bcfcdf7f0edbb486ebb05e1836c90e78047efeb949990f72e5f7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb27f8fb7f5e4c579eb0a2032178073be2893ceada4943265be25b2272b1c6a73a1a264697066735822122005e204a12756170208eb0020fb57895722ec68466ad4776a8213b3e5e2bd4d1564736f6c63430008080033