More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 122 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Set Enabled | 20068601 | 181 days ago | IN | 0 ETH | 0.00023688 | ||||
Withdraw Liquidi... | 18980743 | 334 days ago | IN | 0 ETH | 0.00215736 | ||||
Withdraw Liquidi... | 18713375 | 371 days ago | IN | 0 ETH | 0.00431705 | ||||
Pay Back Loan | 18566536 | 392 days ago | IN | 0.05874905 ETH | 0.00535237 | ||||
Pay Back Loan | 18566309 | 392 days ago | IN | 0.0499062 ETH | 0.00552711 | ||||
Withdraw Liquidi... | 18565521 | 392 days ago | IN | 0 ETH | 0.00521512 | ||||
Pay Back Loan | 18531319 | 397 days ago | IN | 0.06 ETH | 0.00444556 | ||||
Pay Back Loan | 18510552 | 399 days ago | IN | 0.1 ETH | 0.00572352 | ||||
Withdraw Liquidi... | 18400642 | 415 days ago | IN | 0 ETH | 0.00119069 | ||||
Pay Back Loan An... | 18400279 | 415 days ago | IN | 2.14469046 ETH | 0.00489918 | ||||
Withdraw Liquidi... | 18394536 | 416 days ago | IN | 0 ETH | 0.00130992 | ||||
Deposit Liquidit... | 18394513 | 416 days ago | IN | 7 ETH | 0.00168282 | ||||
Withdraw Liquidi... | 18391396 | 416 days ago | IN | 0 ETH | 0.00108297 | ||||
Pay Back Loan An... | 18386507 | 417 days ago | IN | 4.22780081 ETH | 0.00299589 | ||||
Withdraw | 18337036 | 424 days ago | IN | 0 ETH | 0.00133364 | ||||
Withdraw Liquidi... | 18328899 | 425 days ago | IN | 0 ETH | 0.00139124 | ||||
Pay Back Loan | 18322044 | 426 days ago | IN | 0.5 ETH | 0.00270579 | ||||
Withdraw Liquidi... | 18321906 | 426 days ago | IN | 0 ETH | 0.00082774 | ||||
Pay Back Loan | 18321839 | 426 days ago | IN | 0.296 ETH | 0.00165026 | ||||
Withdraw Liquidi... | 18321294 | 426 days ago | IN | 0 ETH | 0.00094585 | ||||
Withdraw Liquidi... | 18315356 | 427 days ago | IN | 0 ETH | 0.00070342 | ||||
Pay Back Loan | 18314956 | 427 days ago | IN | 0.2 ETH | 0.00114256 | ||||
Pay Back Loan | 18314447 | 427 days ago | IN | 0.179 ETH | 0.00262972 | ||||
Pay Back Loan | 18314424 | 427 days ago | IN | 0.45 ETH | 0.00283167 | ||||
Deposit | 18314090 | 427 days ago | IN | 0 ETH | 0.00172564 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
18980743 | 334 days ago | 0.25 ETH | ||||
18863122 | 350 days ago | 0.20061109 ETH | ||||
18817005 | 357 days ago | 0.04680271 ETH | ||||
18713375 | 371 days ago | 0.11 ETH | ||||
18566536 | 392 days ago | 0.00000081 ETH | ||||
18566536 | 392 days ago | 0.00000243 ETH | ||||
18566309 | 392 days ago | 0.00015094 ETH | ||||
18566309 | 392 days ago | 0.00045284 ETH | ||||
18565521 | 392 days ago | 0.18 ETH | ||||
18531319 | 397 days ago | 0.00010651 ETH | ||||
18531319 | 397 days ago | 0.00031955 ETH | ||||
18510552 | 399 days ago | 0.00126869 ETH | ||||
18510552 | 399 days ago | 0.00380609 ETH | ||||
18400642 | 415 days ago | 2.1 ETH | ||||
18400279 | 415 days ago | 0.00107838 ETH | ||||
18400279 | 415 days ago | 0.00239792 ETH | ||||
18400279 | 415 days ago | 0.00719378 ETH | ||||
18394536 | 416 days ago | 7.8 ETH | ||||
18391396 | 416 days ago | 3.5 ETH | ||||
18386507 | 417 days ago | 0.00551371 ETH | ||||
18386507 | 417 days ago | 0.00388003 ETH | ||||
18386507 | 417 days ago | 0.01164009 ETH | ||||
18328899 | 425 days ago | 0.5 ETH | ||||
18322044 | 426 days ago | 0.00169174 ETH | ||||
18322044 | 426 days ago | 0.00507523 ETH |
Loading...
Loading
Contract Name:
LendingPoolExtLP
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import './HLP.sol'; import './LendingPool.sol'; contract LendingPoolExtLP is LendingPool { uint32 public externalLpFeePerc = (DENOMENATOR * 75) / 100; HLP public hlp; constructor( string memory _baseTokenURI, ISwapRouter __swapRouter, IHyperbolicProtocol __hype, ITwapUtils __twapUtils, LendingRewards __lendingRewards, address __WETH ) LendingPool( _baseTokenURI, __swapRouter, __hype, __twapUtils, __lendingRewards, __WETH ) { hlp = new HLP(); } function depositLiquidity() external payable { require(msg.value > 0, 'DEPOSIT: no ETH'); hlp.mint(_msgSender(), msg.value); } function withdrawLiquidity(uint256 _amount) external { hlp.burn(_msgSender(), _amount); (bool _sent, ) = payable(_msgSender()).call{ value: _amount }(''); require(_sent, 'WITHDRAW: ETH not sent'); } function _depositRewards(uint256 _amount) internal override { uint256 _externalLpRewards = (_amount * externalLpFeePerc) / DENOMENATOR; uint256 _hypeHolderRewards = _amount - _externalLpRewards; if (_externalLpRewards > 0) { LendingRewards _lpRewards = hlp.lendingRewards(); _lpRewards.depositRewards{ value: _externalLpRewards }(); } if (_hypeHolderRewards > 0) { _lendingRewards.depositRewards{ value: _hypeHolderRewards }(); } } function setExternalLpFeePerc(uint32 _perc) external onlyOwner { require(_perc <= DENOMENATOR, 'lte 100%'); externalLpFeePerc = _perc; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface KeeperCompatibleInterface { /** * @notice method that is simulated by the keepers to see if any work actually * needs to be performed. This method does does not actually need to be * executable, and since it is only ever simulated it can consume lots of gas. * @dev To ensure that it is never called, you may want to add the * cannotExecute modifier from KeeperBase to your implementation of this * method. * @param checkData specified in the upkeep registration so it is always the * same for a registered upkeep. This can easily be broken down into specific * arguments using `abi.decode`, so multiple upkeeps can be registered on the * same contract and easily differentiated by the contract. * @return upkeepNeeded boolean to indicate whether the keeper should call * performUpkeep or not. * @return performData bytes that the keeper should call performUpkeep with, if * upkeep is needed. If you would like to encode data to decode later, try * `abi.encode`. */ function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData); /** * @notice method that is actually executed by the keepers, via the registry. * The data returned by the checkUpkeep simulation will be passed into * this method to actually be executed. * @dev The input to this method should not be trusted, and the caller of the * method should not even be restricted to any single registry. Anyone should * be able call it, and the input should be validated, there is no guarantee * that the data passed in is the performData returned from checkUpkeep. This * could happen due to malicious keepers, racing keepers, or simply a state * change while the performUpkeep transaction is waiting for confirmation. * Always validate the data passed in. * @param performData is the data which was passed back from the checkData * simulation. If it is encoded, it can easily be decoded into other types by * calling `abi.decode`. This data should not be trusted, and should be * validated against the contract's current state. */ function performUpkeep(bytes calldata performData) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; contract KeeperBase { /** * @notice method that allows it to be simulated via eth_call by checking that * the sender is the zero address. */ function preventExecution() internal view { require(tx.origin == address(0), "only for simulated backend"); } /** * @notice modifier that allows it to be simulated via eth_call by checking * that the sender is the zero address. */ modifier cannotExecute() { preventExecution(); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./KeeperBase.sol"; import "./interfaces/KeeperCompatibleInterface.sol"; abstract contract KeeperCompatible is KeeperBase, KeeperCompatibleInterface {}
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 IERC165 { /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.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 SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @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' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _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 // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC721.sol"; import "./IERC721Metadata.sol"; import "./IERC721Enumerable.sol"; import "./IERC721Receiver.sol"; import "../../introspection/ERC165.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../utils/EnumerableSet.sol"; import "../../utils/EnumerableMap.sol"; import "../../utils/Strings.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../math/SafeMath.sol"; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never * directly accessed. */ library Counters { using SafeMath for uint256; struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { // The {SafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 EnumerableSet { // 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; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. 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] = toDeleteIndex + 1; // All indexes are 1-based // 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) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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); } // 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)))); } // 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)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` 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); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './pool/IUniswapV3PoolImmutables.sol'; import './pool/IUniswapV3PoolState.sol'; import './pool/IUniswapV3PoolDerivedState.sol'; import './pool/IUniswapV3PoolActions.sol'; import './pool/IUniswapV3PoolOwnerActions.sol'; import './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolEvents { }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return _liquidity The amount of liquidity in the position, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 _liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol'; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.7.6; import '@openzeppelin/contracts/token/ERC721/ERC721.sol'; import '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol'; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is IERC721Enumerable, ERC721 { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override(IERC721Enumerable, ERC721) returns (uint256) { require( index < ERC721.balanceOf(owner), 'ERC721Enumerable: owner index out of bounds' ); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override(IERC721Enumerable, ERC721) returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override(IERC721Enumerable, ERC721) returns (uint256) { require( index < ERC721Enumerable.totalSupply(), 'ERC721Enumerable: global index out of bounds' ); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; import './LendingRewards.sol'; contract HLP is ERC20 { address public lendingPool; LendingRewards public lendingRewards; modifier onlyLendingPool() { require(_msgSender() == lendingPool, 'UNAUTHORIZED'); _; } constructor() ERC20('HYPE LP', 'HLP') { lendingPool = _msgSender(); lendingRewards = new LendingRewards(address(this)); } function mint(address _wallet, uint256 _amount) external onlyLendingPool { _mint(_wallet, _amount); } function burn(address _wallet, uint256 _amount) external onlyLendingPool { _burn(_wallet, _amount); } function _transfer( address sender, address recipient, uint256 amount ) internal virtual override { super._transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal override { super._mint(account, amount); _afterTokenTransfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal override { super._burn(account, amount); _afterTokenTransfer(account, address(0), amount); } function _canReceiveRewards(address _wallet) internal view returns (bool) { return _wallet != address(0); } function _afterTokenTransfer( address _from, address _to, uint256 _amount ) internal virtual { if (_canReceiveRewards(_from)) { lendingRewards.setShare(_from, _amount, true); } if (_canReceiveRewards(_to)) { lendingRewards.setShare(_to, _amount, false); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; interface IHyperbolicProtocol { function poolBalToMarketCapRatio() external view returns (uint256 lendPoolETHBal, uint256 marketCapETH); function poolToMarketCapTarget() external view returns (uint32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; interface IRewardsTracker { function claimReward() external; function depositRewards() external payable; function getShares(address wallet) external view returns (uint256); function setShare( address shareholder, uint256 balanceUpdate, bool isRemoving ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; interface ITwapUtils { function twapInterval() external view returns (uint32); function getPoolPriceUSDX96( address priceToken, address pricePool, address nativeStablePool, address WETH9, bool isPoolPairedWETH9 ) external view returns (uint256); function getSqrtPriceX96FromPoolAndInterval( address uniswapV3Pool ) external view returns (uint160 sqrtPriceX96); function getSqrtPriceX96FromPriceX96( uint256 priceX96 ) external pure returns (uint160 sqrtPriceX96); function getPriceX96FromSqrtPriceX96( uint160 sqrtPriceX96 ) external pure returns (uint256 priceX96); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; interface IWETH { function balanceOf(address wallet) external view returns (uint256); function decimals() external view returns (uint8); function deposit() external payable; function withdraw(uint256 _amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma abicoder v2; import '@chainlink/contracts/src/v0.7/KeeperCompatible.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol'; import '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol'; import '@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol'; import '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol'; import './LoanToken.sol'; import './LendingPoolTokenCustodian.sol'; import './LendingRewards.sol'; import './interfaces/IHyperbolicProtocol.sol'; import './interfaces/ITwapUtils.sol'; import './interfaces/IWETH.sol'; contract LendingPool is Ownable, KeeperCompatibleInterface { using SafeERC20 for ERC20; uint32 constant DENOMENATOR = 10000; address immutable _WETH; bool public enabled; bool public liquidateDefaultCapital; uint32 public liquidateSlippage = (DENOMENATOR * 10) / 100; // 10% uint32 public maxLiquidationsPerUpkeep = 10; LendingPoolTokenCustodian public custodian; LoanToken public loanNFT; IHyperbolicProtocol _hype; LendingRewards _lendingRewards; ITwapUtils _twapUtils; ISwapRouter _swapRouter; mapping(address => bool) public whitelistPools; address[] _allWhitelistedPools; mapping(address => uint256) _allWhitelistPoolsInd; uint32 public borrowInitFee = (DENOMENATOR * 3) / 100; // 3% uint32 public borrowAPRMin = (DENOMENATOR * 2) / 100; // 2% uint32 public borrowAPRMax = (DENOMENATOR * 15) / 100; // 15% uint32 public liquidationLTV = (DENOMENATOR * 95) / 100; // 95% uint32 public maxLTVOverall = (DENOMENATOR * 50) / 100; // 50% // pool => LTV override mapping(address => uint32) public maxLTVOverride; // pool => current borrowed ETH mapping(address => uint256) public currentBorrowPerPool; // pool => borrow max mapping(address => uint256) public maxBorrowPerPool; struct Loan { uint256 created; // when the loan was first created address createdBy; // original wallet who created loan for lending rewards uint256 aprStart; // the starting timestamp we should evaluate APR fees from address collateralPool; // Uniswap V3 Pool of collateral token and ETH (WETH) uint256 amountDeposited; // amount of collateral token from collateralPool deposited uint256 amountETHBorrowed; // amount ETH borrowed, this and collateral deposited is used to determine LTV } // tokenId => Loan mapping(uint256 => Loan) public loans; event Deposit( address indexed wallet, uint256 indexed tokenId, uint256 amountCollateral ); event Withdraw( address indexed wallet, uint256 indexed tokenId, uint256 amountCollateral ); event Borrow( address indexed wallet, uint256 indexed tokenId, uint256 amountETH ); event PayBackLoan( address indexed wallet, uint256 indexed tokenId, uint256 amountDesired, uint256 amountFees ); event DeleteLoan(uint256 indexed tokenId); constructor( string memory _baseTokenURI, ISwapRouter __swapRouter, IHyperbolicProtocol __hype, ITwapUtils __twapUtils, LendingRewards __lendingRewards, address __WETH ) { _swapRouter = __swapRouter; _hype = __hype; _twapUtils = __twapUtils; _lendingRewards = __lendingRewards; _WETH = __WETH; custodian = new LendingPoolTokenCustodian(address(_hype)); loanNFT = new LoanToken(_baseTokenURI); loanNFT.setRoyaltyAddress(msg.sender); loanNFT.transferOwnership(msg.sender); } function getLTVX96( uint256 _tokenId ) public view returns ( uint256 ltvX96, uint256 ltvWithFeesX96, uint256 amountETHDepositedX96, uint256 amountETHBorrowedX96 ) { require(loanNFT.doesTokenExist(_tokenId), 'GETLTV: loan must exist'); Loan memory _loan = loans[_tokenId]; uint256 _fees = calculateAPRFees(_loan.amountETHBorrowed, _loan.aprStart); if (_loan.amountDeposited == 0 && _loan.amountETHBorrowed == 0) { return (0, 0, 0, 0); } uint160 _sqrtPriceX96 = _twapUtils.getSqrtPriceX96FromPoolAndInterval( _loan.collateralPool ); uint256 _priceX96 = _twapUtils.getPriceX96FromSqrtPriceX96(_sqrtPriceX96); address _token0 = IUniswapV3Pool(_loan.collateralPool).token0(); uint256 _amountETHDepositedX96 = _token0 == _WETH ? _loan.amountDeposited * (2 ** (96 * 2) / _priceX96) : _priceX96 * _loan.amountDeposited; uint256 _amountETHBorrowedX96 = _loan.amountETHBorrowed * FixedPoint96.Q96; uint256 _amountETHBorrWithFeesX96 = (_loan.amountETHBorrowed + _fees) * FixedPoint96.Q96; return ( (_amountETHBorrowedX96 * FixedPoint96.Q96) / _amountETHDepositedX96, (_amountETHBorrWithFeesX96 * FixedPoint96.Q96) / _amountETHDepositedX96, _amountETHDepositedX96, _amountETHBorrowedX96 ); } function getAllWhitelistedPools() external view returns (address[] memory) { return _allWhitelistedPools; } function getETHBalance(address _wallet) external view returns (uint256) { return address(_wallet).balance; } function depositAndBorrow( uint256 _tokenId, address _pool, uint256 _amountDepositing, uint256 _amountETHBorrowing ) external { _tokenId = _deposit(msg.sender, _tokenId, _pool, _amountDepositing); _borrow(msg.sender, _tokenId, _amountETHBorrowing); } function deposit(uint256 _tokenId, address _pool, uint256 _amount) external { _deposit(msg.sender, _tokenId, _pool, _amount); } function borrow(uint256 _tokenId, uint256 _amountETHBorrowing) external { _borrow(msg.sender, _tokenId, _amountETHBorrowing); } function withdraw(uint256 _tokenId, uint256 _amount) external { _withdraw(msg.sender, _tokenId, _amount); } function payBackLoan(uint256 _tokenId) external payable { _payBackLoan(msg.sender, _tokenId, msg.value); } function payBackLoanAndClose(uint256 _tokenId) external payable { if (loans[_tokenId].amountETHBorrowed > 0) { _payBackLoan(msg.sender, _tokenId, msg.value); } else { require(msg.value == 0, 'PAYBACKLOSE: no ETH needed'); } _withdraw(msg.sender, _tokenId, loans[_tokenId].amountDeposited); } function _deposit( address _wallet, uint256 _tokenId, address _pool, uint256 _amount ) internal returns (uint256) { require(enabled, 'DEPOSIT: not enabled'); (uint256 __tokenId, ) = _getOrCreateLoan(_wallet, _tokenId); _tokenId = __tokenId; Loan storage _loan = loans[_tokenId]; IUniswapV3Pool _uniPool; if (_loan.collateralPool == address(0)) { require(whitelistPools[_pool], 'DEPOSIT: bad pool0'); _loan.created = block.timestamp; _loan.createdBy = _wallet; _loan.aprStart = block.timestamp; _loan.collateralPool = _pool; _uniPool = IUniswapV3Pool(_pool); } else { require(whitelistPools[_loan.collateralPool], 'DEPOSIT: bad pool1'); _uniPool = IUniswapV3Pool(_loan.collateralPool); } _loan.amountDeposited += _amount; address _token0 = _uniPool.token0(); if (_token0 == _WETH) { ERC20 _t1 = ERC20(_uniPool.token1()); _t1.safeTransferFrom(_wallet, address(this), _amount); _t1.approve(address(custodian), _amount); custodian.process(_t1, _loan.createdBy, _amount, false); } else { ERC20 _t0 = ERC20(_token0); _t0.safeTransferFrom(_wallet, address(this), _amount); _t0.approve(address(custodian), _amount); custodian.process(_t0, _loan.createdBy, _amount, false); } emit Deposit(_wallet, _tokenId, _amount); return _tokenId; } function _withdraw( address _wallet, uint256 _tokenId, uint256 _amount ) internal { require(_amount > 0, 'WITHDRAW: must withdraw from loan'); _validateLoanOwner(_wallet, _tokenId); Loan storage _loan = loans[_tokenId]; require(_amount <= _loan.amountDeposited, 'WITHDRAW: too much'); _loan.amountDeposited -= _amount; // get LTV info after we've removed _amount to withdraw from loan (, uint256 _ltvAndFeesX96, , ) = getLTVX96(_tokenId); if (maxLTVOverride[_loan.collateralPool] > 0) { require( _ltvAndFeesX96 <= (FixedPoint96.Q96 * maxLTVOverride[_loan.collateralPool]) / DENOMENATOR, 'WITHDRAW: exceeds max LTV' ); } else { require( _ltvAndFeesX96 <= (FixedPoint96.Q96 * maxLTVOverall) / DENOMENATOR, 'WITHDRAW: exceeds max LTV' ); } IUniswapV3Pool _uniPool = IUniswapV3Pool(_loan.collateralPool); address _token0 = _uniPool.token0(); if (_token0 == _WETH) { ERC20 _t1 = ERC20(_uniPool.token1()); custodian.process(_t1, _loan.createdBy, _amount, true); _t1.safeTransfer(_wallet, _amount); } else { ERC20 _t0 = ERC20(_token0); custodian.process(_t0, _loan.createdBy, _amount, true); _t0.safeTransfer(_wallet, _amount); } if (_loan.amountDeposited == 0) { _deleteLoan(_tokenId); } emit Withdraw(_wallet, _tokenId, _amount); } function _borrow( address _wallet, uint256 _tokenId, uint256 _amountETH ) internal returns (uint256) { require(enabled, 'BORROW: not enabled'); _validateLoanOwner(_wallet, _tokenId); Loan storage _loan = loans[_tokenId]; require(whitelistPools[_loan.collateralPool], 'BORROW: bad pool'); // take out current APR fees from amount borrowing uint256 _amountAPRFees = calculateAPRFees( _loan.amountETHBorrowed, _loan.aprStart ); _loan.aprStart = block.timestamp; (, , uint256 ethDepositedX96, uint256 ethBorrowedX96) = getLTVX96(_tokenId); uint256 ethDeposited = ethDepositedX96 / FixedPoint96.Q96; uint256 ethBorrowed = ethBorrowedX96 / FixedPoint96.Q96; uint256 _maxLoanETH = maxLTVOverride[_loan.collateralPool] > 0 ? (ethDeposited * maxLTVOverride[_loan.collateralPool]) / DENOMENATOR : (ethDeposited * maxLTVOverall) / DENOMENATOR; require(ethBorrowed < _maxLoanETH, 'BORROW: cannot borrow'); if (ethBorrowed + _amountETH > _maxLoanETH) { _amountETH = _maxLoanETH - ethBorrowed; } require(address(this).balance >= _amountETH, 'BORROW: not enough funds'); if (maxBorrowPerPool[_loan.collateralPool] > 0) { require( currentBorrowPerPool[_loan.collateralPool] + _amountETH <= maxBorrowPerPool[_loan.collateralPool], 'BORROW: exceeds pool max' ); } currentBorrowPerPool[_loan.collateralPool] += _amountETH; _loan.amountETHBorrowed += _amountETH; uint256 _amountFees = _amountAPRFees + ((_amountETH * borrowInitFee) / DENOMENATOR); require(_amountETH > _amountFees, 'BORROW: fees more than borrow amount'); uint256 _amountToBorrower = _amountETH - _amountFees; _depositRewards(_amountFees); (bool success, ) = payable(_wallet).call{ value: _amountToBorrower }(''); require(success, 'BORROW: ETH not delivered'); emit Borrow(_wallet, _tokenId, _amountETH); return _tokenId; } function _payBackLoan( address _wallet, uint256 _tokenId, uint256 _amount ) internal { require(_amount > 0, 'PAYBACK: no ETH to pay back'); _validateLoanOwner(_wallet, _tokenId); Loan storage _loan = loans[_tokenId]; // take out current APR fees from amount borrowing uint256 _amountAPRFees = calculateAPRFees( _loan.amountETHBorrowed, _loan.aprStart ); _loan.aprStart = block.timestamp; require(_amount > _amountAPRFees, 'PAYBACK: must pay back above fees'); uint256 _amountBorrowedPlusFees = _loan.amountETHBorrowed + _amountAPRFees; uint256 _refund; if (_amount > _amountBorrowedPlusFees) { _refund = _amount - _amountBorrowedPlusFees; } // remove amount minus fees from the amount borrowed currentBorrowPerPool[_loan.collateralPool] -= (_amount - _amountAPRFees) > currentBorrowPerPool[_loan.collateralPool] ? currentBorrowPerPool[_loan.collateralPool] : _amount - _amountAPRFees; _loan.amountETHBorrowed -= (_amount - _amountAPRFees) > _loan.amountETHBorrowed ? _loan.amountETHBorrowed : _amount - _amountAPRFees; if (_amountAPRFees > 0) { _depositRewards(_amountAPRFees); } if (_refund > 0) { (bool wasRefunded, ) = payable(_wallet).call{ value: _refund }(''); require(wasRefunded, 'PAYBACK: refund unsuccessful'); } emit PayBackLoan(_wallet, _tokenId, _amount, _amountAPRFees); } function _getOrCreateLoan( address _wallet, uint256 _tokenId ) internal returns (uint256 tokenId, bool isNewLoan) { if (_tokenId == 0) { tokenId = loanNFT.mint(_wallet); return (tokenId, true); } _validateLoanOwner(_wallet, _tokenId); tokenId = _tokenId; return (tokenId, false); } function _deleteLoan(uint256 _tokenId) internal { delete loans[_tokenId]; loanNFT.burn(_tokenId); emit DeleteLoan(_tokenId); } function _depositRewards(uint256 _amount) internal virtual { _lendingRewards.depositRewards{ value: _amount }(); } function calculateAPRFees( uint256 _amountETHBorrowed, uint256 _aprStart ) public view returns (uint256) { return ((block.timestamp - _aprStart) * calculateBorrowAPR() * _amountETHBorrowed) / DENOMENATOR / 365 days; } function calculateBorrowAPR() public view returns (uint256) { (uint256 _poolBalETH, uint256 _mcETH) = _hype.poolBalToMarketCapRatio(); uint256 _targetPoolBal = (_mcETH * _hype.poolToMarketCapTarget()) / DENOMENATOR; if (_poolBalETH < _targetPoolBal) { uint256 _aprLessMax = ((borrowAPRMax - borrowAPRMin) * _poolBalETH) / _targetPoolBal; return borrowAPRMax - _aprLessMax; } return borrowAPRMin; } function shouldLiquidateLoan(uint256 _tokenId) external view returns (bool) { return _shouldLiquidateLoan(_tokenId); } function _shouldLiquidateLoan(uint256 _tokenId) internal view returns (bool) { if (!loanNFT.doesTokenExist(_tokenId)) { return false; } (, uint256 _ltvWithFeesX96, , ) = getLTVX96(_tokenId); return _ltvWithFeesX96 >= (FixedPoint96.Q96 * liquidationLTV) / DENOMENATOR; } function _toggleWhitelistCollateralPool(address _pool) internal { if (whitelistPools[_pool]) { uint256 _ind = _allWhitelistPoolsInd[_pool]; address _poolMoving = _allWhitelistedPools[ _allWhitelistedPools.length - 1 ]; _allWhitelistedPools[_ind] = _poolMoving; _allWhitelistPoolsInd[_poolMoving] = _ind; delete whitelistPools[_pool]; _allWhitelistedPools.pop(); } else { // add whitelistPools[_pool] = true; _allWhitelistPoolsInd[_pool] = _allWhitelistedPools.length; _allWhitelistedPools.push(_pool); } } function checkUpkeep( bytes calldata ) external view override returns (bool upkeepNeeded, bytes memory performData) { uint256[] memory _openedLoans = loanNFT.getAllOpenedLoans(); uint256[] memory _upkeepLoans = new uint256[](maxLiquidationsPerUpkeep); uint32 _numUpkeeps = 0; for (uint256 _i = 0; _i < _openedLoans.length; _i++) { if (_numUpkeeps >= maxLiquidationsPerUpkeep) { break; } uint256 _tokenId = _openedLoans[_i]; if (_shouldLiquidateLoan(_tokenId)) { upkeepNeeded = true; _upkeepLoans[_numUpkeeps] = _tokenId; _numUpkeeps++; } } if (upkeepNeeded) { performData = abi.encode(_upkeepLoans); } } function performUpkeep(bytes calldata performData) external override { uint256[] memory _upkeepLoans = abi.decode(performData, (uint256[])); for (uint256 _i = 0; _i < _upkeepLoans.length; _i++) { uint256 _tokenId = _upkeepLoans[_i]; if (_tokenId == 0) { break; } if (_shouldLiquidateLoan(_tokenId)) { Loan memory _loan = loans[_tokenId]; uint256 _amountDeposited = _loan.amountDeposited; IUniswapV3Pool _pool = IUniswapV3Pool(_loan.collateralPool); address _token0 = _pool.token0(); if (_token0 == _WETH) { ERC20 _t1 = ERC20(_pool.token1()); custodian.process(_t1, _loan.createdBy, _amountDeposited, true); _processLiquidatedTokens(_pool, _t1, _loan); } else { ERC20 _t0 = ERC20(_token0); custodian.process(_t0, _loan.createdBy, _amountDeposited, true); _processLiquidatedTokens(_pool, _t0, _loan); } _deleteLoan(_tokenId); } } } function _processLiquidatedTokens( IUniswapV3Pool _pool, ERC20 _token, Loan memory _loan ) internal { if (liquidateDefaultCapital && address(_token) != address(_hype)) { uint160 _sqrtPriceX96 = _twapUtils.getSqrtPriceX96FromPoolAndInterval( address(_pool) ); uint256 _priceX96 = _twapUtils.getPriceX96FromSqrtPriceX96(_sqrtPriceX96); uint256 _priceWETHNumX96 = _pool.token1() == _WETH ? _priceX96 : FixedPoint96.Q96 ** 2 / _priceX96; uint256 _minETHBaseFromPrice = (_priceWETHNumX96 * _loan.amountDeposited) / FixedPoint96.Q96; uint256 _minETHBase = _minETHBaseFromPrice > _loan.amountETHBorrowed ? _minETHBaseFromPrice : _loan.amountETHBorrowed; TransferHelper.safeApprove( address(_token), address(_swapRouter), _loan.amountDeposited ); _swapRouter.exactInputSingle( ISwapRouter.ExactInputSingleParams({ tokenIn: address(_token), tokenOut: _WETH, fee: _pool.fee(), recipient: address(this), deadline: block.timestamp, amountIn: _loan.amountDeposited, amountOutMinimum: (_minETHBase * (DENOMENATOR - liquidateSlippage)) / DENOMENATOR, sqrtPriceLimitX96: 0 }) ); uint256 _balWETH = IERC20(_WETH).balanceOf(address(this)); if (_balWETH > 0) { IWETH(_WETH).withdraw(_balWETH); } } else { _token.safeTransfer(owner(), _loan.amountDeposited); } } function _validateLoanOwner(address _wallet, uint256 _tokenId) internal view { require(_wallet == loanNFT.ownerOf(_tokenId), 'VALIDATEOWNER'); } function setLiquidateDefaultCapital(bool _shouldLiq) external onlyOwner { require(liquidateDefaultCapital != _shouldLiq, 'SETLIQDEF'); liquidateDefaultCapital = _shouldLiq; } function setLiquidateSlippage(uint32 _slippage) external onlyOwner { require(_slippage <= DENOMENATOR, 'lte 100%'); liquidateSlippage = _slippage; } function setBorrowInitFee(uint32 _fee) external onlyOwner { require(_fee <= (DENOMENATOR * 30) / 100, 'SETBFEE: lte 30%'); borrowInitFee = _fee; } function setBorrowAPRMin(uint32 _apr) external onlyOwner { require(_apr <= (DENOMENATOR * 10) / 100, 'SETBAPRMIN: lte 10%'); borrowAPRMin = _apr; } function setBorrowAPRMax(uint32 _apr) external onlyOwner { require(_apr <= DENOMENATOR, 'SETBAPRMAX: lte 100%'); borrowAPRMax = _apr; } function setMaxLTVOverall(uint32 _ltv) external onlyOwner { require(_ltv <= DENOMENATOR, 'SETLTVMAX: lte 100%'); maxLTVOverall = _ltv; } function setMaxLTVOverride(address _pool, uint32 _ltv) external onlyOwner { require(_ltv <= DENOMENATOR, 'SETLTVMAX: lte 100%'); maxLTVOverride[_pool] = _ltv; } function setMaxBorrowPerPool( address _pool, uint256 _amountETH ) external onlyOwner { maxBorrowPerPool[_pool] = _amountETH; } function setLiquidationLTV(uint32 _ltv) external onlyOwner { require(_ltv <= DENOMENATOR, 'SETLPLTV: lte 100%'); liquidationLTV = _ltv; } function setMaxLiquidationsPerUpkeep(uint32 _max) external onlyOwner { maxLiquidationsPerUpkeep = _max; } function setEnabled(bool _enabled) external onlyOwner { require(enabled != _enabled, 'SETENABLED: must toggle'); enabled = _enabled; } function toggleWhitelistCollateralPool(address _pool) external onlyOwner { IUniswapV3Pool _uniPool = IUniswapV3Pool(_pool); address _token0 = _uniPool.token0(); address _token1 = _uniPool.token1(); require(_token0 == _WETH || _token1 == _WETH, 'TOGGLECOLL: no ETH'); uint32[] memory secondsAgo = new uint32[](2); secondsAgo[0] = 5 minutes; secondsAgo[1] = 0; _uniPool.observe(secondsAgo); _toggleWhitelistCollateralPool(_pool); } receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import '@openzeppelin/contracts/access/Ownable.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import './RewardsTracker.sol'; contract LendingPoolTokenCustodian is Ownable, RewardsTracker { using SafeERC20 for IERC20; address public hype; constructor(address _hype) RewardsTracker(_hype) { hype = _hype; } function process( IERC20 _token, address _user, uint256 _balanceUpdate, bool _isWithdrawing ) external onlyOwner { if (_isWithdrawing) { _token.safeTransfer(msg.sender, _balanceUpdate); } else { _token.safeTransferFrom(msg.sender, address(this), _balanceUpdate); } if (address(_token) == hype) { _setShare(_user, _balanceUpdate, _isWithdrawing); } } receive() external payable { uint256 _hypeTokens = IERC20(hype).balanceOf(address(this)); if (_hypeTokens > 0) { _depositRewards(msg.value); } else { (bool _success, ) = payable(owner()).call{ value: msg.value }(''); require(_success, 'RECEIVE: did not send to owner'); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import './RewardsTracker.sol'; contract LendingRewards is RewardsTracker { constructor(address _token) RewardsTracker(_token) {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; // ---------------------------------------------------------------------------- // BokkyPooBah's DateTime Library v1.00 // // A gas-efficient Solidity date and time library // // https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary // // Tested date range 1970/01/01 to 2345/12/31 // // Conventions: // Unit | Range | Notes // :-------- |:-------------:|:----- // timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC // year | 1970 ... 2345 | // month | 1 ... 12 | // day | 1 ... 31 | // hour | 0 ... 23 | // minute | 0 ... 59 | // second | 0 ... 59 | // dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday // // // Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018. // // GNU Lesser General Public License 3.0 // https://www.gnu.org/licenses/lgpl-3.0.en.html // ---------------------------------------------------------------------------- library BokkyPooBahsDateTimeLibrary { uint constant SECONDS_PER_DAY = 24 * 60 * 60; uint constant SECONDS_PER_HOUR = 60 * 60; uint constant SECONDS_PER_MINUTE = 60; int constant OFFSET19700101 = 2440588; uint constant DOW_MON = 1; uint constant DOW_TUE = 2; uint constant DOW_WED = 3; uint constant DOW_THU = 4; uint constant DOW_FRI = 5; uint constant DOW_SAT = 6; uint constant DOW_SUN = 7; // ------------------------------------------------------------------------ // Calculate the number of days from 1970/01/01 to year/month/day using // the date conversion algorithm from // http://aa.usno.navy.mil/faq/docs/JD_Formula.php // and subtracting the offset 2440588 so that 1970/01/01 is day 0 // // days = day // - 32075 // + 1461 * (year + 4800 + (month - 14) / 12) / 4 // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12 // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4 // - offset // ------------------------------------------------------------------------ function _daysFromDate( uint year, uint month, uint day ) internal pure returns (uint _days) { require(year >= 1970); int _year = int(year); int _month = int(month); int _day = int(day); int __days = _day - 32075 + (1461 * (_year + 4800 + (_month - 14) / 12)) / 4 + (367 * (_month - 2 - ((_month - 14) / 12) * 12)) / 12 - (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) / 4 - OFFSET19700101; _days = uint(__days); } // ------------------------------------------------------------------------ // Calculate year/month/day from the number of days since 1970/01/01 using // the date conversion algorithm from // http://aa.usno.navy.mil/faq/docs/JD_Formula.php // and adding the offset 2440588 so that 1970/01/01 is day 0 // // int L = days + 68569 + offset // int N = 4 * L / 146097 // L = L - (146097 * N + 3) / 4 // year = 4000 * (L + 1) / 1461001 // L = L - 1461 * year / 4 + 31 // month = 80 * L / 2447 // dd = L - 2447 * month / 80 // L = month / 11 // month = month + 2 - 12 * L // year = 100 * (N - 49) + year + L // ------------------------------------------------------------------------ function _daysToDate( uint _days ) internal pure returns (uint year, uint month, uint day) { int __days = int(_days); int L = __days + 68569 + OFFSET19700101; int N = (4 * L) / 146097; L = L - (146097 * N + 3) / 4; int _year = (4000 * (L + 1)) / 1461001; L = L - (1461 * _year) / 4 + 31; int _month = (80 * L) / 2447; int _day = L - (2447 * _month) / 80; L = _month / 11; _month = _month + 2 - 12 * L; _year = 100 * (N - 49) + _year + L; year = uint(_year); month = uint(_month); day = uint(_day); } function timestampFromDate( uint year, uint month, uint day ) internal pure returns (uint timestamp) { timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY; } function timestampFromDateTime( uint year, uint month, uint day, uint hour, uint minute, uint second ) internal pure returns (uint timestamp) { timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + hour * SECONDS_PER_HOUR + minute * SECONDS_PER_MINUTE + second; } function timestampToDate( uint timestamp ) internal pure returns (uint year, uint month, uint day) { (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } function timestampToDateTime( uint timestamp ) internal pure returns ( uint year, uint month, uint day, uint hour, uint minute, uint second ) { (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); uint secs = timestamp % SECONDS_PER_DAY; hour = secs / SECONDS_PER_HOUR; secs = secs % SECONDS_PER_HOUR; minute = secs / SECONDS_PER_MINUTE; second = secs % SECONDS_PER_MINUTE; } function isValidDate( uint year, uint month, uint day ) internal pure returns (bool valid) { if (year >= 1970 && month > 0 && month <= 12) { uint daysInMonth = _getDaysInMonth(year, month); if (day > 0 && day <= daysInMonth) { valid = true; } } } function isValidDateTime( uint year, uint month, uint day, uint hour, uint minute, uint second ) internal pure returns (bool valid) { if (isValidDate(year, month, day)) { if (hour < 24 && minute < 60 && second < 60) { valid = true; } } } function isLeapYear(uint timestamp) internal pure returns (bool leapYear) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); leapYear = _isLeapYear(year); } function _isLeapYear(uint year) internal pure returns (bool leapYear) { leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0); } function isWeekDay(uint timestamp) internal pure returns (bool weekDay) { weekDay = getDayOfWeek(timestamp) <= DOW_FRI; } function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) { weekEnd = getDayOfWeek(timestamp) >= DOW_SAT; } function getDaysInMonth( uint timestamp ) internal pure returns (uint daysInMonth) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); daysInMonth = _getDaysInMonth(year, month); } function _getDaysInMonth( uint year, uint month ) internal pure returns (uint daysInMonth) { if ( month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 ) { daysInMonth = 31; } else if (month != 2) { daysInMonth = 30; } else { daysInMonth = _isLeapYear(year) ? 29 : 28; } } // 1 = Monday, 7 = Sunday function getDayOfWeek(uint timestamp) internal pure returns (uint dayOfWeek) { uint _days = timestamp / SECONDS_PER_DAY; dayOfWeek = ((_days + 3) % 7) + 1; } function getYear(uint timestamp) internal pure returns (uint year) { uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } function getMonth(uint timestamp) internal pure returns (uint month) { uint year; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } function getDay(uint timestamp) internal pure returns (uint day) { uint year; uint month; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } function getHour(uint timestamp) internal pure returns (uint hour) { uint secs = timestamp % SECONDS_PER_DAY; hour = secs / SECONDS_PER_HOUR; } function getMinute(uint timestamp) internal pure returns (uint minute) { uint secs = timestamp % SECONDS_PER_HOUR; minute = secs / SECONDS_PER_MINUTE; } function getSecond(uint timestamp) internal pure returns (uint second) { second = timestamp % SECONDS_PER_MINUTE; } function addYears( uint timestamp, uint _years ) internal pure returns (uint newTimestamp) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); year += _years; uint daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY); require(newTimestamp >= timestamp); } function addMonths( uint timestamp, uint _months ) internal pure returns (uint newTimestamp) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); month += _months; year += (month - 1) / 12; month = ((month - 1) % 12) + 1; uint daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY); require(newTimestamp >= timestamp); } function addDays( uint timestamp, uint _days ) internal pure returns (uint newTimestamp) { newTimestamp = timestamp + _days * SECONDS_PER_DAY; require(newTimestamp >= timestamp); } function addHours( uint timestamp, uint _hours ) internal pure returns (uint newTimestamp) { newTimestamp = timestamp + _hours * SECONDS_PER_HOUR; require(newTimestamp >= timestamp); } function addMinutes( uint timestamp, uint _minutes ) internal pure returns (uint newTimestamp) { newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE; require(newTimestamp >= timestamp); } function addSeconds( uint timestamp, uint _seconds ) internal pure returns (uint newTimestamp) { newTimestamp = timestamp + _seconds; require(newTimestamp >= timestamp); } function subYears( uint timestamp, uint _years ) internal pure returns (uint newTimestamp) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); year -= _years; uint daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY); require(newTimestamp <= timestamp); } function subMonths( uint timestamp, uint _months ) internal pure returns (uint newTimestamp) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); uint yearMonth = year * 12 + (month - 1) - _months; year = yearMonth / 12; month = (yearMonth % 12) + 1; uint daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY); require(newTimestamp <= timestamp); } function subDays( uint timestamp, uint _days ) internal pure returns (uint newTimestamp) { newTimestamp = timestamp - _days * SECONDS_PER_DAY; require(newTimestamp <= timestamp); } function subHours( uint timestamp, uint _hours ) internal pure returns (uint newTimestamp) { newTimestamp = timestamp - _hours * SECONDS_PER_HOUR; require(newTimestamp <= timestamp); } function subMinutes( uint timestamp, uint _minutes ) internal pure returns (uint newTimestamp) { newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE; require(newTimestamp <= timestamp); } function subSeconds( uint timestamp, uint _seconds ) internal pure returns (uint newTimestamp) { newTimestamp = timestamp - _seconds; require(newTimestamp <= timestamp); } function diffYears( uint fromTimestamp, uint toTimestamp ) internal pure returns (uint _years) { require(fromTimestamp <= toTimestamp); uint fromYear; uint fromMonth; uint fromDay; uint toYear; uint toMonth; uint toDay; (fromYear, fromMonth, fromDay) = _daysToDate( fromTimestamp / SECONDS_PER_DAY ); (toYear, toMonth, toDay) = _daysToDate(toTimestamp / SECONDS_PER_DAY); _years = toYear - fromYear; } function diffMonths( uint fromTimestamp, uint toTimestamp ) internal pure returns (uint _months) { require(fromTimestamp <= toTimestamp); uint fromYear; uint fromMonth; uint fromDay; uint toYear; uint toMonth; uint toDay; (fromYear, fromMonth, fromDay) = _daysToDate( fromTimestamp / SECONDS_PER_DAY ); (toYear, toMonth, toDay) = _daysToDate(toTimestamp / SECONDS_PER_DAY); _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth; } function diffDays( uint fromTimestamp, uint toTimestamp ) internal pure returns (uint _days) { require(fromTimestamp <= toTimestamp); _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY; } function diffHours( uint fromTimestamp, uint toTimestamp ) internal pure returns (uint _hours) { require(fromTimestamp <= toTimestamp); _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR; } function diffMinutes( uint fromTimestamp, uint toTimestamp ) internal pure returns (uint _minutes) { require(fromTimestamp <= toTimestamp); _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE; } function diffSeconds( uint fromTimestamp, uint toTimestamp ) internal pure returns (uint _seconds) { require(fromTimestamp <= toTimestamp); _seconds = toTimestamp - fromTimestamp; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import '@openzeppelin/contracts/access/Ownable.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC721/ERC721.sol'; import '@openzeppelin/contracts/utils/Counters.sol'; import './ERC721Enumerable.sol'; contract LoanToken is ERC721Enumerable, Ownable { using Strings for uint256; using Counters for Counters.Counter; address public lendingPool; Counters.Counter internal _ids; string private baseTokenURI; // baseTokenURI can point to IPFS folder like https://ipfs.io/ipfs/{cid}/ while address public royaltyAddress; // Royalties basis points (percentage using 2 decimals - 1000 = 100, 500 = 50, 0 = 0) uint256 private royaltyBasisPoints = 50; // 5% uint256[] _openedLoans; // tokenId => _openedLoans idx mapping(uint256 => uint256) _openedIndex; // token IDs owned by user mapping(address => uint256[]) public allUserOwned; // tokenId => allUserOwned idx mapping(uint256 => uint256) public ownedIndex; event Burn(uint256 indexed tokenId, address indexed owner); event Mint(uint256 indexed tokenId, address indexed owner); event SetPaymentAddress(address indexed user); event SetRoyaltyAddress(address indexed user); event SetRoyaltyBasisPoints(uint256 indexed _royaltyBasisPoints); event SetBaseTokenURI(string indexed newUri); modifier onlyLendingPool() { require(msg.sender == lendingPool, 'ONLYLENDINGPOOL'); _; } constructor( string memory _baseTokenURI ) ERC721('Hyperbolic Protocol Loan', 'lHYPE') { baseTokenURI = _baseTokenURI; lendingPool = msg.sender; } function getAllOpenedLoans() external view returns (uint256[] memory) { return _openedLoans; } function mint(address owner) external onlyLendingPool returns (uint256) { _ids.increment(); _safeMint(owner, _ids.current()); emit Mint(_ids.current(), owner); return _ids.current(); } function burn(uint256 _tokenId) external onlyLendingPool { address _user = ownerOf(_tokenId); require(_exists(_tokenId)); _burn(_tokenId); emit Burn(_tokenId, _user); } // Support royalty info - See {EIP-2981}: https://eips.ethereum.org/EIPS/eip-2981 function royaltyInfo( uint256, uint256 _salePrice ) external view returns (address receiver, uint256 royaltyAmount) { return (royaltyAddress, (_salePrice * royaltyBasisPoints) / 1000); } function tokenURI( uint256 _tokenId ) public view virtual override returns (string memory) { require(_exists(_tokenId)); return string(abi.encodePacked(_baseURI(), _tokenId.toString(), '.json')); } // Contract metadata URI - Support for OpenSea: https://docs.opensea.io/docs/contract-level-metadata function contractURI() public view returns (string memory) { return string(abi.encodePacked(_baseURI(), 'contract.json')); } // Override supportsInterface - See {IERC165-supportsInterface} function supportsInterface( bytes4 _interfaceId ) public view virtual override(ERC721Enumerable) returns (bool) { return super.supportsInterface(_interfaceId); } function getLastMintedTokenId() external view returns (uint256) { return _ids.current(); } function doesTokenExist(uint256 _tokenId) external view returns (bool) { return _exists(_tokenId); } function setRoyaltyAddress(address _address) external onlyOwner { royaltyAddress = _address; emit SetRoyaltyAddress(_address); } function setRoyaltyBasisPoints(uint256 _points) external onlyOwner { royaltyBasisPoints = _points; emit SetRoyaltyBasisPoints(_points); } function setBaseURI(string memory _uri) external onlyOwner { baseTokenURI = _uri; emit SetBaseTokenURI(_uri); } function setLendingPool(address _addy) external onlyOwner { lendingPool = _addy; } function getAllUserOwned( address _user ) external view returns (uint256[] memory) { return allUserOwned[_user]; } function _baseURI() internal view returns (string memory) { return baseTokenURI; } function _mint(address to, uint256 tokenId) internal virtual override { super._mint(to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual override { address _owner = ERC721.ownerOf(tokenId); super._burn(tokenId); _afterTokenTransfer(_owner, address(0), tokenId); } function _transfer( address from, address to, uint256 tokenId ) internal virtual override { super._transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } function _afterTokenTransfer( address _from, address _to, uint256 _tokenId ) internal virtual { // ensure token not being minted if (_from != address(0)) { // update user owned uint256 _currIndex = ownedIndex[_tokenId]; uint256 _tokenIdMovingIndices = allUserOwned[_from][ allUserOwned[_from].length - 1 ]; allUserOwned[_from][_currIndex] = _tokenIdMovingIndices; allUserOwned[_from].pop(); ownedIndex[_tokenIdMovingIndices] = _currIndex; // update all opened uint256 _curOpenedIdx = _openedIndex[_tokenId]; uint256 _tokenIdMoveOpened = _openedLoans[_openedLoans.length - 1]; _openedLoans[_curOpenedIdx] = _tokenIdMoveOpened; _openedLoans.pop(); _openedIndex[_tokenIdMoveOpened] = _curOpenedIdx; } // ensure token not being burned if (_to != address(0)) { // update user owned ownedIndex[_tokenId] = allUserOwned[_to].length; allUserOwned[_to].push(_tokenId); // update all opened _openedIndex[_tokenId] = _openedLoans.length; _openedLoans.push(_ids.current()); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import './interfaces/IRewardsTracker.sol'; import './libraries/BokkyPooBahsDateTimeLibrary.sol'; contract RewardsTracker is IRewardsTracker { uint256 constant MULTIPLIER = 10 ** 36; address public token; uint256 public totalStakedUsers; uint256 public totalSharesDeposited; struct Share { uint256 amount; uint256 stakedTime; } struct Reward { uint256 totalExcluded; uint256 totalRealized; } mapping(address => Share) private shares; mapping(address => Reward) public rewards; uint256 public rewardsPerShare; uint256 public totalDistributed; uint256 public totalRewards; mapping(uint256 => uint256) public monthlyRewards; event AddShares(address indexed user, uint256 amount); event RemoveShares(address indexed user, uint256 amount); event ClaimReward(address user); event DistributeReward(address indexed user, uint256 amount); event DepositRewards(address indexed user, uint256 amountTokens); modifier onlyToken() { require(msg.sender == token, 'ONLYTOKEN'); _; } constructor(address _token) { token = _token; } function setShare( address shareholder, uint256 balanceUpdate, bool isRemoving ) public override onlyToken { _setShare(shareholder, balanceUpdate, isRemoving); } function _setShare( address shareholder, uint256 balanceUpdate, bool isRemoving ) internal { if (isRemoving) { _removeShares(shareholder, balanceUpdate); emit RemoveShares(shareholder, balanceUpdate); } else { _addShares(shareholder, balanceUpdate); emit AddShares(shareholder, balanceUpdate); } } function _addShares(address shareholder, uint256 amount) private { if (shares[shareholder].amount > 0) { _distributeReward(shareholder); } uint256 sharesBefore = shares[shareholder].amount; totalSharesDeposited += amount; shares[shareholder].amount += amount; shares[shareholder].stakedTime = block.timestamp; if (sharesBefore == 0 && shares[shareholder].amount > 0) { totalStakedUsers++; } rewards[shareholder].totalExcluded = _cumulativeRewards( shares[shareholder].amount ); } function _removeShares(address shareholder, uint256 amount) private { require( shares[shareholder].amount > 0 && amount <= shares[shareholder].amount, 'REMOVE: no shares' ); _distributeReward(shareholder); totalSharesDeposited -= amount; shares[shareholder].amount -= amount; if (shares[shareholder].amount == 0) { totalStakedUsers--; } rewards[shareholder].totalExcluded = _cumulativeRewards( shares[shareholder].amount ); } function depositRewards() external payable override { _depositRewards(msg.value); } function _depositRewards(uint256 _amount) internal { require(_amount > 0, 'DEPOSIT: no ETH'); require(totalSharesDeposited > 0, 'DEPOSIT: no shares'); totalRewards += _amount; uint256 _month = beginningOfMonth(block.timestamp); monthlyRewards[_month] += _amount; rewardsPerShare += (MULTIPLIER * _amount) / totalSharesDeposited; emit DepositRewards(msg.sender, _amount); } function _distributeReward(address shareholder) internal { if (shares[shareholder].amount == 0) { return; } uint256 amount = getUnpaid(shareholder); rewards[shareholder].totalRealized += amount; rewards[shareholder].totalExcluded = _cumulativeRewards( shares[shareholder].amount ); if (amount > 0) { totalDistributed += amount; uint256 _balBefore = address(this).balance; (bool success, ) = payable(shareholder).call{ value: amount }(''); require(success, 'DIST: could not distribute'); require(address(this).balance >= _balBefore - amount, 'DIST: too much'); emit DistributeReward(shareholder, amount); } } function claimReward() external override { _distributeReward(msg.sender); emit ClaimReward(msg.sender); } function getUnpaid(address shareholder) public view returns (uint256) { if (shares[shareholder].amount == 0) { return 0; } uint256 earnedRewards = _cumulativeRewards(shares[shareholder].amount); uint256 rewardsExcluded = rewards[shareholder].totalExcluded; if (earnedRewards <= rewardsExcluded) { return 0; } return earnedRewards - rewardsExcluded; } function beginningOfMonth(uint256 _timestamp) public view returns (uint256) { (, , uint256 _dayOfMonth) = BokkyPooBahsDateTimeLibrary.timestampToDate( _timestamp ); return _timestamp - ((_dayOfMonth - 1) * 24 * 60 * 60) - (_timestamp % 1 days); } function _cumulativeRewards(uint256 share) internal view returns (uint256) { return (share * rewardsPerShare) / MULTIPLIER; } function getShares(address user) external view override returns (uint256) { return shares[user].amount; } }
{ "metadata": { "bytecodeHash": "none" }, "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"_baseTokenURI","type":"string"},{"internalType":"contract ISwapRouter","name":"__swapRouter","type":"address"},{"internalType":"contract IHyperbolicProtocol","name":"__hype","type":"address"},{"internalType":"contract ITwapUtils","name":"__twapUtils","type":"address"},{"internalType":"contract LendingRewards","name":"__lendingRewards","type":"address"},{"internalType":"address","name":"__WETH","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountETH","type":"uint256"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"DeleteLoan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountCollateral","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountDesired","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountFees","type":"uint256"}],"name":"PayBackLoan","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountCollateral","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_amountETHBorrowing","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"borrowAPRMax","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowAPRMin","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowInitFee","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountETHBorrowed","type":"uint256"},{"internalType":"uint256","name":"_aprStart","type":"uint256"}],"name":"calculateAPRFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calculateBorrowAPR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"checkUpkeep","outputs":[{"internalType":"bool","name":"upkeepNeeded","type":"bool"},{"internalType":"bytes","name":"performData","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"currentBorrowPerPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"custodian","outputs":[{"internalType":"contract LendingPoolTokenCustodian","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amountDepositing","type":"uint256"},{"internalType":"uint256","name":"_amountETHBorrowing","type":"uint256"}],"name":"depositAndBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"enabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"externalLpFeePerc","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllWhitelistedPools","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"getETHBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getLTVX96","outputs":[{"internalType":"uint256","name":"ltvX96","type":"uint256"},{"internalType":"uint256","name":"ltvWithFeesX96","type":"uint256"},{"internalType":"uint256","name":"amountETHDepositedX96","type":"uint256"},{"internalType":"uint256","name":"amountETHBorrowedX96","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hlp","outputs":[{"internalType":"contract HLP","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidateDefaultCapital","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidateSlippage","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidationLTV","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"loanNFT","outputs":[{"internalType":"contract LoanToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"loans","outputs":[{"internalType":"uint256","name":"created","type":"uint256"},{"internalType":"address","name":"createdBy","type":"address"},{"internalType":"uint256","name":"aprStart","type":"uint256"},{"internalType":"address","name":"collateralPool","type":"address"},{"internalType":"uint256","name":"amountDeposited","type":"uint256"},{"internalType":"uint256","name":"amountETHBorrowed","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxBorrowPerPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLTVOverall","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxLTVOverride","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLiquidationsPerUpkeep","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"payBackLoan","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"payBackLoanAndClose","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"performData","type":"bytes"}],"name":"performUpkeep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_apr","type":"uint32"}],"name":"setBorrowAPRMax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_apr","type":"uint32"}],"name":"setBorrowAPRMin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_fee","type":"uint32"}],"name":"setBorrowInitFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_perc","type":"uint32"}],"name":"setExternalLpFeePerc","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldLiq","type":"bool"}],"name":"setLiquidateDefaultCapital","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_slippage","type":"uint32"}],"name":"setLiquidateSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_ltv","type":"uint32"}],"name":"setLiquidationLTV","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amountETH","type":"uint256"}],"name":"setMaxBorrowPerPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_ltv","type":"uint32"}],"name":"setMaxLTVOverall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint32","name":"_ltv","type":"uint32"}],"name":"setMaxLTVOverride","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_max","type":"uint32"}],"name":"setMaxLiquidationsPerUpkeep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"shouldLiquidateLoan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"}],"name":"toggleWhitelistCollateralPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistPools","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60a06040526000805463ffffffff60b01b1916607d60b31b1763ffffffff60d01b1916600560d11b179055600a805463ffffffff1990811661012c1763ffffffff60201b191664c8000000001763ffffffff60401b19166905dc00000000000000001763ffffffff60601b19166d251c0000000000000000000000001763ffffffff60801b191661027160831b17909155600f8054909116611d4c179055348015620000aa57600080fd5b506040516200b6cb3803806200b6cb833981810160405260c0811015620000d057600080fd5b8101908080516040519392919084640100000000821115620000f157600080fd5b9083019060208201858111156200010757600080fd5b82516401000000008111828201881017156200012257600080fd5b82525081516020918201929091019080838360005b838110156200015157818101518382015260200162000137565b50505050905090810190601f1680156200017f5780820380516001836020036101000a031916815260200191505b5060409081526020820151908201516060830151608084015160a09094015192955090935091908585858585856000620001b862000435565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600680546001600160a01b03199081166001600160a01b038881169190911790925560038054821687841617908190556005805483168785161790556004805490921685841617909155606083901b6001600160601b0319166080526040519116906200026f9062000439565b6200027b919062000463565b604051809103906000f08015801562000298573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040518690620002c99062000447565b620002d5919062000477565b604051809103906000f080158015620002f2573d6000803e3d6000fd5b50600280546001600160a01b0319166001600160a01b0392831617908190556040516303692a6d60e11b81529116906306d254da906200033790339060040162000463565b600060405180830381600087803b1580156200035257600080fd5b505af115801562000367573d6000803e3d6000fd5b505060025460405163f2fde38b60e01b81526001600160a01b03909116925063f2fde38b91506200039d90339060040162000463565b600060405180830381600087803b158015620003b857600080fd5b505af1158015620003cd573d6000803e3d6000fd5b50505050505050505050604051620003e59062000455565b604051809103906000f08015801562000402573d6000803e3d6000fd5b50600f60046101000a8154816001600160a01b0302191690836001600160a01b03160217905550505050505050620004cd565b3390565b6114c880620054d583390190565b613058806200699d83390190565b611cd680620099f583390190565b6001600160a01b0391909116815260200190565b6000602080835283518082850152825b81811015620004a55785810183015185820160400152820162000487565b81811115620004b75783604083870101525b50601f01601f1916929092016040019392505050565b60805160601c614fbd62000518600039806112a5528061164d528061168852806124755280612c79528061308852806131d8528061334b52806133ef5280613a635250614fbd6000f3fe6080604052600436106102cd5760003560e01c8063838122cf11610175578063b5df93f0116100dc578063d539c6d411610095578063e1ec3c681161006f578063e1ec3c6814610b7b578063f2c342c314610bf0578063f2fde38b14610c23578063f771183414610c56576102d4565b8063d539c6d414610b03578063dfad779214610b36578063e10e6bda14610b4b576102d4565b8063b5df93f0146109bf578063bc157ac1146109f2578063c8092cf714610a31578063ca593c5914610a46578063cd08f97114610a4e578063d45b621314610ab3576102d4565b8063930cf9731161012e578063930cf973146108ec57806396e41e9e1461091c5780639d32a6801461094c5780639e4d5ddf14610978578063a4b3eb0b1461098d578063b2b8ec41146109aa576102d4565b8063838122cf146107e45780638470fc55146108295780638a05d5f9146108685780638da5cb5b146108925780638e6cce35146108a7578063921b2fb7146108d7576102d4565b80633bb66a7b1161023457806367d4a3d3116101ed5780636e04ff0d116101c75780636e04ff0d146106a15780636faa8b3f1461079d5780636fea6111146107ba578063715018a6146107cf576102d4565b806367d4a3d3146106445780636bc394d3146106775780636bfeba531461068c576102d4565b80633bb66a7b146104dc578063441a3e70146105215780634585e33b146105515780634e9865c7146105cc578063528b1ed8146105fc5780635bc7b7f314610611576102d4565b806323169a7b1161028657806323169a7b146103fc578063238dafe01461042c578063328d8f721461045557806334a4117714610481578063375b74c3146104b25780633a568474146104c7576102d4565b8063051b4d07146102d9578063075ee2c81461030b57806309fff9631461033b5780630a861f2a146103745780630ecbcdab1461039e5780631c57d3d3146103ce576102d4565b366102d457005b600080fd5b3480156102e557600080fd5b50610309600480360360208110156102fc57600080fd5b503563ffffffff16610c86565b005b34801561031757600080fd5b506103096004803603602081101561032e57600080fd5b503563ffffffff16610d40565b34801561034757600080fd5b506103096004803603604081101561035e57600080fd5b506001600160a01b038135169060200135610df5565b34801561038057600080fd5b506103096004803603602081101561039757600080fd5b5035610e73565b3480156103aa57600080fd5b50610309600480360360408110156103c157600080fd5b5080359060200135610f9f565b3480156103da57600080fd5b506103e3610faf565b6040805163ffffffff9092168252519081900360200190f35b34801561040857600080fd5b506103096004803603602081101561041f57600080fd5b503563ffffffff16610fc2565b34801561043857600080fd5b50610441611072565b604080519115158252519081900360200190f35b34801561046157600080fd5b506103096004803603602081101561047857600080fd5b50351515611082565b34801561048d57600080fd5b50610496611133565b604080516001600160a01b039092168252519081900360200190f35b3480156104be57600080fd5b50610496611142565b3480156104d357600080fd5b50610496611151565b3480156104e857600080fd5b5061050f600480360360208110156104ff57600080fd5b50356001600160a01b0316611167565b60408051918252519081900360200190f35b34801561052d57600080fd5b506103096004803603604081101561054457600080fd5b5080359060200135611178565b34801561055d57600080fd5b506103096004803603602081101561057457600080fd5b810190602081018135600160201b81111561058e57600080fd5b8201836020820111156105a057600080fd5b803590602001918460018302840111600160201b831117156105c157600080fd5b509092509050611183565b3480156105d857600080fd5b50610309600480360360208110156105ef57600080fd5b503563ffffffff16611466565b34801561060857600080fd5b506103e36114ee565b34801561061d57600080fd5b506103096004803603602081101561063457600080fd5b50356001600160a01b03166114fa565b34801561065057600080fd5b5061050f6004803603602081101561066757600080fd5b50356001600160a01b03166117d9565b34801561068357600080fd5b506103e36117eb565b34801561069857600080fd5b506103e36117fe565b3480156106ad57600080fd5b5061071c600480360360208110156106c457600080fd5b810190602081018135600160201b8111156106de57600080fd5b8201836020820111156106f057600080fd5b803590602001918460018302840111600160201b8311171561071157600080fd5b509092509050611811565b60405180831515815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610761578181015183820152602001610749565b50505050905090810190601f16801561078e5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b610309600480360360208110156107b357600080fd5b50356119b1565b3480156107c657600080fd5b506103e36119bf565b3480156107db57600080fd5b506103096119cb565b3480156107f057600080fd5b506103096004803603608081101561080757600080fd5b508035906001600160a01b036020820135169060408101359060600135611a77565b34801561083557600080fd5b506103096004803603604081101561084c57600080fd5b5080356001600160a01b0316906020013563ffffffff16611a90565b34801561087457600080fd5b506104416004803603602081101561088b57600080fd5b5035611b4d565b34801561089e57600080fd5b50610496611b5e565b3480156108b357600080fd5b50610309600480360360208110156108ca57600080fd5b503563ffffffff16611b6e565b3480156108e357600080fd5b506103e3611c1e565b3480156108f857600080fd5b506103096004803603602081101561090f57600080fd5b503563ffffffff16611c31565b34801561092857600080fd5b506103096004803603602081101561093f57600080fd5b503563ffffffff16611cd7565b34801561095857600080fd5b506103096004803603602081101561096f57600080fd5b50351515611d87565b34801561098457600080fd5b506103e3611e38565b610309600480360360208110156109a357600080fd5b5035611e4b565b3480156109b657600080fd5b506103e3611eaf565b3480156109cb57600080fd5b50610441600480360360208110156109e257600080fd5b50356001600160a01b0316611ec2565b3480156109fe57600080fd5b5061030960048036036060811015610a1557600080fd5b508035906001600160a01b036020820135169060400135611ed7565b348015610a3d57600080fd5b5061050f611ee3565b610309612083565b348015610a5a57600080fd5b50610a63612145565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610a9f578181015183820152602001610a87565b505050509050019250505060405180910390f35b348015610abf57600080fd5b50610add60048036036020811015610ad657600080fd5b50356121a7565b604080519485526020850193909352838301919091526060830152519081900360800190f35b348015610b0f57600080fd5b506103e360048036036020811015610b2657600080fd5b50356001600160a01b031661251e565b348015610b4257600080fd5b50610441612536565b348015610b5757600080fd5b5061030960048036036020811015610b6e57600080fd5b503563ffffffff16612546565b348015610b8757600080fd5b50610ba560048036036020811015610b9e57600080fd5b503561260c565b60405180878152602001866001600160a01b03168152602001858152602001846001600160a01b03168152602001838152602001828152602001965050505050505060405180910390f35b348015610bfc57600080fd5b5061050f60048036036020811015610c1357600080fd5b50356001600160a01b031661264d565b348015610c2f57600080fd5b5061030960048036036020811015610c4657600080fd5b50356001600160a01b031661265f565b348015610c6257600080fd5b5061050f60048036036040811015610c7957600080fd5b5080359060200135612761565b610c8e612790565b6001600160a01b0316610c9f611b5e565b6001600160a01b031614610ce8576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b6103e863ffffffff82161115610d195760405162461bcd60e51b8152600401610d1090614a6e565b60405180910390fd5b600a805463ffffffff909216600160201b0267ffffffff0000000019909216919091179055565b610d48612790565b6001600160a01b0316610d59611b5e565b6001600160a01b031614610da2576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff82161115610dca5760405162461bcd60e51b8152600401610d1090614964565b600a805463ffffffff909216600160401b026bffffffff000000000000000019909216919091179055565b610dfd612790565b6001600160a01b0316610e0e611b5e565b6001600160a01b031614610e57576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b6001600160a01b039091166000908152600d6020526040902055565b600f54600160201b90046001600160a01b0316639dc29fac610e93612790565b836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b158015610eda57600080fd5b505af1158015610eee573d6000803e3d6000fd5b505050506000610efc612790565b6040516001600160a01b0391909116908390600081818185875af1925050503d8060008114610f47576040519150601f19603f3d011682016040523d82523d6000602084013e610f4c565b606091505b5050905080610f9b576040805162461bcd60e51b815260206004820152601660248201527515d2551211149055ce88115512081b9bdd081cd95b9d60521b604482015290519081900360640190fd5b5050565b610faa338383612794565b505050565b600054600160b01b900463ffffffff1681565b610fca612790565b6001600160a01b0316610fdb611b5e565b6001600160a01b031614611024576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff8216111561104c5760405162461bcd60e51b8152600401610d1090614d8a565b6000805463ffffffff909216600160b01b0263ffffffff60b01b19909216919091179055565b600054600160a01b900460ff1681565b61108a612790565b6001600160a01b031661109b611b5e565b6001600160a01b0316146110e4576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b60005460ff600160a01b90910416151581151514156111155760405162461bcd60e51b8152600401610d1090614c8f565b60008054911515600160a01b0260ff60a01b19909216919091179055565b6002546001600160a01b031681565b6001546001600160a01b031681565b600f54600160201b90046001600160a01b031681565b6001600160a01b038116315b919050565b610f9b338383612ac3565b600061119182840184614652565b905060005b81518110156114605760008282815181106111ad57fe5b6020026020010151905080600014156111c65750611460565b6111cf81612e92565b15611457576000818152600e60209081526040808320815160c0810183528154815260018201546001600160a01b0390811682860152600283015482850152600383015416606082018190526004808401546080840181905260059094015460a08401528451630dfe168160e01b815294519296939591948593630dfe168193828401939092829003018186803b15801561126957600080fd5b505afa15801561127d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112a1919061456e565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031614156113d0576000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561131857600080fd5b505afa15801561132c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611350919061456e565b600180546020880151604051633b6191dd60e01b81529394506001600160a01b0390911692633b6191dd9261138d92869290918a916004016148b7565b600060405180830381600087803b1580156113a757600080fd5b505af11580156113bb573d6000803e3d6000fd5b505050506113ca838287612f4f565b50611449565b600180546020860151604051633b6191dd60e01b815284936001600160a01b0390931692633b6191dd9261140a9286928a916004016148b7565b600060405180830381600087803b15801561142457600080fd5b505af1158015611438573d6000803e3d6000fd5b50505050611447838287612f4f565b505b61145285613483565b505050505b50600101611196565b50505050565b61146e612790565b6001600160a01b031661147f611b5e565b6001600160a01b0316146114c8576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b6000805463ffffffff909216600160d01b0263ffffffff60d01b19909216919091179055565b600f5463ffffffff1681565b611502612790565b6001600160a01b0316611513611b5e565b6001600160a01b03161461155c576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b60008190506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561159c57600080fd5b505afa1580156115b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115d4919061456e565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561161157600080fd5b505afa158015611625573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611649919061456e565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614806116bc57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316145b6116d85760405162461bcd60e51b8152600401610d1090614e17565b60408051600280825260608201835260009260208301908036833701905050905061012c8160008151811061170957fe5b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061173257fe5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0385169063883bdbfd90611773908490600401614879565b60006040518083038186803b15801561178b57600080fd5b505afa15801561179f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526117c7919081019061458a565b50506117d28561355b565b5050505050565b600d6020526000908152604090205481565b600a54600160801b900463ffffffff1681565b600054600160d01b900463ffffffff1681565b600060606000600260009054906101000a90046001600160a01b03166001600160a01b0316636800901a6040518163ffffffff1660e01b815260040160006040518083038186803b15801561186557600080fd5b505afa158015611879573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118a191908101906146e2565b6000805491925090600160d01b900463ffffffff1667ffffffffffffffff811180156118cc57600080fd5b506040519080825280602002602001820160405280156118f6578160200160208202803683370190505b5090506000805b835181101561197d5760005463ffffffff600160d01b9091048116908316106119255761197d565b600084828151811061193357fe5b6020026020010151905061194681612e92565b15611974576001965080848463ffffffff168151811061196257fe5b60209081029190910101526001909201915b506001016118fd565b5084156119a757816040516020016119959190614835565b60405160208183030381529060405293505b5050509250929050565b6119bc3382346136c6565b50565b600a5463ffffffff1681565b6119d3612790565b6001600160a01b03166119e4611b5e565b6001600160a01b031614611a2d576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b611a83338585856138b7565b93506117d2338583612794565b611a98612790565b6001600160a01b0316611aa9611b5e565b6001600160a01b031614611af2576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff82161115611b1a5760405162461bcd60e51b8152600401610d1090614bd4565b6001600160a01b03919091166000908152600b60205260409020805463ffffffff191663ffffffff909216919091179055565b6000611b5882612e92565b92915050565b6000546001600160a01b03165b90565b611b76612790565b6001600160a01b0316611b87611b5e565b6001600160a01b031614611bd0576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff82161115611bf85760405162461bcd60e51b8152600401610d1090614bd4565b600a805463ffffffff909216600160801b0263ffffffff60801b19909216919091179055565b600a54600160601b900463ffffffff1681565b611c39612790565b6001600160a01b0316611c4a611b5e565b6001600160a01b031614611c93576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b610bb863ffffffff82161115611cbb5760405162461bcd60e51b8152600401610d1090614c38565b600a805463ffffffff191663ffffffff92909216919091179055565b611cdf612790565b6001600160a01b0316611cf0611b5e565b6001600160a01b031614611d39576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff82161115611d615760405162461bcd60e51b8152600401610d10906148e0565b600a805463ffffffff909216600160601b0263ffffffff60601b19909216919091179055565b611d8f612790565b6001600160a01b0316611da0611b5e565b6001600160a01b031614611de9576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b60005460ff600160a81b9091041615158115151415611e1a5760405162461bcd60e51b8152600401610d1090614adc565b60008054911515600160a81b0260ff60a81b19909216919091179055565b600a54600160201b900463ffffffff1681565b6000818152600e602052604090206005015415611e7257611e6d3382346136c6565b611e90565b3415611e905760405162461bcd60e51b8152600401610d1090614a37565b6000818152600e60205260409020600401546119bc9033908390612ac3565b600a54600160401b900463ffffffff1681565b60076020526000908152604090205460ff1681565b611460338484846138b7565b6000806000600360009054906101000a90046001600160a01b03166001600160a01b031663fb5ebf366040518163ffffffff1660e01b8152600401604080518083038186803b158015611f3557600080fd5b505afa158015611f49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6d91906147c1565b91509150600061271063ffffffff16600360009054906101000a90046001600160a01b03166001600160a01b0316637e3596996040518163ffffffff1660e01b815260040160206040518083038186803b158015611fca57600080fd5b505afa158015611fde573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200291906147e4565b63ffffffff1683028161201157fe5b0490508083101561206b57600a54600090829063ffffffff600160201b82048116600160401b9092048116919091031685028161204a57fe5b600a54919004600160401b90910463ffffffff16039450611b6b9350505050565b5050600a54600160201b900463ffffffff1692915050565b600034116120ca576040805162461bcd60e51b815260206004820152600f60248201526e0888aa09ea692a87440dcde408aa89608b1b604482015290519081900360640190fd5b600f54600160201b90046001600160a01b03166340c10f196120ea612790565b346040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561213157600080fd5b505af1158015611460573d6000803e3d6000fd5b6060600880548060200260200160405190810160405280929190818152602001828054801561219d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161217f575b5050505050905090565b60025460405163c3738f3f60e01b81526000918291829182916001600160a01b039091169063c3738f3f906121e0908890600401614eac565b60206040518083038186803b1580156121f857600080fd5b505afa15801561220c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122309190614766565b61224c5760405162461bcd60e51b8152600401610d1090614d1c565b6000858152600e60209081526040808320815160c0810183528154815260018201546001600160a01b0390811694820194909452600282015492810183905260038201549093166060840152600481015460808401526005015460a083018190529192916122b991612761565b9050816080015160001480156122d1575060a0820151155b156122eb5760008060008095509550955095505050612517565b6005546060830151604051631ece4f9760e21b81526000926001600160a01b031691637b393e5c916123209190600401614808565b60206040518083038186803b15801561233857600080fd5b505afa15801561234c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612370919061456e565b6005546040516304e09a6160e41b81529192506000916001600160a01b0390911690634e09a610906123a6908590600401614808565b60206040518083038186803b1580156123be57600080fd5b505afa1580156123d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f691906147a9565b9050600084606001516001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561243757600080fd5b505afa15801561244b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061246f919061456e565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316146124b857856080015183026124cd565b82600160c01b816124c557fe5b048660800151025b60a0870151909150600160601b81810291878101909102908390600160c01b02816124f457fe5b0483600160601b83028161250457fe5b919d5090049a5091985096505050505050505b9193509193565b600b6020526000908152604090205463ffffffff1681565b600054600160a81b900460ff1681565b61254e612790565b6001600160a01b031661255f611b5e565b6001600160a01b0316146125a8576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff821611156125f0576040805162461bcd60e51b81526020600482015260086024820152676c7465203130302560c01b604482015290519081900360640190fd5b600f805463ffffffff191663ffffffff92909216919091179055565b600e6020526000908152604090208054600182015460028301546003840154600485015460059095015493946001600160a01b039384169492939091169186565b600c6020526000908152604090205481565b612667612790565b6001600160a01b0316612678611b5e565b6001600160a01b0316146126c1576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b6001600160a01b0381166127065760405162461bcd60e51b8152600401808060200182810382526026815260200180614f1b6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006301e1338061271084612774611ee3565b85420302028161278057fe5b048161278857fe5b049392505050565b3390565b60008054600160a01b900460ff166127be5760405162461bcd60e51b8152600401610d1090614c62565b6127c88484613d80565b6000838152600e6020908152604080832060038101546001600160a01b0316845260079092529091205460ff166128115760405162461bcd60e51b8152600401610d1090614cc6565b600061282582600501548360020154612761565b4260028401559050600080612839876121a7565b9350935050506000600160601b838161284e57fe5b60038701546001600160a01b03166000908152600b6020526040812054929091049250600160601b84049163ffffffff1661289f57600a5461271090600160801b900463ffffffff168402046128ca565b60038701546001600160a01b03166000908152600b60205260409020546127109063ffffffff168402045b90508082106128eb5760405162461bcd60e51b8152600401610d1090614aff565b8089830111156128fb5781810398505b8847101561291b5760405162461bcd60e51b8152600401610d1090614992565b60038701546001600160a01b03166000908152600d6020526040902054156129865760038701546001600160a01b03166000908152600d6020908152604080832054600c909252909120548a0111156129865760405162461bcd60e51b8152600401610d1090614a00565b60038701546001600160a01b03166000908152600c6020526040902080548a0190556005870180548a019055600a5461271063ffffffff9091168a02048601808a116129e45760405162461bcd60e51b8152600401610d1090614dd3565b808a036129f082613e30565b60008d6001600160a01b031682604051612a0990611b6b565b60006040518083038185875af1925050503d8060008114612a46576040519150601f19603f3d011682016040523d82523d6000602084013e612a4b565b606091505b5050905080612a6c5760405162461bcd60e51b8152600401610d1090614c01565b8c8e6001600160a01b03167fe1979fe4c35e0cef342fef5668e2c8e7a7e9f5d5d1ca8fee0ac6c427fa4153af8e604051612aa69190614eac565b60405180910390a38c9a50505050505050505050505b9392505050565b60008111612ae35760405162461bcd60e51b8152600401610d1090614a9b565b612aed8383613d80565b6000828152600e602052604090206004810154821115612b1f5760405162461bcd60e51b8152600401610d109061490c565b60048101805483900390556000612b35846121a7565b505060038401546001600160a01b03166000908152600b602052604090205490925063ffffffff16159050612bb65760038201546001600160a01b03166000908152600b60205260409020546127109063ffffffff16600160601b0204811115612bb15760405162461bcd60e51b8152600401610d1090614d53565b612bf1565b600a5461271090600160601b600160801b90910463ffffffff160204811115612bf15760405162461bcd60e51b8152600401610d1090614d53565b600382015460408051630dfe168160e01b815290516001600160a01b03909216916000918391630dfe168191600480820192602092909190829003018186803b158015612c3d57600080fd5b505afa158015612c51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c75919061456e565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b03161415612dae576000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015612cec57600080fd5b505afa158015612d00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d24919061456e565b6001805487820154604051633b6191dd60e01b81529394506001600160a01b0391821693633b6191dd93612d6193879316918c91906004016148b7565b600060405180830381600087803b158015612d7b57600080fd5b505af1158015612d8f573d6000803e3d6000fd5b50612da8925050506001600160a01b0382168988613f90565b50612e35565b6001805485820154604051633b6191dd60e01b815284936001600160a01b0393841693633b6191dd93612dec93879392909116918c916004016148b7565b600060405180830381600087803b158015612e0657600080fd5b505af1158015612e1a573d6000803e3d6000fd5b50612e33925050506001600160a01b0382168988613f90565b505b6004840154612e4757612e4786613483565b85876001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b56887604051612e819190614eac565b60405180910390a350505050505050565b60025460405163c3738f3f60e01b81526000916001600160a01b03169063c3738f3f90612ec3908590600401614eac565b60206040518083038186803b158015612edb57600080fd5b505afa158015612eef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f139190614766565b612f1f57506000611173565b6000612f2a836121a7565b5050600a5461271063ffffffff600160601b9283900416909102041115949350505050565b600054600160a81b900460ff168015612f7657506003546001600160a01b03838116911614155b1561346257600554604051631ece4f9760e21b81526000916001600160a01b031690637b393e5c90612fac908790600401614808565b60206040518083038186803b158015612fc457600080fd5b505afa158015612fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ffc919061456e565b6005546040516304e09a6160e41b81529192506000916001600160a01b0390911690634e09a61090613032908590600401614808565b60206040518083038186803b15801561304a57600080fd5b505afa15801561305e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308291906147a9565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316866001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156130e957600080fd5b505afa1580156130fd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613121919061456e565b6001600160a01b0316146131425781600160c01b8161313c57fe5b04613144565b815b90506000600160601b856080015183028161315b57fe5b04905060008560a001518211613175578560a00151613177565b815b60065460808801519192506131979189916001600160a01b031690613fe2565b600660009054906101000a90046001600160a01b03166001600160a01b031663414bf3896040518061010001604052808a6001600160a01b031681526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018b6001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b15801561323e57600080fd5b505afa158015613252573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132769190614786565b62ffffff1681523060208201524260408201526080808b0151606083015260005491019061271090600160b01b900463ffffffff908116820316860204815260006020909101526040516001600160e01b031960e084901b1681526132de9190600401614e43565b602060405180830381600087803b1580156132f857600080fd5b505af115801561330c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061333091906147a9565b506040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190613380903090600401614808565b60206040518083038186803b15801561339857600080fd5b505afa1580156133ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d091906147a9565b9050801561345757604051632e1a7d4d60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d90613424908490600401614eac565b600060405180830381600087803b15801561343e57600080fd5b505af1158015613452573d6000803e3d6000fd5b505050505b505050505050610faa565b610faa61346d611b5e565b60808301516001600160a01b0385169190613f90565b6000818152600e60205260408082208281556001810180546001600160a01b03199081169091556002808301859055600383018054909216909155600480830185905560059092019390935591549051630852cd8d60e31b81526001600160a01b03909116916342966c68916134fb91859101614eac565b600060405180830381600087803b15801561351557600080fd5b505af1158015613529573d6000803e3d6000fd5b50506040518392507f40e7dd78d661cb2192925e6eeecc3f99eb4f3e7457c18ea57ddd84cd051d01f39150600090a250565b6001600160a01b03811660009081526007602052604090205460ff1615613653576001600160a01b0381166000908152600960205260408120546008805491929160001981019081106135aa57fe5b600091825260209091200154600880546001600160a01b0390921692508291849081106135d357fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b03948516179055838316825260098152604080832086905592861682526007905220805460ff19169055600880548061362957fe5b600082815260209020810160001990810180546001600160a01b0319169055019055506119bc9050565b6001600160a01b03166000818152600760209081526040808320805460ff19166001908117909155600880546009909452918420839055820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b600081116136e65760405162461bcd60e51b8152600401610d10906149c9565b6136f08383613d80565b6000828152600e60205260408120600581015460028201549192916137159190612761565b426002840155905080831161373c5760405162461bcd60e51b8152600401610d1090614b2e565b6005820154810160008185111561375257508084035b60038401546001600160a01b03166000908152600c60205260409020548386031161377f5782850361379d565b60038401546001600160a01b03166000908152600c60205260409020545b60038501546001600160a01b03166000908152600c6020526040902080549190910390556005840154838603116137d6578285036137dc565b83600501545b60058501805491909103905582156137f7576137f783613e30565b801561387b576000876001600160a01b03168260405161381690611b6b565b60006040518083038185875af1925050503d8060008114613853576040519150601f19603f3d011682016040523d82523d6000602084013e613858565b606091505b50509050806138795760405162461bcd60e51b8152600401610d1090614b6f565b505b85876001600160a01b03167fca92b037c5d17af773d2a576cd91e713e64b80af7c561456d811d12fc92796008786604051612e81929190614eb5565b60008054600160a01b900460ff166138e15760405162461bcd60e51b8152600401610d1090614ba6565b60006138ed8686614129565b506000818152600e602052604081206003810154929750879350916001600160a01b0316613991576001600160a01b03861660009081526007602052604090205460ff1661394d5760405162461bcd60e51b8152600401610d1090614cf0565b50428082556001820180546001600160a01b03808b166001600160a01b031992831617909255600284019290925560038301805491881691909216179055846139dd565b60038201546001600160a01b031660009081526007602052604090205460ff166139cd5760405162461bcd60e51b8152600401610d1090614938565b5060038101546001600160a01b03165b600480830180548701905560408051630dfe168160e01b815290516000926001600160a01b03851692630dfe16819281830192602092829003018186803b158015613a2757600080fd5b505afa158015613a3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a5f919061456e565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b03161415613c22576000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015613ad657600080fd5b505afa158015613aea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0e919061456e565b9050613b256001600160a01b0382168b308a6141d6565b60015460405163095ea7b360e01b81526001600160a01b038381169263095ea7b392613b5992909116908b9060040161481c565b602060405180830381600087803b158015613b7357600080fd5b505af1158015613b87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bab9190614766565b506001805490850154604051633b6191dd60e01b81526001600160a01b0392831692633b6191dd92613bea928692909116908c906000906004016148b7565b600060405180830381600087803b158015613c0457600080fd5b505af1158015613c18573d6000803e3d6000fd5b5050505050613d31565b80613c386001600160a01b0382168b308a6141d6565b60015460405163095ea7b360e01b81526001600160a01b038381169263095ea7b392613c6c92909116908b9060040161481c565b602060405180830381600087803b158015613c8657600080fd5b505af1158015613c9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cbe9190614766565b506001805490850154604051633b6191dd60e01b81526001600160a01b0392831692633b6191dd92613cfd928692909116908c906000906004016148b7565b600060405180830381600087803b158015613d1757600080fd5b505af1158015613d2b573d6000803e3d6000fd5b50505050505b87896001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1588604051613d6b9190614eac565b60405180910390a35095979650505050505050565b6002546040516331a9108f60e11b81526001600160a01b0390911690636352211e90613db0908490600401614eac565b60206040518083038186803b158015613dc857600080fd5b505afa158015613ddc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e00919061456e565b6001600160a01b0316826001600160a01b031614610f9b5760405162461bcd60e51b8152600401610d1090614dac565b600f5461271063ffffffff9091168202048082038115613f27576000600f60049054906101000a90046001600160a01b03166001600160a01b031663ac5da9526040518163ffffffff1660e01b815260040160206040518083038186803b158015613e9a57600080fd5b505afa158015613eae573d6000803e3d6000fd5b505050506040513d6020811015613ec457600080fd5b50516040805163152111f760e01b815290519192506001600160a01b0383169163152111f7918691600480830192600092919082900301818588803b158015613f0c57600080fd5b505af1158015613f20573d6000803e3d6000fd5b5050505050505b8015610faa57600480546040805163152111f760e01b815290516001600160a01b039092169263152111f7928592808301926000929182900301818588803b158015613f7257600080fd5b505af1158015613f86573d6000803e3d6000fd5b5050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610faa90849061422c565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1781529251825160009485949389169392918291908083835b6020831061405e5780518252601f19909201916020918201910161403f565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146140c0576040519150601f19603f3d011682016040523d82523d6000602084013e6140c5565b606091505b50915091508180156140f35750805115806140f357508080602001905160208110156140f057600080fd5b50515b6117d2576040805162461bcd60e51b8152602060048201526002602482015261534160f01b604482015290519081900360640190fd5b600080826141be576002546040516335313c2160e11b81526001600160a01b0390911690636a62784290614161908790600401614808565b602060405180830381600087803b15801561417b57600080fd5b505af115801561418f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141b391906147a9565b9150600190506141cf565b6141c88484613d80565b5081905060005b9250929050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526114609085905b6000614281826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166142dd9092919063ffffffff16565b805190915015610faa578080602001905160208110156142a057600080fd5b5051610faa5760405162461bcd60e51b815260040180806020018281038252602a815260200180614f87602a913960400191505060405180910390fd5b60606142ec84846000856142f4565b949350505050565b6060824710156143355760405162461bcd60e51b8152600401808060200182810382526026815260200180614f416026913960400191505060405180910390fd5b61433e8561444f565b61438f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106143cd5780518252601f1990920191602091820191016143ae565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461442f576040519150601f19603f3d011682016040523d82523d6000602084013e614434565b606091505b5091509150614444828286614455565b979650505050505050565b3b151590565b60608315614464575081612abc565b8251156144745782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156144be5781810151838201526020016144a6565b50505050905090810190601f1680156144eb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b600082601f830112614509578081fd5b8151602061451e61451983614ee7565b614ec3565b828152818101908583018385028701840188101561453a578586fd5b855b8581101561456157815161454f81614f05565b8452928401929084019060010161453c565b5090979650505050505050565b60006020828403121561457f578081fd5b8151612abc81614f05565b6000806040838503121561459c578081fd5b825167ffffffffffffffff808211156145b3578283fd5b818501915085601f8301126145c6578283fd5b815160206145d661451983614ee7565b82815281810190858301838502870184018b10156145f2578788fd5b8796505b848710156146225780518060060b811461460e578889fd5b8352600196909601959183019183016145f6565b509188015191965090935050508082111561463b578283fd5b50614648858286016144f9565b9150509250929050565b60006020808385031215614664578182fd5b823567ffffffffffffffff81111561467a578283fd5b8301601f8101851361468a578283fd5b803561469861451982614ee7565b81815283810190838501858402850186018910156146b4578687fd5b8694505b838510156146d65780358352600194909401939185019185016146b8565b50979650505050505050565b600060208083850312156146f4578182fd5b825167ffffffffffffffff81111561470a578283fd5b8301601f8101851361471a578283fd5b805161472861451982614ee7565b8181528381019083850185840285018601891015614744578687fd5b8694505b838510156146d6578051835260019490940193918501918501614748565b600060208284031215614777578081fd5b81518015158114612abc578182fd5b600060208284031215614797578081fd5b815162ffffff81168114612abc578182fd5b6000602082840312156147ba578081fd5b5051919050565b600080604083850312156147d3578182fd5b505080516020909101519092909150565b6000602082840312156147f5578081fd5b815163ffffffff81168114612abc578182fd5b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561486d57835183529284019291840191600101614851565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561486d57835163ffffffff1683529284019291840191600101614895565b6001600160a01b0394851681529290931660208301526040820152901515606082015260800190565b6020808252601290820152715345544c504c54563a206c7465203130302560701b604082015260600190565b6020808252601290820152710ae92a89088a482ae7440e8dede40daeac6d60731b604082015260600190565b6020808252601290820152714445504f5349543a2062616420706f6f6c3160701b604082015260600190565b602080825260149082015273534554424150524d41583a206c7465203130302560601b604082015260600190565b60208082526018908201527f424f52524f573a206e6f7420656e6f7567682066756e64730000000000000000604082015260600190565b6020808252601b908201527f5041594241434b3a206e6f2045544820746f20706179206261636b0000000000604082015260600190565b60208082526018908201527f424f52524f573a206578636565647320706f6f6c206d61780000000000000000604082015260600190565b6020808252601a908201527f5041594241434b4c4f53453a206e6f20455448206e6565646564000000000000604082015260600190565b602080825260139082015272534554424150524d494e3a206c74652031302560681b604082015260600190565b60208082526021908201527f57495448445241573a206d7573742077697468647261772066726f6d206c6f616040820152603760f91b606082015260800190565b60208082526009908201526829a2aa2624a8a222a360b91b604082015260600190565b602080825260159082015274424f52524f573a2063616e6e6f7420626f72726f7760581b604082015260600190565b60208082526021908201527f5041594241434b3a206d75737420706179206261636b2061626f7665206665656040820152607360f81b606082015260800190565b6020808252601c908201527f5041594241434b3a20726566756e6420756e7375636365737366756c00000000604082015260600190565b60208082526014908201527311115413d4d2550e881b9bdd08195b98589b195960621b604082015260600190565b6020808252601390820152725345544c54564d41583a206c7465203130302560681b604082015260600190565b60208082526019908201527f424f52524f573a20455448206e6f742064656c69766572656400000000000000604082015260600190565b60208082526010908201526f534554424645453a206c74652033302560801b604082015260600190565b6020808252601390820152721093d49493d5ce881b9bdd08195b98589b1959606a1b604082015260600190565b60208082526017908201527f534554454e41424c45443a206d75737420746f67676c65000000000000000000604082015260600190565b60208082526010908201526f1093d49493d5ce88189859081c1bdbdb60821b604082015260600190565b60208082526012908201527104445504f5349543a2062616420706f6f6c360741b604082015260600190565b60208082526017908201527f4745544c54563a206c6f616e206d757374206578697374000000000000000000604082015260600190565b60208082526019908201527f57495448445241573a2065786365656473206d6178204c545600000000000000604082015260600190565b6020808252600890820152676c7465203130302560c01b604082015260600190565b6020808252600d908201526c2b20a624a220aa22a7aba722a960991b604082015260600190565b60208082526024908201527f424f52524f573a2066656573206d6f7265207468616e20626f72726f7720616d6040820152631bdd5b9d60e21b606082015260800190565b6020808252601290820152710a89e8e8e988a869e98987440dcde408aa8960731b604082015260600190565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c0808401519083015260e09283015116918101919091526101000190565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff81118282101715614edf57fe5b604052919050565b600067ffffffffffffffff821115614efb57fe5b5060209081020190565b6001600160a01b03811681146119bc57600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c6343000706000a608060405234801561001057600080fd5b506040516114c83803806114c88339818101604052602081101561003357600080fd5b50518060006100406100be565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600180546001600160a01b039283166001600160a01b031991821617909155600a80549390921692169190911790556100c2565b3390565b6113f7806100d16000396000f3fe6080604052600436106101185760003560e01c806380bb4055116100a0578063d076eabc11610064578063d076eabc14610479578063efca2eed146104a3578063f04da65b146104b8578063f2fde38b146104eb578063fc0c546a1461051e5761025f565b806380bb4055146103f257806389d96917146104075780638da5cb5b1461043a578063b88a802f1461044f578063c7e1d0b1146104645761025f565b806329cc05cf116100e757806329cc05cf1461030b5780633b6191dd1461034c5780633c6e6789146103975780636ecf9f7b146103ac578063715018a6146103dd5761025f565b8063058df06d146102645780630700037d146102a05780630e15561a146102ec578063152111f7146103015761025f565b3661025f57600a54604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561016857600080fd5b505afa15801561017c573d6000803e3d6000fd5b505050506040513d602081101561019257600080fd5b5051905080156101aa576101a534610533565b61025c565b60006101b4610654565b6040516001600160a01b0391909116903490600081818185875af1925050503d80600081146101ff576040519150601f19603f3d011682016040523d82523d6000602084013e610204565b606091505b505090508061025a576040805162461bcd60e51b815260206004820152601e60248201527f524543454956453a20646964206e6f742073656e6420746f206f776e65720000604482015290519081900360640190fd5b505b50005b600080fd5b34801561027057600080fd5b5061028e6004803603602081101561028757600080fd5b5035610663565b60408051918252519081900360200190f35b3480156102ac57600080fd5b506102d3600480360360208110156102c357600080fd5b50356001600160a01b0316610675565b6040805192835260208301919091528051918290030190f35b3480156102f857600080fd5b5061028e61068e565b610309610694565b005b34801561031757600080fd5b506103096004803603606081101561032e57600080fd5b506001600160a01b038135169060208101359060400135151561069f565b34801561035857600080fd5b506103096004803603608081101561036f57600080fd5b506001600160a01b0381358116916020810135909116906040810135906060013515156106fa565b3480156103a357600080fd5b5061028e6107c9565b3480156103b857600080fd5b506103c16107cf565b604080516001600160a01b039092168252519081900360200190f35b3480156103e957600080fd5b506103096107de565b3480156103fe57600080fd5b5061028e61089c565b34801561041357600080fd5b5061028e6004803603602081101561042a57600080fd5b50356001600160a01b03166108a2565b34801561044657600080fd5b506103c1610654565b34801561045b57600080fd5b50610309610921565b34801561047057600080fd5b5061028e61095f565b34801561048557600080fd5b5061028e6004803603602081101561049c57600080fd5b5035610965565b3480156104af57600080fd5b5061028e61099a565b3480156104c457600080fd5b5061028e600480360360208110156104db57600080fd5b50356001600160a01b03166109a0565b3480156104f757600080fd5b506103096004803603602081101561050e57600080fd5b50356001600160a01b03166109bb565b34801561052a57600080fd5b506103c1610acf565b6000811161057a576040805162461bcd60e51b815260206004820152600f60248201526e0888aa09ea692a87440dcde408aa89608b1b604482015290519081900360640190fd5b6000600354116105c6576040805162461bcd60e51b81526020600482015260126024820152714445504f5349543a206e6f2073686172657360701b604482015290519081900360640190fd5b600880548201905560006105d942610965565b60008181526009602052604090208054840190556003549091506ec097ce7bc90715b34b9f100000000083028161060c57fe5b600680549290910491909101905560408051838152905133917fb9ad861b752f80117b35bea6dec99933d8a5ae360f2839ee8784b750d5613409919081900360200190a25050565b6000546001600160a01b031690565b60096020526000908152604090205481565b6005602052600090815260409020805460019091015482565b60085481565b61069d34610533565b565b6001546001600160a01b031633146106ea576040805162461bcd60e51b815260206004820152600960248201526827a7262caa27a5a2a760b91b604482015290519081900360640190fd5b6106f5838383610ade565b505050565b610702610b80565b6001600160a01b0316610713610654565b6001600160a01b03161461076e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b801561078d576107886001600160a01b0385163384610b84565b6107a2565b6107a26001600160a01b038516333085610bd6565b600a546001600160a01b03858116911614156107c3576107c3838383610ade565b50505050565b60035481565b600a546001600160a01b031681565b6107e6610b80565b6001600160a01b03166107f7610654565b6001600160a01b031614610852576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60025481565b6001600160a01b0381166000908152600460205260408120546108c75750600061091c565b6001600160a01b0382166000908152600460205260408120546108e990610c30565b6001600160a01b0384166000908152600560205260409020549091508082116109175760009250505061091c565b900390505b919050565b61092a33610c55565b6040805133815290517f63e32091e4445d16e29c33a6b264577c2d86694021aa4e6f4dd590048f5792e89181900360200190a1565b60065481565b60008061097183610e18565b9250505062015180838161098157fe5b0662015180600019909201919091028303039050919050565b60075481565b6001600160a01b031660009081526004602052604090205490565b6109c3610b80565b6001600160a01b03166109d4610654565b6001600160a01b031614610a2f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610a745760405162461bcd60e51b81526004018080602001828103825260268152602001806113756026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031681565b8015610b3257610aee8383610e37565b6040805183815290516001600160a01b038516917fae0577e1c96b26fbc0b9df702431f5470979d001d24f136eded791b8b6521d6f919081900360200190a26106f5565b610b3c8383610f3f565b6040805183815290516001600160a01b038516917fba8f3777cf908803bf1f3dd58e7f4b7d3de4dbe3c234c4ccab0975d98f7cd388919081900360200190a2505050565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526106f590849061100f565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526107c390859061100f565b60006ec097ce7bc90715b34b9f1000000000600654830281610c4e57fe5b0492915050565b6001600160a01b038116600090815260046020526040902054610c7757610e15565b6000610c82826108a2565b6001600160a01b03831660009081526005602090815260408083206001018054850190556004909152902054909150610cba90610c30565b6001600160a01b0383166000908152600560205260409020558015610e1357600780548201905560405147906000906001600160a01b0385169084908381818185875af1925050503d8060008114610d2e576040519150601f19603f3d011682016040523d82523d6000602084013e610d33565b606091505b5050905080610d89576040805162461bcd60e51b815260206004820152601a60248201527f444953543a20636f756c64206e6f742064697374726962757465000000000000604482015290519081900360640190fd5b828203471015610dd1576040805162461bcd60e51b815260206004820152600e60248201526d08892a6a87440e8dede40daeac6d60931b604482015290519081900360640190fd5b6040805184815290516001600160a01b038616917fe8b160e373db99a103e0a2abfa029b9c3fc8b328984a1ead8a65ae68ae646db7919081900360200190a250505b505b50565b60008080610e2a6201518085046110c0565b9196909550909350915050565b6001600160a01b03821660009081526004602052604090205415801590610e7657506001600160a01b0382166000908152600460205260409020548111155b610ebb576040805162461bcd60e51b815260206004820152601160248201527052454d4f56453a206e6f2073686172657360781b604482015290519081900360640190fd5b610ec482610c55565b6003805482900390556001600160a01b0382166000908152600460205260409020805482900390819055610efd57600280546000190190555b6001600160a01b038216600090815260046020526040902054610f1f90610c30565b6001600160a01b0390921660009081526005602052604090209190915550565b6001600160a01b03821660009081526004602052604090205415610f6657610f6682610c55565b6001600160a01b0382166000908152600460205260409020805460038054840190558154830182554260019092019190915580158015610fbd57506001600160a01b03831660009081526004602052604090205415155b15610fcc576002805460010190555b6001600160a01b038316600090815260046020526040902054610fee90610c30565b6001600160a01b039093166000908152600560205260409020929092555050565b6000611064826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111569092919063ffffffff16565b8051909150156106f55780806020019051602081101561108357600080fd5b50516106f55760405162461bcd60e51b815260040180806020018281038252602a8152602001806113c1602a913960400191505060405180910390fd5b60008080836226496581018262023ab1600483020590506004600362023ab18302010590910390600062164b09610fa0600185010205905060046105b58202058303601f019250600061098f846050028161111757fe5b0590506000605061098f83020585039050600b820560301994909401606402929092018301996002600c90940290910392909201975095509350505050565b6060611165848460008561116f565b90505b9392505050565b6060824710156111b05760405162461bcd60e51b815260040180806020018281038252602681526020018061139b6026913960400191505060405180910390fd5b6111b9856112ca565b61120a576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106112485780518252601f199092019160209182019101611229565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146112aa576040519150601f19603f3d011682016040523d82523d6000602084013e6112af565b606091505b50915091506112bf8282866112d0565b979650505050505050565b3b151590565b606083156112df575081611168565b8251156112ef5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611339578181015183820152602001611321565b50505050905090810190601f1680156113665780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c6343000706000a608060405260326013553480156200001657600080fd5b506040516200305838038062003058833981810160405260208110156200003c57600080fd5b81019080805160405193929190846401000000008211156200005d57600080fd5b9083019060208201858111156200007357600080fd5b82516401000000008111828201881017156200008e57600080fd5b82525081516020918201929091019080838360005b83811015620000bd578181015183820152602001620000a3565b50505050905090810190601f168015620000eb5780820380516001836020036101000a031916815260200191505b5060408181018152601882527f4879706572626f6c69632050726f746f636f6c204c6f616e0000000000000000602080840191909152815180830190925260058252646c4859504560d81b9082015290935091506200015390506301ffc9a760e01b62000241565b815162000168906006906020850190620002ca565b5080516200017e906007906020840190620002ca565b50620001916380ac58cd60e01b62000241565b620001a3635b5e139f60e01b62000241565b620001b563780e9d6360e01b62000241565b5060009050620001c4620002c6565b600e80546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350805162000227906011906020840190620002ca565b5050600f80546001600160a01b0319163317905562000376565b6001600160e01b03198082161415620002a1576040805162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b6001600160e01b0319166000908152602081905260409020805460ff19166001179055565b3390565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826200030257600085556200034d565b82601f106200031d57805160ff19168380011785556200034d565b828001600101855582156200034d579182015b828111156200034d57825182559160200191906001019062000330565b506200035b9291506200035f565b5090565b5b808211156200035b576000815560010162000360565b612cd280620003866000396000f3fe608060405234801561001057600080fd5b506004361061021c5760003560e01c80636a62784211610125578063ad2f852a116100ad578063c87b56dd1161007c578063c87b56dd146107d4578063e8a3d485146107f1578063e985e9c5146107f9578063f2fde38b14610827578063ffa801361461084d5761021c565b8063ad2f852a146106cc578063b6b81940146106d4578063b88d4fde146106f1578063c3738f3f146107b75761021c565b80637974e46a116100f45780637974e46a1461067e5780638da5cb5b1461068657806395d89b411461068e578063a22cb46514610696578063a59a9973146106c45761021c565b80636a627842146106225780636c0360eb1461064857806370a0823114610650578063715018a6146106765761021c565b8063274de61e116101a857806342966c681161017757806342966c68146104cd5780634f6ccce7146104ea57806355f804b3146105075780636352211e146105ad5780636800901a146105ca5761021c565b8063274de61e146104085780632a55205a146104255780632f745c591461046b57806342842e0e146104975761021c565b8063095ea7b3116101ef578063095ea7b31461033a578063113aa8b11461036657806318160ddd1461038c57806320e3fa50146103a657806323b872dd146103d25761021c565b806301ffc9a71461022157806306d254da1461025c57806306fdde0314610284578063081812fc14610301575b600080fd5b6102486004803603602081101561023757600080fd5b50356001600160e01b031916610873565b604080519115158252519081900360200190f35b6102826004803603602081101561027257600080fd5b50356001600160a01b0316610886565b005b61028c610932565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102c65781810151838201526020016102ae565b50505050905090810190601f1680156102f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61031e6004803603602081101561031757600080fd5b50356109c8565b604080516001600160a01b039092168252519081900360200190f35b6102826004803603604081101561035057600080fd5b506001600160a01b038135169060200135610a2a565b6102826004803603602081101561037c57600080fd5b50356001600160a01b0316610b05565b610394610b89565b60408051918252519081900360200190f35b610394600480360360408110156103bc57600080fd5b506001600160a01b038135169060200135610b8f565b610282600480360360608110156103e857600080fd5b506001600160a01b03813581169160208101359091169060400135610bc0565b6103946004803603602081101561041e57600080fd5b5035610c17565b6104486004803603604081101561043b57600080fd5b5080359060200135610c29565b604080516001600160a01b03909316835260208301919091528051918290030190f35b6103946004803603604081101561048157600080fd5b506001600160a01b038135169060200135610c4a565b610282600480360360608110156104ad57600080fd5b506001600160a01b03813581169160208101359091169060400135610cbe565b610282600480360360208110156104e357600080fd5b5035610cd9565b6103946004803603602081101561050057600080fd5b5035610d8c565b6102826004803603602081101561051d57600080fd5b81019060208101813564010000000081111561053857600080fd5b82018360208201111561054a57600080fd5b8035906020019184600183028401116401000000008311171561056c57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610df2945050505050565b61031e600480360360208110156105c357600080fd5b5035610eee565b6105d2610f16565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561060e5781810151838201526020016105f6565b505050509050019250505060405180910390f35b6103946004803603602081101561063857600080fd5b50356001600160a01b0316610f6d565b61028c611025565b6103946004803603602081101561066657600080fd5b50356001600160a01b0316611086565b6102826110ee565b61039461119a565b61031e6111ab565b61028c6111ba565b610282600480360360408110156106ac57600080fd5b506001600160a01b038135169060200135151561121b565b61031e611320565b61031e61132f565b610282600480360360208110156106ea57600080fd5b503561133e565b6102826004803603608081101561070757600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561074257600080fd5b82018360208201111561075457600080fd5b8035906020019184600183028401116401000000008311171561077657600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506113d3945050505050565b610248600480360360208110156107cd57600080fd5b5035611431565b61028c600480360360208110156107ea57600080fd5b503561143c565b61028c611525565b6102486004803603604081101561080f57600080fd5b506001600160a01b03813581169160200135166115b2565b6102826004803603602081101561083d57600080fd5b50356001600160a01b03166115e0565b6105d26004803603602081101561086357600080fd5b50356001600160a01b03166116e3565b600061087e8261174f565b90505b919050565b61088e611774565b6001600160a01b031661089f6111ab565b6001600160a01b0316146108e8576040805162461bcd60e51b81526020600482018190526024820152600080516020612bff833981519152604482015290519081900360640190fd5b601280546001600160a01b0319166001600160a01b0383169081179091556040517f0f2a87e68f9d4311c1d18e960f7873198e70403a037237cdd2c583c69cdddf1f90600090a250565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109be5780601f10610993576101008083540402835291602001916109be565b820191906000526020600020905b8154815290600101906020018083116109a157829003601f168201915b5050505050905090565b60006109d382611778565b610a0e5760405162461bcd60e51b815260040180806020018281038252602c815260200180612bd3602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610a3582610eee565b9050806001600160a01b0316836001600160a01b03161415610a885760405162461bcd60e51b8152600401808060200182810382526021815260200180612c486021913960400191505060405180910390fd5b806001600160a01b0316610a9a611774565b6001600160a01b03161480610abb5750610abb81610ab6611774565b6115b2565b610af65760405162461bcd60e51b8152600401808060200182810382526038815260200180612b486038913960400191505060405180910390fd5b610b008383611785565b505050565b610b0d611774565b6001600160a01b0316610b1e6111ab565b6001600160a01b031614610b67576040805162461bcd60e51b81526020600482018190526024820152600080516020612bff833981519152604482015290519081900360640190fd5b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b600c5490565b60166020528160005260406000208181548110610bab57600080fd5b90600052602060002001600091509150505481565b610bd1610bcb611774565b826117f3565b610c0c5760405162461bcd60e51b8152600401808060200182810382526031815260200180612c696031913960400191505060405180910390fd5b610b00838383611897565b60176020526000908152604090205481565b6012546013546001600160a01b03909116936103e892909102919091049150565b6000610c5583611086565b8210610c925760405162461bcd60e51b815260040180806020018281038252602b815260200180612a4f602b913960400191505060405180910390fd5b506001600160a01b0382166000908152600a602090815260408083208484529091529020545b92915050565b610b00838383604051806020016040528060008152506113d3565b600f546001600160a01b03163314610d2a576040805162461bcd60e51b815260206004820152600f60248201526e13d3931653115391125391d413d3d3608a1b604482015290519081900360640190fd5b6000610d3582610eee565b9050610d4082611778565b610d4957600080fd5b610d52826118ad565b6040516001600160a01b0382169083907ff6554c3a5d28e08c120b5a69c7edbaf52f935bd2596a60b8a18e282cd257cddb90600090a35050565b6000610d96610b89565b8210610dd35760405162461bcd60e51b815260040180806020018281038252602c815260200180612c9a602c913960400191505060405180910390fd5b600c8281548110610de057fe5b90600052602060002001549050919050565b610dfa611774565b6001600160a01b0316610e0b6111ab565b6001600160a01b031614610e54576040805162461bcd60e51b81526020600482018190526024820152600080516020612bff833981519152604482015290519081900360640190fd5b8051610e67906011906020840190612966565b50806040518082805190602001908083835b60208310610e985780518252601f199092019160209182019101610e79565b5181516020939093036101000a60001901801990911692169190911790526040519201829003822093507f199e933997358e1789d8b56ea8c551befeb05ce2fe3fe506199f1230f5a591b492506000919050a250565b600061087e82604051806060016040528060298152602001612baa60299139600291906118d3565b606060148054806020026020016040519081016040528092919081815260200182805480156109be57602002820191906000526020600020905b815481526020019060010190808311610f50575050505050905090565b600f546000906001600160a01b03163314610fc1576040805162461bcd60e51b815260206004820152600f60248201526e13d3931653115391125391d413d3d3608a1b604482015290519081900360640190fd5b610fcb60106118ea565b610fde82610fd960106118f3565b6118f7565b816001600160a01b0316610ff260106118f3565b6040517ff3cea5493d790af0133817606f7350a91d7f154ea52eaa79d179d4d231e5010290600090a361087e60106118f3565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109be5780601f10610993576101008083540402835291602001916109be565b60006001600160a01b0382166110cd5760405162461bcd60e51b815260040180806020018281038252602a815260200180612b80602a913960400191505060405180910390fd5b6001600160a01b038216600090815260016020526040902061087e90611911565b6110f6611774565b6001600160a01b03166111076111ab565b6001600160a01b031614611150576040805162461bcd60e51b81526020600482018190526024820152600080516020612bff833981519152604482015290519081900360640190fd5b600e546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600e80546001600160a01b0319169055565b60006111a660106118f3565b905090565b600e546001600160a01b031690565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109be5780601f10610993576101008083540402835291602001916109be565b611223611774565b6001600160a01b0316826001600160a01b03161415611289576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000611296611774565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff1916921515929092179091556112da611774565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b600f546001600160a01b031681565b6012546001600160a01b031681565b611346611774565b6001600160a01b03166113576111ab565b6001600160a01b0316146113a0576040805162461bcd60e51b81526020600482018190526024820152600080516020612bff833981519152604482015290519081900360640190fd5b601381905560405181907f2ad2ae73af42f598ecb723109218def6abfe2e801eb5719ab4acbf9adc91c65d90600090a250565b6113e46113de611774565b836117f3565b61141f5760405162461bcd60e51b8152600401808060200182810382526031815260200180612c696031913960400191505060405180910390fd5b61142b8484848461191c565b50505050565b600061087e82611778565b606061144782611778565b61145057600080fd5b61145861196e565b611461836119cf565b6040516020018083805190602001908083835b602083106114935780518252601f199092019160209182019101611474565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106114db5780518252601f1990920191602091820191016114bc565b5181516020939093036101000a600019018019909116921691909117905264173539b7b760d91b92019182525060408051808303601a190181526005909201905295945050505050565b606061152f61196e565b6040516020018082805190602001908083835b602083106115615780518252601f199092019160209182019101611542565b6001836020036101000a038019825116818451168082178552505050505050905001806c31b7b73a3930b1ba173539b7b760991b815250600d01915050604051602081830303815290604052905090565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6115e8611774565b6001600160a01b03166115f96111ab565b6001600160a01b031614611642576040805162461bcd60e51b81526020600482018190526024820152600080516020612bff833981519152604482015290519081900360640190fd5b6001600160a01b0381166116875760405162461bcd60e51b8152600401808060200182810382526026815260200180612aac6026913960400191505060405180910390fd5b600e546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811660009081526016602090815260409182902080548351818402810184019094528084526060939283018282801561174357602002820191906000526020600020905b81548152602001906001019080831161172f575b50505050509050919050565b60006001600160e01b0319821663780e9d6360e01b148061087e575061087e82611aaa565b3390565b600061087e600283611ac9565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906117ba82610eee565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006117fe82611778565b6118395760405162461bcd60e51b815260040180806020018281038252602c815260200180612b1c602c913960400191505060405180910390fd5b600061184483610eee565b9050806001600160a01b0316846001600160a01b0316148061187f5750836001600160a01b0316611874846109c8565b6001600160a01b0316145b8061188f575061188f81856115b2565b949350505050565b6118a2838383611ad5565b610b00838383611c21565b60006118b882610eee565b90506118c382611dfa565b6118cf81600084611c21565b5050565b60006118e0848484611ec7565b90505b9392505050565b80546001019055565b5490565b6118cf828260405180602001604052806000815250611f91565b600061087e826118f3565b611927848484611897565b61193384848484611fe3565b61142b5760405162461bcd60e51b8152600401808060200182810382526032815260200180612a7a6032913960400191505060405180910390fd5b60118054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109be5780601f10610993576101008083540402835291602001916109be565b6060816119f457506040805180820190915260018152600360fc1b6020820152610881565b8160005b8115611a0c57600101600a820491506119f8565b60008167ffffffffffffffff81118015611a2557600080fd5b506040519080825280601f01601f191660200182016040528015611a50576020820181803683370190505b50859350905060001982015b8315611aa157600a840660300160f81b82828060019003935081518110611a7f57fe5b60200101906001600160f81b031916908160001a905350600a84049350611a5c565b50949350505050565b6001600160e01b03191660009081526020819052604090205460ff1690565b60006118e3838361214b565b826001600160a01b0316611ae882610eee565b6001600160a01b031614611b2d5760405162461bcd60e51b8152600401808060200182810382526029815260200180612c1f6029913960400191505060405180910390fd5b6001600160a01b038216611b725760405162461bcd60e51b8152600401808060200182810382526024815260200180612ad26024913960400191505060405180910390fd5b611b7d838383612163565b611b88600082611785565b6001600160a01b0383166000908152600160205260409020611baa90826121ec565b506001600160a01b0382166000908152600160205260409020611bcd90826121f8565b50611bda60028284612204565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6001600160a01b03831615611d7d576000818152601760209081526040808320546001600160a01b03871684526016909252822080549192916000198101908110611c6857fe5b906000526020600020015490508060166000876001600160a01b03166001600160a01b031681526020019081526020016000208381548110611ca657fe5b60009182526020808320909101929092556001600160a01b0387168152601690915260409020805480611cd557fe5b600082815260208082208301600019908101839055928301909355838152601783526040808220869055868252601590935291822054601480549193929091908101908110611d2057fe5b906000526020600020015490508060148381548110611d3b57fe5b6000918252602090912001556014805480611d5257fe5b6000828152602080822083016000199081018390559092019092559181526015909152604090205550505b6001600160a01b03821615610b00576001600160a01b038216600090815260166020908152604080832080548585526017845282852081905560018101825590845282842001849055601480548585526015909352922055611ddf60106118f3565b81546001810183556000928352602090922090910155505050565b6000611e0582610eee565b9050611e1381600084612163565b611e1e600083611785565b6000828152600860205260409020546002600019610100600184161502019091160415611e5c576000828152600860205260408120611e5c916129f2565b6001600160a01b0381166000908152600160205260409020611e7e90836121ec565b50611e8a60028361221a565b5060405182906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60008281526001840160205260408120548281611f625760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611f27578181015183820152602001611f0f565b50505050905090810190601f168015611f545780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110611f7557fe5b9060005260206000209060020201600101549150509392505050565b611f9b8383612226565b611fa86000848484611fe3565b610b005760405162461bcd60e51b8152600401808060200182810382526032815260200180612a7a6032913960400191505060405180910390fd5b6000611ff7846001600160a01b031661223c565b6120035750600161188f565b6000612111630a85bd0160e11b612018611774565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561207f578181015183820152602001612067565b50505050905090810190601f1680156120ac5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001612a7a603291396001600160a01b0388169190612242565b9050600081806020019051602081101561212a57600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b61216e838383610b00565b6001600160a01b03831661218a5761218581612251565b6121ad565b816001600160a01b0316836001600160a01b0316146121ad576121ad8382612295565b6001600160a01b0382166121c9576121c48161232a565b610b00565b826001600160a01b0316826001600160a01b031614610b0057610b0082826123b8565b60006118e383836123fc565b60006118e383836124c2565b60006118e084846001600160a01b03851661250c565b60006118e383836125a3565b6122308282612677565b6118cf60008383611c21565b3b151590565b60606118e084846000856127a5565b600c80546000838152600d60205260408120829055600182018355919091527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c70155565b600060016122a284611086565b6000848152600b602052604090205491900391508082146122f7576001600160a01b0384166000908152600a602090815260408083208584528252808320548484528184208190558352600b90915290208190555b506000918252600b602090815260408084208490556001600160a01b039094168352600a81528383209183525290812055565b600c80546000838152600d602052604081205460001983019390928490811061234f57fe5b9060005260206000200154905080600c838154811061236a57fe5b6000918252602080832090910192909255828152600d9091526040808220849055858252812055600c80548061239c57fe5b6001900381819060005260206000200160009055905550505050565b60006123c383611086565b6001600160a01b039093166000908152600a602090815260408083208684528252808320859055938252600b9052919091209190915550565b600081815260018301602052604081205480156124b8578354600019808301919081019060009087908390811061242f57fe5b906000526020600020015490508087600001848154811061244c57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061247c57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610cb8565b6000915050610cb8565b60006124ce838361214b565b61250457508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610cb8565b506000610cb8565b6000828152600184016020526040812054806125715750506040805180820182528381526020808201848152865460018181018955600089815284812095516002909302909501918255915190820155865486845281880190925292909120556118e3565b8285600001600183038154811061258457fe5b90600052602060002090600202016001018190555060009150506118e3565b600081815260018301602052604081205480156124b857835460001980830191908101906000908790839081106125d657fe5b90600052602060002090600202019050808760000184815481106125f657fe5b60009182526020808320845460029093020191825560019384015491840191909155835482528983019052604090209084019055865487908061263557fe5b6000828152602080822060026000199094019384020182815560019081018390559290935588815289820190925260408220919091559450610cb89350505050565b6001600160a01b0382166126d2576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6126db81611778565b1561272d576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b61273960008383612163565b6001600160a01b038216600090815260016020526040902061275b90826121f8565b5061276860028284612204565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6060824710156127e65760405162461bcd60e51b8152600401808060200182810382526026815260200180612af66026913960400191505060405180910390fd5b6127ef8561223c565b612840576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b6020831061287e5780518252601f19909201916020918201910161285f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146128e0576040519150601f19603f3d011682016040523d82523d6000602084013e6128e5565b606091505b50915091506128f5828286612900565b979650505050505050565b6060831561290f5750816118e3565b82511561291f5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315611f27578181015183820152602001611f0f565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261299c57600085556129e2565b82601f106129b557805160ff19168380011785556129e2565b828001600101855582156129e2579182015b828111156129e25782518255916020019190600101906129c7565b506129ee929150612a39565b5090565b50805460018160011615610100020316600290046000825580601f10612a185750612a36565b601f016020900490600052602060002090810190612a369190612a39565b50565b5b808211156129ee5760008155600101612a3a56fe455243373231456e756d657261626c653a206f776e657220696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564455243373231456e756d657261626c653a20676c6f62616c20696e646578206f7574206f6620626f756e6473a164736f6c6343000706000a60806040523480156200001157600080fd5b5060405180604001604052806007815260200166048595045204c560cc1b815250604051806040016040528060038152602001620484c560ec1b81525081600390805190602001906200006692919062000124565b5080516200007c90600490602084019062000124565b50506005805460ff19166012179055506200009662000120565b600560016101000a8154816001600160a01b0302191690836001600160a01b0316021790555030604051620000cb90620001b9565b6001600160a01b03909116815260405190819003602001906000f080158015620000f9573d6000803e3d6000fd5b50600680546001600160a01b0319166001600160a01b0392909216919091179055620001de565b3390565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826200015c5760008555620001a7565b82601f106200017757805160ff1916838001178555620001a7565b82800160010185558215620001a7579182015b82811115620001a75782518255916020019190600101906200018a565b50620001b5929150620001c7565b5090565b610b68806200116e83390190565b5b80821115620001b55760008155600101620001c8565b610f8080620001ee6000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a0823111610097578063a59a997311610066578063a59a997314610305578063a9059cbb14610329578063ac5da95214610355578063dd62ed3e1461035d576100f5565b806370a082311461027f57806395d89b41146102a55780639dc29fac146102ad578063a457c2d7146102d9576100f5565b806323b872dd116100d357806323b872dd146101d1578063313ce56714610207578063395093511461022557806340c10f1914610251576100f5565b806306fdde03146100fa578063095ea7b31461017757806318160ddd146101b7575b600080fd5b61010261038b565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013c578181015183820152602001610124565b50505050905090810190601f1680156101695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561018d57600080fd5b506001600160a01b038135169060200135610421565b604080519115158252519081900360200190f35b6101bf61043e565b60408051918252519081900360200190f35b6101a3600480360360608110156101e757600080fd5b506001600160a01b03813581169160208101359091169060400135610444565b61020f6104cb565b6040805160ff9092168252519081900360200190f35b6101a36004803603604081101561023b57600080fd5b506001600160a01b0381351690602001356104d4565b61027d6004803603604081101561026757600080fd5b506001600160a01b038135169060200135610522565b005b6101bf6004803603602081101561029557600080fd5b50356001600160a01b0316610593565b6101026105ae565b61027d600480360360408110156102c357600080fd5b506001600160a01b03813516906020013561060f565b6101a3600480360360408110156102ef57600080fd5b506001600160a01b03813516906020013561067c565b61030d6106e4565b604080516001600160a01b039092168252519081900360200190f35b6101a36004803603604081101561033f57600080fd5b506001600160a01b0381351690602001356106f8565b61030d61070c565b6101bf6004803603604081101561037357600080fd5b506001600160a01b038135811691602001351661071b565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104175780601f106103ec57610100808354040283529160200191610417565b820191906000526020600020905b8154815290600101906020018083116103fa57829003601f168201915b5050505050905090565b600061043561042e610746565b848461074a565b50600192915050565b60025490565b6000610451848484610836565b6104c18461045d610746565b6104bc85604051806060016040528060288152602001610ebd602891396001600160a01b038a1660009081526001602052604081209061049b610746565b6001600160a01b031681526020810191909152604001600020549190610851565b61074a565b5060019392505050565b60055460ff1690565b60006104356104e1610746565b846104bc85600160006104f2610746565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906108e8565b60055461010090046001600160a01b031661053b610746565b6001600160a01b031614610585576040805162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b604482015290519081900360640190fd5b61058f8282610949565b5050565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104175780601f106103ec57610100808354040283529160200191610417565b60055461010090046001600160a01b0316610628610746565b6001600160a01b031614610672576040805162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b604482015290519081900360640190fd5b61058f828261095f565b6000610435610689610746565b846104bc85604051806060016040528060258152602001610f4f60259139600160006106b3610746565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610851565b60055461010090046001600160a01b031681565b6000610435610705610746565b8484610836565b6006546001600160a01b031681565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b3390565b6001600160a01b03831661078f5760405162461bcd60e51b8152600401808060200182810382526024815260200180610f2b6024913960400191505060405180910390fd5b6001600160a01b0382166107d45760405162461bcd60e51b8152600401808060200182810382526022815260200180610e756022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b610841838383610975565b61084c838383610ad0565b505050565b600081848411156108e05760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156108a557818101518382015260200161088d565b50505050905090810190601f1680156108d25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610942576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6109538282610bd8565b61058f60008383610ad0565b6109698282610cc8565b61058f82600083610ad0565b6001600160a01b0383166109ba5760405162461bcd60e51b8152600401808060200182810382526025815260200180610f066025913960400191505060405180910390fd5b6001600160a01b0382166109ff5760405162461bcd60e51b8152600401808060200182810382526023815260200180610e306023913960400191505060405180910390fd5b610a0a83838361084c565b610a4781604051806060016040528060268152602001610e97602691396001600160a01b0386166000908152602081905260409020549190610851565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610a7690826108e8565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b610ad983610dc4565b15610b5357600654604080516329cc05cf60e01b81526001600160a01b0386811660048301526024820185905260016044830152915191909216916329cc05cf91606480830192600092919082900301818387803b158015610b3a57600080fd5b505af1158015610b4e573d6000803e3d6000fd5b505050505b610b5c82610dc4565b1561084c57600654604080516329cc05cf60e01b81526001600160a01b0385811660048301526024820185905260006044830181905292519316926329cc05cf9260648084019391929182900301818387803b158015610bbb57600080fd5b505af1158015610bcf573d6000803e3d6000fd5b50505050505050565b6001600160a01b038216610c33576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b610c3f6000838361084c565b600254610c4c90826108e8565b6002556001600160a01b038216600090815260208190526040902054610c7290826108e8565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b038216610d0d5760405162461bcd60e51b8152600401808060200182810382526021815260200180610ee56021913960400191505060405180910390fd5b610d198260008361084c565b610d5681604051806060016040528060228152602001610e53602291396001600160a01b0385166000908152602081905260409020549190610851565b6001600160a01b038316600090815260208190526040902055600254610d7c9082610dd2565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b0316151590565b600082821115610e29576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa164736f6c6343000706000a608060405234801561001057600080fd5b50604051610b68380380610b688339818101604052602081101561003357600080fd5b5051600080546001600160a01b039092166001600160a01b0319909216919091179055610b03806100656000396000f3fe6080604052600436106100dd5760003560e01c806389d969171161007f578063d076eabc11610059578063d076eabc14610251578063efca2eed1461027b578063f04da65b14610290578063fc0c546a146102c3576100dd565b806389d96917146101f4578063b88a802f14610227578063c7e1d0b11461023c576100dd565b8063152111f7116100bb578063152111f71461017f57806329cc05cf146101895780633c6e6789146101ca57806380bb4055146101df576100dd565b8063058df06d146100e25780630700037d1461011e5780630e15561a1461016a575b600080fd5b3480156100ee57600080fd5b5061010c6004803603602081101561010557600080fd5b50356102f4565b60408051918252519081900360200190f35b34801561012a57600080fd5b506101516004803603602081101561014157600080fd5b50356001600160a01b0316610306565b6040805192835260208301919091528051918290030190f35b34801561017657600080fd5b5061010c61031f565b610187610325565b005b34801561019557600080fd5b50610187600480360360608110156101ac57600080fd5b506001600160a01b0381351690602081013590604001351515610330565b3480156101d657600080fd5b5061010c61038b565b3480156101eb57600080fd5b5061010c610391565b34801561020057600080fd5b5061010c6004803603602081101561021757600080fd5b50356001600160a01b0316610397565b34801561023357600080fd5b50610187610416565b34801561024857600080fd5b5061010c610454565b34801561025d57600080fd5b5061010c6004803603602081101561027457600080fd5b503561045a565b34801561028757600080fd5b5061010c61048f565b34801561029c57600080fd5b5061010c600480360360208110156102b357600080fd5b50356001600160a01b0316610495565b3480156102cf57600080fd5b506102d86104b0565b604080516001600160a01b039092168252519081900360200190f35b60086020526000908152604090205481565b6004602052600090815260409020805460019091015482565b60075481565b61032e346104bf565b565b6000546001600160a01b0316331461037b576040805162461bcd60e51b815260206004820152600960248201526827a7262caa27a5a2a760b91b604482015290519081900360640190fd5b6103868383836105e0565b505050565b60025481565b60015481565b6001600160a01b0381166000908152600360205260408120546103bc57506000610411565b6001600160a01b0382166000908152600360205260408120546103de90610682565b6001600160a01b03841660009081526004602052604090205490915080821161040c57600092505050610411565b900390505b919050565b61041f336106a7565b6040805133815290517f63e32091e4445d16e29c33a6b264577c2d86694021aa4e6f4dd590048f5792e89181900360200190a1565b60055481565b6000806104668361086a565b9250505062015180838161047657fe5b0662015180600019909201919091028303039050919050565b60065481565b6001600160a01b031660009081526003602052604090205490565b6000546001600160a01b031681565b60008111610506576040805162461bcd60e51b815260206004820152600f60248201526e0888aa09ea692a87440dcde408aa89608b1b604482015290519081900360640190fd5b600060025411610552576040805162461bcd60e51b81526020600482015260126024820152714445504f5349543a206e6f2073686172657360701b604482015290519081900360640190fd5b600780548201905560006105654261045a565b60008181526008602052604090208054840190556002549091506ec097ce7bc90715b34b9f100000000083028161059857fe5b600580549290910491909101905560408051838152905133917fb9ad861b752f80117b35bea6dec99933d8a5ae360f2839ee8784b750d5613409919081900360200190a25050565b8015610634576105f08383610889565b6040805183815290516001600160a01b038516917fae0577e1c96b26fbc0b9df702431f5470979d001d24f136eded791b8b6521d6f919081900360200190a2610386565b61063e8383610991565b6040805183815290516001600160a01b038516917fba8f3777cf908803bf1f3dd58e7f4b7d3de4dbe3c234c4ccab0975d98f7cd388919081900360200190a2505050565b60006ec097ce7bc90715b34b9f10000000006005548302816106a057fe5b0492915050565b6001600160a01b0381166000908152600360205260409020546106c957610867565b60006106d482610397565b6001600160a01b0383166000908152600460209081526040808320600101805485019055600390915290205490915061070c90610682565b6001600160a01b038316600090815260046020526040902055801561086557600680548201905560405147906000906001600160a01b0385169084908381818185875af1925050503d8060008114610780576040519150601f19603f3d011682016040523d82523d6000602084013e610785565b606091505b50509050806107db576040805162461bcd60e51b815260206004820152601a60248201527f444953543a20636f756c64206e6f742064697374726962757465000000000000604482015290519081900360640190fd5b828203471015610823576040805162461bcd60e51b815260206004820152600e60248201526d08892a6a87440e8dede40daeac6d60931b604482015290519081900360640190fd5b6040805184815290516001600160a01b038616917fe8b160e373db99a103e0a2abfa029b9c3fc8b328984a1ead8a65ae68ae646db7919081900360200190a250505b505b50565b6000808061087c620151808504610a60565b9196909550909350915050565b6001600160a01b038216600090815260036020526040902054158015906108c857506001600160a01b0382166000908152600360205260409020548111155b61090d576040805162461bcd60e51b815260206004820152601160248201527052454d4f56453a206e6f2073686172657360781b604482015290519081900360640190fd5b610916826106a7565b6002805482900390556001600160a01b038216600090815260036020526040902080548290039081905561094f57600180546000190190555b6001600160a01b03821660009081526003602052604090205461097190610682565b6001600160a01b0390921660009081526004602052604090209190915550565b6001600160a01b038216600090815260036020526040902054156109b8576109b8826106a7565b6001600160a01b0382166000908152600360205260409020805460028054840190558154830182554260019092019190915580158015610a0f57506001600160a01b03831660009081526003602052604090205415155b15610a1d5760018054810190555b6001600160a01b038316600090815260036020526040902054610a3f90610682565b6001600160a01b039093166000908152600460205260409020929092555050565b60008080836226496581018262023ab1600483020590506004600362023ab18302010590910390600062164b09610fa0600185010205905060046105b58202058303601f019250600061098f8460500281610ab757fe5b0590506000605061098f83020585039050600b820560301994909401606402929092018301996002600c9094029091039290920197509550935050505056fea164736f6c6343000706000a00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156400000000000000000000000085225ed797fd4128ac45a992c46ea4681a7a15da000000000000000000000000bf1858b24243ecbcf7d940f458e36cb7401c2366000000000000000000000000300648a601c584e6379fa0d6a31cbbfcca6177e4000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000003668747470733a2f2f6170692e6879706572626f6c696370726f746f636f6c2e636f6d2f6c6f616e732f6578742f6d657461646174612f00000000000000000000
Deployed Bytecode
0x6080604052600436106102cd5760003560e01c8063838122cf11610175578063b5df93f0116100dc578063d539c6d411610095578063e1ec3c681161006f578063e1ec3c6814610b7b578063f2c342c314610bf0578063f2fde38b14610c23578063f771183414610c56576102d4565b8063d539c6d414610b03578063dfad779214610b36578063e10e6bda14610b4b576102d4565b8063b5df93f0146109bf578063bc157ac1146109f2578063c8092cf714610a31578063ca593c5914610a46578063cd08f97114610a4e578063d45b621314610ab3576102d4565b8063930cf9731161012e578063930cf973146108ec57806396e41e9e1461091c5780639d32a6801461094c5780639e4d5ddf14610978578063a4b3eb0b1461098d578063b2b8ec41146109aa576102d4565b8063838122cf146107e45780638470fc55146108295780638a05d5f9146108685780638da5cb5b146108925780638e6cce35146108a7578063921b2fb7146108d7576102d4565b80633bb66a7b1161023457806367d4a3d3116101ed5780636e04ff0d116101c75780636e04ff0d146106a15780636faa8b3f1461079d5780636fea6111146107ba578063715018a6146107cf576102d4565b806367d4a3d3146106445780636bc394d3146106775780636bfeba531461068c576102d4565b80633bb66a7b146104dc578063441a3e70146105215780634585e33b146105515780634e9865c7146105cc578063528b1ed8146105fc5780635bc7b7f314610611576102d4565b806323169a7b1161028657806323169a7b146103fc578063238dafe01461042c578063328d8f721461045557806334a4117714610481578063375b74c3146104b25780633a568474146104c7576102d4565b8063051b4d07146102d9578063075ee2c81461030b57806309fff9631461033b5780630a861f2a146103745780630ecbcdab1461039e5780631c57d3d3146103ce576102d4565b366102d457005b600080fd5b3480156102e557600080fd5b50610309600480360360208110156102fc57600080fd5b503563ffffffff16610c86565b005b34801561031757600080fd5b506103096004803603602081101561032e57600080fd5b503563ffffffff16610d40565b34801561034757600080fd5b506103096004803603604081101561035e57600080fd5b506001600160a01b038135169060200135610df5565b34801561038057600080fd5b506103096004803603602081101561039757600080fd5b5035610e73565b3480156103aa57600080fd5b50610309600480360360408110156103c157600080fd5b5080359060200135610f9f565b3480156103da57600080fd5b506103e3610faf565b6040805163ffffffff9092168252519081900360200190f35b34801561040857600080fd5b506103096004803603602081101561041f57600080fd5b503563ffffffff16610fc2565b34801561043857600080fd5b50610441611072565b604080519115158252519081900360200190f35b34801561046157600080fd5b506103096004803603602081101561047857600080fd5b50351515611082565b34801561048d57600080fd5b50610496611133565b604080516001600160a01b039092168252519081900360200190f35b3480156104be57600080fd5b50610496611142565b3480156104d357600080fd5b50610496611151565b3480156104e857600080fd5b5061050f600480360360208110156104ff57600080fd5b50356001600160a01b0316611167565b60408051918252519081900360200190f35b34801561052d57600080fd5b506103096004803603604081101561054457600080fd5b5080359060200135611178565b34801561055d57600080fd5b506103096004803603602081101561057457600080fd5b810190602081018135600160201b81111561058e57600080fd5b8201836020820111156105a057600080fd5b803590602001918460018302840111600160201b831117156105c157600080fd5b509092509050611183565b3480156105d857600080fd5b50610309600480360360208110156105ef57600080fd5b503563ffffffff16611466565b34801561060857600080fd5b506103e36114ee565b34801561061d57600080fd5b506103096004803603602081101561063457600080fd5b50356001600160a01b03166114fa565b34801561065057600080fd5b5061050f6004803603602081101561066757600080fd5b50356001600160a01b03166117d9565b34801561068357600080fd5b506103e36117eb565b34801561069857600080fd5b506103e36117fe565b3480156106ad57600080fd5b5061071c600480360360208110156106c457600080fd5b810190602081018135600160201b8111156106de57600080fd5b8201836020820111156106f057600080fd5b803590602001918460018302840111600160201b8311171561071157600080fd5b509092509050611811565b60405180831515815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610761578181015183820152602001610749565b50505050905090810190601f16801561078e5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b610309600480360360208110156107b357600080fd5b50356119b1565b3480156107c657600080fd5b506103e36119bf565b3480156107db57600080fd5b506103096119cb565b3480156107f057600080fd5b506103096004803603608081101561080757600080fd5b508035906001600160a01b036020820135169060408101359060600135611a77565b34801561083557600080fd5b506103096004803603604081101561084c57600080fd5b5080356001600160a01b0316906020013563ffffffff16611a90565b34801561087457600080fd5b506104416004803603602081101561088b57600080fd5b5035611b4d565b34801561089e57600080fd5b50610496611b5e565b3480156108b357600080fd5b50610309600480360360208110156108ca57600080fd5b503563ffffffff16611b6e565b3480156108e357600080fd5b506103e3611c1e565b3480156108f857600080fd5b506103096004803603602081101561090f57600080fd5b503563ffffffff16611c31565b34801561092857600080fd5b506103096004803603602081101561093f57600080fd5b503563ffffffff16611cd7565b34801561095857600080fd5b506103096004803603602081101561096f57600080fd5b50351515611d87565b34801561098457600080fd5b506103e3611e38565b610309600480360360208110156109a357600080fd5b5035611e4b565b3480156109b657600080fd5b506103e3611eaf565b3480156109cb57600080fd5b50610441600480360360208110156109e257600080fd5b50356001600160a01b0316611ec2565b3480156109fe57600080fd5b5061030960048036036060811015610a1557600080fd5b508035906001600160a01b036020820135169060400135611ed7565b348015610a3d57600080fd5b5061050f611ee3565b610309612083565b348015610a5a57600080fd5b50610a63612145565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610a9f578181015183820152602001610a87565b505050509050019250505060405180910390f35b348015610abf57600080fd5b50610add60048036036020811015610ad657600080fd5b50356121a7565b604080519485526020850193909352838301919091526060830152519081900360800190f35b348015610b0f57600080fd5b506103e360048036036020811015610b2657600080fd5b50356001600160a01b031661251e565b348015610b4257600080fd5b50610441612536565b348015610b5757600080fd5b5061030960048036036020811015610b6e57600080fd5b503563ffffffff16612546565b348015610b8757600080fd5b50610ba560048036036020811015610b9e57600080fd5b503561260c565b60405180878152602001866001600160a01b03168152602001858152602001846001600160a01b03168152602001838152602001828152602001965050505050505060405180910390f35b348015610bfc57600080fd5b5061050f60048036036020811015610c1357600080fd5b50356001600160a01b031661264d565b348015610c2f57600080fd5b5061030960048036036020811015610c4657600080fd5b50356001600160a01b031661265f565b348015610c6257600080fd5b5061050f60048036036040811015610c7957600080fd5b5080359060200135612761565b610c8e612790565b6001600160a01b0316610c9f611b5e565b6001600160a01b031614610ce8576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b6103e863ffffffff82161115610d195760405162461bcd60e51b8152600401610d1090614a6e565b60405180910390fd5b600a805463ffffffff909216600160201b0267ffffffff0000000019909216919091179055565b610d48612790565b6001600160a01b0316610d59611b5e565b6001600160a01b031614610da2576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff82161115610dca5760405162461bcd60e51b8152600401610d1090614964565b600a805463ffffffff909216600160401b026bffffffff000000000000000019909216919091179055565b610dfd612790565b6001600160a01b0316610e0e611b5e565b6001600160a01b031614610e57576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b6001600160a01b039091166000908152600d6020526040902055565b600f54600160201b90046001600160a01b0316639dc29fac610e93612790565b836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b158015610eda57600080fd5b505af1158015610eee573d6000803e3d6000fd5b505050506000610efc612790565b6040516001600160a01b0391909116908390600081818185875af1925050503d8060008114610f47576040519150601f19603f3d011682016040523d82523d6000602084013e610f4c565b606091505b5050905080610f9b576040805162461bcd60e51b815260206004820152601660248201527515d2551211149055ce88115512081b9bdd081cd95b9d60521b604482015290519081900360640190fd5b5050565b610faa338383612794565b505050565b600054600160b01b900463ffffffff1681565b610fca612790565b6001600160a01b0316610fdb611b5e565b6001600160a01b031614611024576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff8216111561104c5760405162461bcd60e51b8152600401610d1090614d8a565b6000805463ffffffff909216600160b01b0263ffffffff60b01b19909216919091179055565b600054600160a01b900460ff1681565b61108a612790565b6001600160a01b031661109b611b5e565b6001600160a01b0316146110e4576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b60005460ff600160a01b90910416151581151514156111155760405162461bcd60e51b8152600401610d1090614c8f565b60008054911515600160a01b0260ff60a01b19909216919091179055565b6002546001600160a01b031681565b6001546001600160a01b031681565b600f54600160201b90046001600160a01b031681565b6001600160a01b038116315b919050565b610f9b338383612ac3565b600061119182840184614652565b905060005b81518110156114605760008282815181106111ad57fe5b6020026020010151905080600014156111c65750611460565b6111cf81612e92565b15611457576000818152600e60209081526040808320815160c0810183528154815260018201546001600160a01b0390811682860152600283015482850152600383015416606082018190526004808401546080840181905260059094015460a08401528451630dfe168160e01b815294519296939591948593630dfe168193828401939092829003018186803b15801561126957600080fd5b505afa15801561127d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112a1919061456e565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b031614156113d0576000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561131857600080fd5b505afa15801561132c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611350919061456e565b600180546020880151604051633b6191dd60e01b81529394506001600160a01b0390911692633b6191dd9261138d92869290918a916004016148b7565b600060405180830381600087803b1580156113a757600080fd5b505af11580156113bb573d6000803e3d6000fd5b505050506113ca838287612f4f565b50611449565b600180546020860151604051633b6191dd60e01b815284936001600160a01b0390931692633b6191dd9261140a9286928a916004016148b7565b600060405180830381600087803b15801561142457600080fd5b505af1158015611438573d6000803e3d6000fd5b50505050611447838287612f4f565b505b61145285613483565b505050505b50600101611196565b50505050565b61146e612790565b6001600160a01b031661147f611b5e565b6001600160a01b0316146114c8576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b6000805463ffffffff909216600160d01b0263ffffffff60d01b19909216919091179055565b600f5463ffffffff1681565b611502612790565b6001600160a01b0316611513611b5e565b6001600160a01b03161461155c576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b60008190506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561159c57600080fd5b505afa1580156115b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115d4919061456e565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561161157600080fd5b505afa158015611625573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611649919061456e565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316826001600160a01b031614806116bc57507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b0316145b6116d85760405162461bcd60e51b8152600401610d1090614e17565b60408051600280825260608201835260009260208301908036833701905050905061012c8160008151811061170957fe5b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061173257fe5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0385169063883bdbfd90611773908490600401614879565b60006040518083038186803b15801561178b57600080fd5b505afa15801561179f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526117c7919081019061458a565b50506117d28561355b565b5050505050565b600d6020526000908152604090205481565b600a54600160801b900463ffffffff1681565b600054600160d01b900463ffffffff1681565b600060606000600260009054906101000a90046001600160a01b03166001600160a01b0316636800901a6040518163ffffffff1660e01b815260040160006040518083038186803b15801561186557600080fd5b505afa158015611879573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118a191908101906146e2565b6000805491925090600160d01b900463ffffffff1667ffffffffffffffff811180156118cc57600080fd5b506040519080825280602002602001820160405280156118f6578160200160208202803683370190505b5090506000805b835181101561197d5760005463ffffffff600160d01b9091048116908316106119255761197d565b600084828151811061193357fe5b6020026020010151905061194681612e92565b15611974576001965080848463ffffffff168151811061196257fe5b60209081029190910101526001909201915b506001016118fd565b5084156119a757816040516020016119959190614835565b60405160208183030381529060405293505b5050509250929050565b6119bc3382346136c6565b50565b600a5463ffffffff1681565b6119d3612790565b6001600160a01b03166119e4611b5e565b6001600160a01b031614611a2d576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b611a83338585856138b7565b93506117d2338583612794565b611a98612790565b6001600160a01b0316611aa9611b5e565b6001600160a01b031614611af2576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff82161115611b1a5760405162461bcd60e51b8152600401610d1090614bd4565b6001600160a01b03919091166000908152600b60205260409020805463ffffffff191663ffffffff909216919091179055565b6000611b5882612e92565b92915050565b6000546001600160a01b03165b90565b611b76612790565b6001600160a01b0316611b87611b5e565b6001600160a01b031614611bd0576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff82161115611bf85760405162461bcd60e51b8152600401610d1090614bd4565b600a805463ffffffff909216600160801b0263ffffffff60801b19909216919091179055565b600a54600160601b900463ffffffff1681565b611c39612790565b6001600160a01b0316611c4a611b5e565b6001600160a01b031614611c93576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b610bb863ffffffff82161115611cbb5760405162461bcd60e51b8152600401610d1090614c38565b600a805463ffffffff191663ffffffff92909216919091179055565b611cdf612790565b6001600160a01b0316611cf0611b5e565b6001600160a01b031614611d39576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff82161115611d615760405162461bcd60e51b8152600401610d10906148e0565b600a805463ffffffff909216600160601b0263ffffffff60601b19909216919091179055565b611d8f612790565b6001600160a01b0316611da0611b5e565b6001600160a01b031614611de9576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b60005460ff600160a81b9091041615158115151415611e1a5760405162461bcd60e51b8152600401610d1090614adc565b60008054911515600160a81b0260ff60a81b19909216919091179055565b600a54600160201b900463ffffffff1681565b6000818152600e602052604090206005015415611e7257611e6d3382346136c6565b611e90565b3415611e905760405162461bcd60e51b8152600401610d1090614a37565b6000818152600e60205260409020600401546119bc9033908390612ac3565b600a54600160401b900463ffffffff1681565b60076020526000908152604090205460ff1681565b611460338484846138b7565b6000806000600360009054906101000a90046001600160a01b03166001600160a01b031663fb5ebf366040518163ffffffff1660e01b8152600401604080518083038186803b158015611f3557600080fd5b505afa158015611f49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6d91906147c1565b91509150600061271063ffffffff16600360009054906101000a90046001600160a01b03166001600160a01b0316637e3596996040518163ffffffff1660e01b815260040160206040518083038186803b158015611fca57600080fd5b505afa158015611fde573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200291906147e4565b63ffffffff1683028161201157fe5b0490508083101561206b57600a54600090829063ffffffff600160201b82048116600160401b9092048116919091031685028161204a57fe5b600a54919004600160401b90910463ffffffff16039450611b6b9350505050565b5050600a54600160201b900463ffffffff1692915050565b600034116120ca576040805162461bcd60e51b815260206004820152600f60248201526e0888aa09ea692a87440dcde408aa89608b1b604482015290519081900360640190fd5b600f54600160201b90046001600160a01b03166340c10f196120ea612790565b346040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561213157600080fd5b505af1158015611460573d6000803e3d6000fd5b6060600880548060200260200160405190810160405280929190818152602001828054801561219d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161217f575b5050505050905090565b60025460405163c3738f3f60e01b81526000918291829182916001600160a01b039091169063c3738f3f906121e0908890600401614eac565b60206040518083038186803b1580156121f857600080fd5b505afa15801561220c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122309190614766565b61224c5760405162461bcd60e51b8152600401610d1090614d1c565b6000858152600e60209081526040808320815160c0810183528154815260018201546001600160a01b0390811694820194909452600282015492810183905260038201549093166060840152600481015460808401526005015460a083018190529192916122b991612761565b9050816080015160001480156122d1575060a0820151155b156122eb5760008060008095509550955095505050612517565b6005546060830151604051631ece4f9760e21b81526000926001600160a01b031691637b393e5c916123209190600401614808565b60206040518083038186803b15801561233857600080fd5b505afa15801561234c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612370919061456e565b6005546040516304e09a6160e41b81529192506000916001600160a01b0390911690634e09a610906123a6908590600401614808565b60206040518083038186803b1580156123be57600080fd5b505afa1580156123d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f691906147a9565b9050600084606001516001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561243757600080fd5b505afa15801561244b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061246f919061456e565b905060007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316826001600160a01b0316146124b857856080015183026124cd565b82600160c01b816124c557fe5b048660800151025b60a0870151909150600160601b81810291878101909102908390600160c01b02816124f457fe5b0483600160601b83028161250457fe5b919d5090049a5091985096505050505050505b9193509193565b600b6020526000908152604090205463ffffffff1681565b600054600160a81b900460ff1681565b61254e612790565b6001600160a01b031661255f611b5e565b6001600160a01b0316146125a8576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b61271063ffffffff821611156125f0576040805162461bcd60e51b81526020600482015260086024820152676c7465203130302560c01b604482015290519081900360640190fd5b600f805463ffffffff191663ffffffff92909216919091179055565b600e6020526000908152604090208054600182015460028301546003840154600485015460059095015493946001600160a01b039384169492939091169186565b600c6020526000908152604090205481565b612667612790565b6001600160a01b0316612678611b5e565b6001600160a01b0316146126c1576040805162461bcd60e51b81526020600482018190526024820152600080516020614f67833981519152604482015290519081900360640190fd5b6001600160a01b0381166127065760405162461bcd60e51b8152600401808060200182810382526026815260200180614f1b6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006301e1338061271084612774611ee3565b85420302028161278057fe5b048161278857fe5b049392505050565b3390565b60008054600160a01b900460ff166127be5760405162461bcd60e51b8152600401610d1090614c62565b6127c88484613d80565b6000838152600e6020908152604080832060038101546001600160a01b0316845260079092529091205460ff166128115760405162461bcd60e51b8152600401610d1090614cc6565b600061282582600501548360020154612761565b4260028401559050600080612839876121a7565b9350935050506000600160601b838161284e57fe5b60038701546001600160a01b03166000908152600b6020526040812054929091049250600160601b84049163ffffffff1661289f57600a5461271090600160801b900463ffffffff168402046128ca565b60038701546001600160a01b03166000908152600b60205260409020546127109063ffffffff168402045b90508082106128eb5760405162461bcd60e51b8152600401610d1090614aff565b8089830111156128fb5781810398505b8847101561291b5760405162461bcd60e51b8152600401610d1090614992565b60038701546001600160a01b03166000908152600d6020526040902054156129865760038701546001600160a01b03166000908152600d6020908152604080832054600c909252909120548a0111156129865760405162461bcd60e51b8152600401610d1090614a00565b60038701546001600160a01b03166000908152600c6020526040902080548a0190556005870180548a019055600a5461271063ffffffff9091168a02048601808a116129e45760405162461bcd60e51b8152600401610d1090614dd3565b808a036129f082613e30565b60008d6001600160a01b031682604051612a0990611b6b565b60006040518083038185875af1925050503d8060008114612a46576040519150601f19603f3d011682016040523d82523d6000602084013e612a4b565b606091505b5050905080612a6c5760405162461bcd60e51b8152600401610d1090614c01565b8c8e6001600160a01b03167fe1979fe4c35e0cef342fef5668e2c8e7a7e9f5d5d1ca8fee0ac6c427fa4153af8e604051612aa69190614eac565b60405180910390a38c9a50505050505050505050505b9392505050565b60008111612ae35760405162461bcd60e51b8152600401610d1090614a9b565b612aed8383613d80565b6000828152600e602052604090206004810154821115612b1f5760405162461bcd60e51b8152600401610d109061490c565b60048101805483900390556000612b35846121a7565b505060038401546001600160a01b03166000908152600b602052604090205490925063ffffffff16159050612bb65760038201546001600160a01b03166000908152600b60205260409020546127109063ffffffff16600160601b0204811115612bb15760405162461bcd60e51b8152600401610d1090614d53565b612bf1565b600a5461271090600160601b600160801b90910463ffffffff160204811115612bf15760405162461bcd60e51b8152600401610d1090614d53565b600382015460408051630dfe168160e01b815290516001600160a01b03909216916000918391630dfe168191600480820192602092909190829003018186803b158015612c3d57600080fd5b505afa158015612c51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c75919061456e565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b03161415612dae576000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015612cec57600080fd5b505afa158015612d00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d24919061456e565b6001805487820154604051633b6191dd60e01b81529394506001600160a01b0391821693633b6191dd93612d6193879316918c91906004016148b7565b600060405180830381600087803b158015612d7b57600080fd5b505af1158015612d8f573d6000803e3d6000fd5b50612da8925050506001600160a01b0382168988613f90565b50612e35565b6001805485820154604051633b6191dd60e01b815284936001600160a01b0393841693633b6191dd93612dec93879392909116918c916004016148b7565b600060405180830381600087803b158015612e0657600080fd5b505af1158015612e1a573d6000803e3d6000fd5b50612e33925050506001600160a01b0382168988613f90565b505b6004840154612e4757612e4786613483565b85876001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b56887604051612e819190614eac565b60405180910390a350505050505050565b60025460405163c3738f3f60e01b81526000916001600160a01b03169063c3738f3f90612ec3908590600401614eac565b60206040518083038186803b158015612edb57600080fd5b505afa158015612eef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f139190614766565b612f1f57506000611173565b6000612f2a836121a7565b5050600a5461271063ffffffff600160601b9283900416909102041115949350505050565b600054600160a81b900460ff168015612f7657506003546001600160a01b03838116911614155b1561346257600554604051631ece4f9760e21b81526000916001600160a01b031690637b393e5c90612fac908790600401614808565b60206040518083038186803b158015612fc457600080fd5b505afa158015612fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ffc919061456e565b6005546040516304e09a6160e41b81529192506000916001600160a01b0390911690634e09a61090613032908590600401614808565b60206040518083038186803b15801561304a57600080fd5b505afa15801561305e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308291906147a9565b905060007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316866001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156130e957600080fd5b505afa1580156130fd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613121919061456e565b6001600160a01b0316146131425781600160c01b8161313c57fe5b04613144565b815b90506000600160601b856080015183028161315b57fe5b04905060008560a001518211613175578560a00151613177565b815b60065460808801519192506131979189916001600160a01b031690613fe2565b600660009054906101000a90046001600160a01b03166001600160a01b031663414bf3896040518061010001604052808a6001600160a01b031681526020017f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031681526020018b6001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b15801561323e57600080fd5b505afa158015613252573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132769190614786565b62ffffff1681523060208201524260408201526080808b0151606083015260005491019061271090600160b01b900463ffffffff908116820316860204815260006020909101526040516001600160e01b031960e084901b1681526132de9190600401614e43565b602060405180830381600087803b1580156132f857600080fd5b505af115801561330c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061333091906147a9565b506040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a0823190613380903090600401614808565b60206040518083038186803b15801561339857600080fd5b505afa1580156133ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d091906147a9565b9050801561345757604051632e1a7d4d60e01b81526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21690632e1a7d4d90613424908490600401614eac565b600060405180830381600087803b15801561343e57600080fd5b505af1158015613452573d6000803e3d6000fd5b505050505b505050505050610faa565b610faa61346d611b5e565b60808301516001600160a01b0385169190613f90565b6000818152600e60205260408082208281556001810180546001600160a01b03199081169091556002808301859055600383018054909216909155600480830185905560059092019390935591549051630852cd8d60e31b81526001600160a01b03909116916342966c68916134fb91859101614eac565b600060405180830381600087803b15801561351557600080fd5b505af1158015613529573d6000803e3d6000fd5b50506040518392507f40e7dd78d661cb2192925e6eeecc3f99eb4f3e7457c18ea57ddd84cd051d01f39150600090a250565b6001600160a01b03811660009081526007602052604090205460ff1615613653576001600160a01b0381166000908152600960205260408120546008805491929160001981019081106135aa57fe5b600091825260209091200154600880546001600160a01b0390921692508291849081106135d357fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b03948516179055838316825260098152604080832086905592861682526007905220805460ff19169055600880548061362957fe5b600082815260209020810160001990810180546001600160a01b0319169055019055506119bc9050565b6001600160a01b03166000818152600760209081526040808320805460ff19166001908117909155600880546009909452918420839055820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b600081116136e65760405162461bcd60e51b8152600401610d10906149c9565b6136f08383613d80565b6000828152600e60205260408120600581015460028201549192916137159190612761565b426002840155905080831161373c5760405162461bcd60e51b8152600401610d1090614b2e565b6005820154810160008185111561375257508084035b60038401546001600160a01b03166000908152600c60205260409020548386031161377f5782850361379d565b60038401546001600160a01b03166000908152600c60205260409020545b60038501546001600160a01b03166000908152600c6020526040902080549190910390556005840154838603116137d6578285036137dc565b83600501545b60058501805491909103905582156137f7576137f783613e30565b801561387b576000876001600160a01b03168260405161381690611b6b565b60006040518083038185875af1925050503d8060008114613853576040519150601f19603f3d011682016040523d82523d6000602084013e613858565b606091505b50509050806138795760405162461bcd60e51b8152600401610d1090614b6f565b505b85876001600160a01b03167fca92b037c5d17af773d2a576cd91e713e64b80af7c561456d811d12fc92796008786604051612e81929190614eb5565b60008054600160a01b900460ff166138e15760405162461bcd60e51b8152600401610d1090614ba6565b60006138ed8686614129565b506000818152600e602052604081206003810154929750879350916001600160a01b0316613991576001600160a01b03861660009081526007602052604090205460ff1661394d5760405162461bcd60e51b8152600401610d1090614cf0565b50428082556001820180546001600160a01b03808b166001600160a01b031992831617909255600284019290925560038301805491881691909216179055846139dd565b60038201546001600160a01b031660009081526007602052604090205460ff166139cd5760405162461bcd60e51b8152600401610d1090614938565b5060038101546001600160a01b03165b600480830180548701905560408051630dfe168160e01b815290516000926001600160a01b03851692630dfe16819281830192602092829003018186803b158015613a2757600080fd5b505afa158015613a3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a5f919061456e565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b03161415613c22576000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015613ad657600080fd5b505afa158015613aea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0e919061456e565b9050613b256001600160a01b0382168b308a6141d6565b60015460405163095ea7b360e01b81526001600160a01b038381169263095ea7b392613b5992909116908b9060040161481c565b602060405180830381600087803b158015613b7357600080fd5b505af1158015613b87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bab9190614766565b506001805490850154604051633b6191dd60e01b81526001600160a01b0392831692633b6191dd92613bea928692909116908c906000906004016148b7565b600060405180830381600087803b158015613c0457600080fd5b505af1158015613c18573d6000803e3d6000fd5b5050505050613d31565b80613c386001600160a01b0382168b308a6141d6565b60015460405163095ea7b360e01b81526001600160a01b038381169263095ea7b392613c6c92909116908b9060040161481c565b602060405180830381600087803b158015613c8657600080fd5b505af1158015613c9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cbe9190614766565b506001805490850154604051633b6191dd60e01b81526001600160a01b0392831692633b6191dd92613cfd928692909116908c906000906004016148b7565b600060405180830381600087803b158015613d1757600080fd5b505af1158015613d2b573d6000803e3d6000fd5b50505050505b87896001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1588604051613d6b9190614eac565b60405180910390a35095979650505050505050565b6002546040516331a9108f60e11b81526001600160a01b0390911690636352211e90613db0908490600401614eac565b60206040518083038186803b158015613dc857600080fd5b505afa158015613ddc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e00919061456e565b6001600160a01b0316826001600160a01b031614610f9b5760405162461bcd60e51b8152600401610d1090614dac565b600f5461271063ffffffff9091168202048082038115613f27576000600f60049054906101000a90046001600160a01b03166001600160a01b031663ac5da9526040518163ffffffff1660e01b815260040160206040518083038186803b158015613e9a57600080fd5b505afa158015613eae573d6000803e3d6000fd5b505050506040513d6020811015613ec457600080fd5b50516040805163152111f760e01b815290519192506001600160a01b0383169163152111f7918691600480830192600092919082900301818588803b158015613f0c57600080fd5b505af1158015613f20573d6000803e3d6000fd5b5050505050505b8015610faa57600480546040805163152111f760e01b815290516001600160a01b039092169263152111f7928592808301926000929182900301818588803b158015613f7257600080fd5b505af1158015613f86573d6000803e3d6000fd5b5050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610faa90849061422c565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1781529251825160009485949389169392918291908083835b6020831061405e5780518252601f19909201916020918201910161403f565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146140c0576040519150601f19603f3d011682016040523d82523d6000602084013e6140c5565b606091505b50915091508180156140f35750805115806140f357508080602001905160208110156140f057600080fd5b50515b6117d2576040805162461bcd60e51b8152602060048201526002602482015261534160f01b604482015290519081900360640190fd5b600080826141be576002546040516335313c2160e11b81526001600160a01b0390911690636a62784290614161908790600401614808565b602060405180830381600087803b15801561417b57600080fd5b505af115801561418f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141b391906147a9565b9150600190506141cf565b6141c88484613d80565b5081905060005b9250929050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526114609085905b6000614281826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166142dd9092919063ffffffff16565b805190915015610faa578080602001905160208110156142a057600080fd5b5051610faa5760405162461bcd60e51b815260040180806020018281038252602a815260200180614f87602a913960400191505060405180910390fd5b60606142ec84846000856142f4565b949350505050565b6060824710156143355760405162461bcd60e51b8152600401808060200182810382526026815260200180614f416026913960400191505060405180910390fd5b61433e8561444f565b61438f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106143cd5780518252601f1990920191602091820191016143ae565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461442f576040519150601f19603f3d011682016040523d82523d6000602084013e614434565b606091505b5091509150614444828286614455565b979650505050505050565b3b151590565b60608315614464575081612abc565b8251156144745782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156144be5781810151838201526020016144a6565b50505050905090810190601f1680156144eb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b600082601f830112614509578081fd5b8151602061451e61451983614ee7565b614ec3565b828152818101908583018385028701840188101561453a578586fd5b855b8581101561456157815161454f81614f05565b8452928401929084019060010161453c565b5090979650505050505050565b60006020828403121561457f578081fd5b8151612abc81614f05565b6000806040838503121561459c578081fd5b825167ffffffffffffffff808211156145b3578283fd5b818501915085601f8301126145c6578283fd5b815160206145d661451983614ee7565b82815281810190858301838502870184018b10156145f2578788fd5b8796505b848710156146225780518060060b811461460e578889fd5b8352600196909601959183019183016145f6565b509188015191965090935050508082111561463b578283fd5b50614648858286016144f9565b9150509250929050565b60006020808385031215614664578182fd5b823567ffffffffffffffff81111561467a578283fd5b8301601f8101851361468a578283fd5b803561469861451982614ee7565b81815283810190838501858402850186018910156146b4578687fd5b8694505b838510156146d65780358352600194909401939185019185016146b8565b50979650505050505050565b600060208083850312156146f4578182fd5b825167ffffffffffffffff81111561470a578283fd5b8301601f8101851361471a578283fd5b805161472861451982614ee7565b8181528381019083850185840285018601891015614744578687fd5b8694505b838510156146d6578051835260019490940193918501918501614748565b600060208284031215614777578081fd5b81518015158114612abc578182fd5b600060208284031215614797578081fd5b815162ffffff81168114612abc578182fd5b6000602082840312156147ba578081fd5b5051919050565b600080604083850312156147d3578182fd5b505080516020909101519092909150565b6000602082840312156147f5578081fd5b815163ffffffff81168114612abc578182fd5b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561486d57835183529284019291840191600101614851565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561486d57835163ffffffff1683529284019291840191600101614895565b6001600160a01b0394851681529290931660208301526040820152901515606082015260800190565b6020808252601290820152715345544c504c54563a206c7465203130302560701b604082015260600190565b6020808252601290820152710ae92a89088a482ae7440e8dede40daeac6d60731b604082015260600190565b6020808252601290820152714445504f5349543a2062616420706f6f6c3160701b604082015260600190565b602080825260149082015273534554424150524d41583a206c7465203130302560601b604082015260600190565b60208082526018908201527f424f52524f573a206e6f7420656e6f7567682066756e64730000000000000000604082015260600190565b6020808252601b908201527f5041594241434b3a206e6f2045544820746f20706179206261636b0000000000604082015260600190565b60208082526018908201527f424f52524f573a206578636565647320706f6f6c206d61780000000000000000604082015260600190565b6020808252601a908201527f5041594241434b4c4f53453a206e6f20455448206e6565646564000000000000604082015260600190565b602080825260139082015272534554424150524d494e3a206c74652031302560681b604082015260600190565b60208082526021908201527f57495448445241573a206d7573742077697468647261772066726f6d206c6f616040820152603760f91b606082015260800190565b60208082526009908201526829a2aa2624a8a222a360b91b604082015260600190565b602080825260159082015274424f52524f573a2063616e6e6f7420626f72726f7760581b604082015260600190565b60208082526021908201527f5041594241434b3a206d75737420706179206261636b2061626f7665206665656040820152607360f81b606082015260800190565b6020808252601c908201527f5041594241434b3a20726566756e6420756e7375636365737366756c00000000604082015260600190565b60208082526014908201527311115413d4d2550e881b9bdd08195b98589b195960621b604082015260600190565b6020808252601390820152725345544c54564d41583a206c7465203130302560681b604082015260600190565b60208082526019908201527f424f52524f573a20455448206e6f742064656c69766572656400000000000000604082015260600190565b60208082526010908201526f534554424645453a206c74652033302560801b604082015260600190565b6020808252601390820152721093d49493d5ce881b9bdd08195b98589b1959606a1b604082015260600190565b60208082526017908201527f534554454e41424c45443a206d75737420746f67676c65000000000000000000604082015260600190565b60208082526010908201526f1093d49493d5ce88189859081c1bdbdb60821b604082015260600190565b60208082526012908201527104445504f5349543a2062616420706f6f6c360741b604082015260600190565b60208082526017908201527f4745544c54563a206c6f616e206d757374206578697374000000000000000000604082015260600190565b60208082526019908201527f57495448445241573a2065786365656473206d6178204c545600000000000000604082015260600190565b6020808252600890820152676c7465203130302560c01b604082015260600190565b6020808252600d908201526c2b20a624a220aa22a7aba722a960991b604082015260600190565b60208082526024908201527f424f52524f573a2066656573206d6f7265207468616e20626f72726f7720616d6040820152631bdd5b9d60e21b606082015260800190565b6020808252601290820152710a89e8e8e988a869e98987440dcde408aa8960731b604082015260600190565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c0808401519083015260e09283015116918101919091526101000190565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff81118282101715614edf57fe5b604052919050565b600067ffffffffffffffff821115614efb57fe5b5060209081020190565b6001600160a01b03811681146119bc57600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c6343000706000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156400000000000000000000000085225ed797fd4128ac45a992c46ea4681a7a15da000000000000000000000000bf1858b24243ecbcf7d940f458e36cb7401c2366000000000000000000000000300648a601c584e6379fa0d6a31cbbfcca6177e4000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000003668747470733a2f2f6170692e6879706572626f6c696370726f746f636f6c2e636f6d2f6c6f616e732f6578742f6d657461646174612f00000000000000000000
-----Decoded View---------------
Arg [0] : _baseTokenURI (string): https://api.hyperbolicprotocol.com/loans/ext/metadata/
Arg [1] : __swapRouter (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564
Arg [2] : __hype (address): 0x85225Ed797fd4128Ac45A992C46eA4681a7A15dA
Arg [3] : __twapUtils (address): 0xBf1858b24243Ecbcf7d940f458e36CB7401c2366
Arg [4] : __lendingRewards (address): 0x300648a601c584E6379fa0D6a31CbBFCcA6177e4
Arg [5] : __WETH (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [1] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [2] : 00000000000000000000000085225ed797fd4128ac45a992c46ea4681a7a15da
Arg [3] : 000000000000000000000000bf1858b24243ecbcf7d940f458e36cb7401c2366
Arg [4] : 000000000000000000000000300648a601c584e6379fa0d6a31cbbfcca6177e4
Arg [5] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000036
Arg [7] : 68747470733a2f2f6170692e6879706572626f6c696370726f746f636f6c2e63
Arg [8] : 6f6d2f6c6f616e732f6578742f6d657461646174612f00000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | Ether (ETH) | 100.00% | $3,732.92 | 0.00722692 | $26.98 |
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.