Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Multi Chain
Multichain Addresses
1 address found via
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
YangNFTVault
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 50 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.6; pragma abicoder v2; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import "@uniswap/v3-core/contracts/libraries/TickMath.sol"; import "@uniswap/v3-periphery/contracts/libraries/LiquidityAmounts.sol"; import "../interfaces/yang/IYangNFTVault.sol"; import "../interfaces/chi/ICHIManager.sol"; import "../interfaces/chi/ICHIVault.sol"; import "../libraries/YANGPosition.sol"; import "../libraries/PriceHelper.sol"; import "./LockLiquidity.sol"; contract YangNFTVault is IYangNFTVault, LockLiquidity, ReentrancyGuardUpgradeable, OwnableUpgradeable, ERC721Upgradeable { using SafeERC20 for IERC20; using SafeMath for uint256; // chiManager address private chiManager; // chainlink feed registry address public registry; // nft and Yang tokenId uint256 private _nextId; address private _tempAccount; mapping(address => uint256) private _usersMap; modifier isAuthorizedForToken(uint256 tokenId) { require(_isApprovedOrOwner(msg.sender, tokenId), "not approved"); _; } modifier subscripting(address account) { _tempAccount = account; _; _tempAccount = address(0); } // initialize function initialize(address _registry) public initializer { registry = _registry; _nextId = 1; __LockLiquidity__init(); __Ownable_init(); __ReentrancyGuard_init(); __ERC721_init("YIN Asset Manager Vault", "YANG"); } function setCHIManager(address _chiManager) external override onlyOwner { chiManager = _chiManager; } function updateLockSeconds(uint256 lockInSeconds) external onlyOwner { _updateLockSeconds(lockInSeconds); } function updateLockState(uint256 chiId, bool state) external onlyOwner { _updateLockState(chiId, state); } function mint(address recipient) external override returns (uint256 tokenId) { require(_usersMap[recipient] == 0, "only mint once"); // _mint function check tokenId existence _mint(recipient, (tokenId = _nextId++)); emit MintYangNFT(recipient, tokenId); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { if (from != address(0)) { require(_usersMap[from] == tokenId, "invalid tokenId"); _usersMap[from] = 0; } if (to != address(0)) { require(_usersMap[to] == 0, "only accept one"); _usersMap[to] = tokenId; } } function _withdraw( address token0, uint256 amount0, address token1, uint256 amount1 ) internal { if (amount0 > 0) { IERC20(token0).safeTransfer(msg.sender, amount0); } if (amount1 > 0) { IERC20(token1).safeTransfer(msg.sender, amount1); } } function subscribeSingle(SubscribeSingleParam memory params) external override subscripting(msg.sender) isAuthorizedForToken(params.yangId) nonReentrant returns ( uint256 amount0, uint256 amount1, uint256 shares ) { require(!checkMaxUSDLimit(params.chiId), "MUL"); (shares, amount0, amount1) = ICHIManager(chiManager).subscribeSingle( params.yangId, params.chiId, params.zeroForOne, params.exactAmount, params.maxTokenAmount, params.minShares ); _updateAccountLockDurations( params.yangId, params.chiId, block.timestamp ); emit Subscribe(params.yangId, params.chiId, shares); } function subscribe(SubscribeParam memory params) external override subscripting(msg.sender) isAuthorizedForToken(params.yangId) nonReentrant returns ( uint256 amount0, uint256 amount1, uint256 shares ) { require(chiManager != address(0), "CHI"); require(!checkMaxUSDLimit(params.chiId), "MUL"); (shares, amount0, amount1) = ICHIManager(chiManager).subscribe( params.yangId, params.chiId, params.amount0Desired, params.amount1Desired, params.amount0Min, params.amount1Min ); _updateAccountLockDurations( params.yangId, params.chiId, block.timestamp ); emit Subscribe(params.yangId, params.chiId, shares); } function unsubscribe(UnSubscribeParam memory params) external override nonReentrant isAuthorizedForToken(params.yangId) afterLockUnsubscribe(params.yangId, params.chiId) { require(chiManager != address(0), "CHI"); (uint256 amount0, uint256 amount1) = ICHIManager(chiManager) .unsubscribe( params.yangId, params.chiId, params.shares, params.amount0Min, params.amount1Min ); (, , address _pool, , , , , ) = ICHIManager(chiManager).chi( params.chiId ); IUniswapV3Pool pool = IUniswapV3Pool(_pool); _withdraw(pool.token0(), amount0, pool.token1(), amount1); emit UnSubscribe(params.yangId, params.chiId, amount0, amount1); } function unsubscribeSingle(UnSubscribeSingleParam memory params) external override nonReentrant isAuthorizedForToken(params.yangId) afterLockUnsubscribe(params.yangId, params.chiId) { require(chiManager != address(0), "CHI"); (, , address _pool, , , , , ) = ICHIManager(chiManager).chi( params.chiId ); IUniswapV3Pool pool = IUniswapV3Pool(_pool); uint256 amount = ICHIManager(chiManager).unsubscribeSingle( params.yangId, params.chiId, params.zeroForOne, params.shares, params.amountOutMin ); require(amount >= params.amountOutMin); address tokenOut = params.zeroForOne ? pool.token1() : pool.token0(); _withdraw(tokenOut, amount, address(0), 0); emit UnSubscribe(params.yangId, params.chiId, amount, 0); } // views function function checkMaxUSDLimit(uint256 chiId) public view override returns (bool) { (, , address pool, address vault, , , , ) = ICHIManager(chiManager).chi( chiId ); (, , uint256 maxUSDLimit) = ICHIManager(chiManager).config(chiId); (uint256 amount0, uint256 amount1) = ICHIVault(vault).getTotalAmounts(); return PriceHelper.isReachMaxUSDLimit( registry, IUniswapV3Pool(pool).token0(), amount0, IUniswapV3Pool(pool).token1(), amount1, maxUSDLimit ); } function positions(uint256 yangId, uint256 chiId) external view override returns ( uint256 amount0, uint256 amount1, uint256 shares ) { shares = ICHIManager(chiManager).yang(yangId, chiId); (uint256 _amount0, uint256 _amount1) = getAmounts(chiId, shares); amount0 = _amount0; amount1 = _amount1; } function getTokenId(address recipient) public view override returns (uint256) { return _usersMap[recipient]; } function getShares( uint256 chiId, uint256 amount0Desired, uint256 amount1Desired ) external view override returns ( uint256 shares, uint256 amount0, uint256 amount1 ) { require(chiManager != address(0), "CHI"); (, , , address _vault, , , , uint256 _totalShares) = ICHIManager( chiManager ).chi(chiId); (uint256 total0, uint256 total1) = ICHIVault(_vault).getTotalAmounts(); if (_totalShares == 0) { // For first deposit, just use the amounts desired amount0 = amount0Desired; amount1 = amount1Desired; shares = Math.max(amount0, amount1); } else if (total0 == 0) { amount1 = amount1Desired; shares = amount1.mul(_totalShares).div(total1); } else if (total1 == 0) { amount0 = amount0Desired; shares = amount0.mul(_totalShares).div(total0); } else { uint256 cross = Math.min( amount0Desired.mul(total1), amount1Desired.mul(total0) ); if (cross != 0) { // Round up amounts amount0 = cross.sub(1).div(total1).add(1); amount1 = cross.sub(1).div(total0).add(1); shares = cross.mul(_totalShares).div(total0).div(total1); } } } function getAmounts(uint256 chiId, uint256 shares) public view override returns (uint256 amount0, uint256 amount1) { require(chiManager != address(0), "CHI"); (, , , address _vault, , , , uint256 _totalShares) = ICHIManager( chiManager ).chi(chiId); if (_totalShares > 0) { (uint256 total0, uint256 total1) = ICHIVault(_vault) .getTotalAmounts(); amount0 = total0.mul(shares).div(_totalShares); amount1 = total1.mul(shares).div(_totalShares); } } function YANGDepositCallback( IERC20 token0, uint256 amount0, IERC20 token1, uint256 amount1, address recipient ) external override { require(chiManager != address(0), "CHI"); require(msg.sender == chiManager, "manager"); if (amount0 > 0) token0.safeTransferFrom(_tempAccount, recipient, amount0); if (amount1 > 0) token1.safeTransferFrom(_tempAccount, recipient, amount1); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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.7.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.7.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.7.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { 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; } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../../utils/ContextUpgradeable.sol"; import "./IERC721Upgradeable.sol"; import "./IERC721MetadataUpgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "../../introspection/ERC165Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/EnumerableSetUpgradeable.sol"; import "../../utils/EnumerableMapUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable, IERC721EnumerableUpgradeable { using SafeMathUpgradeable for uint256; using AddressUpgradeable for address; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet; using EnumerableMapUpgradeable for EnumerableMapUpgradeable.UintToAddressMap; using StringsUpgradeable 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 => EnumerableSetUpgradeable.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMapUpgradeable.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. */ function __ERC721_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _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 = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721Upgradeable.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 = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721Upgradeable.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 = ERC721Upgradeable.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(ERC721Upgradeable.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( IERC721ReceiverUpgradeable(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(ERC721Upgradeable.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 { } uint256[41] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../proxy/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } uint256[49] private __gap; }
// 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 Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= uint256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import '@uniswap/v3-core/contracts/libraries/FullMath.sol'; import '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol'; /// @title Liquidity amount functions /// @notice Provides functions for computing liquidity amounts from token amounts and prices library LiquidityAmounts { /// @notice Downcasts uint256 to uint128 /// @param x The uint258 to be downcasted /// @return y The passed value, downcasted to uint128 function toUint128(uint256 x) private pure returns (uint128 y) { require((y = uint128(x)) == x); } /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96); return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount of token0 being sent in /// @param amount1 The amount of token1 being sent in /// @return liquidity The maximum amount of liquidity received function getLiquidityForAmounts( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0); } else if (sqrtRatioX96 < sqrtRatioBX96) { uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0); uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1); liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1; } else { liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv( uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96 ) / sqrtRatioAX96; } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function getAmountsForLiquidity( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } else if (sqrtRatioX96 < sqrtRatioBX96) { amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity); amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity); } else { amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.6; pragma abicoder v2; import "./IYANGDepositCallBack.sol"; interface IYangNFTVault is IYANGDepositCallBack { struct SubscribeParam { uint256 yangId; uint256 chiId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; } struct UnSubscribeParam { uint256 yangId; uint256 chiId; uint256 shares; uint256 amount0Min; uint256 amount1Min; } struct SubscribeSingleParam { uint256 yangId; uint256 chiId; bool zeroForOne; uint256 exactAmount; uint256 maxTokenAmount; uint256 minShares; } struct UnSubscribeSingleParam { uint256 yangId; uint256 chiId; bool zeroForOne; uint256 shares; uint256 amountOutMin; } event AcceptOwnerShip(address owner, address nextowner); event MintYangNFT(address recipient, uint256 tokenId); event Subscribe(uint256 yangId, uint256 chiId, uint256 share); event UnSubscribe( uint256 yangId, uint256 chiId, uint256 amount0, uint256 amount1 ); function setCHIManager(address) external; function mint(address recipient) external returns (uint256 tokenId); function subscribe(SubscribeParam memory params) external returns ( uint256 amount0, uint256 amount1, uint256 share ); function unsubscribe(UnSubscribeParam memory params) external; function subscribeSingle(SubscribeSingleParam memory params) external returns ( uint256 amount0, uint256 amount1, uint256 share ); function unsubscribeSingle(UnSubscribeSingleParam memory params) external; // view function getShares( uint256 chiId, uint256 amount0Desired, uint256 amount1Desired ) external view returns ( uint256, uint256, uint256 ); function getAmounts(uint256 chiId, uint256 shares) external view returns (uint256, uint256); function checkMaxUSDLimit(uint256 chiId) external view returns (bool); // positions function positions(uint256 yangId, uint256 chiId) external returns ( uint256 amount0, uint256 amount1, uint256 shares ); function getTokenId(address recipient) external view returns (uint256); }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.6; pragma abicoder v2; import "./ICHIVault.sol"; import "./ICHIDepositCallBack.sol"; interface ICHIManager is ICHIDepositCallBack { // CHI config struct CHIConfig { bool paused; bool archived; uint256 maxUSDLimit; } // CHI data struct CHIData { address operator; address pool; address vault; CHIConfig config; } struct MintParams { address recipient; address token0; address token1; uint24 fee; } struct RangeParams { int24 tickLower; int24 tickUpper; } function chi(uint256 tokenId) external view returns ( address owner, address operator, address pool, address vault, uint256 accruedProtocolFees0, uint256 accruedProtocolFees1, uint24 fee, uint256 totalShares ); function config(uint256 tokenId) external view returns ( bool isPaused, bool isArchived, uint256 maxUSDLimit ); function chiVault(uint256 tokenId) external view returns ( uint256 amount0, uint256 amount1, uint256 collect0, uint256 collect1 ); function mint(MintParams calldata params, bytes32[] calldata merkleProof) external returns (uint256 tokenId, address vault); function subscribeSingle( uint256 yangId, uint256 tokenId, bool zeroForOne, uint256 exactAmount, uint256 maxTokenAmount, uint256 minShares ) external returns ( uint256 shares, uint256 amount0, uint256 amount1 ); function subscribe( uint256 yangId, uint256 tokenId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min ) external returns ( uint256 shares, uint256 amount0, uint256 amount1 ); function unsubscribeSingle( uint256 yangId, uint256 tokenId, bool zeroForOne, uint256 shares, uint256 amountOutMin ) external returns (uint256 amount); function unsubscribe( uint256 yangId, uint256 tokenId, uint256 shares, uint256 amount0Min, uint256 amount1Min ) external returns (uint256 amount0, uint256 amount1); function addAndRemoveRanges( uint256 tokenId, RangeParams[] calldata addRanges, RangeParams[] calldata removeRanges ) external; function collectProtocol(uint256 tokenId) external; function addAllLiquidityToPosition( uint256 tokenId, uint256[] calldata ranges, uint256[] calldata amount0Totals, uint256[] calldata amount1Totals ) external; function removeRangesLiquidityFromPosition( uint256 tokenId, uint256[] calldata ranges, uint128[] calldata liquidities ) external; function removeRangesAllLiquidityFromPosition( uint256 tokenId, uint256[] calldata ranges ) external; function pausedCHI(uint256 tokenId) external; function unpausedCHI(uint256 tokenId) external; function archivedCHI(uint256 tokenId) external; function sweep( uint256 tokenId, address token, address to ) external; function emergencyBurn( uint256 tokenId, int24 tickLower, int24 tickUpper ) external; function swap(uint256 tokenId, ICHIVault.SwapParams memory params) external returns (uint256); function yang(uint256 yangId, uint256 chiId) external view returns (uint256 shares); event Create( uint256 tokenId, address pool, address vault, uint256 vaultFee ); event ChangeLiquidity(uint256 tokenId, address vault); event UpdateMerkleRoot( address account, bytes32 oldMerkleRoot, bytes32 newMerkleRoot ); event UpdateVaultFee( address account, uint256 oldVaultFee, uint256 newVaultFee ); event UpdateProviderFee( address account, uint256 oldProviderFee, uint256 newProviderFee ); event UpdateGovernance( address account, address oldGovernance, address newGovernance ); event UpdateMaxUSDLimit( address account, uint256 oldMaxUSDLimit, uint256 newMaxUSDLimit ); event UpdateSwapSwitch( address account, bool oldStatus, bool newStatus ); // Events event Sweep( address account, address recipient, address token, uint256 tokenId ); event EmergencyBurn( address account, uint256 tokenId, int24 tickLower, int24 tickUpper ); event Swap( uint256 tokenId, address tokenIn, address tokenOut, uint256 percentage, uint256 amountOut ); }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.6; pragma abicoder v2; interface ICHIVault { // fee function accruedProtocolFees0() external view returns (uint256); function accruedProtocolFees1() external view returns (uint256); function accruedCollectFees0() external view returns (uint256); function accruedCollectFees1() external view returns (uint256); function feeTier() external view returns (uint24); function balanceToken0() external view returns (uint256); function balanceToken1() external view returns (uint256); // shares function totalSupply() external view returns (uint256); // range function getRangeCount() external view returns (uint256); function getRange(uint256 index) external view returns (int24 tickLower, int24 tickUpper); function addRange(int24 _tickLower, int24 _tickUpper) external; function removeRange(int24 _tickLower, int24 _tickUpper) external; function getTotalLiquidityAmounts() external view returns (uint256 amount0, uint256 amount1); function getTotalAmounts() external view returns (uint256 amount0, uint256 amount1); function collectProtocol( uint256 amount0, uint256 amount1, address to ) external; function depositSingle( uint256 yangId, bool zeroForOne, uint256 exactAmount, uint256 maxTokenAmount, uint256 minShares ) external returns ( uint256 shares, uint256 amount0, uint256 amount1 ); function deposit( uint256 yangId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min ) external returns ( uint256 shares, uint256 amount0, uint256 amount1 ); function withdrawSingle( uint256 yangId, bool zeroForOne, uint256 shares, uint256 amountOutMin, address to ) external returns (uint256 amount); function withdraw( uint256 yangId, uint256 shares, uint256 amount0Min, uint256 amount1Min, address to ) external returns (uint256 amount0, uint256 amount1); function addLiquidityToPosition( uint256 _rangeIndex, uint256 amount0Desired, uint256 amount1Desired ) external; function removeLiquidityFromPosition(uint256 rangeIndex, uint128 liquidity) external returns (uint256 amount0, uint256 amount1); function removeAllLiquidityFromPosition(uint256 rangeIndex) external returns (uint256 amount0, uint256 amount1); function sweep(address token, address to) external; function emergencyBurn(int24 tickLower, int24 tickUpper) external; function swapPercentage(SwapParams memory params) external returns (uint256); struct SwapParams { address tokenIn; address tokenOut; uint32 interval; uint16 slippageTolerance; uint256 percentage; uint160 sqrtRatioX96; } struct SwapCallbackData { bool isDeposit; address tokenIn; address tokenOut; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.6; library YANGPosition { // info stored for each user's position struct Info { uint256 shares; } function get( mapping(bytes32 => Info) storage self, uint256 yangId, uint256 chiId ) internal view returns (YANGPosition.Info storage position) { position = self[keccak256(abi.encodePacked(yangId, chiId))]; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.6; pragma abicoder v2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../interfaces/yang/IERC20Minimal.sol"; import "../interfaces/yang/IChainLinkFeedsRegistry.sol"; import "../libraries/BinaryExp.sol"; library PriceHelper { using SafeMath for uint256; function isReachMaxUSDLimit( address registry, address token0, uint256 amount0, address token1, uint256 amount1, uint256 maxUSDLimit ) internal view returns (bool) { // maxUSDLimit 1e8 base if (maxUSDLimit == 0) { return false; } else { uint256 balance0 = IChainLinkFeedsRegistry(registry) .getUSDPrice(token0) .mul(amount0) .div(BinaryExp.pow(10, IERC20Minimal(token0).decimals())); uint256 balance1 = IChainLinkFeedsRegistry(registry) .getUSDPrice(token1) .mul(amount1) .div(BinaryExp.pow(10, IERC20Minimal(token1).decimals())); return balance0.add(balance1) >= maxUSDLimit ? true : false; } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.6; import "@openzeppelin/contracts/math/SafeMath.sol"; abstract contract LockLiquidity { using SafeMath for uint256; modifier afterLockUnsubscribe(uint256 yangId, uint256 chiId) { require( _isUnLocked[chiId] || (!_isUnLocked[chiId] && block.timestamp > _locks[yangId][chiId]), "locks" ); _; } function _updateLockSeconds(uint256 __locksInSeconds) internal { _lockInSeconds = __locksInSeconds; emit LockSeconds(_lockInSeconds); } function _updateLockState(uint256 chiId, bool state) internal { emit LockState(chiId, _isUnLocked[chiId], state); _isUnLocked[chiId] = state; } function _updateAccountLockDurations( uint256 yangId, uint256 chiId, uint256 currentTime ) internal { if (!_isUnLocked[chiId]) { uint256 durationTime = currentTime.add(_lockInSeconds); _locks[yangId][chiId] = durationTime > _locks[yangId][chiId] ? durationTime : _locks[yangId][chiId]; emit LockAccount(yangId, chiId, _locks[yangId][chiId]); } } function durations(uint256 yangId, uint256 chiId) external view returns (uint256) { return _locks[yangId][chiId]; } function __LockLiquidity__init() internal { _lockInSeconds = 3600 * 24 * 7; } uint256 private _lockInSeconds; mapping(uint256 => bool) private _isUnLocked; mapping(uint256 => mapping(uint256 => uint256)) private _locks; event LockSeconds(uint256); event LockState(uint256, bool, bool); event LockAccount(uint256, uint256, uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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; import "../proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with 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 ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } 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; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // 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); } 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.7.0; import "../../introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @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.7.0; import "./IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @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.7.0; import "./IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @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.7.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @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.7.0; import "./IERC165Upgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { /* * 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; function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { // 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; } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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 SafeMathUpgradeable { /** * @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.7.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // 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.7.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 EnumerableMapUpgradeable { // 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.7.0; /** * @dev String operations. */ library StringsUpgradeable { /** * @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: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// 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 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.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 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 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 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: MIT pragma solidity >=0.4.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = -denominator & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } }
// 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: UNLICENSED pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IYANGDepositCallBack { function YANGDepositCallback( IERC20 token0, uint256 amount0, IERC20 token1, uint256 amount1, address recipient ) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface ICHIDepositCallBack { function CHIDepositCallback( IERC20 token0, uint256 amount0, IERC20 token1, uint256 amount1, address recipient ) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.6; interface IERC20Minimal { function decimals() external view returns (uint8); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.6; pragma abicoder v2; interface IChainLinkFeedsRegistry { struct Registry { address index; uint256 decimals; } struct InputInitParam { address asset; bool isUSD; address registry; uint256 decimals; } function getUSDPrice(address asset) external view returns (uint256); function getETHPrice(address asset) external view returns (uint256); function addUSDFeed( address asset, address index, uint256 decimals ) external; function addETHFeed( address asset, address index, uint256 decimals ) external; function removeUSDFeed(address asset) external; function removeETHFeed(address asset) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.6; import "@openzeppelin/contracts/math/SafeMath.sol"; library BinaryExp { using SafeMath for uint256; function pow(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { return 1; } else if (b == 1) { return a; } else { uint256 ret = 1; for (; b > 0; ) { if (b.mod(2) == 1) { ret = ret.mul(a); } a = a.mul(a); b = b.div(2); } return ret; } } }
{ "optimizer": { "enabled": true, "runs": 50 }, "metadata": { "bytecodeHash": "none" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"nextowner","type":"address"}],"name":"AcceptOwnerShip","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"LockAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"LockSeconds","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"","type":"uint256"},{"indexed":false,"internalType":"bool","name":"","type":"bool"},{"indexed":false,"internalType":"bool","name":"","type":"bool"}],"name":"LockState","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"MintYangNFT","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":false,"internalType":"uint256","name":"yangId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"chiId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"share","type":"uint256"}],"name":"Subscribe","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"yangId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"chiId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"UnSubscribe","type":"event"},{"inputs":[{"internalType":"contract IERC20","name":"token0","type":"address"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"contract IERC20","name":"token1","type":"address"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"YANGDepositCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chiId","type":"uint256"}],"name":"checkMaxUSDLimit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"yangId","type":"uint256"},{"internalType":"uint256","name":"chiId","type":"uint256"}],"name":"durations","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chiId","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"getAmounts","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chiId","type":"uint256"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"}],"name":"getShares","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"getTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_registry","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"yangId","type":"uint256"},{"internalType":"uint256","name":"chiId","type":"uint256"}],"name":"positions","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_chiManager","type":"address"}],"name":"setCHIManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"yangId","type":"uint256"},{"internalType":"uint256","name":"chiId","type":"uint256"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"}],"internalType":"struct IYangNFTVault.SubscribeParam","name":"params","type":"tuple"}],"name":"subscribe","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"yangId","type":"uint256"},{"internalType":"uint256","name":"chiId","type":"uint256"},{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"uint256","name":"exactAmount","type":"uint256"},{"internalType":"uint256","name":"maxTokenAmount","type":"uint256"},{"internalType":"uint256","name":"minShares","type":"uint256"}],"internalType":"struct IYangNFTVault.SubscribeSingleParam","name":"params","type":"tuple"}],"name":"subscribeSingle","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"yangId","type":"uint256"},{"internalType":"uint256","name":"chiId","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"}],"internalType":"struct IYangNFTVault.UnSubscribeParam","name":"params","type":"tuple"}],"name":"unsubscribe","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"yangId","type":"uint256"},{"internalType":"uint256","name":"chiId","type":"uint256"},{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"}],"internalType":"struct IYangNFTVault.UnSubscribeSingleParam","name":"params","type":"tuple"}],"name":"unsubscribeSingle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"lockInSeconds","type":"uint256"}],"name":"updateLockSeconds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chiId","type":"uint256"},{"internalType":"bool","name":"state","type":"bool"}],"name":"updateLockState","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50614a57806100206000396000f3fe608060405234801561001057600080fd5b50600436106101e75760003560e01c80636c0360eb11610110578063a22cb465116100a8578063a22cb465146103fc578063a244a4811461040f578063afffc50214610422578063b88d4fde14610435578063c4d66de814610448578063c87b56dd1461045b578063e985e9c51461046e578063f153768614610481578063f2fde38b14610494578063f779e66f146104a7576101e7565b80636c0360eb1461038857806370a0823114610390578063715018a6146103a35780637b103999146103ab578063815a4940146103b3578063870efa7c146103c65780638da5cb5b146103d957806395d89b41146103e1578063a07f6188146103e9576101e7565b80632f745c59116101835780632f745c59146102dd5780633ab2e4ba146102f057806342842e0e1461030357806342e6e0fe146103165780634f6ccce71461032957806352749da21461033c5780635c0d107e1461034f5780636352211e146103625780636a62784214610375576101e7565b806301ffc9a7146101ec57806306fdde0314610215578063081812fc1461022a578063095ea7b31461024a5780630a8610c51461025f57806316529c461461027257806318160ddd1461029357806323b872dd146102a85780632675e94b146102bb575b600080fd5b6101ff6101fa3660046140f6565b6104ba565b60405161020c9190614481565b60405180910390f35b61021d6104dd565b60405161020c919061448c565b61023d610238366004614343565b610573565b60405161020c9190614454565b61025d610258366004614089565b6105d5565b005b61025d61026d3660046142d3565b6106ab565b610285610280366004614397565b610a8c565b60405161020c9291906145e3565b61029b610bfc565b60405161020c91906145da565b61025d6102b6366004613f67565b610c0d565b6102ce6102c9366004614397565b610c64565b60405161020c9392919061463c565b61029b6102eb366004614089565b610d0a565b61025d6102fe36600461426b565b610d35565b61025d610311366004613f67565b6110c2565b6102ce6103243660046143db565b6110dd565b61029b610337366004614343565b6112d7565b6101ff61034a366004614343565b6112ed565b6102ce61035d36600461417c565b61158b565b61023d610370366004614343565b61178b565b61029b610383366004613e5e565b6117b3565b61021d61183f565b61029b61039e366004613e5e565b6118a0565b61025d611908565b61023d6119a2565b61025d6103c136600461411e565b6119b1565b61029b6103d4366004614397565b611a4e565b61023d611a6b565b61021d611a7a565b6102ce6103f73660046141ee565b611adb565b61025d61040a36600461405c565b611be7565b61025d61041d366004613e5e565b611ce8565b61025d610430366004614343565b611d6c565b61025d610443366004613fa7565b611dda565b61025d610456366004613e5e565b611e38565b61021d610469366004614343565b611f69565b6101ff61047c366004613e96565b6121ea565b61029b61048f366004613e5e565b612218565b61025d6104a2366004613e5e565b612234565b61025d6104b5366004614373565b612325565b6001600160e01b031981166000908152609a602052604090205460ff165b919050565b60d18054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105695780601f1061053e57610100808354040283529160200191610569565b820191906000526020600020905b81548152906001019060200180831161054c57829003601f168201915b5050505050905090565b600061057e82612391565b6105b95760405162461bcd60e51b815260040180806020018281038252602c81526020018061490b602c913960400191505060405180910390fd5b50600090815260cf60205260409020546001600160a01b031690565b60006105e08261178b565b9050806001600160a01b0316836001600160a01b031614156106335760405162461bcd60e51b81526004018080602001828103825260218152602001806149cf6021913960400191505060405180910390fd5b806001600160a01b031661064561239e565b6001600160a01b0316148061066157506106618161047c61239e565b61069c5760405162461bcd60e51b815260040180806020018281038252603881526020018061480f6038913960400191505060405180910390fd5b6106a683836123a2565b505050565b600260045414156106f1576040805162461bcd60e51b815260206004820152601f6024820152600080516020614721833981519152604482015290519081900360640190fd5b600260045580516107023382612410565b6107275760405162461bcd60e51b815260040161071e9061458b565b60405180910390fd5b81516020808401516000818152600190925260409091205460ff168061077f575060008181526001602052604090205460ff1615801561077f5750600082815260026020908152604080832084845290915290205442115b6107b8576040805162461bcd60e51b81526020600482015260056024820152646c6f636b7360d81b604482015290519081900360640190fd5b60fe546001600160a01b03166107e05760405162461bcd60e51b815260040161071e9061451d565b60fe546020850151604051635cef66b360e11b81526000926001600160a01b03169163b9decd669161081591906004016145da565b6101006040518083038186803b15801561082e57600080fd5b505afa158015610842573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108669190613ece565b5050505050925050506000819050600060fe60009054906101000a90046001600160a01b03166001600160a01b031663a9f1021c886000015189602001518a604001518b606001518c608001516040518663ffffffff1660e01b81526004016108d39594939291906145f1565b602060405180830381600087803b1580156108ed57600080fd5b505af1158015610901573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610925919061435b565b9050866080015181101561093857600080fd5b600087604001516109b957826001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561097c57600080fd5b505afa158015610990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b49190613e7a565b610a2a565b826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156109f257600080fd5b505afa158015610a06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2a9190613e7a565b9050610a3981836000806124b4565b875160208901516040517fb65ca58d729d89d58e1ed48a179b40d4a6b56e3e101a10085a0f43915cf1448892610a759290918690600090614652565b60405180910390a150506001600455505050505050565b60fe5460009081906001600160a01b0316610ab95760405162461bcd60e51b815260040161071e9061451d565b60fe54604051635cef66b360e11b815260009182916001600160a01b039091169063b9decd6690610aee9089906004016145da565b6101006040518083038186803b158015610b0757600080fd5b505afa158015610b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3f9190613ece565b975050505094505050506000811115610bf357600080836001600160a01b031663c4a7761e6040518163ffffffff1660e01b8152600401604080518083038186803b158015610b8d57600080fd5b505afa158015610ba1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc591906143b8565b9092509050610bde83610bd8848a6124e8565b90612541565b9550610bee83610bd8838a6124e8565b945050505b50509250929050565b6000610c0860cd6125a5565b905090565b610c1e610c1861239e565b82612410565b610c595760405162461bcd60e51b81526004018080602001828103825260318152602001806149f06031913960400191505060405180910390fd5b6106a68383836125b0565b60fe546040516309211d7160e21b8152600091829182916001600160a01b03169063248475c490610c9b90889088906004016145e3565b60206040518083038186803b158015610cb357600080fd5b505afa158015610cc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ceb919061435b565b9050600080610cfa8684610a8c565b9098909750929550919350505050565b6001600160a01b038216600090815260cc60205260408120610d2c90836126fc565b90505b92915050565b60026004541415610d7b576040805162461bcd60e51b815260206004820152601f6024820152600080516020614721833981519152604482015290519081900360640190fd5b60026004558051610d8c3382612410565b610da85760405162461bcd60e51b815260040161071e9061458b565b81516020808401516000818152600190925260409091205460ff1680610e00575060008181526001602052604090205460ff16158015610e005750600082815260026020908152604080832084845290915290205442115b610e39576040805162461bcd60e51b81526020600482015260056024820152646c6f636b7360d81b604482015290519081900360640190fd5b60fe546001600160a01b0316610e615760405162461bcd60e51b815260040161071e9061451d565b60fe5484516020860151604080880151606089015160808a015192516346698e7560e01b815260009687966001600160a01b03909116956346698e7595610eae959294919360040161466d565b6040805180830381600087803b158015610ec757600080fd5b505af1158015610edb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eff91906143b8565b60fe546020890151604051635cef66b360e11b81529395509193506000926001600160a01b039091169163b9decd6691610f3c91906004016145da565b6101006040518083038186803b158015610f5557600080fd5b505afa158015610f69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8d9190613ece565b5050505050925050506000819050611087816001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015610fd757600080fd5b505afa158015610feb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100f9190613e7a565b85836001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561104957600080fd5b505afa15801561105d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110819190613e7a565b866124b4565b875160208901516040517fb65ca58d729d89d58e1ed48a179b40d4a6b56e3e101a10085a0f43915cf1448892610a7592909188908890614652565b6106a683838360405180602001604052806000815250611dda565b60fe54600090819081906001600160a01b031661110c5760405162461bcd60e51b815260040161071e9061451d565b60fe54604051635cef66b360e11b815260009182916001600160a01b039091169063b9decd6690611141908b906004016145da565b6101006040518083038186803b15801561115a57600080fd5b505afa15801561116e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111929190613ece565b97505050509450505050600080836001600160a01b031663c4a7761e6040518163ffffffff1660e01b8152600401604080518083038186803b1580156111d757600080fd5b505afa1580156111eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120f91906143b8565b9150915082600014156112335788955087945061122c8686612708565b96506112ca565b816112495787945061122c81610bd887866124e8565b8061125f5788955061122c82610bd888866124e8565b600061127d61126e8b846124e8565b6112788b866124e8565b61271f565b905080156112c85761129e600161129884610bd8858461272e565b9061278b565b96506112b3600161129885610bd8858461272e565b95506112c582610bd8858185896124e8565b97505b505b5050505093509350939050565b6000806112e560cd846127e3565b509392505050565b60fe54604051635cef66b360e11b8152600091829182916001600160a01b03169063b9decd66906113229087906004016145da565b6101006040518083038186803b15801561133b57600080fd5b505afa15801561134f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113739190613ece565b505060fe54604051638469176760e01b815294985092965060009550506001600160a01b0390911692506384691767916113b2915088906004016145da565b60606040518083038186803b1580156113ca57600080fd5b505afa1580156113de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140291906140b4565b92505050600080836001600160a01b031663c4a7761e6040518163ffffffff1660e01b8152600401604080518083038186803b15801561144157600080fd5b505afa158015611455573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147991906143b8565b9150915061158060ff60009054906101000a90046001600160a01b0316866001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b1580156114cf57600080fd5b505afa1580156114e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115079190613e7a565b84886001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561154157600080fd5b505afa158015611555573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115799190613e7a565b85886127ff565b979650505050505050565b61010180546001600160a01b03191633908117909155815160009182918291906115b58282612410565b6115d15760405162461bcd60e51b815260040161071e9061458b565b60026004541415611617576040805162461bcd60e51b815260206004820152601f6024820152600080516020614721833981519152604482015290519081900360640190fd5b600260045560fe546001600160a01b03166116445760405162461bcd60e51b815260040161071e9061451d565b61165186602001516112ed565b1561166e5760405162461bcd60e51b815260040161071e906144df565b60fe54865160208801516040808a015160608b015160808c015160a08d01519351633b0a3f2b60e21b81526001600160a01b039097169663ec28fcac966116be9690959094939291600401614690565b606060405180830381600087803b1580156116d857600080fd5b505af11580156116ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117109190614406565b885160208a015192985090965091945061172b9190426129b8565b855160208701516040517f17de92c1076ec5855c3edd4a6084a82c184adfda177deb99d6532697cdac91cb92611764929091879061463c565b60405180910390a15050600160045561010180546001600160a01b03191690559193909250565b6000610d2f826040518060600160405280602981526020016148716029913960cd9190612a81565b6001600160a01b03811660009081526101026020526040812054156117ea5760405162461bcd60e51b815260040161071e9061453a565b506101008054600181019091556118018282612a98565b7f74629109564de5ce9d04dc84bb5ecd8fbb0c98843a3fbd43f057825a9255449c8282604051611832929190614468565b60405180910390a1919050565b60d48054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105695780601f1061053e57610100808354040283529160200191610569565b60006001600160a01b0382166118e75760405162461bcd60e51b815260040180806020018281038252602a815260200180614847602a913960400191505060405180910390fd5b6001600160a01b038216600090815260cc60205260409020610d2f906125a5565b61191061239e565b6001600160a01b0316611921611a6b565b6001600160a01b03161461196a576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b6068546040516000916001600160a01b031690600080516020614957833981519152908390a3606880546001600160a01b0319169055565b60ff546001600160a01b031681565b60fe546001600160a01b03166119d95760405162461bcd60e51b815260040161071e9061451d565b60fe546001600160a01b03163314611a035760405162461bcd60e51b815260040161071e906144fc565b8315611a255761010154611a25906001600160a01b0387811691168387612bc6565b8115611a475761010154611a47906001600160a01b0385811691168385612bc6565b5050505050565b600091825260026020908152604080842092845291905290205490565b6068546001600160a01b031690565b60d28054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105695780601f1061053e57610100808354040283529160200191610569565b61010180546001600160a01b0319163390811790915581516000918291829190611b058282612410565b611b215760405162461bcd60e51b815260040161071e9061458b565b60026004541415611b67576040805162461bcd60e51b815260206004820152601f6024820152600080516020614721833981519152604482015290519081900360640190fd5b60026004556020860151611b7a906112ed565b15611b975760405162461bcd60e51b815260040161071e906144df565b60fe54865160208801516040808a015160608b015160808c015160a08d015193516381b6acc960e01b81526001600160a01b03909716966381b6acc9966116be9690959094939291600401614614565b611bef61239e565b6001600160a01b0316826001600160a01b03161415611c51576040805162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b604482015290519081900360640190fd5b8060d06000611c5e61239e565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155611ca261239e565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b611cf061239e565b6001600160a01b0316611d01611a6b565b6001600160a01b031614611d4a576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b60fe80546001600160a01b0319166001600160a01b0392909216919091179055565b611d7461239e565b6001600160a01b0316611d85611a6b565b6001600160a01b031614611dce576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b611dd781612c20565b50565b611deb611de561239e565b83612410565b611e265760405162461bcd60e51b81526004018080602001828103825260318152602001806149f06031913960400191505060405180910390fd5b611e3284848484612c5b565b50505050565b600354610100900460ff1680611e515750611e51612cad565b80611e5f575060035460ff16155b611e9a5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015611ec5576003805460ff1961ff0019909116610100171660011790555b60ff80546001600160a01b0319166001600160a01b038416179055600161010055611eee612cbe565b611ef6612cc7565b611efe612d78565b611f536040518060400160405280601781526020017616525388105cdcd95d0813585b9859d95c8815985d5b1d604a1b8152506040518060400160405280600481526020016359414e4760e01b815250612e0d565b8015611f65576003805461ff00191690555b5050565b6060611f7482612391565b611faf5760405162461bcd60e51b815260040180806020018281038252602f8152602001806149a0602f913960400191505060405180910390fd5b600082815260d3602090815260408083208054825160026001831615610100026000190190921691909104601f8101859004850282018501909352828152929091908301828280156120425780601f1061201757610100808354040283529160200191612042565b820191906000526020600020905b81548152906001019060200180831161202557829003601f168201915b50505050509050600061205361183f565b9050805160001415612067575090506104d8565b8151156121285780826040516020018083805190602001908083835b602083106120a25780518252601f199092019160209182019101612083565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106120ea5780518252601f1990920191602091820191016120cb565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050506104d8565b8061213285612eca565b6040516020018083805190602001908083835b602083106121645780518252601f199092019160209182019101612145565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106121ac5780518252601f19909201916020918201910161218d565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b6001600160a01b03918216600090815260d06020908152604080832093909416825291909152205460ff1690565b6001600160a01b03166000908152610102602052604090205490565b61223c61239e565b6001600160a01b031661224d611a6b565b6001600160a01b031614612296576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b6001600160a01b0381166122db5760405162461bcd60e51b81526004018080602001828103825260268152602001806147736026913960400191505060405180910390fd5b6068546040516001600160a01b0380841692169060008051602061495783398151915290600090a3606880546001600160a01b0319166001600160a01b0392909216919091179055565b61232d61239e565b6001600160a01b031661233e611a6b565b6001600160a01b031614612387576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b611f658282612fa4565b6000610d2f60cd8361301d565b3390565b600081815260cf6020526040902080546001600160a01b0319166001600160a01b03841690811790915581906123d78261178b565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061241b82612391565b6124565760405162461bcd60e51b815260040180806020018281038252602c8152602001806147e3602c913960400191505060405180910390fd5b60006124618361178b565b9050806001600160a01b0316846001600160a01b0316148061249c5750836001600160a01b031661249184610573565b6001600160a01b0316145b806124ac57506124ac81856121ea565b949350505050565b82156124ce576124ce6001600160a01b0385163385613029565b8015611e3257611e326001600160a01b0383163383613029565b6000826124f757506000610d2f565b8282028284828161250457fe5b0414610d2c5760405162461bcd60e51b81526004018080602001828103825260218152602001806148ea6021913960400191505060405180910390fd5b6000808211612594576040805162461bcd60e51b815260206004820152601a602482015279536166654d6174683a206469766973696f6e206279207a65726f60301b604482015290519081900360640190fd5b81838161259d57fe5b049392505050565b6000610d2f8261307b565b826001600160a01b03166125c38261178b565b6001600160a01b0316146126085760405162461bcd60e51b81526004018080602001828103825260298152602001806149776029913960400191505060405180910390fd5b6001600160a01b03821661264d5760405162461bcd60e51b81526004018080602001828103825260248152602001806147996024913960400191505060405180910390fd5b61265883838361307f565b6126636000826123a2565b6001600160a01b038316600090815260cc602052604090206126859082613146565b506001600160a01b038216600090815260cc602052604090206126a89082613152565b506126b560cd828461315e565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000610d2c8383613174565b6000818310156127185781610d2c565b5090919050565b60008183106127185781610d2c565b600082821115612785576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082820183811015610d2c576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b60008080806127f286866131d8565b9097909650945050505050565b60008161280e575060006129ae565b6000612917612891600a896001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561285157600080fd5b505afa158015612865573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128899190614433565b60ff16613253565b610bd8888b6001600160a01b0316638b2f0f4f8c6040518263ffffffff1660e01b81526004016128c19190614454565b60206040518083038186803b1580156128d957600080fd5b505afa1580156128ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612911919061435b565b906124e8565b9050600061298c61295c600a886001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561285157600080fd5b610bd8878c6001600160a01b0316638b2f0f4f8b6040518263ffffffff1660e01b81526004016128c19190614454565b905083612999838361278b565b10156129a65760006129a9565b60015b925050505b9695505050505050565b60008281526001602052604090205460ff166106a657600080546129dd90839061278b565b60008581526002602090815260408083208784529091529020549091508111612a1f576000848152600260209081526040808320868452909152902054612a21565b805b6000858152600260209081526040808320878452825291829020839055815187815290810186905280820192909252517fe59659d62a1104e86fae20067091468a746d4e2d54bbbe5ebeea6af71a4410f89181900360600190a150505050565b6000612a8e8484846132c0565b90505b9392505050565b6001600160a01b038216612af3576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b612afc81612391565b15612b4e576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b612b5a6000838361307f565b6001600160a01b038216600090815260cc60205260409020612b7c9082613152565b50612b8960cd828461315e565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611e3290859061338a565b60008190556040805182815290517f4c63d2fb169038d4154d6316b93f4b26b01573602cb811b1cff783e287667cdf9181900360200190a150565b612c668484846125b0565b612c728484848461343b565b611e325760405162461bcd60e51b81526004018080602001828103825260328152602001806147416032913960400191505060405180910390fd5b6000612cb8306135a3565b15905090565b62093a80600055565b600354610100900460ff1680612ce05750612ce0612cad565b80612cee575060035460ff16155b612d295760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015612d54576003805460ff1961ff0019909116610100171660011790555b612d5c6135a9565b612d64613649565b8015611dd7576003805461ff001916905550565b600354610100900460ff1680612d915750612d91612cad565b80612d9f575060035460ff16155b612dda5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015612e05576003805460ff1961ff0019909116610100171660011790555b612d64613730565b600354610100900460ff1680612e265750612e26612cad565b80612e34575060035460ff16155b612e6f5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015612e9a576003805460ff1961ff0019909116610100171660011790555b612ea26135a9565b612eaa6137d6565b612eb48383613873565b80156106a6576003805461ff0019169055505050565b606081612eef57506040805180820190915260018152600360fc1b60208201526104d8565b8160005b8115612f0757600101600a82049150612ef3565b6000816001600160401b0381118015612f1f57600080fd5b506040519080825280601f01601f191660200182016040528015612f4a576020820181803683370190505b50859350905060001982015b8315612f9b57600a840660300160f81b82828060019003935081518110612f7957fe5b60200101906001600160f81b031916908160001a905350600a84049350612f56565b50949350505050565b60008281526001602090815260409182902054825185815260ff9091161515918101919091528215158183015290517f057ae73d74608fe6ebcaee8a2f24e09d88448499312fc90fcb1a5fde7f74924f9181900360600190a1600091825260016020526040909120805460ff1916911515919091179055565b6000610d2c8383613958565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526106a690849061338a565b5490565b6001600160a01b038316156130e1576001600160a01b0383166000908152610102602052604090205481146130c65760405162461bcd60e51b815260040161071e90614562565b6001600160a01b038316600090815261010260205260408120555b6001600160a01b038216156106a6576001600160a01b03821660009081526101026020526040902054156131275760405162461bcd60e51b815260040161071e906145b1565b6001600160a01b03919091166000908152610102602052604090205550565b6000610d2c8383613970565b6000610d2c8383613a36565b6000612a8e84846001600160a01b038516613a80565b815460009082106131b65760405162461bcd60e51b81526004018080602001828103825260228152602001806146ff6022913960400191505060405180910390fd5b8260000182815481106131c557fe5b9060005260206000200154905092915050565b81546000908190831061321c5760405162461bcd60e51b81526004018080602001828103825260228152602001806148c86022913960400191505060405180910390fd5b600084600001848154811061322d57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008161326257506001610d2f565b8160011415613272575081610d2f565b60015b82156132b957613286836002613b17565b6001141561329b5761329881856124e8565b90505b6132a584806124e8565b93506132b2836002612541565b9250613275565b9050610d2f565b6000828152600184016020526040812054828161335b5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613320578181015183820152602001613308565b50505050905090810190601f16801561334d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061336e57fe5b9060005260206000209060020201600101549150509392505050565b60006133df826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613b799092919063ffffffff16565b8051909150156106a6578080602001905160208110156133fe57600080fd5b50516106a65760405162461bcd60e51b815260040180806020018281038252602a815260200180614a21602a913960400191505060405180910390fd5b600061344f846001600160a01b03166135a3565b61345b575060016124ac565b6000613569630a85bd0160e11b61347061239e565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156134d75781810151838201526020016134bf565b50505050905090810190601f1680156135045780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001614741603291396001600160a01b0388169190613b79565b9050600081806020019051602081101561358257600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b3b151590565b600354610100900460ff16806135c257506135c2612cad565b806135d0575060035460ff16155b61360b5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015612d64576003805460ff1961ff0019909116610100171660011790558015611dd7576003805461ff001916905550565b600354610100900460ff16806136625750613662612cad565b80613670575060035460ff16155b6136ab5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff161580156136d6576003805460ff1961ff0019909116610100171660011790555b60006136e061239e565b606880546001600160a01b0319166001600160a01b03831690811790915560405191925090600090600080516020614957833981519152908290a3508015611dd7576003805461ff001916905550565b600354610100900460ff16806137495750613749612cad565b80613757575060035460ff16155b6137925760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff161580156137bd576003805460ff1961ff0019909116610100171660011790555b60016004558015611dd7576003805461ff001916905550565b600354610100900460ff16806137ef57506137ef612cad565b806137fd575060035460ff16155b6138385760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015613863576003805460ff1961ff0019909116610100171660011790555b612d646301ffc9a760e01b613b88565b600354610100900460ff168061388c575061388c612cad565b8061389a575060035460ff16155b6138d55760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015613900576003805460ff1961ff0019909116610100171660011790555b82516139139060d1906020860190613dbd565b5081516139279060d2906020850190613dbd565b506139386380ac58cd60e01b613b88565b613948635b5e139f60e01b613b88565b612eb463780e9d6360e01b613b88565b60009081526001919091016020526040902054151590565b60008181526001830160205260408120548015613a2c57835460001980830191908101906000908790839081106139a357fe5b90600052602060002001549050808760000184815481106139c057fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806139f057fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610d2f565b6000915050610d2f565b6000613a428383613958565b613a7857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610d2f565b506000610d2f565b600082815260018401602052604081205480613ae5575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055612a91565b82856000016001830381548110613af857fe5b9060005260206000209060020201600101819055506000915050612a91565b6000808211613b68576040805162461bcd60e51b8152602060048201526018602482015277536166654d6174683a206d6f64756c6f206279207a65726f60401b604482015290519081900360640190fd5b818381613b7157fe5b069392505050565b6060612a8e8484600085613c0c565b6001600160e01b03198082161415613be7576040805162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b6001600160e01b0319166000908152609a60205260409020805460ff19166001179055565b606082471015613c4d5760405162461bcd60e51b81526004018080602001828103825260268152602001806147bd6026913960400191505060405180910390fd5b613c56856135a3565b613ca7576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310613ce55780518252601f199092019160209182019101613cc6565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613d47576040519150601f19603f3d011682016040523d82523d6000602084013e613d4c565b606091505b509150915061158082828660608315613d66575081612a91565b825115613d765782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315613320578181015183820152602001613308565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282613df35760008555613e39565b82601f10613e0c57805160ff1916838001178555613e39565b82800160010185558215613e39579182015b82811115613e39578251825591602001919060010190613e1e565b50613e45929150613e49565b5090565b5b80821115613e455760008155600101613e4a565b600060208284031215613e6f578081fd5b8135610d2c816146db565b600060208284031215613e8b578081fd5b8151610d2c816146db565b60008060408385031215613ea8578081fd5b8235613eb3816146db565b91506020830135613ec3816146db565b809150509250929050565b600080600080600080600080610100898b031215613eea578384fd5b8851613ef5816146db565b60208a0151909850613f06816146db565b60408a0151909750613f17816146db565b60608a0151909650613f28816146db565b809550506080890151935060a0890151925060c089015162ffffff81168114613f4f578283fd5b8092505060e089015190509295985092959890939650565b600080600060608486031215613f7b578283fd5b8335613f86816146db565b92506020840135613f96816146db565b929592945050506040919091013590565b60008060008060808587031215613fbc578182fd5b8435613fc7816146db565b9350602085810135613fd8816146db565b93506040860135925060608601356001600160401b0380821115613ffa578384fd5b818801915088601f83011261400d578384fd5b81358181111561401957fe5b61402b601f8201601f191685016146b8565b91508082528984828501011115614040578485fd5b8084840185840137810190920192909252939692955090935050565b6000806040838503121561406e578182fd5b8235614079816146db565b91506020830135613ec3816146f0565b6000806040838503121561409b578182fd5b82356140a6816146db565b946020939093013593505050565b6000806000606084860312156140c8578081fd5b83516140d3816146f0565b60208501519093506140e4816146f0565b80925050604084015190509250925092565b600060208284031215614107578081fd5b81356001600160e01b031981168114610d2c578182fd5b600080600080600060a08688031215614135578283fd5b8535614140816146db565b9450602086013593506040860135614157816146db565b925060608601359150608086013561416e816146db565b809150509295509295909350565b600060c0828403121561418d578081fd5b60405160c081018181106001600160401b03821117156141a957fe5b8060405250823581526020830135602082015260408301356040820152606083013560608201526080830135608082015260a083013560a08201528091505092915050565b600060c082840312156141ff578081fd5b60405160c081018181106001600160401b038211171561421b57fe5b80604052508235815260208301356020820152604083013561423c816146f0565b80604083015250606083013560608201526080830135608082015260a083013560a08201528091505092915050565b600060a0828403121561427c578081fd5b60405160a081018181106001600160401b038211171561429857fe5b806040525082358152602083013560208201526040830135604082015260608301356060820152608083013560808201528091505092915050565b600060a082840312156142e4578081fd5b60405160a081018181106001600160401b038211171561430057fe5b806040525082358152602083013560208201526040830135614321816146f0565b6040820152606083810135908201526080928301359281019290925250919050565b600060208284031215614354578081fd5b5035919050565b60006020828403121561436c578081fd5b5051919050565b60008060408385031215614385578182fd5b823591506020830135613ec3816146f0565b600080604083850312156143a9578182fd5b50508035926020909101359150565b600080604083850312156143ca578182fd5b505080516020909101519092909150565b6000806000606084860312156143ef578081fd5b505081359360208301359350604090920135919050565b60008060006060848603121561441a578081fd5b8351925060208401519150604084015190509250925092565b600060208284031215614444578081fd5b815160ff81168114610d2c578182fd5b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6000602080835283518082850152825b818110156144b85785810183015185820160400152820161449c565b818111156144c95783604083870101525b50601f01601f1916929092016040019392505050565b60208082526003908201526213555360ea1b604082015260600190565b60208082526007908201526636b0b730b3b2b960c91b604082015260600190565b60208082526003908201526243484960e81b604082015260600190565b6020808252600e908201526d6f6e6c79206d696e74206f6e636560901b604082015260600190565b6020808252600f908201526e1a5b9d985b1a59081d1bdad95b9259608a1b604082015260600190565b6020808252600c908201526b1b9bdd08185c1c1c9bdd995960a21b604082015260600190565b6020808252600f908201526e6f6e6c7920616363657074206f6e6560881b604082015260600190565b90815260200190565b918252602082015260400190565b948552602085019390935290151560408401526060830152608082015260a00190565b958652602086019490945291151560408501526060840152608083015260a082015260c00190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b948552602085019390935260408401919091526060830152608082015260a00190565b958652602086019490945260408501929092526060840152608083015260a082015260c00190565b6040518181016001600160401b03811182821017156146d357fe5b604052919050565b6001600160a01b0381168114611dd757600080fd5b8015158114611dd757600080fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64735265656e7472616e637947756172643a207265656e7472616e742063616c6c004552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e6473536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e04552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665645361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c6343000706000a
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101e75760003560e01c80636c0360eb11610110578063a22cb465116100a8578063a22cb465146103fc578063a244a4811461040f578063afffc50214610422578063b88d4fde14610435578063c4d66de814610448578063c87b56dd1461045b578063e985e9c51461046e578063f153768614610481578063f2fde38b14610494578063f779e66f146104a7576101e7565b80636c0360eb1461038857806370a0823114610390578063715018a6146103a35780637b103999146103ab578063815a4940146103b3578063870efa7c146103c65780638da5cb5b146103d957806395d89b41146103e1578063a07f6188146103e9576101e7565b80632f745c59116101835780632f745c59146102dd5780633ab2e4ba146102f057806342842e0e1461030357806342e6e0fe146103165780634f6ccce71461032957806352749da21461033c5780635c0d107e1461034f5780636352211e146103625780636a62784214610375576101e7565b806301ffc9a7146101ec57806306fdde0314610215578063081812fc1461022a578063095ea7b31461024a5780630a8610c51461025f57806316529c461461027257806318160ddd1461029357806323b872dd146102a85780632675e94b146102bb575b600080fd5b6101ff6101fa3660046140f6565b6104ba565b60405161020c9190614481565b60405180910390f35b61021d6104dd565b60405161020c919061448c565b61023d610238366004614343565b610573565b60405161020c9190614454565b61025d610258366004614089565b6105d5565b005b61025d61026d3660046142d3565b6106ab565b610285610280366004614397565b610a8c565b60405161020c9291906145e3565b61029b610bfc565b60405161020c91906145da565b61025d6102b6366004613f67565b610c0d565b6102ce6102c9366004614397565b610c64565b60405161020c9392919061463c565b61029b6102eb366004614089565b610d0a565b61025d6102fe36600461426b565b610d35565b61025d610311366004613f67565b6110c2565b6102ce6103243660046143db565b6110dd565b61029b610337366004614343565b6112d7565b6101ff61034a366004614343565b6112ed565b6102ce61035d36600461417c565b61158b565b61023d610370366004614343565b61178b565b61029b610383366004613e5e565b6117b3565b61021d61183f565b61029b61039e366004613e5e565b6118a0565b61025d611908565b61023d6119a2565b61025d6103c136600461411e565b6119b1565b61029b6103d4366004614397565b611a4e565b61023d611a6b565b61021d611a7a565b6102ce6103f73660046141ee565b611adb565b61025d61040a36600461405c565b611be7565b61025d61041d366004613e5e565b611ce8565b61025d610430366004614343565b611d6c565b61025d610443366004613fa7565b611dda565b61025d610456366004613e5e565b611e38565b61021d610469366004614343565b611f69565b6101ff61047c366004613e96565b6121ea565b61029b61048f366004613e5e565b612218565b61025d6104a2366004613e5e565b612234565b61025d6104b5366004614373565b612325565b6001600160e01b031981166000908152609a602052604090205460ff165b919050565b60d18054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105695780601f1061053e57610100808354040283529160200191610569565b820191906000526020600020905b81548152906001019060200180831161054c57829003601f168201915b5050505050905090565b600061057e82612391565b6105b95760405162461bcd60e51b815260040180806020018281038252602c81526020018061490b602c913960400191505060405180910390fd5b50600090815260cf60205260409020546001600160a01b031690565b60006105e08261178b565b9050806001600160a01b0316836001600160a01b031614156106335760405162461bcd60e51b81526004018080602001828103825260218152602001806149cf6021913960400191505060405180910390fd5b806001600160a01b031661064561239e565b6001600160a01b0316148061066157506106618161047c61239e565b61069c5760405162461bcd60e51b815260040180806020018281038252603881526020018061480f6038913960400191505060405180910390fd5b6106a683836123a2565b505050565b600260045414156106f1576040805162461bcd60e51b815260206004820152601f6024820152600080516020614721833981519152604482015290519081900360640190fd5b600260045580516107023382612410565b6107275760405162461bcd60e51b815260040161071e9061458b565b60405180910390fd5b81516020808401516000818152600190925260409091205460ff168061077f575060008181526001602052604090205460ff1615801561077f5750600082815260026020908152604080832084845290915290205442115b6107b8576040805162461bcd60e51b81526020600482015260056024820152646c6f636b7360d81b604482015290519081900360640190fd5b60fe546001600160a01b03166107e05760405162461bcd60e51b815260040161071e9061451d565b60fe546020850151604051635cef66b360e11b81526000926001600160a01b03169163b9decd669161081591906004016145da565b6101006040518083038186803b15801561082e57600080fd5b505afa158015610842573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108669190613ece565b5050505050925050506000819050600060fe60009054906101000a90046001600160a01b03166001600160a01b031663a9f1021c886000015189602001518a604001518b606001518c608001516040518663ffffffff1660e01b81526004016108d39594939291906145f1565b602060405180830381600087803b1580156108ed57600080fd5b505af1158015610901573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610925919061435b565b9050866080015181101561093857600080fd5b600087604001516109b957826001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561097c57600080fd5b505afa158015610990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b49190613e7a565b610a2a565b826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156109f257600080fd5b505afa158015610a06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2a9190613e7a565b9050610a3981836000806124b4565b875160208901516040517fb65ca58d729d89d58e1ed48a179b40d4a6b56e3e101a10085a0f43915cf1448892610a759290918690600090614652565b60405180910390a150506001600455505050505050565b60fe5460009081906001600160a01b0316610ab95760405162461bcd60e51b815260040161071e9061451d565b60fe54604051635cef66b360e11b815260009182916001600160a01b039091169063b9decd6690610aee9089906004016145da565b6101006040518083038186803b158015610b0757600080fd5b505afa158015610b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3f9190613ece565b975050505094505050506000811115610bf357600080836001600160a01b031663c4a7761e6040518163ffffffff1660e01b8152600401604080518083038186803b158015610b8d57600080fd5b505afa158015610ba1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc591906143b8565b9092509050610bde83610bd8848a6124e8565b90612541565b9550610bee83610bd8838a6124e8565b945050505b50509250929050565b6000610c0860cd6125a5565b905090565b610c1e610c1861239e565b82612410565b610c595760405162461bcd60e51b81526004018080602001828103825260318152602001806149f06031913960400191505060405180910390fd5b6106a68383836125b0565b60fe546040516309211d7160e21b8152600091829182916001600160a01b03169063248475c490610c9b90889088906004016145e3565b60206040518083038186803b158015610cb357600080fd5b505afa158015610cc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ceb919061435b565b9050600080610cfa8684610a8c565b9098909750929550919350505050565b6001600160a01b038216600090815260cc60205260408120610d2c90836126fc565b90505b92915050565b60026004541415610d7b576040805162461bcd60e51b815260206004820152601f6024820152600080516020614721833981519152604482015290519081900360640190fd5b60026004558051610d8c3382612410565b610da85760405162461bcd60e51b815260040161071e9061458b565b81516020808401516000818152600190925260409091205460ff1680610e00575060008181526001602052604090205460ff16158015610e005750600082815260026020908152604080832084845290915290205442115b610e39576040805162461bcd60e51b81526020600482015260056024820152646c6f636b7360d81b604482015290519081900360640190fd5b60fe546001600160a01b0316610e615760405162461bcd60e51b815260040161071e9061451d565b60fe5484516020860151604080880151606089015160808a015192516346698e7560e01b815260009687966001600160a01b03909116956346698e7595610eae959294919360040161466d565b6040805180830381600087803b158015610ec757600080fd5b505af1158015610edb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eff91906143b8565b60fe546020890151604051635cef66b360e11b81529395509193506000926001600160a01b039091169163b9decd6691610f3c91906004016145da565b6101006040518083038186803b158015610f5557600080fd5b505afa158015610f69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8d9190613ece565b5050505050925050506000819050611087816001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015610fd757600080fd5b505afa158015610feb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100f9190613e7a565b85836001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561104957600080fd5b505afa15801561105d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110819190613e7a565b866124b4565b875160208901516040517fb65ca58d729d89d58e1ed48a179b40d4a6b56e3e101a10085a0f43915cf1448892610a7592909188908890614652565b6106a683838360405180602001604052806000815250611dda565b60fe54600090819081906001600160a01b031661110c5760405162461bcd60e51b815260040161071e9061451d565b60fe54604051635cef66b360e11b815260009182916001600160a01b039091169063b9decd6690611141908b906004016145da565b6101006040518083038186803b15801561115a57600080fd5b505afa15801561116e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111929190613ece565b97505050509450505050600080836001600160a01b031663c4a7761e6040518163ffffffff1660e01b8152600401604080518083038186803b1580156111d757600080fd5b505afa1580156111eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120f91906143b8565b9150915082600014156112335788955087945061122c8686612708565b96506112ca565b816112495787945061122c81610bd887866124e8565b8061125f5788955061122c82610bd888866124e8565b600061127d61126e8b846124e8565b6112788b866124e8565b61271f565b905080156112c85761129e600161129884610bd8858461272e565b9061278b565b96506112b3600161129885610bd8858461272e565b95506112c582610bd8858185896124e8565b97505b505b5050505093509350939050565b6000806112e560cd846127e3565b509392505050565b60fe54604051635cef66b360e11b8152600091829182916001600160a01b03169063b9decd66906113229087906004016145da565b6101006040518083038186803b15801561133b57600080fd5b505afa15801561134f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113739190613ece565b505060fe54604051638469176760e01b815294985092965060009550506001600160a01b0390911692506384691767916113b2915088906004016145da565b60606040518083038186803b1580156113ca57600080fd5b505afa1580156113de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140291906140b4565b92505050600080836001600160a01b031663c4a7761e6040518163ffffffff1660e01b8152600401604080518083038186803b15801561144157600080fd5b505afa158015611455573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147991906143b8565b9150915061158060ff60009054906101000a90046001600160a01b0316866001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b1580156114cf57600080fd5b505afa1580156114e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115079190613e7a565b84886001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561154157600080fd5b505afa158015611555573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115799190613e7a565b85886127ff565b979650505050505050565b61010180546001600160a01b03191633908117909155815160009182918291906115b58282612410565b6115d15760405162461bcd60e51b815260040161071e9061458b565b60026004541415611617576040805162461bcd60e51b815260206004820152601f6024820152600080516020614721833981519152604482015290519081900360640190fd5b600260045560fe546001600160a01b03166116445760405162461bcd60e51b815260040161071e9061451d565b61165186602001516112ed565b1561166e5760405162461bcd60e51b815260040161071e906144df565b60fe54865160208801516040808a015160608b015160808c015160a08d01519351633b0a3f2b60e21b81526001600160a01b039097169663ec28fcac966116be9690959094939291600401614690565b606060405180830381600087803b1580156116d857600080fd5b505af11580156116ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117109190614406565b885160208a015192985090965091945061172b9190426129b8565b855160208701516040517f17de92c1076ec5855c3edd4a6084a82c184adfda177deb99d6532697cdac91cb92611764929091879061463c565b60405180910390a15050600160045561010180546001600160a01b03191690559193909250565b6000610d2f826040518060600160405280602981526020016148716029913960cd9190612a81565b6001600160a01b03811660009081526101026020526040812054156117ea5760405162461bcd60e51b815260040161071e9061453a565b506101008054600181019091556118018282612a98565b7f74629109564de5ce9d04dc84bb5ecd8fbb0c98843a3fbd43f057825a9255449c8282604051611832929190614468565b60405180910390a1919050565b60d48054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105695780601f1061053e57610100808354040283529160200191610569565b60006001600160a01b0382166118e75760405162461bcd60e51b815260040180806020018281038252602a815260200180614847602a913960400191505060405180910390fd5b6001600160a01b038216600090815260cc60205260409020610d2f906125a5565b61191061239e565b6001600160a01b0316611921611a6b565b6001600160a01b03161461196a576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b6068546040516000916001600160a01b031690600080516020614957833981519152908390a3606880546001600160a01b0319169055565b60ff546001600160a01b031681565b60fe546001600160a01b03166119d95760405162461bcd60e51b815260040161071e9061451d565b60fe546001600160a01b03163314611a035760405162461bcd60e51b815260040161071e906144fc565b8315611a255761010154611a25906001600160a01b0387811691168387612bc6565b8115611a475761010154611a47906001600160a01b0385811691168385612bc6565b5050505050565b600091825260026020908152604080842092845291905290205490565b6068546001600160a01b031690565b60d28054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105695780601f1061053e57610100808354040283529160200191610569565b61010180546001600160a01b0319163390811790915581516000918291829190611b058282612410565b611b215760405162461bcd60e51b815260040161071e9061458b565b60026004541415611b67576040805162461bcd60e51b815260206004820152601f6024820152600080516020614721833981519152604482015290519081900360640190fd5b60026004556020860151611b7a906112ed565b15611b975760405162461bcd60e51b815260040161071e906144df565b60fe54865160208801516040808a015160608b015160808c015160a08d015193516381b6acc960e01b81526001600160a01b03909716966381b6acc9966116be9690959094939291600401614614565b611bef61239e565b6001600160a01b0316826001600160a01b03161415611c51576040805162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b604482015290519081900360640190fd5b8060d06000611c5e61239e565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155611ca261239e565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b611cf061239e565b6001600160a01b0316611d01611a6b565b6001600160a01b031614611d4a576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b60fe80546001600160a01b0319166001600160a01b0392909216919091179055565b611d7461239e565b6001600160a01b0316611d85611a6b565b6001600160a01b031614611dce576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b611dd781612c20565b50565b611deb611de561239e565b83612410565b611e265760405162461bcd60e51b81526004018080602001828103825260318152602001806149f06031913960400191505060405180910390fd5b611e3284848484612c5b565b50505050565b600354610100900460ff1680611e515750611e51612cad565b80611e5f575060035460ff16155b611e9a5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015611ec5576003805460ff1961ff0019909116610100171660011790555b60ff80546001600160a01b0319166001600160a01b038416179055600161010055611eee612cbe565b611ef6612cc7565b611efe612d78565b611f536040518060400160405280601781526020017616525388105cdcd95d0813585b9859d95c8815985d5b1d604a1b8152506040518060400160405280600481526020016359414e4760e01b815250612e0d565b8015611f65576003805461ff00191690555b5050565b6060611f7482612391565b611faf5760405162461bcd60e51b815260040180806020018281038252602f8152602001806149a0602f913960400191505060405180910390fd5b600082815260d3602090815260408083208054825160026001831615610100026000190190921691909104601f8101859004850282018501909352828152929091908301828280156120425780601f1061201757610100808354040283529160200191612042565b820191906000526020600020905b81548152906001019060200180831161202557829003601f168201915b50505050509050600061205361183f565b9050805160001415612067575090506104d8565b8151156121285780826040516020018083805190602001908083835b602083106120a25780518252601f199092019160209182019101612083565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106120ea5780518252601f1990920191602091820191016120cb565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050506104d8565b8061213285612eca565b6040516020018083805190602001908083835b602083106121645780518252601f199092019160209182019101612145565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106121ac5780518252601f19909201916020918201910161218d565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b6001600160a01b03918216600090815260d06020908152604080832093909416825291909152205460ff1690565b6001600160a01b03166000908152610102602052604090205490565b61223c61239e565b6001600160a01b031661224d611a6b565b6001600160a01b031614612296576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b6001600160a01b0381166122db5760405162461bcd60e51b81526004018080602001828103825260268152602001806147736026913960400191505060405180910390fd5b6068546040516001600160a01b0380841692169060008051602061495783398151915290600090a3606880546001600160a01b0319166001600160a01b0392909216919091179055565b61232d61239e565b6001600160a01b031661233e611a6b565b6001600160a01b031614612387576040805162461bcd60e51b81526020600482018190526024820152600080516020614937833981519152604482015290519081900360640190fd5b611f658282612fa4565b6000610d2f60cd8361301d565b3390565b600081815260cf6020526040902080546001600160a01b0319166001600160a01b03841690811790915581906123d78261178b565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061241b82612391565b6124565760405162461bcd60e51b815260040180806020018281038252602c8152602001806147e3602c913960400191505060405180910390fd5b60006124618361178b565b9050806001600160a01b0316846001600160a01b0316148061249c5750836001600160a01b031661249184610573565b6001600160a01b0316145b806124ac57506124ac81856121ea565b949350505050565b82156124ce576124ce6001600160a01b0385163385613029565b8015611e3257611e326001600160a01b0383163383613029565b6000826124f757506000610d2f565b8282028284828161250457fe5b0414610d2c5760405162461bcd60e51b81526004018080602001828103825260218152602001806148ea6021913960400191505060405180910390fd5b6000808211612594576040805162461bcd60e51b815260206004820152601a602482015279536166654d6174683a206469766973696f6e206279207a65726f60301b604482015290519081900360640190fd5b81838161259d57fe5b049392505050565b6000610d2f8261307b565b826001600160a01b03166125c38261178b565b6001600160a01b0316146126085760405162461bcd60e51b81526004018080602001828103825260298152602001806149776029913960400191505060405180910390fd5b6001600160a01b03821661264d5760405162461bcd60e51b81526004018080602001828103825260248152602001806147996024913960400191505060405180910390fd5b61265883838361307f565b6126636000826123a2565b6001600160a01b038316600090815260cc602052604090206126859082613146565b506001600160a01b038216600090815260cc602052604090206126a89082613152565b506126b560cd828461315e565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000610d2c8383613174565b6000818310156127185781610d2c565b5090919050565b60008183106127185781610d2c565b600082821115612785576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082820183811015610d2c576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b60008080806127f286866131d8565b9097909650945050505050565b60008161280e575060006129ae565b6000612917612891600a896001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561285157600080fd5b505afa158015612865573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128899190614433565b60ff16613253565b610bd8888b6001600160a01b0316638b2f0f4f8c6040518263ffffffff1660e01b81526004016128c19190614454565b60206040518083038186803b1580156128d957600080fd5b505afa1580156128ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612911919061435b565b906124e8565b9050600061298c61295c600a886001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561285157600080fd5b610bd8878c6001600160a01b0316638b2f0f4f8b6040518263ffffffff1660e01b81526004016128c19190614454565b905083612999838361278b565b10156129a65760006129a9565b60015b925050505b9695505050505050565b60008281526001602052604090205460ff166106a657600080546129dd90839061278b565b60008581526002602090815260408083208784529091529020549091508111612a1f576000848152600260209081526040808320868452909152902054612a21565b805b6000858152600260209081526040808320878452825291829020839055815187815290810186905280820192909252517fe59659d62a1104e86fae20067091468a746d4e2d54bbbe5ebeea6af71a4410f89181900360600190a150505050565b6000612a8e8484846132c0565b90505b9392505050565b6001600160a01b038216612af3576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b612afc81612391565b15612b4e576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b612b5a6000838361307f565b6001600160a01b038216600090815260cc60205260409020612b7c9082613152565b50612b8960cd828461315e565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611e3290859061338a565b60008190556040805182815290517f4c63d2fb169038d4154d6316b93f4b26b01573602cb811b1cff783e287667cdf9181900360200190a150565b612c668484846125b0565b612c728484848461343b565b611e325760405162461bcd60e51b81526004018080602001828103825260328152602001806147416032913960400191505060405180910390fd5b6000612cb8306135a3565b15905090565b62093a80600055565b600354610100900460ff1680612ce05750612ce0612cad565b80612cee575060035460ff16155b612d295760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015612d54576003805460ff1961ff0019909116610100171660011790555b612d5c6135a9565b612d64613649565b8015611dd7576003805461ff001916905550565b600354610100900460ff1680612d915750612d91612cad565b80612d9f575060035460ff16155b612dda5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015612e05576003805460ff1961ff0019909116610100171660011790555b612d64613730565b600354610100900460ff1680612e265750612e26612cad565b80612e34575060035460ff16155b612e6f5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015612e9a576003805460ff1961ff0019909116610100171660011790555b612ea26135a9565b612eaa6137d6565b612eb48383613873565b80156106a6576003805461ff0019169055505050565b606081612eef57506040805180820190915260018152600360fc1b60208201526104d8565b8160005b8115612f0757600101600a82049150612ef3565b6000816001600160401b0381118015612f1f57600080fd5b506040519080825280601f01601f191660200182016040528015612f4a576020820181803683370190505b50859350905060001982015b8315612f9b57600a840660300160f81b82828060019003935081518110612f7957fe5b60200101906001600160f81b031916908160001a905350600a84049350612f56565b50949350505050565b60008281526001602090815260409182902054825185815260ff9091161515918101919091528215158183015290517f057ae73d74608fe6ebcaee8a2f24e09d88448499312fc90fcb1a5fde7f74924f9181900360600190a1600091825260016020526040909120805460ff1916911515919091179055565b6000610d2c8383613958565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526106a690849061338a565b5490565b6001600160a01b038316156130e1576001600160a01b0383166000908152610102602052604090205481146130c65760405162461bcd60e51b815260040161071e90614562565b6001600160a01b038316600090815261010260205260408120555b6001600160a01b038216156106a6576001600160a01b03821660009081526101026020526040902054156131275760405162461bcd60e51b815260040161071e906145b1565b6001600160a01b03919091166000908152610102602052604090205550565b6000610d2c8383613970565b6000610d2c8383613a36565b6000612a8e84846001600160a01b038516613a80565b815460009082106131b65760405162461bcd60e51b81526004018080602001828103825260228152602001806146ff6022913960400191505060405180910390fd5b8260000182815481106131c557fe5b9060005260206000200154905092915050565b81546000908190831061321c5760405162461bcd60e51b81526004018080602001828103825260228152602001806148c86022913960400191505060405180910390fd5b600084600001848154811061322d57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008161326257506001610d2f565b8160011415613272575081610d2f565b60015b82156132b957613286836002613b17565b6001141561329b5761329881856124e8565b90505b6132a584806124e8565b93506132b2836002612541565b9250613275565b9050610d2f565b6000828152600184016020526040812054828161335b5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613320578181015183820152602001613308565b50505050905090810190601f16801561334d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061336e57fe5b9060005260206000209060020201600101549150509392505050565b60006133df826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613b799092919063ffffffff16565b8051909150156106a6578080602001905160208110156133fe57600080fd5b50516106a65760405162461bcd60e51b815260040180806020018281038252602a815260200180614a21602a913960400191505060405180910390fd5b600061344f846001600160a01b03166135a3565b61345b575060016124ac565b6000613569630a85bd0160e11b61347061239e565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156134d75781810151838201526020016134bf565b50505050905090810190601f1680156135045780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001614741603291396001600160a01b0388169190613b79565b9050600081806020019051602081101561358257600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b3b151590565b600354610100900460ff16806135c257506135c2612cad565b806135d0575060035460ff16155b61360b5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015612d64576003805460ff1961ff0019909116610100171660011790558015611dd7576003805461ff001916905550565b600354610100900460ff16806136625750613662612cad565b80613670575060035460ff16155b6136ab5760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff161580156136d6576003805460ff1961ff0019909116610100171660011790555b60006136e061239e565b606880546001600160a01b0319166001600160a01b03831690811790915560405191925090600090600080516020614957833981519152908290a3508015611dd7576003805461ff001916905550565b600354610100900460ff16806137495750613749612cad565b80613757575060035460ff16155b6137925760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff161580156137bd576003805460ff1961ff0019909116610100171660011790555b60016004558015611dd7576003805461ff001916905550565b600354610100900460ff16806137ef57506137ef612cad565b806137fd575060035460ff16155b6138385760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015613863576003805460ff1961ff0019909116610100171660011790555b612d646301ffc9a760e01b613b88565b600354610100900460ff168061388c575061388c612cad565b8061389a575060035460ff16155b6138d55760405162461bcd60e51b815260040180806020018281038252602e81526020018061489a602e913960400191505060405180910390fd5b600354610100900460ff16158015613900576003805460ff1961ff0019909116610100171660011790555b82516139139060d1906020860190613dbd565b5081516139279060d2906020850190613dbd565b506139386380ac58cd60e01b613b88565b613948635b5e139f60e01b613b88565b612eb463780e9d6360e01b613b88565b60009081526001919091016020526040902054151590565b60008181526001830160205260408120548015613a2c57835460001980830191908101906000908790839081106139a357fe5b90600052602060002001549050808760000184815481106139c057fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806139f057fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610d2f565b6000915050610d2f565b6000613a428383613958565b613a7857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610d2f565b506000610d2f565b600082815260018401602052604081205480613ae5575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055612a91565b82856000016001830381548110613af857fe5b9060005260206000209060020201600101819055506000915050612a91565b6000808211613b68576040805162461bcd60e51b8152602060048201526018602482015277536166654d6174683a206d6f64756c6f206279207a65726f60401b604482015290519081900360640190fd5b818381613b7157fe5b069392505050565b6060612a8e8484600085613c0c565b6001600160e01b03198082161415613be7576040805162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b6001600160e01b0319166000908152609a60205260409020805460ff19166001179055565b606082471015613c4d5760405162461bcd60e51b81526004018080602001828103825260268152602001806147bd6026913960400191505060405180910390fd5b613c56856135a3565b613ca7576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310613ce55780518252601f199092019160209182019101613cc6565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613d47576040519150601f19603f3d011682016040523d82523d6000602084013e613d4c565b606091505b509150915061158082828660608315613d66575081612a91565b825115613d765782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315613320578181015183820152602001613308565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282613df35760008555613e39565b82601f10613e0c57805160ff1916838001178555613e39565b82800160010185558215613e39579182015b82811115613e39578251825591602001919060010190613e1e565b50613e45929150613e49565b5090565b5b80821115613e455760008155600101613e4a565b600060208284031215613e6f578081fd5b8135610d2c816146db565b600060208284031215613e8b578081fd5b8151610d2c816146db565b60008060408385031215613ea8578081fd5b8235613eb3816146db565b91506020830135613ec3816146db565b809150509250929050565b600080600080600080600080610100898b031215613eea578384fd5b8851613ef5816146db565b60208a0151909850613f06816146db565b60408a0151909750613f17816146db565b60608a0151909650613f28816146db565b809550506080890151935060a0890151925060c089015162ffffff81168114613f4f578283fd5b8092505060e089015190509295985092959890939650565b600080600060608486031215613f7b578283fd5b8335613f86816146db565b92506020840135613f96816146db565b929592945050506040919091013590565b60008060008060808587031215613fbc578182fd5b8435613fc7816146db565b9350602085810135613fd8816146db565b93506040860135925060608601356001600160401b0380821115613ffa578384fd5b818801915088601f83011261400d578384fd5b81358181111561401957fe5b61402b601f8201601f191685016146b8565b91508082528984828501011115614040578485fd5b8084840185840137810190920192909252939692955090935050565b6000806040838503121561406e578182fd5b8235614079816146db565b91506020830135613ec3816146f0565b6000806040838503121561409b578182fd5b82356140a6816146db565b946020939093013593505050565b6000806000606084860312156140c8578081fd5b83516140d3816146f0565b60208501519093506140e4816146f0565b80925050604084015190509250925092565b600060208284031215614107578081fd5b81356001600160e01b031981168114610d2c578182fd5b600080600080600060a08688031215614135578283fd5b8535614140816146db565b9450602086013593506040860135614157816146db565b925060608601359150608086013561416e816146db565b809150509295509295909350565b600060c0828403121561418d578081fd5b60405160c081018181106001600160401b03821117156141a957fe5b8060405250823581526020830135602082015260408301356040820152606083013560608201526080830135608082015260a083013560a08201528091505092915050565b600060c082840312156141ff578081fd5b60405160c081018181106001600160401b038211171561421b57fe5b80604052508235815260208301356020820152604083013561423c816146f0565b80604083015250606083013560608201526080830135608082015260a083013560a08201528091505092915050565b600060a0828403121561427c578081fd5b60405160a081018181106001600160401b038211171561429857fe5b806040525082358152602083013560208201526040830135604082015260608301356060820152608083013560808201528091505092915050565b600060a082840312156142e4578081fd5b60405160a081018181106001600160401b038211171561430057fe5b806040525082358152602083013560208201526040830135614321816146f0565b6040820152606083810135908201526080928301359281019290925250919050565b600060208284031215614354578081fd5b5035919050565b60006020828403121561436c578081fd5b5051919050565b60008060408385031215614385578182fd5b823591506020830135613ec3816146f0565b600080604083850312156143a9578182fd5b50508035926020909101359150565b600080604083850312156143ca578182fd5b505080516020909101519092909150565b6000806000606084860312156143ef578081fd5b505081359360208301359350604090920135919050565b60008060006060848603121561441a578081fd5b8351925060208401519150604084015190509250925092565b600060208284031215614444578081fd5b815160ff81168114610d2c578182fd5b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6000602080835283518082850152825b818110156144b85785810183015185820160400152820161449c565b818111156144c95783604083870101525b50601f01601f1916929092016040019392505050565b60208082526003908201526213555360ea1b604082015260600190565b60208082526007908201526636b0b730b3b2b960c91b604082015260600190565b60208082526003908201526243484960e81b604082015260600190565b6020808252600e908201526d6f6e6c79206d696e74206f6e636560901b604082015260600190565b6020808252600f908201526e1a5b9d985b1a59081d1bdad95b9259608a1b604082015260600190565b6020808252600c908201526b1b9bdd08185c1c1c9bdd995960a21b604082015260600190565b6020808252600f908201526e6f6e6c7920616363657074206f6e6560881b604082015260600190565b90815260200190565b918252602082015260400190565b948552602085019390935290151560408401526060830152608082015260a00190565b958652602086019490945291151560408501526060840152608083015260a082015260c00190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b948552602085019390935260408401919091526060830152608082015260a00190565b958652602086019490945260408501929092526060840152608083015260a082015260c00190565b6040518181016001600160401b03811182821017156146d357fe5b604052919050565b6001600160a01b0381168114611dd757600080fd5b8015158114611dd757600080fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64735265656e7472616e637947756172643a207265656e7472616e742063616c6c004552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e6473536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e04552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665645361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c6343000706000a
Loading...
Loading
Loading...
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.
[ 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.