ERC-721
Overview
Max Total Supply
0 HOT8888
Holders
531
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Balance
4 HOT8888Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
OptionsManager
Compiler Version
v0.8.6+commit.11564f7e
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "../Interfaces/IOptionsManager.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Options Manager Contract * @notice The contract that buys the options contracts for the options holders * as well as checks whether the contract that is used for buying/exercising * options has been been granted with the permission to do it on the user's behalf. **/ contract OptionsManager is IOptionsManager, ERC721("Hegic V8888 Options (Tokenized)", "HOT8888"), AccessControl { bytes32 public constant HEGIC_POOL_ROLE = keccak256("HEGIC_POOL_ROLE"); uint256 public nextTokenId = 0; mapping(uint256 => address) public override tokenPool; constructor() { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /** * @dev See EIP-165: ERC-165 Standard Interface Detection * https://eips.ethereum.org/EIPS/eip-165 **/ function createOptionFor(address holder) public override onlyRole(HEGIC_POOL_ROLE) returns (uint256 id) { id = nextTokenId++; tokenPool[id] = msg.sender; _safeMint(holder, id); } /** * @dev See EIP-165: ERC-165 Standard Interface Detection * https://eips.ethereum.org/EIPS/eip-165 **/ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, AccessControl, IERC165) returns (bool) { return interfaceId == type(IOptionsManager).interfaceId || AccessControl.supportsInterface(interfaceId) || ERC721.supportsInterface(interfaceId); } /** * @notice Used for checking whether the user has approved * the contract to buy/exercise the options on her behalf. * @param spender The address of the contract * that is used for exercising the options * @param tokenId The ERC721 token ID that is linked to the option **/ function isApprovedOrOwner(address spender, uint256 tokenId) external view virtual override returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "./Interfaces/IOptionsManager.sol"; import "./Interfaces/Interfaces.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Exerciser Contract * @notice The contract that allows to automatically exercise options half an hour before expiration **/ contract Exerciser { IOptionsManager immutable optionsManager; constructor(IOptionsManager manager) { optionsManager = manager; } function exercise(uint256 optionId) external { IHegicPool pool = IHegicPool(optionsManager.tokenPool(optionId)); (, , , , uint256 expired, , ) = pool.options(optionId); require( block.timestamp > expired - 30 minutes, "Facade Error: Automatically exercise for this option is not available yet" ); pool.exercise(optionId); } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; /** * @notice The interface for the contract * that tokenizes options as ERC721. **/ interface IOptionsManager is IERC721 { /** * @param holder The option buyer address **/ function createOptionFor(address holder) external returns (uint256); /** * @param tokenId The ERC721 token ID linked to the option **/ function tokenPool(uint256 tokenId) external returns (address pool); /** * @param spender The option buyer address or another address * with the granted permission to buy/exercise options on the user's behalf * @param tokenId The ERC721 token ID linked to the option **/ function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool); }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@chainlink/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol"; import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol"; // /** // * @author 0mllwntrmt3 // * @title Hegic Protocol V8888 Interface // * @notice The interface for the price calculator, // * options, pools and staking contracts. // **/ /** * @notice The interface fot the contract that calculates * the options prices (the premiums) that are adjusted * through balancing the `ImpliedVolRate` parameter. **/ interface IPriceCalculator { /** * @param period The option period * @param amount The option size * @param strike The option strike **/ function calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) external view returns (uint256 settlementFee, uint256 premium); } /** * @notice The interface for the contract that manages pools and the options parameters, * accumulates the funds from the liquidity providers and makes the withdrawals for them, * sells the options contracts to the options buyers and collateralizes them, * exercises the ITM (in-the-money) options with the unrealized P&L and settles them, * unlocks the expired options and distributes the premiums among the liquidity providers. **/ interface IHegicPool is IERC721, IPriceCalculator { enum OptionState {Invalid, Active, Exercised, Expired} enum TrancheState {Invalid, Open, Closed} /** * @param state The state of the option: Invalid, Active, Exercised, Expired * @param strike The option strike * @param amount The option size * @param lockedAmount The option collateral size locked * @param expired The option expiration timestamp * @param hedgePremium The share of the premium paid for hedging from the losses * @param unhedgePremium The share of the premium paid to the hedged liquidity provider **/ struct Option { OptionState state; uint256 strike; uint256 amount; uint256 lockedAmount; uint256 expired; uint256 hedgePremium; uint256 unhedgePremium; } /** * @param state The state of the liquidity tranche: Invalid, Open, Closed * @param share The liquidity provider's share in the pool * @param amount The size of liquidity provided * @param creationTimestamp The liquidity deposit timestamp * @param hedged The liquidity tranche type: hedged or unhedged (classic) **/ struct Tranche { TrancheState state; uint256 share; uint256 amount; uint256 creationTimestamp; bool hedged; } /** * @param id The ERC721 token ID linked to the option * @param settlementFee The part of the premium that * is distributed among the HEGIC staking participants * @param premium The part of the premium that * is distributed among the liquidity providers **/ event Acquired(uint256 indexed id, uint256 settlementFee, uint256 premium); /** * @param id The ERC721 token ID linked to the option * @param profit The profits of the option if exercised **/ event Exercised(uint256 indexed id, uint256 profit); /** * @param id The ERC721 token ID linked to the option **/ event Expired(uint256 indexed id); /** * @param account The liquidity provider's address * @param trancheID The liquidity tranche ID **/ event Withdrawn( address indexed account, uint256 indexed trancheID, uint256 amount ); /** * @param id The ERC721 token ID linked to the option **/ function unlock(uint256 id) external; /** * @param id The ERC721 token ID linked to the option **/ function exercise(uint256 id) external; function setLockupPeriod(uint256, uint256) external; /** * @param value The hedging pool address **/ function setHedgePool(address value) external; /** * @param trancheID The liquidity tranche ID * @return amount The liquidity to be received with * the positive or negative P&L earned or lost during * the period of holding the liquidity tranche considered **/ function withdraw(uint256 trancheID) external returns (uint256 amount); function pricer() external view returns (IPriceCalculator); /** * @return amount The unhedged liquidity size * (unprotected from the losses on selling the options) **/ function unhedgedBalance() external view returns (uint256 amount); /** * @return amount The hedged liquidity size * (protected from the losses on selling the options) **/ function hedgedBalance() external view returns (uint256 amount); /** * @param account The liquidity provider's address * @param amount The size of the liquidity tranche * @param hedged The type of the liquidity tranche * @param minShare The minimum share in the pool of the user **/ function provideFrom( address account, uint256 amount, bool hedged, uint256 minShare ) external returns (uint256 share); /** * @param holder The option buyer address * @param period The option period * @param amount The option size * @param strike The option strike **/ function sellOption( address holder, uint256 period, uint256 amount, uint256 strike ) external returns (uint256 id); /** * @param trancheID The liquidity tranche ID * @return amount The amount to be received after the withdrawal **/ function withdrawWithoutHedge(uint256 trancheID) external returns (uint256 amount); /** * @return amount The total liquidity provided into the pool **/ function totalBalance() external view returns (uint256 amount); /** * @return amount The total liquidity locked in the pool **/ function lockedAmount() external view returns (uint256 amount); function token() external view returns (IERC20); /** * @return state The state of the option: Invalid, Active, Exercised, Expired * @return strike The option strike * @return amount The option size * @return lockedAmount The option collateral size locked * @return expired The option expiration timestamp * @return hedgePremium The share of the premium paid for hedging from the losses * @return unhedgePremium The share of the premium paid to the hedged liquidity provider **/ function options(uint256 id) external view returns ( OptionState state, uint256 strike, uint256 amount, uint256 lockedAmount, uint256 expired, uint256 hedgePremium, uint256 unhedgePremium ); /** * @return state The state of the liquidity tranche: Invalid, Open, Closed * @return share The liquidity provider's share in the pool * @return amount The size of liquidity provided * @return creationTimestamp The liquidity deposit timestamp * @return hedged The liquidity tranche type: hedged or unhedged (classic) **/ function tranches(uint256 id) external view returns ( TrancheState state, uint256 share, uint256 amount, uint256 creationTimestamp, bool hedged ); } /** * @notice The interface for the contract that stakes HEGIC tokens * through buying microlots (any amount of HEGIC tokens per microlot) * and staking lots (888,000 HEGIC per lot), accumulates the staking * rewards (settlement fees) and distributes the staking rewards among * the microlots and staking lots holders (should be claimed manually). **/ interface IHegicStaking { event Claim(address indexed account, uint256 amount); event Profit(uint256 amount); event MicroLotsAcquired(address indexed account, uint256 amount); event MicroLotsSold(address indexed account, uint256 amount); function claimProfits(address account) external returns (uint256 profit); function buyStakingLot(uint256 amount) external; function sellStakingLot(uint256 amount) external; function distributeUnrealizedRewards() external; function profitOf(address account) external view returns (uint256); } interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 value) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @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 _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @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 baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || 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 _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_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 { _setOwner(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"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.7.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `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.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../Interfaces/Interfaces.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Staking Contract * @notice The contract that stakes the HEGIC tokens through * buying the microlots (any amount of HEGIC tokens per microlot) * and the staking lots (888,000 HEGIC per lot), accumulates the staking * rewards (settlement fees) and distributes the staking rewards among * the microlots and staking lots holders (should be claimed manually). **/ contract HegicStaking is ERC20, IHegicStaking { using SafeERC20 for IERC20; IERC20 public immutable HEGIC; IERC20 public immutable token; uint256 public constant STAKING_LOT_PRICE = 888_000e18; uint256 internal constant ACCURACY = 1e30; uint256 internal realisedBalance; uint256 public microLotsTotal = 0; mapping(address => uint256) public microBalance; uint256 public totalProfit = 0; mapping(address => uint256) internal lastProfit; uint256 public microLotsProfits = 0; mapping(address => uint256) internal lastMicroLotProfits; mapping(address => uint256) internal savedProfit; uint256 public classicLockupPeriod = 1 days; uint256 public microLockupPeriod = 1 days; mapping(address => uint256) public lastBoughtTimestamp; mapping(address => uint256) public lastMicroBoughtTimestamp; mapping(address => bool) public _revertTransfersInLockUpPeriod; constructor( ERC20 _hegic, ERC20 _token, string memory name, string memory short ) ERC20(name, short) { HEGIC = _hegic; token = _token; } function decimals() public pure override returns (uint8) { return 0; } /** * @notice Used by the HEGIC microlots holders * or staking lots holders for claiming * the accumulated staking rewards. **/ function claimProfits(address account) external override returns (uint256 profit) { saveProfits(account); profit = savedProfit[account]; require(profit > 0, "Zero profit"); savedProfit[account] = 0; realisedBalance -= profit; token.safeTransfer(account, profit); emit Claim(account, profit); } /** * @notice Used for staking any amount of the HEGIC tokens * higher than zero in the form of buying the microlot * for receiving a pro rata share of 20% of the total staking * rewards (settlement fees) generated by the protocol. **/ function buyMicroLot(uint256 amount) external { require(amount > 0, "Amount is zero"); saveProfits(msg.sender); lastMicroBoughtTimestamp[msg.sender] = block.timestamp; microLotsTotal += amount; microBalance[msg.sender] += amount; HEGIC.safeTransferFrom(msg.sender, address(this), amount); emit MicroLotsAcquired(msg.sender, amount); } /** * @notice Used for unstaking the HEGIC tokens * in the form of selling the microlot. **/ function sellMicroLot(uint256 amount) external { require(amount > 0, "Amount is zero"); require( lastMicroBoughtTimestamp[msg.sender] + microLockupPeriod < block.timestamp, "The action is suspended due to the lockup" ); saveProfits(msg.sender); microLotsTotal -= amount; microBalance[msg.sender] -= amount; HEGIC.safeTransfer(msg.sender, amount); emit MicroLotsSold(msg.sender, amount); } /** * @notice Used for staking the fixed amount of 888,000 HEGIC * tokens in the form of buying the staking lot (transferrable) * for receiving a pro rata share of 80% of the total staking * rewards (settlement fees) generated by the protocol. **/ function buyStakingLot(uint256 amount) external override { lastBoughtTimestamp[msg.sender] = block.timestamp; require(amount > 0, "Amount is zero"); _mint(msg.sender, amount); HEGIC.safeTransferFrom( msg.sender, address(this), amount * STAKING_LOT_PRICE ); } /** * @notice Used for unstaking 888,000 HEGIC * tokens in the form of selling the staking lot. **/ function sellStakingLot(uint256 amount) external override lockupFree { _burn(msg.sender, amount); HEGIC.safeTransfer(msg.sender, amount * STAKING_LOT_PRICE); } function revertTransfersInLockUpPeriod(bool value) external { _revertTransfersInLockUpPeriod[msg.sender] = value; } /** * @notice Returns the amount of unclaimed staking rewards. **/ function profitOf(address account) external view override returns (uint256) { (uint256 profit, uint256 micro) = getUnsavedProfits(account); return savedProfit[account] + profit + micro; } /** * @notice Used for calculating the amount of accumulated * staking rewards before the share of the staking participant * changes higher (buying more microlots or staking lots) * or lower (selling more microlots or staking lots). **/ function getUnsavedProfits(address account) internal view returns (uint256 total, uint256 micro) { total = ((totalProfit - lastProfit[account]) * balanceOf(account)) / ACCURACY; micro = ((microLotsProfits - lastMicroLotProfits[account]) * microBalance[account]) / ACCURACY; } /** * @notice Used for saving the amount of accumulated * staking rewards before the staking participant's share * changes higher (buying more microlots or staking lots) * or lower (selling more microlots or staking lots). **/ function saveProfits(address account) internal { (uint256 unsaved, uint256 micro) = getUnsavedProfits(account); lastProfit[account] = totalProfit; lastMicroLotProfits[account] = microLotsProfits; savedProfit[account] += unsaved; savedProfit[account] += micro; } function _beforeTokenTransfer( address from, address to, uint256 ) internal override { if (from != address(0)) saveProfits(from); if (to != address(0)) saveProfits(to); if ( lastBoughtTimestamp[from] + classicLockupPeriod > block.timestamp && lastBoughtTimestamp[from] > lastBoughtTimestamp[to] ) { require( !_revertTransfersInLockUpPeriod[to], "The recipient does not agree to accept the locked funds" ); lastBoughtTimestamp[to] = lastBoughtTimestamp[from]; } } /** * @notice Used for distributing the staking rewards * among the microlots and staking lots holders. **/ function distributeUnrealizedRewards() external override { uint256 amount = token.balanceOf(address(this)) - realisedBalance; realisedBalance += amount; uint256 _totalSupply = totalSupply(); if (microLotsTotal + _totalSupply > 0) { if (microLotsTotal == 0) { totalProfit += (amount * ACCURACY) / _totalSupply; } else if (_totalSupply == 0) { microLotsProfits += (amount * ACCURACY) / microLotsTotal; } else { uint256 microAmount = amount / 5; uint256 baseAmount = amount - microAmount; microLotsProfits += (microAmount * ACCURACY) / microLotsTotal; totalProfit += (baseAmount * ACCURACY) / _totalSupply; } emit Profit(amount); } } modifier lockupFree { require( lastBoughtTimestamp[msg.sender] + classicLockupPeriod <= block.timestamp, "The action is suspended due to the lockup" ); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "../Interfaces/Interfaces.sol"; import "../Interfaces/IOptionsManager.sol"; import "../Interfaces/Interfaces.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Main Pool Contract * @notice One of the main contracts that manages the pools and the options parameters, * accumulates the funds from the liquidity providers and makes the withdrawals for them, * sells the options contracts to the options buyers and collateralizes them, * exercises the ITM (in-the-money) options with the unrealized P&L and settles them, * unlocks the expired options and distributes the premiums among the liquidity providers. **/ abstract contract HegicPool is IHegicPool, ERC721, AccessControl, ReentrancyGuard { using SafeERC20 for IERC20; uint256 public constant INITIAL_RATE = 1e20; IOptionsManager public immutable optionsManager; AggregatorV3Interface public immutable priceProvider; IPriceCalculator public override pricer; uint256 public lockupPeriodForHedgedTranches = 60 days; uint256 public lockupPeriodForUnhedgedTranches = 30 days; uint256 public hedgeFeeRate = 80; uint256 public maxUtilizationRate = 80; uint256 public collateralizationRatio = 50; uint256 public override lockedAmount; uint256 public maxDepositAmount = type(uint256).max; uint256 public maxHedgedDepositAmount = type(uint256).max; uint256 public unhedgedShare = 0; uint256 public hedgedShare = 0; uint256 public override unhedgedBalance = 0; uint256 public override hedgedBalance = 0; IHegicStaking public settlementFeeRecipient; address public hedgePool; Tranche[] public override tranches; mapping(uint256 => Option) public override options; IERC20 public override token; constructor( IERC20 _token, string memory name, string memory symbol, IOptionsManager manager, IPriceCalculator _pricer, IHegicStaking _settlementFeeRecipient, AggregatorV3Interface _priceProvider ) ERC721(name, symbol) { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); priceProvider = _priceProvider; settlementFeeRecipient = _settlementFeeRecipient; pricer = _pricer; token = _token; hedgePool = _msgSender(); optionsManager = manager; } /** * @notice Used for setting the liquidity lock-up periods during which * the liquidity providers who deposited the funds into the pools contracts * won't be able to withdraw them. Note that different lock-ups could * be set for the hedged and unhedged — classic — liquidity tranches. * @param hedgedValue Hedged liquidity tranches lock-up in seconds * @param unhedgedValue Unhedged (classic) liquidity tranches lock-up in seconds **/ function setLockupPeriod(uint256 hedgedValue, uint256 unhedgedValue) external override onlyRole(DEFAULT_ADMIN_ROLE) { require( hedgedValue <= 60 days, "The lockup period for hedged tranches is too long" ); require( unhedgedValue <= 30 days, "The lockup period for unhedged tranches is too long" ); lockupPeriodForHedgedTranches = hedgedValue; lockupPeriodForUnhedgedTranches = unhedgedValue; } /** * @notice Used for setting the total maximum amount * that could be deposited into the pools contracts. * Note that different total maximum amounts could be set * for the hedged and unhedged — classic — liquidity tranches. * @param total Maximum amount of assets in the pool * in hedged and unhedged (classic) liquidity tranches combined * @param hedged Maximum amount of assets in the pool * in hedged liquidity tranches only **/ function setMaxDepositAmount(uint256 total, uint256 hedged) external onlyRole(DEFAULT_ADMIN_ROLE) { require( total >= hedged, "Pool Error: The total amount shouldn't be lower than the hedged amount" ); maxDepositAmount = total; maxHedgedDepositAmount = hedged; } /** * @notice Used for setting the maximum share of the pool * size that could be utilized as a collateral in the options. * * Example: if `MaxUtilizationRate` = 50, then only 50% * of liquidity on the pools contracts would be used for * collateralizing options while 50% will be sitting idle * available for withdrawals by the liquidity providers. * @param value The utilization ratio in a range of 50% — 100% **/ function setMaxUtilizationRate(uint256 value) external onlyRole(DEFAULT_ADMIN_ROLE) { require( 50 <= value && value <= 100, "Pool error: Wrong utilization rate limitation value" ); maxUtilizationRate = value; } /** * @notice Used for setting the collateralization ratio for the option * collateral size that will be locked at the moment of buying them. * * Example: if `CollateralizationRatio` = 50, then 50% of an option's * notional size will be locked in the pools at the moment of buying it: * say, 1 ETH call option will be collateralized with 0.5 ETH (50%). * Note that if an option holder's net P&L USD value (as options * are cash-settled) will exceed the amount of the collateral locked * in the option, she will receive the required amount at the moment * of exercising the option using the pool's unutilized (unlocked) funds. * @param value The collateralization ratio in a range of 30% — 100% **/ function setCollateralizationRatio(uint256 value) external onlyRole(DEFAULT_ADMIN_ROLE) { require( 30 <= value && value <= 100, "Pool Error: Wrong collateralization ratio value" ); collateralizationRatio = value; } /** * @dev See EIP-165: ERC-165 Standard Interface Detection * https://eips.ethereum.org/EIPS/eip-165. **/ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, AccessControl, IERC165) returns (bool) { return interfaceId == type(IHegicPool).interfaceId || AccessControl.supportsInterface(interfaceId) || ERC721.supportsInterface(interfaceId); } /** * @notice Used for changing the hedging pool address * that will be accumulating the hedging premiums paid * as a share of the total premium redirected to this address. * @param value The address for receiving hedging premiums **/ function setHedgePool(address value) external override onlyRole(DEFAULT_ADMIN_ROLE) { require(value != address(0)); hedgePool = value; } /** * @notice Used for selling the options contracts * with the parameters chosen by the option buyer * such as the period of holding, option size (amount), * strike price and the premium to be paid for the option. * @param holder The option buyer address * @param period The option period * @param amount The option size * @param strike The option strike * @return id ID of ERC721 token linked to the option **/ function sellOption( address holder, uint256 period, uint256 amount, uint256 strike ) external override returns (uint256 id) { if (strike == 0) strike = _currentPrice(); uint256 balance = totalBalance(); uint256 amountToBeLocked = _calculateLockedAmount(amount); require(period >= 1 days, "Pool Error: The period is too short"); require(period <= 90 days, "Pool Error: The period is too long"); require( (lockedAmount + amountToBeLocked) * 100 <= balance * maxUtilizationRate, "Pool Error: The amount is too large" ); (uint256 settlementFee, uint256 premium) = _calculateTotalPremium(period, amount, strike); uint256 hedgedPremiumTotal = (premium * hedgedBalance) / balance; uint256 hedgeFee = (hedgedPremiumTotal * hedgeFeeRate) / 100; uint256 hedgePremium = hedgedPremiumTotal - hedgeFee; uint256 unhedgePremium = premium - hedgedPremiumTotal; lockedAmount += amountToBeLocked; id = optionsManager.createOptionFor(holder); options[id] = Option( OptionState.Active, strike, amount, amountToBeLocked, block.timestamp + period, hedgePremium, unhedgePremium ); token.safeTransferFrom( _msgSender(), address(this), premium + settlementFee ); token.safeTransfer(address(settlementFeeRecipient), settlementFee); settlementFeeRecipient.distributeUnrealizedRewards(); if (hedgeFee > 0) token.safeTransfer(hedgePool, hedgeFee); emit Acquired(id, settlementFee, premium); } /** * @notice Used for setting the price calculator * contract that will be used for pricing the options. * @param pc A new price calculator contract address **/ function setPriceCalculator(IPriceCalculator pc) public onlyRole(DEFAULT_ADMIN_ROLE) { pricer = pc; } /** * @notice Used for exercising the ITM (in-the-money) * options contracts in case of having the unrealized profits * accrued during the period of holding the option contract. * @param id ID of ERC721 token linked to the option **/ function exercise(uint256 id) external override { Option storage option = options[id]; uint256 profit = _profitOf(option); require( optionsManager.isApprovedOrOwner(_msgSender(), id), "Pool Error: msg.sender can't exercise this option" ); require( option.expired > block.timestamp, "Pool Error: The option has already expired" ); require( profit > 0, "Pool Error: There are no unrealized profits for this option" ); _unlock(option); option.state = OptionState.Exercised; _send(optionsManager.ownerOf(id), profit); emit Exercised(id, profit); } function _send(address to, uint256 transferAmount) private { require(to != address(0)); uint256 hedgeLoss = (transferAmount * hedgedBalance) / totalBalance(); uint256 unhedgeLoss = transferAmount - hedgeLoss; hedgedBalance -= hedgeLoss; unhedgedBalance -= unhedgeLoss; token.safeTransfer(to, transferAmount); } /** * @notice Used for unlocking the expired OTM (out-of-the-money) * options contracts in case if there was no unrealized P&L * accrued during the period of holding a particular option. * Note that the `unlock` function releases the liquidity that * was locked in the option when it was active and the premiums * that are distributed pro rata among the liquidity providers. * @param id ID of ERC721 token linked to the option **/ function unlock(uint256 id) external override { Option storage option = options[id]; require( option.expired < block.timestamp, "Pool Error: The option has not expired yet" ); _unlock(option); option.state = OptionState.Expired; emit Expired(id); } function _unlock(Option storage option) internal { require( option.state == OptionState.Active, "Pool Error: The option with such an ID has already been exercised or expired" ); lockedAmount -= option.lockedAmount; hedgedBalance += option.hedgePremium; unhedgedBalance += option.unhedgePremium; } function _calculateLockedAmount(uint256 amount) internal virtual returns (uint256) { return (amount * collateralizationRatio) / 100; } /** * @notice Used for depositing the funds into the pool * and minting the liquidity tranche ERC721 token * which represents the liquidity provider's share * in the pool and her unrealized P&L for this tranche. * @param account The liquidity provider's address * @param amount The size of the liquidity tranche * @param hedged The type of the liquidity tranche * @param minShare The minimum share in the pool for the user **/ function provideFrom( address account, uint256 amount, bool hedged, uint256 minShare ) external override nonReentrant returns (uint256 share) { uint256 totalShare = hedged ? hedgedShare : unhedgedShare; uint256 balance = hedged ? hedgedBalance : unhedgedBalance; share = totalShare > 0 && balance > 0 ? (amount * totalShare) / balance : amount * INITIAL_RATE; uint256 limit = hedged ? maxHedgedDepositAmount - hedgedBalance : maxDepositAmount - hedgedBalance - unhedgedBalance; require(share >= minShare, "Pool Error: The mint limit is too large"); require(share > 0, "Pool Error: The amount is too small"); require( amount <= limit, "Pool Error: Depositing into the pool is not available" ); if (hedged) { hedgedShare += share; hedgedBalance += amount; } else { unhedgedShare += share; unhedgedBalance += amount; } uint256 trancheID = tranches.length; tranches.push( Tranche(TrancheState.Open, share, amount, block.timestamp, hedged) ); _safeMint(account, trancheID); token.safeTransferFrom(_msgSender(), address(this), amount); } /** * @notice Used for withdrawing the funds from the pool * plus the net positive P&L earned or * minus the net negative P&L lost on * providing liquidity and selling options. * @param trancheID The liquidity tranche ID * @return amount The amount received after the withdrawal **/ function withdraw(uint256 trancheID) external override nonReentrant returns (uint256 amount) { address owner = ownerOf(trancheID); Tranche memory t = tranches[trancheID]; amount = _withdraw(owner, trancheID); if (t.hedged && amount < t.amount) { token.safeTransferFrom(hedgePool, owner, t.amount - amount); amount = t.amount; } emit Withdrawn(owner, trancheID, amount); } /** * @notice Used for withdrawing the funds from the pool * by the hedged liquidity tranches providers * in case of an urgent need to withdraw the liquidity * without receiving the loss compensation from * the hedging pool: the net difference between * the amount deposited and the withdrawal amount. * @param trancheID ID of liquidity tranche * @return amount The amount received after the withdrawal **/ function withdrawWithoutHedge(uint256 trancheID) external override nonReentrant returns (uint256 amount) { address owner = ownerOf(trancheID); amount = _withdraw(owner, trancheID); emit Withdrawn(owner, trancheID, amount); } function _withdraw(address owner, uint256 trancheID) internal returns (uint256 amount) { Tranche storage t = tranches[trancheID]; uint256 lockupPeriod = t.hedged ? lockupPeriodForHedgedTranches : lockupPeriodForUnhedgedTranches; require(t.state == TrancheState.Open); require(_isApprovedOrOwner(_msgSender(), trancheID)); require( block.timestamp > t.creationTimestamp + lockupPeriod, "Pool Error: The withdrawal is locked up" ); t.state = TrancheState.Closed; if (t.hedged) { amount = (t.share * hedgedBalance) / hedgedShare; hedgedShare -= t.share; hedgedBalance -= amount; } else { amount = (t.share * unhedgedBalance) / unhedgedShare; unhedgedShare -= t.share; unhedgedBalance -= amount; } token.safeTransfer(owner, amount); } /** * @return balance Returns the amount of liquidity available for withdrawing **/ function availableBalance() public view returns (uint256 balance) { return totalBalance() - lockedAmount; } /** * @return balance Returns the total balance of liquidity provided to the pool **/ function totalBalance() public view override returns (uint256 balance) { return hedgedBalance + unhedgedBalance; } function _beforeTokenTransfer( address, address, uint256 id ) internal view override { require( tranches[id].state == TrancheState.Open, "Pool Error: The closed tranches can not be transferred" ); } /** * @notice Returns the amount of unrealized P&L of the option * that could be received by the option holder in case * if she exercises it as an ITM (in-the-money) option. * @param id ID of ERC721 token linked to the option **/ function profitOf(uint256 id) external view returns (uint256) { return _profitOf(options[id]); } function _profitOf(Option memory option) internal view virtual returns (uint256 amount); /** * @notice Used for calculating the `TotalPremium` * for the particular option with regards to * the parameters chosen by the option buyer * such as the period of holding, size (amount) * and strike price. * @param period The period of holding the option * @param period The size of the option **/ function calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) external view override returns (uint256 settlementFee, uint256 premium) { return _calculateTotalPremium(period, amount, strike); } function _calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) internal view virtual returns (uint256 settlementFee, uint256 premium) { (settlementFee, premium) = pricer.calculateTotalPremium( period, amount, strike ); require( settlementFee + premium > amount / 1000, "HegicPool: The option's price is too low" ); } /** * @notice Used for changing the `settlementFeeRecipient` * contract address for distributing the settlement fees * (staking rewards) among the staking participants. * @param recipient New staking contract address **/ function setSettlementFeeRecipient(IHegicStaking recipient) external onlyRole(DEFAULT_ADMIN_ROLE) { require(address(recipient) != address(0)); settlementFeeRecipient = recipient; } function _currentPrice() internal view returns (uint256 price) { (, int256 latestPrice, , , ) = priceProvider.latestRoundData(); price = uint256(latestPrice); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 ReentrancyGuard { // 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; constructor() { _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; } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "./HegicPool.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Put Liquidity Pool Contract * @notice The Put Liquidity Pool Contract **/ contract HegicPUT is HegicPool { uint256 private immutable SpotDecimals; // 1e18 uint256 private constant TokenDecimals = 1e6; // 1e6 /** * @param name The pool contract name * @param symbol The pool ticker for the ERC721 options **/ constructor( IERC20 _token, string memory name, string memory symbol, IOptionsManager manager, IPriceCalculator _pricer, IHegicStaking _settlementFeeRecipient, AggregatorV3Interface _priceProvider, uint8 spotDecimals ) HegicPool( _token, name, symbol, manager, _pricer, _settlementFeeRecipient, _priceProvider ) { SpotDecimals = 10**spotDecimals; } function _profitOf(Option memory option) internal view override returns (uint256 amount) { uint256 currentPrice = _currentPrice(); if (currentPrice > option.strike) return 0; return ((option.strike - currentPrice) * option.amount * TokenDecimals) / SpotDecimals / 1e8; } function _calculateLockedAmount(uint256 amount) internal view override returns (uint256) { return (amount * collateralizationRatio * _currentPrice() * TokenDecimals) / SpotDecimals / 1e8 / 100; } function _calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) internal view override returns (uint256 settlementFee, uint256 premium) { uint256 currentPrice = _currentPrice(); (settlementFee, premium) = pricer.calculateTotalPremium( period, amount, strike ); settlementFee = (settlementFee * currentPrice * TokenDecimals) / 1e8 / SpotDecimals; premium = (premium * currentPrice * TokenDecimals) / 1e8 / SpotDecimals; } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "../Interfaces/Interfaces.sol"; import "../Interfaces/IOptionsManager.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Facade Contract * @notice The contract that calculates the options prices, * conducts the process of buying options, converts the premiums * into the token that the pool is denominated in and grants * permissions to the contracts such as GSN (Gas Station Network). **/ contract Facade is Ownable { using SafeERC20 for IERC20; IWETH public immutable WETH; IUniswapV2Router01 public immutable exchange; IOptionsManager public immutable optionsManager; address public _trustedForwarder; constructor( IWETH weth, IUniswapV2Router01 router, IOptionsManager manager, address trustedForwarder ) { WETH = weth; exchange = router; _trustedForwarder = trustedForwarder; optionsManager = manager; } /** * @notice Used for calculating the option price (the premium) and using * the swap router (if needed) to convert the tokens with which the user * pays the premium into the token in which the pool is denominated. * @param period The option period * @param amount The option size * @param strike The option strike * @param total The total premium * @param baseTotal The part of the premium that * is distributed among the liquidity providers * @param settlementFee The part of the premium that * is distributed among the HEGIC staking participants **/ function getOptionPrice( IHegicPool pool, uint256 period, uint256 amount, uint256 strike, address[] calldata swappath ) public view returns ( uint256 total, uint256 baseTotal, uint256 settlementFee, uint256 premium ) { (uint256 _baseTotal, uint256 baseSettlementFee, uint256 basePremium) = getBaseOptionCost(pool, period, amount, strike); if (swappath.length > 1) total = exchange.getAmountsIn(_baseTotal, swappath)[0]; else total = _baseTotal; baseTotal = _baseTotal; settlementFee = (total * baseSettlementFee) / baseTotal; premium = (total * basePremium) / baseTotal; } /** * @notice Used for calculating the option price (the premium) * in the token in which the pool is denominated. * @param period The option period * @param amount The option size * @param strike The option strike **/ function getBaseOptionCost( IHegicPool pool, uint256 period, uint256 amount, uint256 strike ) public view returns ( uint256 total, uint256 settlementFee, uint256 premium ) { (settlementFee, premium) = pool.calculateTotalPremium( period, amount, strike ); total = premium + settlementFee; } /** * @notice Used for approving the pools contracts addresses. **/ function poolApprove(IHegicPool pool) external { pool.token().safeApprove(address(pool), 0); pool.token().safeApprove(address(pool), type(uint256).max); } /** * @notice Used for buying the option contract and converting * the buyer's tokens (the total premium) into the token * in which the pool is denominated. * @param period The option period * @param amount The option size * @param strike The option strike * @param acceptablePrice The highest acceptable price **/ function createOption( IHegicPool pool, uint256 period, uint256 amount, uint256 strike, address[] calldata swappath, uint256 acceptablePrice ) external payable { address buyer = _msgSender(); (uint256 optionPrice, uint256 rawOptionPrice, , ) = getOptionPrice(pool, period, amount, strike, swappath); require( optionPrice <= acceptablePrice, "Facade Error: The option price is too high" ); IERC20 paymentToken = IERC20(swappath[0]); paymentToken.safeTransferFrom(buyer, address(this), optionPrice); if (swappath.length > 1) { if ( paymentToken.allowance(address(this), address(exchange)) < optionPrice ) { paymentToken.safeApprove(address(exchange), 0); paymentToken.safeApprove(address(exchange), type(uint256).max); } exchange.swapTokensForExactTokens( rawOptionPrice, optionPrice, swappath, address(this), block.timestamp ); } pool.sellOption(buyer, period, amount, strike); } /** * @notice Used for converting the liquidity provider's Ether (ETH) * into Wrapped Ether (WETH) and providing the funds into the pool. * @param hedged The liquidity tranche type: hedged or unhedged (classic) **/ function provideEthToPool( IHegicPool pool, bool hedged, uint256 minShare ) external payable returns (uint256) { WETH.deposit{value: msg.value}(); if (WETH.allowance(address(this), address(pool)) < msg.value) WETH.approve(address(pool), type(uint256).max); return pool.provideFrom(msg.sender, msg.value, hedged, minShare); } /** * @notice Unlocks the array of options. * @param optionIDs The array of options **/ function unlockAll(IHegicPool pool, uint256[] calldata optionIDs) external { uint256 arrayLength = optionIDs.length; for (uint256 i = 0; i < arrayLength; i++) { pool.unlock(optionIDs[i]); } } /** * @notice Used for granting the GSN (Gas Station Network) contract * the permission to pay the gas (transaction) fees for the users. * @param forwarder GSN (Gas Station Network) contract address **/ function isTrustedForwarder(address forwarder) public view returns (bool) { return forwarder == _trustedForwarder; } function claimAllStakingProfits( IHegicStaking[] calldata stakings, address account ) external { uint256 arrayLength = stakings.length; for (uint256 i = 0; i < arrayLength; i++) { IHegicStaking s = stakings[i]; if (s.profitOf(account) > 0) s.claimProfits(account); } } function _msgSender() internal view override returns (address signer) { signer = msg.sender; if (msg.data.length >= 20 && isTrustedForwarder(signer)) { assembly { signer := shr(96, calldataload(sub(calldatasize(), 20))) } } } function exercise(uint256 optionId) external { require( optionsManager.isApprovedOrOwner(_msgSender(), optionId), "Facade Error: _msgSender is not eligible to exercise the option" ); IHegicPool(optionsManager.tokenPool(optionId)).exercise(optionId); } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "./HegicPool.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Call Liquidity Pool Contract * @notice The Call Liquidity Pool Contract **/ contract HegicCALL is HegicPool { /** * @param name The pool contract name * @param symbol The pool ticker for the ERC721 options **/ constructor( IERC20 _token, string memory name, string memory symbol, IOptionsManager manager, IPriceCalculator _pricer, IHegicStaking _settlementFeeRecipient, AggregatorV3Interface _priceProvider ) HegicPool( _token, name, symbol, manager, _pricer, _settlementFeeRecipient, _priceProvider ) {} function _profitOf(Option memory option) internal view override returns (uint256 amount) { uint256 currentPrice = _currentPrice(); if (currentPrice < option.strike) return 0; return ((currentPrice - option.strike) * option.amount) / currentPrice; } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract ERC20Mock is ERC20 { uint8 private immutable _decimals; constructor( string memory name, string memory symbol, uint8 __decimals ) ERC20("token", "symbol") { _decimals = __decimals; } function decimals() public view override returns (uint8) { return _decimals; } function mintTo(address account, uint256 amount) public { _mint(account, amount); } function mint(uint256 amount) public { _mint(msg.sender, amount); } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "./ERC20Mock.sol"; contract WETHMock is ERC20Mock("WETH", "Wrapped Ether", 18) { function deposit() external payable { _mint(msg.sender, msg.value); } function withdraw(uint256 amount) external { _burn(msg.sender, amount); payable(msg.sender).transfer(amount); } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "./ERC20Mock.sol"; import "@chainlink/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol"; contract UniswapRouterMock { ERC20Mock public immutable WBTC; ERC20Mock public immutable USDC; AggregatorV3Interface public immutable WBTCPriceProvider; AggregatorV3Interface public immutable ETHPriceProvider; constructor( ERC20Mock _wbtc, ERC20Mock _usdc, AggregatorV3Interface wpp, AggregatorV3Interface epp ) { WBTC = _wbtc; USDC = _usdc; WBTCPriceProvider = wpp; ETHPriceProvider = epp; } function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 /*deadline*/ ) external payable returns (uint256[] memory amounts) { require(path.length == 2, "UniswapMock: wrong path"); require( path[1] == address(USDC) || path[1] == address(WBTC), "UniswapMock: too small value" ); amounts = getAmountsIn(amountOut, path); require(msg.value >= amounts[0], "UniswapMock: too small value"); if (msg.value > amounts[0]) payable(msg.sender).transfer(msg.value - amounts[0]); ERC20Mock(path[1]).mintTo(to, amountOut); } function getAmountsIn(uint256 amountOut, address[] calldata path) public view returns (uint256[] memory amounts) { require(path.length == 2, "UniswapMock: wrong path"); uint256 amount; if (path[1] == address(USDC)) { (, int256 ethPrice, , , ) = ETHPriceProvider.latestRoundData(); amount = (amountOut * 1e8) / uint256(ethPrice); } else if (path[1] == address(WBTC)) { (, int256 ethPrice, , , ) = ETHPriceProvider.latestRoundData(); (, int256 wbtcPrice, , , ) = WBTCPriceProvider.latestRoundData(); amount = (amountOut * uint256(wbtcPrice)) / uint256(ethPrice); } else { revert("UniswapMock: wrong path"); } amounts = new uint256[](2); amounts[0] = (amount * 103) / 100; amounts[1] = amountOut; } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ import "../Interfaces/Interfaces.sol"; import "../utils/Math.sol"; /** * @author 0mllwntrmt3 * @title Hegic Protocol V8888 Price Calculator Contract * @notice The contract that calculates the options prices (the premiums) * that are adjusted through the `ImpliedVolRate` parameter. **/ contract PriceCalculator is IPriceCalculator, Ownable { using HegicMath for uint256; uint256 public impliedVolRate; uint256 internal constant PRICE_DECIMALS = 1e8; uint256 internal constant PRICE_MODIFIER_DECIMALS = 1e8; uint256 public utilizationRate = 0; AggregatorV3Interface public priceProvider; IHegicPool pool; constructor( uint256 initialRate, AggregatorV3Interface _priceProvider, IHegicPool _pool ) { pool = _pool; priceProvider = _priceProvider; impliedVolRate = initialRate; } /** * @notice Used for adjusting the options prices (the premiums) * while balancing the asset's implied volatility rate. * @param value New IVRate value **/ function setImpliedVolRate(uint256 value) external onlyOwner { impliedVolRate = value; } /** * @notice Used for updating utilizationRate value * @param value New utilizationRate value **/ function setUtilizationRate(uint256 value) external onlyOwner { utilizationRate = value; } /** * @notice Used for calculating the options prices * @param period The option period in seconds (1 days <= period <= 90 days) * @param amount The option size * @param strike The option strike * @return settlementFee The part of the premium that * is distributed among the HEGIC staking participants * @return premium The part of the premium that * is distributed among the liquidity providers **/ function calculateTotalPremium( uint256 period, uint256 amount, uint256 strike ) public view override returns (uint256 settlementFee, uint256 premium) { uint256 currentPrice = _currentPrice(); if (strike == 0) strike = currentPrice; require( strike == currentPrice, "Only ATM options are currently available" ); uint256 total = _calculatePeriodFee(amount, period); settlementFee = total / 5; premium = total - settlementFee; } /** * @notice Calculates and prices in the time value of the option * @param amount Option size * @param period The option period in seconds (1 days <= period <= 90 days) * @return fee The premium size to be paid **/ function _calculatePeriodFee(uint256 amount, uint256 period) internal view returns (uint256 fee) { return (amount * _priceModifier(amount, period, pool)) / PRICE_DECIMALS / PRICE_MODIFIER_DECIMALS; } /** * @notice Calculates `periodFee` of the option * @param amount The option size * @param period The option period in seconds (1 days <= period <= 90 days) **/ function _priceModifier( uint256 amount, uint256 period, IHegicPool pool ) internal view returns (uint256 iv) { uint256 poolBalance = pool.totalBalance(); require(poolBalance > 0, "Pool Error: The pool is empty"); iv = impliedVolRate * period.sqrt(); uint256 lockedAmount = pool.lockedAmount() + amount; uint256 utilization = (lockedAmount * 100e8) / poolBalance; if (utilization > 40e8) { iv += (iv * (utilization - 40e8) * utilizationRate) / 40e16; } } /** * @notice Used for requesting the current price of the asset * using the ChainLink data feeds contracts. * See https://feeds.chain.link/ * @return price Price **/ function _currentPrice() internal view returns (uint256 price) { (, int256 latestPrice, , , ) = priceProvider.latestRoundData(); price = uint256(latestPrice); } }
pragma solidity 0.8.6; /** * SPDX-License-Identifier: GPL-3.0-or-later * Hegic * Copyright (C) 2021 Hegic Protocol * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ library HegicMath { /** * @dev Calculates a square root of the number. * Responds with an "invalid opcode" at uint(-1). **/ function sqrt(uint256 x) internal pure returns (uint256 result) { result = x; uint256 k = (x >> 1) + 1; while (k < result) (result, k) = (k, (x / k + k) >> 1); } }
pragma solidity >=0.5.0; interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; }
pragma solidity >=0.5.0; interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); }
pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; }
pragma solidity >=0.5.0; interface IUniswapV2Callee { function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external; }
pragma solidity >=0.5.0; interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); }
pragma solidity >=0.5.0; interface IUniswapV2ERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; }
pragma solidity >=0.6.0; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "metadata": { "useLiteralContent": true } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","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"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HEGIC_POOL_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","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":[{"internalType":"address","name":"holder","type":"address"}],"name":"createOptionFor","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"spender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isApprovedOrOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","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":"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":"","type":"uint256"}],"name":"tokenPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"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"}]
Contract Creation Code
608060405260006007553480156200001657600080fd5b50604080518082018252601f81527f4865676963205638383838204f7074696f6e732028546f6b656e697a656429006020808301918252835180850190945260078452660909ea8707070760cb1b9084015281519192916200007b916000916200015d565b508051620000919060019060208401906200015d565b50620000a391506000905033620000a9565b62000240565b620000b58282620000b9565b5050565b60008281526006602090815260408083206001600160a01b038516845290915290205460ff16620000b55760008281526006602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001193390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b8280546200016b9062000203565b90600052602060002090601f0160209004810192826200018f5760008555620001da565b82601f10620001aa57805160ff1916838001178555620001da565b82800160010185558215620001da579182015b82811115620001da578251825591602001919060010190620001bd565b50620001e8929150620001ec565b5090565b5b80821115620001e85760008155600101620001ed565b600181811c908216806200021857607f821691505b602082108114156200023a57634e487b7160e01b600052602260045260246000fd5b50919050565b611ad480620002506000396000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c806375794a3c116100c3578063a22cb4651161007c578063a22cb465146102f6578063b88d4fde14610309578063c40c11bb1461031c578063c87b56dd14610345578063d547741f14610358578063e985e9c51461036b57600080fd5b806375794a3c1461029057806391d148541461029957806395d89b41146102ac5780639606c080146102b457806397eef5b7146102c7578063a217fddf146102ee57600080fd5b80632f2ff15d116101155780632f2ff15d1461021e57806336568abe1461023157806342842e0e14610244578063430c2081146102575780636352211e1461026a57806370a082311461027d57600080fd5b806301ffc9a71461015d57806306fdde0314610185578063081812fc1461019a578063095ea7b3146101c557806323b872dd146101da578063248a9ca3146101ed575b600080fd5b61017061016b366004611727565b6103a7565b60405190151581526020015b60405180910390f35b61018d6103e1565b60405161017c919061186e565b6101ad6101a83660046116eb565b610473565b6040516001600160a01b03909116815260200161017c565b6101d86101d33660046116c1565b61050d565b005b6101d86101e836600461156d565b610623565b6102106101fb3660046116eb565b60009081526006602052604090206001015490565b60405190815260200161017c565b6101d861022c366004611704565b610654565b6101d861023f366004611704565b61067a565b6101d861025236600461156d565b6106f8565b6101706102653660046116c1565b610713565b6101ad6102783660046116eb565b610792565b61021061028b36600461151f565b610809565b61021060075481565b6101706102a7366004611704565b610890565b61018d6108bb565b6102106102c236600461151f565b6108ca565b6102107f985cb37a5a8b8be3316b4239830f14f158762f12abaae14c979a055dd9bbee6f81565b610210600081565b6101d8610304366004611685565b61093b565b6101d86103173660046115a9565b610a00565b6101ad61032a3660046116eb565b6008602052600090815260409020546001600160a01b031681565b61018d6103533660046116eb565b610a38565b6101d8610366366004611704565b610b20565b61017061037936600461153a565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60006001600160e01b0319821663088378dd60e11b14806103cc57506103cc82610b46565b806103db57506103db82610b67565b92915050565b6060600080546103f0906119c9565b80601f016020809104026020016040519081016040528092919081815260200182805461041c906119c9565b80156104695780601f1061043e57610100808354040283529160200191610469565b820191906000526020600020905b81548152906001019060200180831161044c57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166104f15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061051882610792565b9050806001600160a01b0316836001600160a01b031614156105865760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016104e8565b336001600160a01b03821614806105a257506105a28133610379565b6106145760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016104e8565b61061e8383610bb7565b505050565b61062d3382610c25565b6106495760405162461bcd60e51b81526004016104e8906118d3565b61061e838383610ca9565b6000828152600660205260409020600101546106708133610e49565b61061e8383610ead565b6001600160a01b03811633146106ea5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016104e8565b6106f48282610f33565b5050565b61061e83838360405180602001604052806000815250610a00565b60008061071f83610792565b9050806001600160a01b0316846001600160a01b0316148061075a5750836001600160a01b031661074f84610473565b6001600160a01b0316145b8061078a57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b6000818152600260205260408120546001600160a01b0316806103db5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016104e8565b60006001600160a01b0382166108745760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016104e8565b506001600160a01b031660009081526003602052604090205490565b60009182526006602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600180546103f0906119c9565b60007f985cb37a5a8b8be3316b4239830f14f158762f12abaae14c979a055dd9bbee6f6108f78133610e49565b60078054906000610907836119fe565b90915550600081815260086020526040902080546001600160a01b0319163317905591506109358383610f9a565b50919050565b6001600160a01b0382163314156109945760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016104e8565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610a0a3383610c25565b610a265760405162461bcd60e51b81526004016104e8906118d3565b610a3284848484610fb4565b50505050565b6000818152600260205260409020546060906001600160a01b0316610ab75760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016104e8565b6000610ace60408051602081019091526000815290565b90506000815111610aee5760405180602001604052806000815250610b19565b80610af884610fe7565b604051602001610b0992919061178d565b6040516020818303038152906040525b9392505050565b600082815260066020526040902060010154610b3c8133610e49565b61061e8383610f33565b60006001600160e01b03198216637965db0b60e01b14806103db57506103db825b60006001600160e01b031982166380ac58cd60e01b1480610b9857506001600160e01b03198216635b5e139f60e01b145b806103db57506301ffc9a760e01b6001600160e01b03198316146103db565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610bec82610792565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316610c9e5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016104e8565b600061071f83610792565b826001600160a01b0316610cbc82610792565b6001600160a01b031614610d245760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016104e8565b6001600160a01b038216610d865760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016104e8565b610d91600082610bb7565b6001600160a01b0383166000908152600360205260408120805460019290610dba90849061196f565b90915550506001600160a01b0382166000908152600360205260408120805460019290610de8908490611924565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b610e538282610890565b6106f457610e6b816001600160a01b031660146110e5565b610e768360206110e5565b604051602001610e879291906117bc565b60408051601f198184030181529082905262461bcd60e51b82526104e89160040161186e565b610eb78282610890565b6106f45760008281526006602090815260408083206001600160a01b03851684529091529020805460ff19166001179055610eef3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610f3d8282610890565b156106f45760008281526006602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6106f4828260405180602001604052806000815250611281565b610fbf848484610ca9565b610fcb848484846112b4565b610a325760405162461bcd60e51b81526004016104e890611881565b60608161100b5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611035578061101f816119fe565b915061102e9050600a8361193c565b915061100f565b60008167ffffffffffffffff81111561105057611050611a6f565b6040519080825280601f01601f19166020018201604052801561107a576020820181803683370190505b5090505b841561078a5761108f60018361196f565b915061109c600a86611a19565b6110a7906030611924565b60f81b8183815181106110bc576110bc611a59565b60200101906001600160f81b031916908160001a9053506110de600a8661193c565b945061107e565b606060006110f4836002611950565b6110ff906002611924565b67ffffffffffffffff81111561111757611117611a6f565b6040519080825280601f01601f191660200182016040528015611141576020820181803683370190505b509050600360fc1b8160008151811061115c5761115c611a59565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061118b5761118b611a59565b60200101906001600160f81b031916908160001a90535060006111af846002611950565b6111ba906001611924565b90505b6001811115611232576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106111ee576111ee611a59565b1a60f81b82828151811061120457611204611a59565b60200101906001600160f81b031916908160001a90535060049490941c9361122b816119b2565b90506111bd565b508315610b195760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016104e8565b61128b83836113c1565b61129860008484846112b4565b61061e5760405162461bcd60e51b81526004016104e890611881565b60006001600160a01b0384163b156113b657604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906112f8903390899088908890600401611831565b602060405180830381600087803b15801561131257600080fd5b505af1925050508015611342575060408051601f3d908101601f1916820190925261133f91810190611744565b60015b61139c573d808015611370576040519150601f19603f3d011682016040523d82523d6000602084013e611375565b606091505b5080516113945760405162461bcd60e51b81526004016104e890611881565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061078a565b506001949350505050565b6001600160a01b0382166114175760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016104e8565b6000818152600260205260409020546001600160a01b03161561147c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016104e8565b6001600160a01b03821660009081526003602052604081208054600192906114a5908490611924565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b80356001600160a01b038116811461151a57600080fd5b919050565b60006020828403121561153157600080fd5b610b1982611503565b6000806040838503121561154d57600080fd5b61155683611503565b915061156460208401611503565b90509250929050565b60008060006060848603121561158257600080fd5b61158b84611503565b925061159960208501611503565b9150604084013590509250925092565b600080600080608085870312156115bf57600080fd5b6115c885611503565b93506115d660208601611503565b925060408501359150606085013567ffffffffffffffff808211156115fa57600080fd5b818701915087601f83011261160e57600080fd5b81358181111561162057611620611a6f565b604051601f8201601f19908116603f0116810190838211818310171561164857611648611a6f565b816040528281528a602084870101111561166157600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806040838503121561169857600080fd5b6116a183611503565b9150602083013580151581146116b657600080fd5b809150509250929050565b600080604083850312156116d457600080fd5b6116dd83611503565b946020939093013593505050565b6000602082840312156116fd57600080fd5b5035919050565b6000806040838503121561171757600080fd5b8235915061156460208401611503565b60006020828403121561173957600080fd5b8135610b1981611a85565b60006020828403121561175657600080fd5b8151610b1981611a85565b60008151808452611779816020860160208601611986565b601f01601f19169290920160200192915050565b6000835161179f818460208801611986565b8351908301906117b3818360208801611986565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516117f4816017850160208801611986565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611825816028840160208801611986565b01602801949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061186490830184611761565b9695505050505050565b602081526000610b196020830184611761565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561193757611937611a2d565b500190565b60008261194b5761194b611a43565b500490565b600081600019048311821515161561196a5761196a611a2d565b500290565b60008282101561198157611981611a2d565b500390565b60005b838110156119a1578181015183820152602001611989565b83811115610a325750506000910152565b6000816119c1576119c1611a2d565b506000190190565b600181811c908216806119dd57607f821691505b6020821081141561093557634e487b7160e01b600052602260045260246000fd5b6000600019821415611a1257611a12611a2d565b5060010190565b600082611a2857611a28611a43565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114611a9b57600080fd5b5056fea26469706673582212205b7e2193a0ab05c385f234572d7ef1e1e4fbd7eb1ac58c468d12952ea214932e64736f6c63430008060033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101585760003560e01c806375794a3c116100c3578063a22cb4651161007c578063a22cb465146102f6578063b88d4fde14610309578063c40c11bb1461031c578063c87b56dd14610345578063d547741f14610358578063e985e9c51461036b57600080fd5b806375794a3c1461029057806391d148541461029957806395d89b41146102ac5780639606c080146102b457806397eef5b7146102c7578063a217fddf146102ee57600080fd5b80632f2ff15d116101155780632f2ff15d1461021e57806336568abe1461023157806342842e0e14610244578063430c2081146102575780636352211e1461026a57806370a082311461027d57600080fd5b806301ffc9a71461015d57806306fdde0314610185578063081812fc1461019a578063095ea7b3146101c557806323b872dd146101da578063248a9ca3146101ed575b600080fd5b61017061016b366004611727565b6103a7565b60405190151581526020015b60405180910390f35b61018d6103e1565b60405161017c919061186e565b6101ad6101a83660046116eb565b610473565b6040516001600160a01b03909116815260200161017c565b6101d86101d33660046116c1565b61050d565b005b6101d86101e836600461156d565b610623565b6102106101fb3660046116eb565b60009081526006602052604090206001015490565b60405190815260200161017c565b6101d861022c366004611704565b610654565b6101d861023f366004611704565b61067a565b6101d861025236600461156d565b6106f8565b6101706102653660046116c1565b610713565b6101ad6102783660046116eb565b610792565b61021061028b36600461151f565b610809565b61021060075481565b6101706102a7366004611704565b610890565b61018d6108bb565b6102106102c236600461151f565b6108ca565b6102107f985cb37a5a8b8be3316b4239830f14f158762f12abaae14c979a055dd9bbee6f81565b610210600081565b6101d8610304366004611685565b61093b565b6101d86103173660046115a9565b610a00565b6101ad61032a3660046116eb565b6008602052600090815260409020546001600160a01b031681565b61018d6103533660046116eb565b610a38565b6101d8610366366004611704565b610b20565b61017061037936600461153a565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60006001600160e01b0319821663088378dd60e11b14806103cc57506103cc82610b46565b806103db57506103db82610b67565b92915050565b6060600080546103f0906119c9565b80601f016020809104026020016040519081016040528092919081815260200182805461041c906119c9565b80156104695780601f1061043e57610100808354040283529160200191610469565b820191906000526020600020905b81548152906001019060200180831161044c57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166104f15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061051882610792565b9050806001600160a01b0316836001600160a01b031614156105865760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016104e8565b336001600160a01b03821614806105a257506105a28133610379565b6106145760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016104e8565b61061e8383610bb7565b505050565b61062d3382610c25565b6106495760405162461bcd60e51b81526004016104e8906118d3565b61061e838383610ca9565b6000828152600660205260409020600101546106708133610e49565b61061e8383610ead565b6001600160a01b03811633146106ea5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016104e8565b6106f48282610f33565b5050565b61061e83838360405180602001604052806000815250610a00565b60008061071f83610792565b9050806001600160a01b0316846001600160a01b0316148061075a5750836001600160a01b031661074f84610473565b6001600160a01b0316145b8061078a57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b6000818152600260205260408120546001600160a01b0316806103db5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016104e8565b60006001600160a01b0382166108745760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016104e8565b506001600160a01b031660009081526003602052604090205490565b60009182526006602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600180546103f0906119c9565b60007f985cb37a5a8b8be3316b4239830f14f158762f12abaae14c979a055dd9bbee6f6108f78133610e49565b60078054906000610907836119fe565b90915550600081815260086020526040902080546001600160a01b0319163317905591506109358383610f9a565b50919050565b6001600160a01b0382163314156109945760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016104e8565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610a0a3383610c25565b610a265760405162461bcd60e51b81526004016104e8906118d3565b610a3284848484610fb4565b50505050565b6000818152600260205260409020546060906001600160a01b0316610ab75760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016104e8565b6000610ace60408051602081019091526000815290565b90506000815111610aee5760405180602001604052806000815250610b19565b80610af884610fe7565b604051602001610b0992919061178d565b6040516020818303038152906040525b9392505050565b600082815260066020526040902060010154610b3c8133610e49565b61061e8383610f33565b60006001600160e01b03198216637965db0b60e01b14806103db57506103db825b60006001600160e01b031982166380ac58cd60e01b1480610b9857506001600160e01b03198216635b5e139f60e01b145b806103db57506301ffc9a760e01b6001600160e01b03198316146103db565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610bec82610792565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316610c9e5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016104e8565b600061071f83610792565b826001600160a01b0316610cbc82610792565b6001600160a01b031614610d245760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016104e8565b6001600160a01b038216610d865760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016104e8565b610d91600082610bb7565b6001600160a01b0383166000908152600360205260408120805460019290610dba90849061196f565b90915550506001600160a01b0382166000908152600360205260408120805460019290610de8908490611924565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b610e538282610890565b6106f457610e6b816001600160a01b031660146110e5565b610e768360206110e5565b604051602001610e879291906117bc565b60408051601f198184030181529082905262461bcd60e51b82526104e89160040161186e565b610eb78282610890565b6106f45760008281526006602090815260408083206001600160a01b03851684529091529020805460ff19166001179055610eef3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610f3d8282610890565b156106f45760008281526006602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6106f4828260405180602001604052806000815250611281565b610fbf848484610ca9565b610fcb848484846112b4565b610a325760405162461bcd60e51b81526004016104e890611881565b60608161100b5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611035578061101f816119fe565b915061102e9050600a8361193c565b915061100f565b60008167ffffffffffffffff81111561105057611050611a6f565b6040519080825280601f01601f19166020018201604052801561107a576020820181803683370190505b5090505b841561078a5761108f60018361196f565b915061109c600a86611a19565b6110a7906030611924565b60f81b8183815181106110bc576110bc611a59565b60200101906001600160f81b031916908160001a9053506110de600a8661193c565b945061107e565b606060006110f4836002611950565b6110ff906002611924565b67ffffffffffffffff81111561111757611117611a6f565b6040519080825280601f01601f191660200182016040528015611141576020820181803683370190505b509050600360fc1b8160008151811061115c5761115c611a59565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061118b5761118b611a59565b60200101906001600160f81b031916908160001a90535060006111af846002611950565b6111ba906001611924565b90505b6001811115611232576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106111ee576111ee611a59565b1a60f81b82828151811061120457611204611a59565b60200101906001600160f81b031916908160001a90535060049490941c9361122b816119b2565b90506111bd565b508315610b195760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016104e8565b61128b83836113c1565b61129860008484846112b4565b61061e5760405162461bcd60e51b81526004016104e890611881565b60006001600160a01b0384163b156113b657604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906112f8903390899088908890600401611831565b602060405180830381600087803b15801561131257600080fd5b505af1925050508015611342575060408051601f3d908101601f1916820190925261133f91810190611744565b60015b61139c573d808015611370576040519150601f19603f3d011682016040523d82523d6000602084013e611375565b606091505b5080516113945760405162461bcd60e51b81526004016104e890611881565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061078a565b506001949350505050565b6001600160a01b0382166114175760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016104e8565b6000818152600260205260409020546001600160a01b03161561147c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016104e8565b6001600160a01b03821660009081526003602052604081208054600192906114a5908490611924565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b80356001600160a01b038116811461151a57600080fd5b919050565b60006020828403121561153157600080fd5b610b1982611503565b6000806040838503121561154d57600080fd5b61155683611503565b915061156460208401611503565b90509250929050565b60008060006060848603121561158257600080fd5b61158b84611503565b925061159960208501611503565b9150604084013590509250925092565b600080600080608085870312156115bf57600080fd5b6115c885611503565b93506115d660208601611503565b925060408501359150606085013567ffffffffffffffff808211156115fa57600080fd5b818701915087601f83011261160e57600080fd5b81358181111561162057611620611a6f565b604051601f8201601f19908116603f0116810190838211818310171561164857611648611a6f565b816040528281528a602084870101111561166157600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806040838503121561169857600080fd5b6116a183611503565b9150602083013580151581146116b657600080fd5b809150509250929050565b600080604083850312156116d457600080fd5b6116dd83611503565b946020939093013593505050565b6000602082840312156116fd57600080fd5b5035919050565b6000806040838503121561171757600080fd5b8235915061156460208401611503565b60006020828403121561173957600080fd5b8135610b1981611a85565b60006020828403121561175657600080fd5b8151610b1981611a85565b60008151808452611779816020860160208601611986565b601f01601f19169290920160200192915050565b6000835161179f818460208801611986565b8351908301906117b3818360208801611986565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516117f4816017850160208801611986565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611825816028840160208801611986565b01602801949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061186490830184611761565b9695505050505050565b602081526000610b196020830184611761565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561193757611937611a2d565b500190565b60008261194b5761194b611a43565b500490565b600081600019048311821515161561196a5761196a611a2d565b500290565b60008282101561198157611981611a2d565b500390565b60005b838110156119a1578181015183820152602001611989565b83811115610a325750506000910152565b6000816119c1576119c1611a2d565b506000190190565b600181811c908216806119dd57607f821691505b6020821081141561093557634e487b7160e01b600052602260045260246000fd5b6000600019821415611a1257611a12611a2d565b5060010190565b600082611a2857611a28611a43565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114611a9b57600080fd5b5056fea26469706673582212205b7e2193a0ab05c385f234572d7ef1e1e4fbd7eb1ac58c468d12952ea214932e64736f6c63430008060033
Deployed Bytecode Sourcemap
1266:1899:33:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2145:364;;;;;;:::i;:::-;;:::i;:::-;;;6262:14:40;;6255:22;6237:41;;6225:2;6210:18;2145:364:33;;;;;;;;2414:98:8;;;:::i;:::-;;;;;;;:::i;3925:217::-;;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;5560:32:40;;;5542:51;;5530:2;5515:18;3925:217:8;5497:102:40;3463:401:8;;;;;;:::i;:::-;;:::i;:::-;;4789:330;;;;;;:::i;:::-;;:::i;5447:121:1:-;;;;;;:::i;:::-;5513:7;5539:12;;;:6;:12;;;;;:22;;;;5447:121;;;;6435:25:40;;;6423:2;6408:18;5447:121:1;6390:76:40;5818:145:1;;;;;;:::i;:::-;;:::i;6835:214::-;;;;;;:::i;:::-;;:::i;5185:179:8:-;;;;;;:::i;:::-;;:::i;2826:337:33:-;;;;;;:::i;:::-;;:::i;2117:235:8:-;;;;;;:::i;:::-;;:::i;1855:205::-;;;;;;:::i;:::-;;:::i;1472:30:33:-;;;;;;4364:137:1;;;;;;:::i;:::-;;:::i;2576:102:8:-;;;:::i;1772:242:33:-;;;;;;:::i;:::-;;:::i;1396:70::-;;1438:28;1396:70;;2396:49:1;;2441:4;2396:49;;4209:290:8;;;;;;:::i;:::-;;:::i;5430:320::-;;;;;;:::i;:::-;;:::i;1508:53:33:-;;;;;;:::i;:::-;;;;;;;;;;;;-1:-1:-1;;;;;1508:53:33;;;2744:329:8;;;;;;:::i;:::-;;:::i;6197:147:1:-;;;;;;:::i;:::-;;:::i;4565:162:8:-;;;;;;:::i;:::-;-1:-1:-1;;;;;4685:25:8;;;4662:4;4685:25;;;:18;:25;;;;;;;;:35;;;;;;;;;;;;;;;4565:162;2145:364:33;2302:4;-1:-1:-1;;;;;;2341:48:33;;-1:-1:-1;;;2341:48:33;;:108;;;2405:44;2437:11;2405:31;:44::i;:::-;2341:161;;;;2465:37;2490:11;2465:24;:37::i;:::-;2322:180;2145:364;-1:-1:-1;;2145:364:33:o;2414:98:8:-;2468:13;2500:5;2493:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2414:98;:::o;3925:217::-;4001:7;7310:16;;;:7;:16;;;;;;-1:-1:-1;;;;;7310:16:8;4020:73;;;;-1:-1:-1;;;4020:73:8;;10813:2:40;4020:73:8;;;10795:21:40;10852:2;10832:18;;;10825:30;10891:34;10871:18;;;10864:62;-1:-1:-1;;;10942:18:40;;;10935:42;10994:19;;4020:73:8;;;;;;;;;-1:-1:-1;4111:24:8;;;;:15;:24;;;;;;-1:-1:-1;;;;;4111:24:8;;3925:217::o;3463:401::-;3543:13;3559:23;3574:7;3559:14;:23::i;:::-;3543:39;;3606:5;-1:-1:-1;;;;;3600:11:8;:2;-1:-1:-1;;;;;3600:11:8;;;3592:57;;;;-1:-1:-1;;;3592:57:8;;12052:2:40;3592:57:8;;;12034:21:40;12091:2;12071:18;;;12064:30;12130:34;12110:18;;;12103:62;-1:-1:-1;;;12181:18:40;;;12174:31;12222:19;;3592:57:8;12024:223:40;3592:57:8;665:10:13;-1:-1:-1;;;;;3681:21:8;;;;:62;;-1:-1:-1;3706:37:8;3723:5;665:10:13;4565:162:8;:::i;3706:37::-;3660:165;;;;-1:-1:-1;;;3660:165:8;;9206:2:40;3660:165:8;;;9188:21:40;9245:2;9225:18;;;9218:30;9284:34;9264:18;;;9257:62;9355:26;9335:18;;;9328:54;9399:19;;3660:165:8;9178:246:40;3660:165:8;3836:21;3845:2;3849:7;3836:8;:21::i;:::-;3533:331;3463:401;;:::o;4789:330::-;4978:41;665:10:13;5011:7:8;4978:18;:41::i;:::-;4970:103;;;;-1:-1:-1;;;4970:103:8;;;;;;;:::i;:::-;5084:28;5094:4;5100:2;5104:7;5084:9;:28::i;5818:145:1:-;5513:7;5539:12;;;:6;:12;;;;;:22;;;3960:30;3971:4;665:10:13;3960::1;:30::i;:::-;5931:25:::1;5942:4;5948:7;5931:10;:25::i;6835:214::-:0;-1:-1:-1;;;;;6930:23:1;;665:10:13;6930:23:1;6922:83;;;;-1:-1:-1;;;6922:83:1;;12872:2:40;6922:83:1;;;12854:21:40;12911:2;12891:18;;;12884:30;12950:34;12930:18;;;12923:62;-1:-1:-1;;;13001:18:40;;;12994:45;13056:19;;6922:83:1;12844:237:40;6922:83:1;7016:26;7028:4;7034:7;7016:11;:26::i;:::-;6835:214;;:::o;5185:179:8:-;5318:39;5335:4;5341:2;5345:7;5318:39;;;;;;;;;;;;:16;:39::i;2826:337:33:-;2967:4;2987:13;3003:23;3018:7;3003:14;:23::i;:::-;2987:39;;3055:5;-1:-1:-1;;;;;3044:16:33;:7;-1:-1:-1;;;;;3044:16:33;;:63;;;;3100:7;-1:-1:-1;;;;;3076:31:33;:20;3088:7;3076:11;:20::i;:::-;-1:-1:-1;;;;;3076:31:33;;3044:63;:111;;;-1:-1:-1;;;;;;4685:25:8;;;4662:4;4685:25;;;:18;:25;;;;;;;;:35;;;;;;;;;;;;3123:32:33;3036:120;2826:337;-1:-1:-1;;;;2826:337:33:o;2117:235:8:-;2189:7;2224:16;;;:7;:16;;;;;;-1:-1:-1;;;;;2224:16:8;2258:19;2250:73;;;;-1:-1:-1;;;2250:73:8;;10042:2:40;2250:73:8;;;10024:21:40;10081:2;10061:18;;;10054:30;10120:34;10100:18;;;10093:62;-1:-1:-1;;;10171:18:40;;;10164:39;10220:19;;2250:73:8;10014:231:40;1855:205:8;1927:7;-1:-1:-1;;;;;1954:19:8;;1946:74;;;;-1:-1:-1;;;1946:74:8;;9631:2:40;1946:74:8;;;9613:21:40;9670:2;9650:18;;;9643:30;9709:34;9689:18;;;9682:62;-1:-1:-1;;;9760:18:40;;;9753:40;9810:19;;1946:74:8;9603:232:40;1946:74:8;-1:-1:-1;;;;;;2037:16:8;;;;;:9;:16;;;;;;;1855:205::o;4364:137:1:-;4442:4;4465:12;;;:6;:12;;;;;;;;-1:-1:-1;;;;;4465:29:1;;;;;;;;;;;;;;;4364:137::o;2576:102:8:-;2632:13;2664:7;2657:14;;;;;:::i;1772:242:33:-;1896:10;1438:28;3960:30:1;1438:28:33;665:10:13;3960::1;:30::i;:::-;1927:11:33::1;:13:::0;;;:11:::1;:13;::::0;::::1;:::i;:::-;::::0;;;-1:-1:-1;1950:13:33::1;::::0;;;:9:::1;:13;::::0;;;;:26;;-1:-1:-1;;;;;;1950:26:33::1;1966:10;1950:26;::::0;;1922:18;-1:-1:-1;1986:21:33::1;1996:6:::0;1922:18;1986:9:::1;:21::i;:::-;1772:242:::0;;;;:::o;4209:290:8:-;-1:-1:-1;;;;;4311:24:8;;665:10:13;4311:24:8;;4303:62;;;;-1:-1:-1;;;4303:62:8;;8439:2:40;4303:62:8;;;8421:21:40;8478:2;8458:18;;;8451:30;8517:27;8497:18;;;8490:55;8562:18;;4303:62:8;8411:175:40;4303:62:8;665:10:13;4376:32:8;;;;:18;:32;;;;;;;;-1:-1:-1;;;;;4376:42:8;;;;;;;;;;;;:53;;-1:-1:-1;;4376:53:8;;;;;;;;;;4444:48;;6237:41:40;;;4376:42:8;;665:10:13;4444:48:8;;6210:18:40;4444:48:8;;;;;;;4209:290;;:::o;5430:320::-;5599:41;665:10:13;5632:7:8;5599:18;:41::i;:::-;5591:103;;;;-1:-1:-1;;;5591:103:8;;;;;;;:::i;:::-;5704:39;5718:4;5724:2;5728:7;5737:5;5704:13;:39::i;:::-;5430:320;;;;:::o;2744:329::-;7287:4;7310:16;;;:7;:16;;;;;;2817:13;;-1:-1:-1;;;;;7310:16:8;2842:76;;;;-1:-1:-1;;;2842:76:8;;11636:2:40;2842:76:8;;;11618:21:40;11675:2;11655:18;;;11648:30;11714:34;11694:18;;;11687:62;-1:-1:-1;;;11765:18:40;;;11758:45;11820:19;;2842:76:8;11608:237:40;2842:76:8;2929:21;2953:10;3390:9;;;;;;;;;-1:-1:-1;3390:9:8;;;3314:92;2953:10;2929:34;;3004:1;2986:7;2980:21;:25;:86;;;;;;;;;;;;;;;;;3032:7;3041:18;:7;:16;:18::i;:::-;3015:45;;;;;;;;;:::i;:::-;;;;;;;;;;;;;2980:86;2973:93;2744:329;-1:-1:-1;;;2744:329:8:o;6197:147:1:-;5513:7;5539:12;;;:6;:12;;;;;:22;;;3960:30;3971:4;665:10:13;3960::1;:30::i;:::-;6311:26:::1;6323:4;6329:7;6311:11;:26::i;4075:202::-:0;4160:4;-1:-1:-1;;;;;;4183:47:1;;-1:-1:-1;;;4183:47:1;;:87;;;4234:36;4258:11;1496:300:8;1598:4;-1:-1:-1;;;;;;1633:40:8;;-1:-1:-1;;;1633:40:8;;:104;;-1:-1:-1;;;;;;;1689:48:8;;-1:-1:-1;;;1689:48:8;1633:104;:156;;;-1:-1:-1;;;;;;;;;;871:40:15;;;1753:36:8;763:155:15;11073:171:8;11147:24;;;;:15;:24;;;;;:29;;-1:-1:-1;;;;;;11147:29:8;-1:-1:-1;;;;;11147:29:8;;;;;;;;:24;;11200:23;11147:24;11200:14;:23::i;:::-;-1:-1:-1;;;;;11191:46:8;;;;;;;;;;;11073:171;;:::o;7505:344::-;7598:4;7310:16;;;:7;:16;;;;;;-1:-1:-1;;;;;7310:16:8;7614:73;;;;-1:-1:-1;;;7614:73:8;;8793:2:40;7614:73:8;;;8775:21:40;8832:2;8812:18;;;8805:30;8871:34;8851:18;;;8844:62;-1:-1:-1;;;8922:18:40;;;8915:42;8974:19;;7614:73:8;8765:234:40;7614:73:8;7697:13;7713:23;7728:7;7713:14;:23::i;10402:560::-;10556:4;-1:-1:-1;;;;;10529:31:8;:23;10544:7;10529:14;:23::i;:::-;-1:-1:-1;;;;;10529:31:8;;10521:85;;;;-1:-1:-1;;;10521:85:8;;11226:2:40;10521:85:8;;;11208:21:40;11265:2;11245:18;;;11238:30;11304:34;11284:18;;;11277:62;-1:-1:-1;;;11355:18:40;;;11348:39;11404:19;;10521:85:8;11198:231:40;10521:85:8;-1:-1:-1;;;;;10624:16:8;;10616:65;;;;-1:-1:-1;;;10616:65:8;;8034:2:40;10616:65:8;;;8016:21:40;8073:2;8053:18;;;8046:30;8112:34;8092:18;;;8085:62;-1:-1:-1;;;8163:18:40;;;8156:34;8207:19;;10616:65:8;8006:226:40;10616:65:8;10793:29;10810:1;10814:7;10793:8;:29::i;:::-;-1:-1:-1;;;;;10833:15:8;;;;;;:9;:15;;;;;:20;;10852:1;;10833:15;:20;;10852:1;;10833:20;:::i;:::-;;;;-1:-1:-1;;;;;;;10863:13:8;;;;;;:9;:13;;;;;:18;;10880:1;;10863:13;:18;;10880:1;;10863:18;:::i;:::-;;;;-1:-1:-1;;10891:16:8;;;;:7;:16;;;;;;:21;;-1:-1:-1;;;;;;10891:21:8;-1:-1:-1;;;;;10891:21:8;;;;;;;;;10928:27;;10891:16;;10928:27;;;;;;;10402:560;;;:::o;4782:484:1:-;4862:22;4870:4;4876:7;4862;:22::i;:::-;4857:403;;5045:41;5073:7;-1:-1:-1;;;;;5045:41:1;5083:2;5045:19;:41::i;:::-;5157:38;5185:4;5192:2;5157:19;:38::i;:::-;4952:265;;;;;;;;;:::i;:::-;;;;-1:-1:-1;;4952:265:1;;;;;;;;;;-1:-1:-1;;;4900:349:1;;;;;;;:::i;8047:224::-;8121:22;8129:4;8135:7;8121;:22::i;:::-;8116:149;;8159:12;;;;:6;:12;;;;;;;;-1:-1:-1;;;;;8159:29:1;;;;;;;;;:36;;-1:-1:-1;;8159:36:1;8191:4;8159:36;;;8241:12;665:10:13;;586:96;8241:12:1;-1:-1:-1;;;;;8214:40:1;8232:7;-1:-1:-1;;;;;8214:40:1;8226:4;8214:40;;;;;;;;;;8047:224;;:::o;8277:225::-;8351:22;8359:4;8365:7;8351;:22::i;:::-;8347:149;;;8421:5;8389:12;;;:6;:12;;;;;;;;-1:-1:-1;;;;;8389:29:1;;;;;;;;;;:37;;-1:-1:-1;;8389:37:1;;;8445:40;665:10:13;;8389:12:1;;8445:40;;8421:5;8445:40;8277:225;;:::o;8179:108:8:-;8254:26;8264:2;8268:7;8254:26;;;;;;;;;;;;:9;:26::i;6612:307::-;6763:28;6773:4;6779:2;6783:7;6763:9;:28::i;:::-;6809:48;6832:4;6838:2;6842:7;6851:5;6809:22;:48::i;:::-;6801:111;;;;-1:-1:-1;;;6801:111:8;;;;;;;:::i;275:703:14:-;331:13;548:10;544:51;;-1:-1:-1;;574:10:14;;;;;;;;;;;;-1:-1:-1;;;574:10:14;;;;;275:703::o;544:51::-;619:5;604:12;658:75;665:9;;658:75;;690:8;;;;:::i;:::-;;-1:-1:-1;712:10:14;;-1:-1:-1;720:2:14;712:10;;:::i;:::-;;;658:75;;;742:19;774:6;764:17;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;764:17:14;;742:39;;791:150;798:10;;791:150;;824:11;834:1;824:11;;:::i;:::-;;-1:-1:-1;892:10:14;900:2;892:5;:10;:::i;:::-;879:24;;:2;:24;:::i;:::-;866:39;;849:6;856;849:14;;;;;;;;:::i;:::-;;;;:56;-1:-1:-1;;;;;849:56:14;;;;;;;;-1:-1:-1;919:11:14;928:2;919:11;;:::i;:::-;;;791:150;;1535:441;1610:13;1635:19;1667:10;1671:6;1667:1;:10;:::i;:::-;:14;;1680:1;1667:14;:::i;:::-;1657:25;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1657:25:14;;1635:47;;-1:-1:-1;;;1692:6:14;1699:1;1692:9;;;;;;;;:::i;:::-;;;;:15;-1:-1:-1;;;;;1692:15:14;;;;;;;;;-1:-1:-1;;;1717:6:14;1724:1;1717:9;;;;;;;;:::i;:::-;;;;:15;-1:-1:-1;;;;;1717:15:14;;;;;;;;-1:-1:-1;1747:9:14;1759:10;1763:6;1759:1;:10;:::i;:::-;:14;;1772:1;1759:14;:::i;:::-;1747:26;;1742:132;1779:1;1775;:5;1742:132;;;-1:-1:-1;;;1826:5:14;1834:3;1826:11;1813:25;;;;;;;:::i;:::-;;;;1801:6;1808:1;1801:9;;;;;;;;:::i;:::-;;;;:37;-1:-1:-1;;;;;1801:37:14;;;;;;;;-1:-1:-1;1862:1:14;1852:11;;;;;1782:3;;;:::i;:::-;;;1742:132;;;-1:-1:-1;1891:10:14;;1883:55;;;;-1:-1:-1;;;1883:55:14;;6897:2:40;1883:55:14;;;6879:21:40;;;6916:18;;;6909:30;6975:34;6955:18;;;6948:62;7027:18;;1883:55:14;6869:182:40;8508:311:8;8633:18;8639:2;8643:7;8633:5;:18::i;:::-;8682:54;8713:1;8717:2;8721:7;8730:5;8682:22;:54::i;:::-;8661:151;;;;-1:-1:-1;;;8661:151:8;;;;;;;:::i;11797:782::-;11947:4;-1:-1:-1;;;;;11967:13:8;;1034:20:12;1080:8;11963:610:8;;12002:72;;-1:-1:-1;;;12002:72:8;;-1:-1:-1;;;;;12002:36:8;;;;;:72;;665:10:13;;12053:4:8;;12059:7;;12068:5;;12002:72;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;12002:72:8;;;;;;;;-1:-1:-1;;12002:72:8;;;;;;;;;;;;:::i;:::-;;;11998:523;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;12245:13:8;;12241:266;;12287:60;;-1:-1:-1;;;12287:60:8;;;;;;;:::i;12241:266::-;12459:6;12453:13;12444:6;12440:2;12436:15;12429:38;11998:523;-1:-1:-1;;;;;;12124:55:8;-1:-1:-1;;;12124:55:8;;-1:-1:-1;12117:62:8;;11963:610;-1:-1:-1;12558:4:8;11797:782;;;;;;:::o;9141:372::-;-1:-1:-1;;;;;9220:16:8;;9212:61;;;;-1:-1:-1;;;9212:61:8;;10452:2:40;9212:61:8;;;10434:21:40;;;10471:18;;;10464:30;10530:34;10510:18;;;10503:62;10582:18;;9212:61:8;10424:182:40;9212:61:8;7287:4;7310:16;;;:7;:16;;;;;;-1:-1:-1;;;;;7310:16:8;:30;9283:58;;;;-1:-1:-1;;;9283:58:8;;7677:2:40;9283:58:8;;;7659:21:40;7716:2;7696:18;;;7689:30;7755;7735:18;;;7728:58;7803:18;;9283:58:8;7649:178:40;9283:58:8;-1:-1:-1;;;;;9408:13:8;;;;;;:9;:13;;;;;:18;;9425:1;;9408:13;:18;;9425:1;;9408:18;:::i;:::-;;;;-1:-1:-1;;9436:16:8;;;;:7;:16;;;;;;:21;;-1:-1:-1;;;;;;9436:21:8;-1:-1:-1;;;;;9436:21:8;;;;;;;;9473:33;;9436:16;;;9473:33;;9436:16;;9473:33;9141:372;;:::o;14:173:40:-;82:20;;-1:-1:-1;;;;;131:31:40;;121:42;;111:2;;177:1;174;167:12;111:2;63:124;;;:::o;192:186::-;251:6;304:2;292:9;283:7;279:23;275:32;272:2;;;320:1;317;310:12;272:2;343:29;362:9;343:29;:::i;383:260::-;451:6;459;512:2;500:9;491:7;487:23;483:32;480:2;;;528:1;525;518:12;480:2;551:29;570:9;551:29;:::i;:::-;541:39;;599:38;633:2;622:9;618:18;599:38;:::i;:::-;589:48;;470:173;;;;;:::o;648:328::-;725:6;733;741;794:2;782:9;773:7;769:23;765:32;762:2;;;810:1;807;800:12;762:2;833:29;852:9;833:29;:::i;:::-;823:39;;881:38;915:2;904:9;900:18;881:38;:::i;:::-;871:48;;966:2;955:9;951:18;938:32;928:42;;752:224;;;;;:::o;981:1138::-;1076:6;1084;1092;1100;1153:3;1141:9;1132:7;1128:23;1124:33;1121:2;;;1170:1;1167;1160:12;1121:2;1193:29;1212:9;1193:29;:::i;:::-;1183:39;;1241:38;1275:2;1264:9;1260:18;1241:38;:::i;:::-;1231:48;;1326:2;1315:9;1311:18;1298:32;1288:42;;1381:2;1370:9;1366:18;1353:32;1404:18;1445:2;1437:6;1434:14;1431:2;;;1461:1;1458;1451:12;1431:2;1499:6;1488:9;1484:22;1474:32;;1544:7;1537:4;1533:2;1529:13;1525:27;1515:2;;1566:1;1563;1556:12;1515:2;1602;1589:16;1624:2;1620;1617:10;1614:2;;;1630:18;;:::i;:::-;1705:2;1699:9;1673:2;1759:13;;-1:-1:-1;;1755:22:40;;;1779:2;1751:31;1747:40;1735:53;;;1803:18;;;1823:22;;;1800:46;1797:2;;;1849:18;;:::i;:::-;1889:10;1885:2;1878:22;1924:2;1916:6;1909:18;1964:7;1959:2;1954;1950;1946:11;1942:20;1939:33;1936:2;;;1985:1;1982;1975:12;1936:2;2041;2036;2032;2028:11;2023:2;2015:6;2011:15;1998:46;2086:1;2081:2;2076;2068:6;2064:15;2060:24;2053:35;2107:6;2097:16;;;;;;;1111:1008;;;;;;;:::o;2124:347::-;2189:6;2197;2250:2;2238:9;2229:7;2225:23;2221:32;2218:2;;;2266:1;2263;2256:12;2218:2;2289:29;2308:9;2289:29;:::i;:::-;2279:39;;2368:2;2357:9;2353:18;2340:32;2415:5;2408:13;2401:21;2394:5;2391:32;2381:2;;2437:1;2434;2427:12;2381:2;2460:5;2450:15;;;2208:263;;;;;:::o;2476:254::-;2544:6;2552;2605:2;2593:9;2584:7;2580:23;2576:32;2573:2;;;2621:1;2618;2611:12;2573:2;2644:29;2663:9;2644:29;:::i;:::-;2634:39;2720:2;2705:18;;;;2692:32;;-1:-1:-1;;;2563:167:40:o;2735:180::-;2794:6;2847:2;2835:9;2826:7;2822:23;2818:32;2815:2;;;2863:1;2860;2853:12;2815:2;-1:-1:-1;2886:23:40;;2805:110;-1:-1:-1;2805:110:40:o;2920:254::-;2988:6;2996;3049:2;3037:9;3028:7;3024:23;3020:32;3017:2;;;3065:1;3062;3055:12;3017:2;3101:9;3088:23;3078:33;;3130:38;3164:2;3153:9;3149:18;3130:38;:::i;3179:245::-;3237:6;3290:2;3278:9;3269:7;3265:23;3261:32;3258:2;;;3306:1;3303;3296:12;3258:2;3345:9;3332:23;3364:30;3388:5;3364:30;:::i;3429:249::-;3498:6;3551:2;3539:9;3530:7;3526:23;3522:32;3519:2;;;3567:1;3564;3557:12;3519:2;3599:9;3593:16;3618:30;3642:5;3618:30;:::i;3868:257::-;3909:3;3947:5;3941:12;3974:6;3969:3;3962:19;3990:63;4046:6;4039:4;4034:3;4030:14;4023:4;4016:5;4012:16;3990:63;:::i;:::-;4107:2;4086:15;-1:-1:-1;;4082:29:40;4073:39;;;;4114:4;4069:50;;3917:208;-1:-1:-1;;3917:208:40:o;4130:470::-;4309:3;4347:6;4341:13;4363:53;4409:6;4404:3;4397:4;4389:6;4385:17;4363:53;:::i;:::-;4479:13;;4438:16;;;;4501:57;4479:13;4438:16;4535:4;4523:17;;4501:57;:::i;:::-;4574:20;;4317:283;-1:-1:-1;;;;4317:283:40:o;4605:786::-;5016:25;5011:3;5004:38;4986:3;5071:6;5065:13;5087:62;5142:6;5137:2;5132:3;5128:12;5121:4;5113:6;5109:17;5087:62;:::i;:::-;-1:-1:-1;;;5208:2:40;5168:16;;;5200:11;;;5193:40;5258:13;;5280:63;5258:13;5329:2;5321:11;;5314:4;5302:17;;5280:63;:::i;:::-;5363:17;5382:2;5359:26;;4994:397;-1:-1:-1;;;;4994:397:40:o;5604:488::-;-1:-1:-1;;;;;5873:15:40;;;5855:34;;5925:15;;5920:2;5905:18;;5898:43;5972:2;5957:18;;5950:34;;;6020:3;6015:2;6000:18;;5993:31;;;5798:4;;6041:45;;6066:19;;6058:6;6041:45;:::i;:::-;6033:53;5807:285;-1:-1:-1;;;;;;5807:285:40:o;6471:219::-;6620:2;6609:9;6602:21;6583:4;6640:44;6680:2;6669:9;6665:18;6657:6;6640:44;:::i;7056:414::-;7258:2;7240:21;;;7297:2;7277:18;;;7270:30;7336:34;7331:2;7316:18;;7309:62;-1:-1:-1;;;7402:2:40;7387:18;;7380:48;7460:3;7445:19;;7230:240::o;12252:413::-;12454:2;12436:21;;;12493:2;12473:18;;;12466:30;12532:34;12527:2;12512:18;;12505:62;-1:-1:-1;;;12598:2:40;12583:18;;12576:47;12655:3;12640:19;;12426:239::o;13268:128::-;13308:3;13339:1;13335:6;13332:1;13329:13;13326:2;;;13345:18;;:::i;:::-;-1:-1:-1;13381:9:40;;13316:80::o;13401:120::-;13441:1;13467;13457:2;;13472:18;;:::i;:::-;-1:-1:-1;13506:9:40;;13447:74::o;13526:168::-;13566:7;13632:1;13628;13624:6;13620:14;13617:1;13614:21;13609:1;13602:9;13595:17;13591:45;13588:2;;;13639:18;;:::i;:::-;-1:-1:-1;13679:9:40;;13578:116::o;13699:125::-;13739:4;13767:1;13764;13761:8;13758:2;;;13772:18;;:::i;:::-;-1:-1:-1;13809:9:40;;13748:76::o;13829:258::-;13901:1;13911:113;13925:6;13922:1;13919:13;13911:113;;;14001:11;;;13995:18;13982:11;;;13975:39;13947:2;13940:10;13911:113;;;14042:6;14039:1;14036:13;14033:2;;;-1:-1:-1;;14077:1:40;14059:16;;14052:27;13882:205::o;14092:136::-;14131:3;14159:5;14149:2;;14168:18;;:::i;:::-;-1:-1:-1;;;14204:18:40;;14139:89::o;14233:380::-;14312:1;14308:12;;;;14355;;;14376:2;;14430:4;14422:6;14418:17;14408:27;;14376:2;14483;14475:6;14472:14;14452:18;14449:38;14446:2;;;14529:10;14524:3;14520:20;14517:1;14510:31;14564:4;14561:1;14554:15;14592:4;14589:1;14582:15;14618:135;14657:3;-1:-1:-1;;14678:17:40;;14675:2;;;14698:18;;:::i;:::-;-1:-1:-1;14745:1:40;14734:13;;14665:88::o;14758:112::-;14790:1;14816;14806:2;;14821:18;;:::i;:::-;-1:-1:-1;14855:9:40;;14796:74::o;14875:127::-;14936:10;14931:3;14927:20;14924:1;14917:31;14967:4;14964:1;14957:15;14991:4;14988:1;14981:15;15007:127;15068:10;15063:3;15059:20;15056:1;15049:31;15099:4;15096:1;15089:15;15123:4;15120:1;15113:15;15139:127;15200:10;15195:3;15191:20;15188:1;15181:31;15231:4;15228:1;15221:15;15255:4;15252:1;15245:15;15271:127;15332:10;15327:3;15323:20;15320:1;15313:31;15363:4;15360:1;15353:15;15387:4;15384:1;15377:15;15403:131;-1:-1:-1;;;;;;15477:32:40;;15467:43;;15457:2;;15524:1;15521;15514:12;15457:2;15447:87;:::o
Swarm Source
ipfs://5b7e2193a0ab05c385f234572d7ef1e1e4fbd7eb1ac58c468d12952ea214932e
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.