Feature Tip: Add private address tag to any address under My Name Tag !
ERC-20
Overview
Max Total Supply
45,746,167.316787354436686588 PARTY
Holders
1,141
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Balance
18,417.198962738806652928 PARTYValue
$0.00Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Source Code Verified (Exact Match)
Contract Name:
PoolParty
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.21; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "./PerpetualStakePool.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract PoolParty is ERC20, ERC20Snapshot, ReentrancyGuard { /// ACTIVATION using SafeERC20 for IERC20; uint256 ACTIVATION_TIMESTAMP; // Liquidity Fund // The liquidity fund address gets a copy of the initial supply. // The liquidity fund will start as a series of V3 Pools and then transition into V2 Pools. V2 pool tokens will be dripped out to users. address public LIQUIDITY_FUND_ADDRESS; address public LIFEGUARD_ADDRESS;// This is the user that can run specific functions on behalf of this and related contracts during the setup process. The Lifeguard can not mint coins or access any user's coin or stop anything. //Initial Supply Points bool public ITS_GO_TIME; mapping (address => bool) public HAS_REDEEMED_INITIAL_SUPPLY_POINTS; // Records if points have been converted to PARTY. bytes32 constant public INITIAL_SUPPLY_ROOT = 0xc080050f7fa523e1ca454092bd721ecccc0252c67082bdfd3b7d6ab539a78d20; //merkle root for initial supply points event Mint(address indexed minter, uint256 amount); // Name Tag NFT Minting Contract // Name Tag NFTs are simple erc721 NFTs connected on chain to a 9 character text string. Name Tags were created with the intent to use as a verified ecosystem asset name registrar, but can be used for anything. NameTag NameTagContract; address public NAME_TAG_NFT_CONTRACT_ADDRESS; address constant NAMECLAIM_ADDRESS = 0x8b39b9b6fEe1854a585321fBd3b2BAB49cFB2359; // contract address from pre-launch nametag claim contract. // Reward Distribution Contract // PARTY Holders can claim rewards twice a month. address public REWARD_DISTRIBUTION_CONTRACT_ADDRESS; // contract that HEX rewards go into and where PARTY holders claim rewards from. constructor( address liquidity_fund_address) ERC20("Maximus Pool Party", "PARTY") ReentrancyGuard() { LIFEGUARD_ADDRESS=msg.sender; LIQUIDITY_FUND_ADDRESS=liquidity_fund_address; _mint(liquidity_fund_address, 50000000*(10**18)); emit Mint(liquidity_fund_address,50000000*(10**18)); ACTIVATION_TIMESTAMP = block.timestamp; RewardDistribution rdc = new RewardDistribution(address(this), LIFEGUARD_ADDRESS); // deploy the reward distribution contract for PARTY holders REWARD_DISTRIBUTION_CONTRACT_ADDRESS = address(rdc); NameTagContract = new NameTag(address(this)); // Deploy Name Tag NFT contract NAME_TAG_NFT_CONTRACT_ADDRESS = address(NameTagContract); } /** * @notice Allows a user to mint PARTY tokens proportional to the amount of Initial Supply Points they accumulated through the Poly Water and Nameclaim experiences. * The function can only be called once per user. */ function redeemInitialSupplyPoints(bytes32[] memory proof, uint256 merkle_amount) external nonReentrant { require(ITS_GO_TIME, "Give time for liquidity fund to be setup"); require(verifyInitialSupplyPoints(proof, msg.sender, merkle_amount), "Must be eligible address and amount pair."); require(HAS_REDEEMED_INITIAL_SUPPLY_POINTS[msg.sender]==false, "Already claimed"); // Ensures they havent already minted their Name Claim Points. mint(merkle_amount); // Mints PARTY equal to the number of Name Claim Airdrop Points. HAS_REDEEMED_INITIAL_SUPPLY_POINTS[msg.sender]=true; // Records the user as having claimed Name Claim points. emit Mint(msg.sender, merkle_amount); } ///@notice returns True if Provided Merkle Proof is valid. ///@param proof Merkle Proof related to user address ///@param addr User address ///@param merkle_amount Number related to user address in the merkle tree. function verifyInitialSupplyPoints(bytes32[] memory proof,address addr,uint256 merkle_amount) public pure returns (bool isValid) { bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(addr, merkle_amount)))); return MerkleProof.verify(proof, INITIAL_SUPPLY_ROOT, leaf); } function itsGoTime() public nonReentrant { require(msg.sender==LIFEGUARD_ADDRESS, "Only lifeguard"); ITS_GO_TIME=true; } /// PARTY STAKING event StakeStart(address indexed staker, uint principal, uint end_day, uint yield, uint stake_id); event StakeEnd(address indexed staker, uint principal, uint end_day, uint yield, uint stake_id); uint256 public stakedSupply; // Total amount of PARTY staked. Increased when stakes start and decreased when stakes end. mapping (address=>uint256) public STAKER_NUMBER_STAKES; // Number of stakes for each user. mapping (address => mapping(uint256 => StakeRecord)) public STAKER_LOG; // A log of all stake records for a user. bytes32 constant public YIELD_MERKLE_ROOT = 0xfe1001d98a99b01293dcc713f45e6b3122511f8a6f8de820e04e660508d747b3; struct StakeRecord { address staker; uint256 principal; uint256 end_day; uint256 yield; bool started; bool ended; } ///@notice returns True if Provided Merkle Proof is valid. function verifyYield(bytes32[] memory proof,uint256 days_staked,uint256 merkle_amount) public pure returns (bool isValid) { bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(days_staked, merkle_amount)))); return MerkleProof.verify(proof, YIELD_MERKLE_ROOT, leaf); } //@notice Used to calculate the yield that a stake will earn. //@params amount Principal amount staked. //@params length number of weeks staked. function calculateYield(uint256 principal, uint256 length, bytes32[] memory proof,uint256 merkle_amount) public pure returns (uint256) { require(principal > 5224, "Must be larger than minimum stake amount."); require(verifyYield(proof, length, merkle_amount)); return principal * merkle_amount / (10**8); } //@notice startStake(amount, days_staked) is used to start a PARTY stake. Keep in mind: No early end-staking. PARTY Yield is minted when stake is ended. Staked PARTY does not earn HEX rewards. //@params amount the amount of PARTY to stake account for 18 decimal places. //@params weeks_staked the number of weeks to stake for. function startStake(uint256 amount, uint256 days_staked, bytes32[] memory proof,uint256 merkle_amount) external nonReentrant { uint256 i = STAKER_NUMBER_STAKES[msg.sender]; // Get Stake Record ID. uint256 end_day = days_staked + day() + 1; // Get day number of the day the stake ends. uint256 yield = calculateYield(amount, days_staked, proof, merkle_amount); // Calculate the amount of PARTY that may be minted when the stake is ended. STAKER_LOG[msg.sender][i] = StakeRecord(msg.sender, amount, end_day, yield, true, false); // Create the stake record. STAKER_NUMBER_STAKES[msg.sender] +=1; // Increment Stake Record ID for next stake. _burn(msg.sender, amount); // removes staked PARTY from supply stakedSupply += amount; // track the staked Supply emit StakeStart(msg.sender, amount, end_day, yield, i); } //@notice endStake(id) is used to end a PARTY stake. //@params id The ID of the staker's stake. function endStake(uint256 id) external nonReentrant { StakeRecord storage stake_record = STAKER_LOG[msg.sender][id]; // retrieve the stake require(stake_record.started == true, "This stake must exist."); // Ensure the stake exists. require(day()>stake_record.end_day, "This stake is not complete yet."); // Ensure the stake is complete. require(stake_record.ended ==false, "This stake was already ended."); // Ensure the stake has not already been ended. mint(stake_record.principal + stake_record.yield); // Mint the principal and the yield stakedSupply -=stake_record.principal; // Track the staked supply stake_record.ended = true; // Mark stake as ended. emit StakeEnd(msg.sender, stake_record.principal, stake_record.end_day, stake_record.yield, id); } /// PARTY Income Distribution uint256 public LATEST_SNAPSHOT_DAY; // The day that the latest snapshot was recorded. Used to schedule snapshots. mapping (address => mapping(uint256 =>uint256)) public TOKEN_PERIOD_EARNINGS; event AssetProcessed(address token_address, uint256 indexed period, uint256 amount, uint256 latest_balance); ///@notice Used to record the supply and balances snapshot. function recordSnapshot() public nonReentrant { uint256 current_day = day(); require(current_day>LATEST_SNAPSHOT_DAY + 14 , "Snapshot can only be taken once every 2 weeks."); _snapshot(); // Record snapshot. LATEST_SNAPSHOT_DAY = current_day; // Updates the latest snapshot day. } /** * @notice Processes an ERC20 token for reward distribution. * @dev Transfers all the available balance of a given token from this contract to the REWARD_DISTRIBUTION_CONTRACT_ADDRESS and schedules earnings for it. * @param tokenAddress The address of the ERC20 token to be processed. * Emits an {AssetProcessed} event indicating the processed token and the snapshot taken. */ function processAsset(address tokenAddress) external nonReentrant{ IERC20 token = IERC20(tokenAddress); uint256 balance = token.balanceOf(address(this)); require(balance>0, "no balance."); address RDCA = REWARD_DISTRIBUTION_CONTRACT_ADDRESS; uint256 RDCA_balance = token.balanceOf(RDCA); token.safeTransfer(REWARD_DISTRIBUTION_CONTRACT_ADDRESS, balance); uint256 snapshotId=getCurrentSnapshotId(); uint256 amount_received = token.balanceOf(RDCA) - RDCA_balance; // Schedule the earnings for the token. Claimable with token holders who appear in the balance snapshot of the target period. uint256 target_period = snapshotId+1; TOKEN_PERIOD_EARNINGS[tokenAddress][target_period] += amount_received; emit AssetProcessed(tokenAddress, snapshotId, amount_received, TOKEN_PERIOD_EARNINGS[tokenAddress][target_period]); } function getCurrentSnapshotId() public view returns (uint256) { return _getCurrentSnapshotId(); } //@notice Used to get the earnings of a PARTY holder from a given period. //@params holder Address of the holder. //@params period Snapshot period //@returns earnings Amount of HEX earned by the user in the given period. function getEarningsDetails(address holder, address token_address, uint256 period) public view returns (uint256 earnings) { require(period<=getCurrentSnapshotId(), "Period Has Not Happened Yet"); // Ensure period has not happened yet. return (10**18) * TOKEN_PERIOD_EARNINGS[token_address][period] *balanceOfAt(holder, period) /( (10**18)*(totalSupplyAt(period))); //Calculate earnings. } //@notice Used to get the earnings of a PARTY holder from a consecutive group of snapshot periods. //@params holder Address of the holder. //@params first_period first period to measure. //@params last_period last period to measure. //@returns earnings Amount of HEX earned by the user in the given period. function getBatchEarningsDetails(address holder,address token_address ,uint256 first_period, uint256 last_period) public view returns (uint256 earnings) { uint256 total_amount; for (uint256 i = first_period; i <=last_period; i++) { total_amount+=getEarningsDetails(holder,token_address, i); // increment total_amount by the earnings from each period. } return total_amount; } /// NAME AUCTIONS event MintNameNFT(address indexed owner, string ticker, uint nft_id); //@notice Used by NAMECLAIM Participants to mint the NFT associated with the ticker name they claimed. //@params ticker name of NFT. function mintFromNameclaim(string memory ticker) public nonReentrant{ iPoolPartyNameClaim nameclaim = iPoolPartyNameClaim(NAMECLAIM_ADDRESS); // Connect to NameClaim contract. require(nameclaim.NAME_OWNERS(ticker)==msg.sender, "Sender must be the owner of the ticker name in NameClaim."); // uint256 nft_id = mintTickerNameNft(msg.sender, ticker); // Mint the ticker Name emit MintNameNFT(msg.sender, ticker, nft_id); } //@notice Helper function for minting name NFTs from the Name NFT contract. //@params account address to mint the NFT to. //@params ticker name of NFT. function mintTickerNameNft(address account, string memory ticker) private returns(uint256 nft_id){ uint256 n_id = NameTagContract.mintName(account, ticker); // Call Name Contract and mint to designated account return n_id; } event AuctionStarted(string ticker,address indexed starter, uint starting_bid, uint timestamp); event Bid(string ticker, address indexed bidder, uint bid, uint timestamp); event AuctionEnded(string ticker, address indexed ender, address indexed winner, uint winning_bid); struct TickerAuctionData{ uint256 lastBidTimestamp; // updated with every bid uint256 firstBidTimestamp; // initialized when auction starts and doesnt change uint256 auctionEndTimestamp; // updated with bids made within 6 minutes of end. address controller; // updated with each bid, finalized after auctionEndTimestamp uint256 bidAmount; // updated with each bid, finalized after auctionEndTimestamp bool auctionStarted; // Set to true when auction starts bool auctionEnded; // set to true when auction ends } uint256 public MINIMUM_STARTING_BID=100000000*(10**18); mapping (string => TickerAuctionData) public TICKER_AUCTION_DATABASE; //@notice At the Lifeguard's discretion, the minimum bid amount can be decreased. This may be done in the event that PARTY price goes so high that it becomes unreasonably expensive to start nametag NFT auctions. function setMinimumBid(uint256 amount) public { require(msg.sender==LIFEGUARD_ADDRESS, "Only the lifeguard may run this."); require(amount<MINIMUM_STARTING_BID, "Minimum starting bid can only decrease."); MINIMUM_STARTING_BID=amount; } /** @notice Starts an auction for a given unclaimed ticker with an initial bid amount. @dev This function starts an auction if the ticker is not already claimed, and if it has not already started. It also checks that the initial bid is larger than or equal to the minimum starting bid. This function burns the initial bid amount from the message sender's balance. It initializes and updates the auction details in the TICKER_AUCTION_DATABASE mapping, and emits an AuctionStarted event. This function is nonReentrant to prevent re-entrancy attacks. @param ticker The name of the ticker for which the auction is to be started. @param initial_bid_amount The initial amount that the message sender is willing to bid for the ticker. */ function startAuction(string memory ticker, uint256 initial_bid_amount) external nonReentrant { require(iPoolPartyNameClaim(NAMECLAIM_ADDRESS).NAME_OWNERS(ticker)==address(0), "Name must not be reserved."); TickerAuctionData storage td = TICKER_AUCTION_DATABASE[ticker]; require(td.auctionStarted==false, "This auction has already started"); require(initial_bid_amount >= MINIMUM_STARTING_BID, "Must be larger than the minimum starting bid."); _burn(msg.sender, initial_bid_amount); td.auctionStarted=true; td.bidAmount = initial_bid_amount; td.controller = msg.sender; td.firstBidTimestamp=block.timestamp; td.lastBidTimestamp = block.timestamp; td.auctionEndTimestamp = block.timestamp + 86400; emit AuctionStarted(ticker, msg.sender, initial_bid_amount, block.timestamp); } /** @notice Places a bid on an ongoing auction for a given ticker with a specified bid amount. @dev This function allows a user to bid on an ongoing auction. It requires that the auction has already started, and has not already ended. The bid amount must be at least 5% larger than the previous bid. The function checks if the current time is within the auction duration and extends the duration if a bid is placed within the last 6 minutes. The current bid is burned, and the previous bid amount is reminted to the address that was out-bid. The function updates the auction details in the TICKER_AUCTION_DATABASE mapping and emits a Bid event. @param ticker The name of the ticker for which the bid is placed. @param bid_amount The amount that the message sender is willing to bid for the ticker. */ function bid(string memory ticker, uint256 bid_amount) external nonReentrant { TickerAuctionData storage td = TICKER_AUCTION_DATABASE[ticker]; // Get ticker auction data require(td.auctionStarted==true, "This auction must have been started already"); // Ensure that the auction has already started. require(td.auctionEnded==false, "This auction must not have been ended.."); // Ensure that the auction has not already ended. require(bid_amount>=td.bidAmount * 10500000/10000000, "Bid must be 5% larger than prior bid."); // Ensure that the bid meets the size requirement. require(block.timestamp <= td.auctionEndTimestamp, "Auction is over"); // Ensure that the auction has not exceeded its deadline. if (td.auctionEndTimestamp-block.timestamp <360) { // If a bid is placed in the last 6 minutes of an auction... td.auctionEndTimestamp+=360; /// ...add another 6 minutes to the auction. } _burn(msg.sender, bid_amount); // burn the current bid _mint(td.controller, td.bidAmount); // remint the latest bid back to the address that got out-bid td.bidAmount = bid_amount; // update the bid record td.controller = msg.sender; // set the current bidder to be the controller. td.lastBidTimestamp = block.timestamp; // record the timestamp of the bid. emit Bid(ticker, msg.sender, bid_amount, block.timestamp); } /** @notice Ends an ongoing auction for a given ticker. @dev This function ends an auction that has already started and has reached its deadline. The function marks the auction as ended, mints a TickerNameNFT for the winning bidder (the controller), and emits an AuctionEnded and MintNameNFT events. This function can only be called after the auction has ended and cannot be called if the auction has already been marked as ended. This function is nonReentrant to prevent re-entrancy attacks. @param ticker The name of the ticker for which the auction is to be ended. */ function endAuction(string memory ticker) public nonReentrant { TickerAuctionData storage td = TICKER_AUCTION_DATABASE[ticker]; require(td.auctionStarted==true, "Auction must have already started."); require(block.timestamp > td.auctionEndTimestamp, "Auction must be over to end."); require(td.auctionEnded==false, "Auction has already been ended."); td.auctionEnded = true; uint256 nft_id = mintTickerNameNft(td.controller, ticker); emit AuctionEnded(ticker, msg.sender, td.controller, td.bidAmount); emit MintNameNFT(msg.sender, ticker, nft_id); } /// UTILITIES function mint(uint256 amount) private {_mint(msg.sender, amount);} function day() public view returns (uint256) {return _day();} function _day() internal view returns (uint256) {return (block.timestamp - ACTIVATION_TIMESTAMP) / 1 days;} uint256 constant scalar = 10**8; bool WAS_FINALIZED; //@notice Sends the ETH or PLS to the liquidity fund and mints the liquidity fund its portion of tokens. half of the total funds will be allocated to a series of symmetrical liquidity pools and the LP tokens will drip out to party holders. //@notice Used by lifeguard to manage the nametag NFT meta data hosting function updateURI(string memory new_uri) public { require(msg.sender==LIFEGUARD_ADDRESS); NameTagContract.updateURI(new_uri); } // required by the Snapshot library. function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20Snapshot) {super._beforeTokenTransfer(from, to, amount);} } contract RewardDistribution is ReentrancyGuard { address public POOL_PARTY_ADDRESS; using SafeERC20 for IERC20; address public LIFE_GUARD; // Address that can clean out the unclaimed rewards. uint256 public constant REWARD_EXPIRY_PERIODS = 33; // if 33 snapshot periods have elapsed, the rewards may be cleared out. mapping (address => mapping (address => mapping (uint256 => bool))) public USER_TOKEN_PERIODS_CLAIMED; // Record periods an address has claimed from. event RewardsClaimed(address indexed claimant, address indexed token_address, uint amount, uint first_period, uint last_period); event UnclaimedRewardsResolved(address indexed account, uint amount, uint first_period, uint last_period); constructor(address pool_party_address, address life_guard_address) ReentrancyGuard() { POOL_PARTY_ADDRESS = pool_party_address; LIFE_GUARD = life_guard_address; } //@notice Used to claim rewards //@params first_period first period to measure. //@params last_period last period to measure. function claimRewards(address token_address, uint256 first_period, uint256 last_period) public nonReentrant { iPoolParty pool_party = iPoolParty(POOL_PARTY_ADDRESS); // Connect to Pool Party Contract. uint256 total_amount = pool_party.getBatchEarningsDetails(msg.sender, token_address, first_period, last_period);// Calculate rewards the user may claim. for (uint256 i = first_period; i <=last_period; i++) { // loop through the input periods. require(USER_TOKEN_PERIODS_CLAIMED[msg.sender][token_address][i]==false, "Already claimed"); //Ensure that the rewards from a period have not been claimed yet. USER_TOKEN_PERIODS_CLAIMED[msg.sender][token_address][i]=true; // Record of rewards being claimed from a period. } IERC20(token_address).safeTransfer(msg.sender, total_amount); // Transfer rewards to claimant. emit RewardsClaimed(msg.sender, token_address,total_amount, first_period, last_period); } //@notice used to record pool party snapshot count as part of the unclaimed rewards resolver. //There are certain addresses that may be eligible for rewards, but are impossible to claim. Primary example is the uniswap liquidity pool contract, which may hold a significant amount of liquid PARTY.To prevent the HEX from being wasted by unclaimable addresses, the Life Guard may clear rewards once they are 77 weeks old. //params account Address which has unclaimed rewards. //@params first_period first period to measure. //@params last_period last period to measure. function resolveUnclaimedRewards(address account, address token_address, uint256 first_period, uint256 last_period) public nonReentrant { require(msg.sender==LIFE_GUARD, "Only the lifeguard can clean the pool.");//Ensures only the lifeguard can run the function iPoolParty pool_party = iPoolParty(POOL_PARTY_ADDRESS); //Connects to pool party contract. uint256 total_amount = pool_party.getBatchEarningsDetails(account, token_address, first_period, last_period); // Amount of unclaimed rewards. for (uint256 i = first_period; i <=last_period; i++) { require(pool_party.getCurrentSnapshotId()>REWARD_EXPIRY_PERIODS + i, "Rewards are not expired yet.");// Ensure that the rewards have expired, meaning 33 weeks have elapsed since the period with unclaimed rewards. require(USER_TOKEN_PERIODS_CLAIMED[account][token_address][i]==false, "Already claimed"); // Ensure that the unclaimed rewards from the given period have not been claimed already. USER_TOKEN_PERIODS_CLAIMED[account][token_address][i]=true; // Records which period's unclaimed rewards have been resolved. } IERC20(token_address).safeTransfer(msg.sender, total_amount); // Transfers the HEX to the life guard. emit UnclaimedRewardsResolved(account, total_amount, first_period, last_period); } } contract NameTag is ERC721, ERC721Enumerable, Ownable, ReentrancyGuard{ using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; mapping(uint256 => string) public ID_NAME; mapping(string => uint256) public NAME_ID; address public POOL_PARTY_CONTRACT_ADDRESS; string public URI = "https://poolpartynft.anvil.app/_/api/metadata/"; constructor(address pool_party_contract_address) ERC721("Pool Party Nametags", "Nametags") ReentrancyGuard() { _tokenIdCounter.increment(); POOL_PARTY_CONTRACT_ADDRESS = pool_party_contract_address; } function _baseURI() internal view override returns (string memory) { return URI; } function updateURI(string memory new_uri) external onlyOwner { URI=new_uri; } function mintName(address to, string memory ticker) external onlyOwner returns (uint256){ require(NAME_ID[ticker]==0, "Must not have been assigned already."); // Ensure it has not already been minted uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); ID_NAME[tokenId]=ticker; NAME_ID[ticker]=tokenId; return tokenId; } // The following functions are overrides required by Solidity. function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId, batchSize); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } } interface iNameTag { function NAME_ID(string memory) external returns (uint256); function transferFrom(address, address, uint256) external; } interface iPoolPartyNameClaim { function NAME_CLAIMER_AIRDROP_POINTS(address) external view returns (uint256); function NAME_OWNERS(string memory) external view returns (address); } interface iPoolParty { function getBatchEarningsDetails(address, address, uint256, uint256) external view returns (uint256); function getCurrentSnapshotId() external view returns (uint256); } contract PartyPoolDeployer is ReentrancyGuard(){ constructor(address ticker_contract, address pool_party_address) ReentrancyGuard() { POOL_PARTY_CONTRACT_ADDRESS=pool_party_address; NAME_TAG_CONTRACT = ticker_contract; } event PoolDeployment(string ticker, uint256 initial_mint_duration, uint256 stake_duration, uint256 reload_duration, string name, uint256 organizer_share, address organizer_address, address pool_address); address public NAME_TAG_CONTRACT; address public POOL_PARTY_CONTRACT_ADDRESS; mapping (string => address) public POOL_RECORD; function deployPool(string memory ticker, uint256 initial_mint_duration, uint256 stake_duration, uint256 reload_duration, string memory name, uint256 organizer_share, address organizer_address) public nonReentrant { require(organizer_share<=9900, "must be less than 99.00%"); uint256 ticker_name_nft_id = iNameTag(NAME_TAG_CONTRACT).NAME_ID(ticker); PerpetualPool New_Pool = new PerpetualPool(initial_mint_duration, stake_duration, reload_duration,name,ticker, organizer_address, organizer_share, POOL_PARTY_CONTRACT_ADDRESS); address pool_address=address(New_Pool); POOL_RECORD[ticker] = pool_address; iNameTag(NAME_TAG_CONTRACT).transferFrom(msg.sender, address(New_Pool), ticker_name_nft_id); emit PoolDeployment(ticker, initial_mint_duration, stake_duration, reload_duration,name, organizer_share,organizer_address,pool_address); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) 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 making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) 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() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { 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 { _transferOwnership(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"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.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)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @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 // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev See {ERC721-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual override { super._beforeTokenTransfer(from, to, firstTokenId, batchSize); if (batchSize > 1) { // Will only trigger during construction. Batch transferring (minting) is not available afterwards. revert("ERC721Enumerable: consecutive transfers not supported"); } uint256 tokenId = firstTokenId; if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.2) (token/ERC721/ERC721.sol) 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: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); 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) { _requireMinted(tokenId); 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 overridden 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 token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_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: caller is not token owner or 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: caller is not token owner or 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 the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @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 _ownerOf(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) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == 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, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @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 from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @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.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.2; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol"; contract HedronToken { function approve(address spender, uint256 amount) external returns (bool) {} function transfer(address recipient, uint256 amount) external returns (bool) {} function mintNative(uint256 stakeIndex, uint40 stakeId) external returns (uint256) {} function claimNative(uint256 stakeIndex, uint40 stakeId) external returns (uint256) {} function currentDay() external view returns (uint256) {} } contract HEXToken { function currentDay() external view returns (uint256){} function stakeStart(uint256 newStakedHearts, uint256 newStakedDays) external {} function approve(address spender, uint256 amount) external returns (bool) {} function transfer(address recipient, uint256 amount) public returns (bool) {} function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam) public {} function stakeCount(address stakerAddr) external view returns (uint256) {} function stakeLists(address owner, uint256 stakeIndex) external view returns (uint40, uint72, uint72, uint16, uint16, uint16, bool) {} } contract COMToken { struct Stake { uint256 stakeID; uint256 stakedHearts; uint256 stakeShares; uint256 lockedDay; uint256 stakedDays; uint256 unlockedDay; } struct PayoutResponse { uint256 recalculatedStakeShares; uint256 stakesOriginalShareRate; uint256 maxPayout; } function mintStartBonus(uint256 stakeIndex, uint256 stakeID, bool applyRestakeBonus, address referrer, uint256 stakeAmount) external {} function mintEndBonus(uint256 stakeIndex, uint256 stakeID, address referrer, uint256 stakeAmount) external {} function stakeIdStartBonusPayout(uint256) public returns (uint256){} } /* /$$$$$$$ /$$ /$$ | $$__ $$ | $$ | $$ | $$ \ $$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ | $$ /$$$$$$$ | $$$$$$$//$$__ $$ /$$__ $$ /$$__ $$ /$$__ $$|_ $$_/ | $$ | $$ |____ $$| $$ /$$_____/ | $$____/| $$$$$$$$| $$ \__/| $$ \ $$| $$$$$$$$ | $$ | $$ | $$ /$$$$$$$| $$| $$$$$$ | $$ | $$_____/| $$ | $$ | $$| $$_____/ | $$ /$$| $$ | $$ /$$__ $$| $$ \____ $$ | $$ | $$$$$$$| $$ | $$$$$$$/| $$$$$$$ | $$$$/| $$$$$$/| $$$$$$$| $$ /$$$$$$$/ |__/ \_______/|__/ | $$____/ \_______/ \___/ \______/ \_______/|__/|_______/ | $$ | $$ |__/ // Anyone may choose to mint 1 Perpetual Pool Token per HEX pledged to the Perpetual Pool Contract during the minting phase. // Pool Tokens are a standard ERC20 token, only minted upon HEX deposit and burnt upon HEX redemption with no pre-mine. // Pool Token holders may choose to burn their Pool Tokens to redeem HEX principal and yield pro-rata from the Pool Token Contract Address during the reload phase. // The Perpetual Pools start with an initial minting phase, followed by a stake phase. Then once the HEX stake has ended they enter a reload phase where HEX may be redeemed with Pool Tokens or Pool Tokens may be minted with HEX - all at the same redemption rate. // Then after the reload phase ends another Stake Phase begins and the cycle repeats forever. // PHASES: |----- Minting Phase ----|------ Stake Phase -----...-----|---- Reload Phase ----->|----- Stake Phase -------...----|----> REPEAT FOREVER // WHAT HAPPENS? | Mint and redeem | No Minting or Redeeming | Mint and redeem | No Minting or Redeeming | // FUNCTIONS USED:| pledgeHEX(),redeemHEX()|mintStartBonusCom() | pledgeHEX(),redeemHEX()|mintStartBonusCom() | | | initiateBonusSequence()^ |claimBonus() | initiateBonusSequence()^ | | |mintHedron() mintEndBonusCom()^ | |mintHedron() mintEndBonusCom()^ | | | completeBonusSequence()^| | completeBonusSequence()^| // TRANSITION FUNCTION: stakeStart() ^ endStakeHex() ^ stakeStart() ^ endStakeHex()^ THE PERPETUAL POOLS CONTRACTS, SUPPORTING WEBSITES, AND ALL OTHER INTERFACES (THE SOFTWARE) IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. BY INTERACTING WITH THE SOFTWARE YOU ARE ASSERTING THAT YOU BEAR ALL THE RISKS ASSOCIATED WITH DOING SO. AN INFINITE NUMBER OF UNPREDICTABLE THINGS MAY GO WRONG WHICH COULD POTENTIALLY RESULT IN CRITICAL FAILURE AND FINANCIAL LOSS. BY INTERACTING WITH THE SOFTWARE YOU ARE ASSERTING THAT YOU AGREE THERE IS NO RECOURSE AVAILABLE AND YOU WILL NOT SEEK IT. INTERACTING WITH THE SOFTWARE SHALL NOT BE CONSIDERED AN INVESTMENT OR A COMMON ENTERPRISE. INSTEAD, INTERACTING WITH THE SOFTWARE IS EQUIVALENT TO CARPOOLING WITH FRIENDS TO SAVE ON GAS AND EXPERIENCE THE BENEFITS OF THE H.O.V. LANE. YOU SHALL HAVE NO EXPECTATION OF PROFIT OR ANY TYPE OF GAIN FROM THE WORK OF OTHER PEOPLE. */ contract PerpetualPool is ERC20, ERC20Burnable, ReentrancyGuard, ERC20Snapshot { // Core Parameters // all days are measured in terms of the HEX contract day number uint256 public RELOAD_PHASE_DURATION; // How many days are between each stake uint256 public RELOAD_PHASE_START; // the day when the current reload phase starts, is updated as each stake ends uint256 public RELOAD_PHASE_END; // the day when the current reload phase ends, is updated as each stake ends uint256 public STAKE_START_DAY; // the day when the current stake starts, is updated as each stake starts uint256 public STAKE_END_DAY; // the day when the current stake ends, is updated as each stake starts uint256 public STAKE_LENGTH; // length of the stake uint256 public HEX_REDEMPTION_RATE=100000000; // Number of HEX units redeemable per Perpetual Pool Token and the number of HEX required to mint a new Perpetual Pool Token after a stake ends bool public STAKE_IS_ACTIVE; // Used to keep track of whether or not the HEX stake is active. Is TRUE during stake phases and FALSE during reload ohases address public END_STAKER; // Address who paid the gas to end the stake uint256 public CURRENT_STAKE_PRINCIPAL; // Principal of current stake, updated whenever a stake starts and reset to zero when a stake ends. uint256 public CURRENT_PERIOD; // even numbers are Reload Period, odd numbers are staking periods. address public ORGANIZER; uint256 public ORGANIZER_SHARE; constructor(uint256 initial_mint_duration, uint256 stake_duration, uint256 reload_duration, string memory name, string memory ticker, address organizer_address,uint256 organizer_share, address party_address) ERC20(name, ticker) ReentrancyGuard() { RELOAD_PHASE_DURATION=reload_duration; uint256 start_day=hex_token.currentDay(); RELOAD_PHASE_START = start_day; RELOAD_PHASE_END = start_day+initial_mint_duration; // The initial RELOAD PHASE may be set to be different than the ongoing reload phases. STAKE_LENGTH=stake_duration; require(STAKE_LENGTH>0, "Stake must be longer than 1 day."); STAKE_IS_ACTIVE=false; PARTY_ADDRESS=party_address; ORGANIZER = organizer_address; ORGANIZER_SHARE = organizer_share; } address POOL_ADDRESS =address(this); address constant HEX_ADDRESS = 0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39; // "2b, 5 9 1e? that is the question..." address constant HEDRON_ADDRESS=0x3819f64f282bf135d62168C1e513280dAF905e06; address constant COM_ADDRESS=0x5A9780Bfe63f3ec57f01b087cD65BD656C9034A8; address public PARTY_ADDRESS; IERC20 hex_contract = IERC20(HEX_ADDRESS); IERC20 hedron_contract=IERC20(HEDRON_ADDRESS); HEXToken hex_token = HEXToken(HEX_ADDRESS); HedronToken hedron_token = HedronToken(HEDRON_ADDRESS); // Minting and Redemption event PledgeHEX(address indexed user, uint256 indexed redemption_rate, uint256 hex_deposit, uint256 tokens_minted); event RedeemHEX(address indexed user, uint256 indexed redemption_rate, uint256 hex_redeemed, uint256 tokens_burnt); /** * @dev Ensures that Pool Token Minting Phase is ongoing and that the user has allowed the Perpetual Pool Contract address to spend the amount of HEX the user intends to pledge to The Perpetual Pool. Then sends the designated HEX from the user to the Perpetual Pool Contract address and mints 1 Pool Token per HEX pledged. * @param amount of HEX user chose to pledge, measured in hearts */ function pledgeHEX(uint256 amount) nonReentrant external { require(STAKE_IS_ACTIVE==false, "Minting may only be done if a stake is not active"); require(hex_token.currentDay()<=RELOAD_PHASE_END, "Minting Phase is Done"); require(hex_contract.allowance(msg.sender, POOL_ADDRESS)>=amount, "Please approve contract address as allowed spender in the hex contract."); hex_contract.transferFrom(msg.sender, POOL_ADDRESS, amount); uint256 mintable_amount = (10**8)*amount/HEX_REDEMPTION_RATE; mint(mintable_amount); emit PledgeHEX(msg.sender, HEX_REDEMPTION_RATE, amount, mintable_amount); } /** * @dev Ensures that it is currently a redemption period (before stake starts or after stake ends) and that the user has at least the number of Pool Tokens they entered. Then it calculates how much hex may be redeemed, burns the Pool Token, and transfers them the hex. * @param amount number of Pool Tokens that the user is redeeming, measured in mini */ function redeemHEX(uint256 amount) nonReentrant external { require(STAKE_IS_ACTIVE==false, "Redemption can not happen while stake is active"); uint256 your_balance = balanceOf(msg.sender); require(your_balance>=amount, "You do not have that much of the Pool Token."); uint256 raw_redeemable_amount = amount*HEX_REDEMPTION_RATE; uint256 redeemable_amount = raw_redeemable_amount/(10**8); //scaled back down to handle integer rounding burn(amount); hex_token.transfer(msg.sender, redeemable_amount); emit RedeemHEX(msg.sender, HEX_REDEMPTION_RATE, redeemable_amount, amount); } // Staking Functions // Anyone may run these functions during the allowed time, so long as they pay the gas. // While nothing is forcing you to, gracious Perpetual Pool members will tip the sender some ETH for paying gas to end your stake. event StakeStart (uint256 period, uint256 principal, uint256 days_staked, uint256 stake_start, uint256 stake_end, uint256 organizer_revenue, address organizer); event StakeEnd (uint stake_period, uint hex_redemption_rate, address end_staker, uint balance_hex, uint total_token_supply); /** * @dev Ensures that the stake has not started yet and that the minting phase is over. Then it stakes all the hex in the contract and schedules the STAKE_END_DAY. * @notice This will trigger the start of the HEX stake. If you run this, you will pay the gas on behalf of the contract and you should not expect reimbursement. */ function stakeHEX() nonReentrant external { require(STAKE_IS_ACTIVE==false, "Stake has already started."); uint256 current_day = hex_token.currentDay(); require(current_day>RELOAD_PHASE_END, "Minting Phase is still ongoing - see RELOAD_PHASE_END day."); uint256 amount = hex_contract.balanceOf(address(this)); uint256 thank_you_party = amount/200; uint256 scaled_organizer_amount = (amount)*ORGANIZER_SHARE*(10**8)/10000; uint256 thank_you_organizer = scaled_organizer_amount/(10**8); IERC20(HEX_ADDRESS).transfer(ORGANIZER, thank_you_organizer); IERC20(HEX_ADDRESS).transfer(PARTY_ADDRESS, thank_you_party); uint256 stake_amount= IERC20(HEX_ADDRESS).balanceOf(address(this)); _stakeHEX(stake_amount); CURRENT_STAKE_PRINCIPAL=stake_amount; STAKE_START_DAY=current_day; STAKE_END_DAY=current_day+STAKE_LENGTH; STAKE_IS_ACTIVE=true; CURRENT_PERIOD = CURRENT_PERIOD+1; emit StakeStart(CURRENT_PERIOD, CURRENT_STAKE_PRINCIPAL, STAKE_LENGTH, STAKE_START_DAY, STAKE_END_DAY,thank_you_organizer, ORGANIZER); } function _stakeHEX(uint256 amount) private { hex_token.stakeStart(amount,STAKE_LENGTH); } function _endStakeHEX(uint256 stakeIndex,uint40 stakeIdParam ) private { hex_token.stakeEnd(stakeIndex, stakeIdParam); } /** * @dev Ensures that the stake is fully complete and that it has not already been ended. Then it ends the hex stake and updates the redemption rate. * @notice This will trigger the ending of the HEX stake and calculate the new redemption rate. This may be very expensive. If you run this, you will pay the gas on behalf of the contract and you should not expect reimbursement. * @param stakeIndex index of stake found in stakeLists[contract_address] in hex contract. * @param stakeIdParam stake identifier found in stakeLists[contract_address] in hex contract. */ function endStakeHEX(uint256 stakeIndex,uint40 stakeIdParam ) nonReentrant external { require(hex_token.currentDay()>STAKE_END_DAY, "Stake is not complete yet."); require(BONUSES_READY, "Bonus distribution sequence must be complete."); require(STAKE_IS_ACTIVE==true, "Stake must be active."); _endStakeHEX(stakeIndex, stakeIdParam); uint256 hex_balance = hex_contract.balanceOf(address(this)); uint256 total_supply = IERC20(address(this)).totalSupply(); HEX_REDEMPTION_RATE = calculate_redemption_rate(hex_balance, total_supply); END_STAKER=msg.sender; CURRENT_STAKE_PRINCIPAL=0; STAKE_IS_ACTIVE=false; RELOAD_PHASE_START=hex_token.currentDay(); RELOAD_PHASE_END=RELOAD_PHASE_START+RELOAD_PHASE_DURATION; CURRENT_PERIOD = CURRENT_PERIOD+1; BONUSES_READY=false; BONUS_PROCESSING_DEADLINE=0; emit StakeEnd(CURRENT_PERIOD - 1, HEX_REDEMPTION_RATE, msg.sender,hex_balance, total_supply); } // HDRN Minting /** * @dev Public function which calls the private function which is used for minting available HDRN accumulated by the contract stake. * @notice This will trigger the minting of the mintable Hedron earned by the stake. If you run this, you will pay the gas on behalf of the contract and you should not expect reimbursement. If check to make sure this has not been run yet already or the transaction will fail. * @param stakeIndex index of stake found in stakeLists[contract_address] in hex contract. * @param stakeId stake identifier found in stakeLists[contract_address] in hex contract. */ function mintHedron(uint256 stakeIndex,uint40 stakeId ) external { _mintHedron(stakeIndex, stakeId); } /** * @dev Private function used for minting available HDRN accumulated by the contract stake. * @param stakeIndex index of stake found in stakeLists[contract_address] in hex contract. * @param stakeId stake identifier found in stakeLists[contract_address] in hex contract. */ function _mintHedron(uint256 stakeIndex,uint40 stakeId ) private { hedron_token.mintNative(stakeIndex, stakeId); } // COM Minting /** * @dev Public function used for minting available COM via the contract stake start bonus. * @param stakeIndex index of stake found in stakeLists[contract_address] in hex contract. * @param stakeID stake identifier found in stakeLists[contract_address] in hex contract. */ function mintStartBonusCom(uint256 stakeIndex, uint256 stakeID) external { COMToken(COM_ADDRESS).mintStartBonus(stakeIndex, stakeID, false, PARTY_ADDRESS, 0); } /** * @dev Public function used for minting available COM via the contract stake end bonus. Automatically stakes half to be eligible for next bonus. * @param stakeIndex index of stake found in stakeLists[contract_address] in hex contract. * @param stakeID stake identifier found in stakeLists[contract_address] in hex contract. */ function mintEndBonusCom(uint256 stakeIndex, uint40 stakeID) external nonReentrant { Stake memory s = memoryStake(address(this), stakeIndex, stakeID); COMToken com = COMToken(COM_ADDRESS); PayoutResponse memory pr = getComPayout(s); uint256 endBonusPayout= pr.maxPayout-com.stakeIdStartBonusPayout(stakeID); uint256 stakeAmount = endBonusPayout*5000/10000; com.mintEndBonus(stakeIndex, stakeID, PARTY_ADDRESS, stakeAmount); } // Bonus Management event ClaimBonus(address indexed user, uint256 indexed snapshot, uint256 balance, uint256 hdrn_claimed, uint256 com_claimed); event BonusSequenceInitiated(uint256 indexed period, uint256 deadline); event BonusSequenceCompleted(uint256 indexed period); mapping (string => mapping(uint256 => uint256)) public BONUS_REDEMPTION_RATES; mapping (address=>mapping ( uint256=>bool)) public DID_CLAIM; bool public BONUSES_READY; uint256 public BONUS_PROCESSING_DEADLINE; /** * @dev If eligible to run, sets a BONUS_PROCESSING_DEADLINE in 6 hours. During this 6 Hour period is when the final mintHedron() and mintEndBonusCom() can be run. */ function initiateBonusSequence() public nonReentrant { require(BONUS_PROCESSING_DEADLINE==0, "Can only inititate once per cycle."); require(hex_token.currentDay()>STAKE_END_DAY, "Stake is not complete yet."); require(STAKE_IS_ACTIVE==true, "Stake must be active."); BONUS_PROCESSING_DEADLINE = block.timestamp + 6 hours; emit BonusSequenceInitiated(CURRENT_PERIOD, BONUS_PROCESSING_DEADLINE); } /** * @dev If eligible to run, records a snapshot used for bonus claiming and then sets BONUSES_READY to true which enables the stake to end. */ function completeBonusSequence() public nonReentrant { require(BONUSES_READY==false, "Function already ran."); require(BONUS_PROCESSING_DEADLINE>0, "Must run startBonusSequence first."); require(block.timestamp>BONUS_PROCESSING_DEADLINE, "Must wait until deadline."); processSnapshot(); BONUSES_READY=true; emit BonusSequenceCompleted(CURRENT_PERIOD); } function processSnapshot() internal { _snapshot(); uint256 hdrn_balance = IERC20(HEDRON_ADDRESS).balanceOf(address(this)); uint256 com_balance = IERC20(COM_ADDRESS).balanceOf(address(this)); uint256 s = _getCurrentSnapshotId(); uint256 supply = totalSupplyAt(s); BONUS_REDEMPTION_RATES["HDRN"][s] = calculate_redemption_rate(hdrn_balance, supply); BONUS_REDEMPTION_RATES["COM"][s] = calculate_redemption_rate(com_balance, supply); } /** * @notice Used to claim HDRN and COM rewards if the signer had a positive balance at the latest snapshot. If a user has rewards to claim, they will be able to claim them until the next snapshot at the end of the next stake cycle. Unclaimed rewards roll forward. */ function claimBonus() public nonReentrant { uint256 snapshotId = _getCurrentSnapshotId(); uint256 balance = balanceOfAt(msg.sender, snapshotId); require(balance>0, "Zero balance at snapshot."); require(DID_CLAIM[msg.sender][snapshotId]==false, "Already claimed from this snapshot."); uint256 hdrn_reward = BONUS_REDEMPTION_RATES["HDRN"][snapshotId] * balance / (10**8); IERC20(HEDRON_ADDRESS).transfer(msg.sender,hdrn_reward ); uint256 com_reward = BONUS_REDEMPTION_RATES["COM"][snapshotId] * balance / (10**8); IERC20(COM_ADDRESS).transfer(msg.sender,com_reward ); DID_CLAIM[msg.sender][snapshotId]=true; emit ClaimBonus(msg.sender, snapshotId, balance, hdrn_reward, com_reward); } // Utilities /** * @dev View number of decimal places the Pool Token is divisible to. Manually overwritten from default 18 to 8 to match that of HEX. 1 Pool Token = 10^8 mini */ function decimals() public view virtual override returns (uint8) {return 8;} /** * @dev Returns the current Period. Even numbers are Reload Phases, Odd numbers are staking phases. * @return Current Period */ function getCurrentPeriod() external view returns (uint256){ return CURRENT_PERIOD; } // @dev Returns the current day from the hex contract. function getHexDay() external view returns (uint256){ uint256 day = hex_token.currentDay(); return day; } /** * @dev Returns the address of the person who ends stake. May be used by external gas pooling contracts. If stake has not been ended yet will return 0x000...000" * @return end_staker_address This person should be honored and celebrated as a hero. */ function getEndStaker() external view returns (address end_staker_address) {return END_STAKER;} // Pool Token Issuance and Redemption Functions /** * @dev Mints Pool Token. * @param amount of Pool Tokens to mint, measured in minis */ function mint(uint256 amount) private { _mint(msg.sender, amount); } /** * @dev Calculates the pro-rata redemption rate of any coin per Pool Token. Scales value by 10^8 to handle integer rounding. * @param treasury_balance The balance of coins in contract address (either HEX or HEDRON) * @param token_supply total Pool Token supply * @return redemption_rate Number of units redeemable per 10^8 decimal units of Pool Tokens. Is scaled back down by 10^8 on redemption transaction. */ function calculate_redemption_rate(uint treasury_balance, uint token_supply) private pure returns (uint redemption_rate) { uint256 scalar = 10**8; uint256 scaled = (treasury_balance * scalar) / token_supply; // scale value to calculate redemption amount per Pool Token and then divide by same scalar after multiplication return scaled; } function getCurrentSnapshotId() public view returns (uint256) { return _getCurrentSnapshotId(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20Snapshot) {super._beforeTokenTransfer(from, to, amount);} struct PayoutResponse { uint256 recalculatedStakeShares; uint256 stakesOriginalShareRate; uint256 maxPayout; } struct Stake { uint256 stakeID; uint256 stakedHearts; uint256 stakeShares; uint256 lockedDay; uint256 stakedDays; uint256 unlockedDay; } function memoryStake(address adr, uint256 stakeIndex, uint256 stakeID) internal view returns (Stake memory) { uint40 _stakeID; uint72 _stakedHearts; uint72 _stakeShares; uint16 _lockedDay; uint16 _stakedDays; uint16 _unlockedDay; (_stakeID, _stakedHearts, _stakeShares, _lockedDay, _stakedDays, _unlockedDay, ) = HEXToken(HEX_ADDRESS).stakeLists(address(adr), stakeIndex); require(_stakeID == stakeID, "COM: Assure correct and current stake"); return Stake(_stakeID, _stakedHearts, _stakeShares, _lockedDay, _stakedDays, _unlockedDay); } /** * * @dev Reverse engineer amount of bonus HEX hearts that were used in * determining stake's HEX shares (this data is not kept in HEX storage) * * Formula is derived from HEX smart contract * */ function getStakesBonusHearts(Stake memory s) internal pure returns (uint256 stakesBonusHearts) { uint256 cappedDays = 0; if (s.stakedDays > 1) cappedDays = s.stakedDays <= 3640 ? s.stakedDays - 1 : 3640; uint256 cappedHearts = s.stakedHearts <= (15 * (10 ** 15)) ? s.stakedHearts : (15 * (10 ** 15)); stakesBonusHearts = s.stakedHearts * ((cappedDays * (15 * (10 ** 16))) + (cappedHearts * 1820)) / (273 * (10 ** 18)); } /** * * @dev Recalculate amount of bonus HEX hearts that would be applied if * the cappedDays were not limited to 3640 days * * Formula is derived from HEX smart contract * */ function getRecalculatedBonusHearts(Stake memory s) internal pure returns (uint256 recalculatedBonusHearts) { uint256 cappedDays = s.stakedDays - 1; uint256 cappedHearts = s.stakedHearts <= (15 * (10 ** 15)) ? s.stakedHearts : (15 * (10 ** 15)); recalculatedBonusHearts = s.stakedHearts * ((cappedDays * (15 * (10 ** 16))) + (cappedHearts * 1820)) / (273 * (10 ** 18)); } /** * * @dev Creates a consistent PayoutResponse for any given Stake * * Reverse engineer stakes original share rate as stakesOriginalShareRate using reverse engineered stakes bonus hearts * * Recalculate Stake Shares with new Recalculated Bonus Hearts and using Reverse engineered stakesOriginalShareRate * * Calculate penalty for amount days staked out of possible max length staked days of 5555, derived from HEX smart contract * * Max payout represents the maximum possible value that can be minted for any given Stake * */ function getComPayout(Stake memory s) public pure returns (PayoutResponse memory pr) { uint256 stakesOriginalShareRate = ((s.stakedHearts + getStakesBonusHearts(s)) * (10 ** 5)) / s.stakeShares; uint256 recalculatedStakeShares = (s.stakedHearts + getRecalculatedBonusHearts(s)) * (10 ** 17) / stakesOriginalShareRate; pr.stakesOriginalShareRate = stakesOriginalShareRate; pr.recalculatedStakeShares = recalculatedStakeShares; uint256 penalty = (s.stakedDays * (10 ** 15)) / 5555; pr.maxPayout = (recalculatedStakeShares * penalty) / (10 ** 15); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata( bytes32[] calldata proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC20Snapshot.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../utils/Arrays.sol"; import "../../../utils/Counters.sol"; /** * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and * total supply at the time are recorded for later access. * * This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting. * In naive implementations it's possible to perform a "double spend" attack by reusing the same balance from different * accounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also be * used to create an efficient ERC20 forking mechanism. * * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a * snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot * id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id * and the account address. * * NOTE: Snapshot policy can be customized by overriding the {_getCurrentSnapshotId} method. For example, having it * return `block.number` will trigger the creation of snapshot at the beginning of each new block. When overriding this * function, be careful about the monotonicity of its result. Non-monotonic snapshot ids will break the contract. * * Implementing snapshots for every block using this method will incur significant gas costs. For a gas-efficient * alternative consider {ERC20Votes}. * * ==== Gas Costs * * Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log * n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much * smaller since identical balances in subsequent snapshots are stored as a single entry. * * There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent * transfers will have normal cost until the next snapshot, and so on. */ abstract contract ERC20Snapshot is ERC20 { // Inspired by Jordi Baylina's MiniMeToken to record historical balances: // https://github.com/Giveth/minime/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol using Arrays for uint256[]; using Counters for Counters.Counter; // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a // Snapshot struct, but that would impede usage of functions that work on an array. struct Snapshots { uint256[] ids; uint256[] values; } mapping(address => Snapshots) private _accountBalanceSnapshots; Snapshots private _totalSupplySnapshots; // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid. Counters.Counter private _currentSnapshotId; /** * @dev Emitted by {_snapshot} when a snapshot identified by `id` is created. */ event Snapshot(uint256 id); /** * @dev Creates a new snapshot and returns its snapshot id. * * Emits a {Snapshot} event that contains the same id. * * {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a * set of accounts, for example using {AccessControl}, or it may be open to the public. * * [WARNING] * ==== * While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking, * you must consider that it can potentially be used by attackers in two ways. * * First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow * logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target * specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs * section above. * * We haven't measured the actual numbers; if this is something you're interested in please reach out to us. * ==== */ function _snapshot() internal virtual returns (uint256) { _currentSnapshotId.increment(); uint256 currentId = _getCurrentSnapshotId(); emit Snapshot(currentId); return currentId; } /** * @dev Get the current snapshotId */ function _getCurrentSnapshotId() internal view virtual returns (uint256) { return _currentSnapshotId.current(); } /** * @dev Retrieves the balance of `account` at the time `snapshotId` was created. */ function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) { (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]); return snapshotted ? value : balanceOf(account); } /** * @dev Retrieves the total supply at the time `snapshotId` was created. */ function totalSupplyAt(uint256 snapshotId) public view virtual returns (uint256) { (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots); return snapshotted ? value : totalSupply(); } // Update balance and/or total supply snapshots before the values are modified. This is implemented // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations. function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { // mint _updateAccountSnapshot(to); _updateTotalSupplySnapshot(); } else if (to == address(0)) { // burn _updateAccountSnapshot(from); _updateTotalSupplySnapshot(); } else { // transfer _updateAccountSnapshot(from); _updateAccountSnapshot(to); } } function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) { require(snapshotId > 0, "ERC20Snapshot: id is 0"); require(snapshotId <= _getCurrentSnapshotId(), "ERC20Snapshot: nonexistent id"); // When a valid snapshot is queried, there are three possibilities: // a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never // created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds // to this id is the current one. // b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the // requested id, and its value is the one to return. // c) More snapshots were created after the requested one, and the queried value was later modified. There will be // no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is // larger than the requested one. // // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does // exactly this. uint256 index = snapshots.ids.findUpperBound(snapshotId); if (index == snapshots.ids.length) { return (false, 0); } else { return (true, snapshots.values[index]); } } function _updateAccountSnapshot(address account) private { _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account)); } function _updateTotalSupplySnapshot() private { _updateSnapshot(_totalSupplySnapshots, totalSupply()); } function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private { uint256 currentId = _getCurrentSnapshotId(); if (_lastSnapshotId(snapshots.ids) < currentId) { snapshots.ids.push(currentId); snapshots.values.push(currentValue); } } function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) { if (ids.length == 0) { return 0; } else { return ids[ids.length - 1]; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../utils/Context.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { _spendAllowance(account, _msgSender(), amount); _burn(account, amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) 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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead 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: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, 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}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, 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}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, 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) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, 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) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * 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: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, 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; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _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; // Overflow not possible: amount <= accountBalance <= totalSupply. _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 Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - 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 // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) 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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @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] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) 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 // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "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"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) 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 // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) 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 `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) 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`. * * 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; /** * @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * 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 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 the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Arrays.sol) pragma solidity ^0.8.0; import "./StorageSlot.sol"; import "./math/Math.sol"; /** * @dev Collection of functions related to array types. */ library Arrays { using StorageSlot for bytes32; /** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is * returned. Time complexity O(log n). * * `array` is expected to be sorted in ascending order, and to contain no * repeated elements. */ function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { if (array.length == 0) { return 0; } uint256 low = 0; uint256 high = array.length; while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds down (it does integer division with truncation). if (unsafeAccess(array, mid).value > element) { high = mid; } else { low = mid + 1; } } // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. if (low > 0 && unsafeAccess(array, low - 1).value == element) { return low - 1; } else { return low; } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) { bytes32 slot; /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getAddressSlot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) { bytes32 slot; /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getBytes32Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) { bytes32 slot; /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getUint256Slot(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) 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 // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) 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 // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"liquidity_fund_address","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token_address","type":"address"},{"indexed":true,"internalType":"uint256","name":"period","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"latest_balance","type":"uint256"}],"name":"AssetProcessed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ticker","type":"string"},{"indexed":true,"internalType":"address","name":"ender","type":"address"},{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":false,"internalType":"uint256","name":"winning_bid","type":"uint256"}],"name":"AuctionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ticker","type":"string"},{"indexed":true,"internalType":"address","name":"starter","type":"address"},{"indexed":false,"internalType":"uint256","name":"starting_bid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"AuctionStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ticker","type":"string"},{"indexed":true,"internalType":"address","name":"bidder","type":"address"},{"indexed":false,"internalType":"uint256","name":"bid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Bid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"string","name":"ticker","type":"string"},{"indexed":false,"internalType":"uint256","name":"nft_id","type":"uint256"}],"name":"MintNameNFT","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Snapshot","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"principal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"end_day","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"yield","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stake_id","type":"uint256"}],"name":"StakeEnd","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"principal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"end_day","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"yield","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stake_id","type":"uint256"}],"name":"StakeStart","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"HAS_REDEEMED_INITIAL_SUPPLY_POINTS","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INITIAL_SUPPLY_ROOT","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ITS_GO_TIME","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LATEST_SNAPSHOT_DAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LIFEGUARD_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LIQUIDITY_FUND_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_STARTING_BID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAME_TAG_NFT_CONTRACT_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REWARD_DISTRIBUTION_CONTRACT_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"STAKER_LOG","outputs":[{"internalType":"address","name":"staker","type":"address"},{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"end_day","type":"uint256"},{"internalType":"uint256","name":"yield","type":"uint256"},{"internalType":"bool","name":"started","type":"bool"},{"internalType":"bool","name":"ended","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"STAKER_NUMBER_STAKES","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"TICKER_AUCTION_DATABASE","outputs":[{"internalType":"uint256","name":"lastBidTimestamp","type":"uint256"},{"internalType":"uint256","name":"firstBidTimestamp","type":"uint256"},{"internalType":"uint256","name":"auctionEndTimestamp","type":"uint256"},{"internalType":"address","name":"controller","type":"address"},{"internalType":"uint256","name":"bidAmount","type":"uint256"},{"internalType":"bool","name":"auctionStarted","type":"bool"},{"internalType":"bool","name":"auctionEnded","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"TOKEN_PERIOD_EARNINGS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"YIELD_MERKLE_ROOT","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"snapshotId","type":"uint256"}],"name":"balanceOfAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"ticker","type":"string"},{"internalType":"uint256","name":"bid_amount","type":"uint256"}],"name":"bid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"length","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"merkle_amount","type":"uint256"}],"name":"calculateYield","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"day","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"ticker","type":"string"}],"name":"endAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"endStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"address","name":"token_address","type":"address"},{"internalType":"uint256","name":"first_period","type":"uint256"},{"internalType":"uint256","name":"last_period","type":"uint256"}],"name":"getBatchEarningsDetails","outputs":[{"internalType":"uint256","name":"earnings","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentSnapshotId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"address","name":"token_address","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"getEarningsDetails","outputs":[{"internalType":"uint256","name":"earnings","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"itsGoTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"ticker","type":"string"}],"name":"mintFromNameclaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"processAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"recordSnapshot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"merkle_amount","type":"uint256"}],"name":"redeemInitialSupplyPoints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setMinimumBid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakedSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"ticker","type":"string"},{"internalType":"uint256","name":"initial_bid_amount","type":"uint256"}],"name":"startAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"days_staked","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"merkle_amount","type":"uint256"}],"name":"startStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"snapshotId","type":"uint256"}],"name":"totalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"new_uri","type":"string"}],"name":"updateURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"merkle_amount","type":"uint256"}],"name":"verifyInitialSupplyPoints","outputs":[{"internalType":"bool","name":"isValid","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"days_staked","type":"uint256"},{"internalType":"uint256","name":"merkle_amount","type":"uint256"}],"name":"verifyYield","outputs":[{"internalType":"bool","name":"isValid","type":"bool"}],"stateMutability":"pure","type":"function"}]
Contract Creation Code
60806040526a52b7d2dcc80cd2e40000006016553480156200001f575f80fd5b50604051620062de380380620062de833981016040819052620000429162000461565b604051806040016040528060128152602001714d6178696d757320506f6f6c20506172747960701b81525060405180604001604052806005815260200164504152545960d81b81525081600390816200009c91906200052d565b506004620000ab82826200052d565b5050600160095550600c8054336001600160a01b031991821617909155600b80549091166001600160a01b038316179055620000f3816a295be96e6406697200000062000226565b806001600160a01b03167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d41213968856a295be96e640669720000006040516200013a91815260200190565b60405180910390a242600a55600c546040515f9130916001600160a01b0390911690620001679062000445565b6001600160a01b03928316815291166020820152604001604051809103905ff08015801562000198573d5f803e3d5ffd5b50601080546001600160a01b0319166001600160a01b0383161790556040519091503090620001c79062000453565b6001600160a01b039091168152602001604051809103905ff080158015620001f1573d5f803e3d5ffd5b50600e80546001600160a01b03929092166001600160a01b03199283168117909155600f805490921617905550620006539050565b6001600160a01b038216620002815760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b6200028e5f8383620002f7565b8060025f828254620002a191906200060d565b90915550506001600160a01b0382165f81815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6200030483838362000309565b505050565b6001600160a01b0383166200032d57620003238262000358565b620003046200038f565b6001600160a01b0382166200034757620003238362000358565b620003528362000358565b62000304825b6001600160a01b0381165f90815260056020908152604080832091839052909120546200038c9190620003a1565b620003a1565b50565b6200039f60066200038660025490565b565b5f620003ac620003ee565b905080620003ba84620003fe565b101562000304578254600180820185555f858152602080822090930193909355938401805494850181558252902090910155565b5f620003f960085490565b905090565b80545f9081036200041057505f919050565b81548290620004229060019062000629565b815481106200043557620004356200063f565b905f5260205f2001549050919050565b610b62806200372483390190565b612058806200428683390190565b5f6020828403121562000472575f80fd5b81516001600160a01b038116811462000489575f80fd5b9392505050565b634e487b7160e01b5f52604160045260245ffd5b600181811c90821680620004b957607f821691505b602082108103620004d857634e487b7160e01b5f52602260045260245ffd5b50919050565b601f8211156200030457805f5260205f20601f840160051c81016020851015620005055750805b601f840160051c820191505b8181101562000526575f815560010162000511565b5050505050565b81516001600160401b0381111562000549576200054962000490565b62000561816200055a8454620004a4565b84620004de565b602080601f83116001811462000597575f84156200057f5750858301515b5f19600386901b1c1916600185901b178555620005f1565b5f85815260208120601f198616915b82811015620005c757888601518255948401946001909101908401620005a6565b5085821015620005e557878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b634e487b7160e01b5f52601160045260245ffd5b80820180821115620006235762000623620005f9565b92915050565b81810381811115620006235762000623620005f9565b634e487b7160e01b5f52603260045260245ffd5b6130c380620006615f395ff3fe608060405234801561000f575f80fd5b506004361061028c575f3560e01c80637b76ac9111610161578063ae660895116100ca578063d41ce4b111610084578063d41ce4b114610679578063dd62ed3e14610682578063e823e55f14610695578063eaf2caaa146106a8578063f2dd96e0146106bb578063fb9e6a2a14610760575f80fd5b8063ae660895146105f3578063b45540f41461061a578063b9de1f9c1461062d578063c27051c314610640578063c30f4a5a14610653578063ce2ba9bf14610666575f80fd5b8063a457c2d71161011b578063a457c2d714610580578063a9059cbb14610593578063aa3330b6146105a6578063aae00fbe146105c5578063aca0b6ce146105cd578063acefe02e146105e0575f80fd5b80637b76ac911461052e578063862882e51461053657806386495b041461054957806395d89b411461055c578063981b24d0146105645780639f9eba3514610577575f80fd5b80633595be6d116102035780635439ad86116101bd5780635439ad86146104ae5780635f483313146104b65780635fbacb2d146104c95780636b023bc8146104eb57806370a08231146104f3578063798c48a71461051b575f80fd5b80633595be6d14610423578063395093511461044e5780633bb09178146104615780634eb21696146104745780634ee2cd7e14610488578063519bf24e1461049b575f80fd5b80631633f1cb116102545780631633f1cb14610324578063174f8c34146103bc57806318160ddd146103e657806323b872dd146103ee5780632bd34b7d14610401578063313ce56714610414575f80fd5b806306fdde0314610290578063095ea7b3146102ae5780630cbe28d6146102d15780630d7c223f146102e65780631403829f146102fd575b5f80fd5b610298610773565b6040516102a59190612afe565b60405180910390f35b6102c16102bc366004612b24565b610803565b60405190151581526020016102a5565b6102e46102df366004612b4e565b61081c565b005b6102ef60165481565b6040519081526020016102a5565b6102ef7ffe1001d98a99b01293dcc713f45e6b3122511f8a6f8de820e04e660508d747b381565b610381610332366004612b24565b601360209081525f9283526040808420909152908252902080546001820154600283015460038401546004909401546001600160a01b0390931693919290919060ff8082169161010090041686565b604080516001600160a01b039097168752602087019590955293850192909252606084015215156080830152151560a082015260c0016102a5565b6102ef6103ca366004612b24565b601560209081525f928352604080842090915290825290205481565b6002546102ef565b6102c16103fc366004612b65565b6109f5565b6102e461040f366004612c54565b610a18565b604051601281526020016102a5565b600f54610436906001600160a01b031681565b6040516001600160a01b0390911681526020016102a5565b6102c161045c366004612b24565b610b72565b6102e461046f366004612cf8565b610b93565b600c546102c190600160a01b900460ff1681565b6102ef610496366004612b24565b610d29565b6102c16104a9366004612d3a565b610d80565b6102ef610dfb565b6102e46104c4366004612d84565b610e09565b6102c16104d7366004612db7565b600d6020525f908152604090205460ff1681565b6102e4611091565b6102ef610501366004612db7565b6001600160a01b03165f9081526020819052604090205490565b6102ef610529366004612dd2565b611103565b6102ef611143565b6102e4610544366004612d84565b61114c565b6102e4610557366004612b4e565b61138b565b61029861144b565b6102ef610572366004612b4e565b61145a565b6102ef60145481565b6102c161058e366004612b24565b611480565b6102c16105a1366004612b24565b6114fa565b6102ef6105b4366004612db7565b60126020525f908152604090205481565b6102e4611507565b6102e46105db366004612e15565b6115a4565b601054610436906001600160a01b031681565b6102ef7fc080050f7fa523e1ca454092bd721ecccc0252c67082bdfd3b7d6ab539a78d2081565b6102ef610628366004612e15565b61172c565b6102e461063b366004612db7565b6117bc565b6102ef61064e366004612b65565b611a3b565b6102e4610661366004612c54565b611b01565b6102e4610674366004612c54565b611b77565b6102ef60115481565b6102ef610690366004612e69565b611d6c565b6102c16106a3366004612ea0565b611d96565b600b54610436906001600160a01b031681565b61071f6106c9366004612c54565b80516020818301810180516017825292820191909301209152805460018201546002830154600384015460048501546005909501549394929391926001600160a01b039091169160ff8082169161010090041687565b604080519788526020880196909652948601939093526001600160a01b0390911660608501526080840152151560a0830152151560c082015260e0016102a5565b600c54610436906001600160a01b031681565b60606003805461078290612ee5565b80601f01602080910402602001604051908101604052809291908181526020018280546107ae90612ee5565b80156107f95780601f106107d0576101008083540402835291602001916107f9565b820191905f5260205f20905b8154815290600101906020018083116107dc57829003601f168201915b5050505050905090565b5f33610810818585611e18565b60019150505b92915050565b610824611f3c565b335f9081526013602090815260408083208484529091529020600481015460ff1615156001146108945760405162461bcd60e51b81526020600482015260166024820152752a3434b99039ba30b5b29036bab9ba1032bc34b9ba1760511b60448201526064015b60405180910390fd5b80600201546108a1611143565b116108ee5760405162461bcd60e51b815260206004820152601f60248201527f54686973207374616b65206973206e6f7420636f6d706c657465207965742e00604482015260640161088b565b6004810154610100900460ff16156109485760405162461bcd60e51b815260206004820152601d60248201527f54686973207374616b652077617320616c726561647920656e6465642e000000604482015260640161088b565b6109648160030154826001015461095f9190612f31565b611f95565b806001015460115f8282546109799190612f44565b909155505060048101805461ff001916610100179055600181015460028201546003830154604080519384526020840192909252908201526060810183905233907f1deb31f039e2645a4e97af07659090228d39e7f992bfaf37af3838ad9665e23a9060800160405180910390a2506109f26001600955565b50565b5f33610a02858285611f9f565b610a0d858585612011565b506001949350505050565b610a20611f3c565b60405163353791d960e11b8152738b39b9b6fee1854a585321fbd3b2bab49cfb23599033908290636a6f23b290610a5b908690600401612afe565b602060405180830381865afa158015610a76573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a9a9190612f57565b6001600160a01b031614610b165760405162461bcd60e51b815260206004820152603960248201527f53656e646572206d75737420626520746865206f776e6572206f66207468652060448201527f7469636b6572206e616d6520696e204e616d65436c61696d2e00000000000000606482015260840161088b565b5f610b2133846121be565b9050336001600160a01b03167fa53c02935736fbd1872c0fcd3656afcab41dab13824356904b8d86916356e40b8483604051610b5e929190612f72565b60405180910390a250506109f26001600955565b5f33610810818585610b848383611d6c565b610b8e9190612f31565b611e18565b610b9b611f3c565b600c54600160a01b900460ff16610c055760405162461bcd60e51b815260206004820152602860248201527f476976652074696d6520666f72206c69717569646974792066756e6420746f20604482015267062652073657475760c41b606482015260840161088b565b610c10823383611d96565b610c6e5760405162461bcd60e51b815260206004820152602960248201527f4d75737420626520656c696769626c65206164647265737320616e6420616d6f6044820152683ab73a103830b4b91760b91b606482015260840161088b565b335f908152600d602052604090205460ff1615610cbf5760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818db185a5b5959608a1b604482015260640161088b565b610cc881611f95565b335f818152600d602052604090819020805460ff19166001179055517f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688590610d139084815260200190565b60405180910390a2610d256001600955565b5050565b6001600160a01b0382165f90815260056020526040812081908190610d4f908590612234565b9150915081610d75576001600160a01b0385165f90815260208190526040902054610d77565b805b95945050505050565b5f808383604051602001610d9e929190918252602082015260400190565b60408051808303601f1901815282825280516020918201208184015281518084038201815292820190915281519101209050610d77857ffe1001d98a99b01293dcc713f45e6b3122511f8a6f8de820e04e660508d747b383612324565b5f610e04612339565b905090565b610e11611f3c565b5f601783604051610e229190612f93565b908152604051908190036020019020600581015490915060ff161515600114610ea15760405162461bcd60e51b815260206004820152602b60248201527f546869732061756374696f6e206d7573742068617665206265656e207374617260448201526a74656420616c726561647960a81b606482015260840161088b565b6005810154610100900460ff1615610f0b5760405162461bcd60e51b815260206004820152602760248201527f546869732061756374696f6e206d757374206e6f742068617665206265656e2060448201526632b73232b2171760c91b606482015260840161088b565b62989680816004015462a037a0610f229190612fae565b610f2c9190612fc5565b821015610f895760405162461bcd60e51b815260206004820152602560248201527f426964206d757374206265203525206c6172676572207468616e207072696f72604482015264103134b21760d91b606482015260840161088b565b8060020154421115610fcf5760405162461bcd60e51b815260206004820152600f60248201526e20bab1ba34b7b71034b99037bb32b960891b604482015260640161088b565b610168428260020154610fe29190612f44565b101561100357610168816002015f828254610ffd9190612f31565b90915550505b61100d3383612343565b6003810154600482015461102a916001600160a01b03169061247b565b600481018290556003810180546001600160a01b03191633908117909155428083556040517f4155205ee6ae19e622283dcaa46bc29ed1b902788b4ab7919a3150cb98c95e479161107e9187918791612fe4565b60405180910390a250610d256001600955565b611099611f3c565b600c546001600160a01b031633146110e45760405162461bcd60e51b815260206004820152600e60248201526d13db9b1e481b1a599959dd585c9960921b604482015260640161088b565b600c805460ff60a01b1916600160a01b1790556111016001600955565b565b5f80835b83811161113757611119878783611a3b565b6111239083612f31565b91508061112f81613008565b915050611107565b5090505b949350505050565b5f610e04612543565b611154611f3c565b60405163353791d960e11b81525f90738b39b9b6fee1854a585321fbd3b2bab49cfb235990636a6f23b29061118d908690600401612afe565b602060405180830381865afa1580156111a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111cc9190612f57565b6001600160a01b0316146112225760405162461bcd60e51b815260206004820152601a60248201527f4e616d65206d757374206e6f742062652072657365727665642e000000000000604482015260640161088b565b5f6017836040516112339190612f93565b908152604051908190036020019020600581015490915060ff161561129a5760405162461bcd60e51b815260206004820181905260248201527f546869732061756374696f6e2068617320616c72656164792073746172746564604482015260640161088b565b6016548210156113025760405162461bcd60e51b815260206004820152602d60248201527f4d757374206265206c6172676572207468616e20746865206d696e696d756d2060448201526c39ba30b93a34b733903134b21760991b606482015260840161088b565b61130c3383612343565b60058101805460ff19166001908117909155600482018390556003820180546001600160a01b03191633179055429082018190558082556113509062015180612f31565b600282015560405133907f188ca2341cb9d0cffff3f6ae500f2640ca09feeb2f47ce508ac07c9564f9bb589061107e90869086904290612fe4565b600c546001600160a01b031633146113e55760405162461bcd60e51b815260206004820181905260248201527f4f6e6c7920746865206c6966656775617264206d61792072756e20746869732e604482015260640161088b565b60165481106114465760405162461bcd60e51b815260206004820152602760248201527f4d696e696d756d207374617274696e67206269642063616e206f6e6c7920646560448201526631b932b0b9b29760c91b606482015260840161088b565b601655565b60606004805461078290612ee5565b5f805f611468846006612234565b91509150816114795760025461113b565b9392505050565b5f338161148d8286611d6c565b9050838110156114ed5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161088b565b610a0d8286868403611e18565b5f33610810818585612011565b61150f611f3c565b5f611518611143565b9050601454600e6115299190612f31565b811161158e5760405162461bcd60e51b815260206004820152602e60248201527f536e617073686f742063616e206f6e6c792062652074616b656e206f6e63652060448201526d32bb32b93c9019103bb2b2b5b99760911b606482015260840161088b565b611596612560565b506014556111016001600955565b6115ac611f3c565b335f90815260126020526040812054906115c4611143565b6115ce9086612f31565b6115d9906001612f31565b90505f6115e88787878761172c565b6040805160c0810182523380825260208083018c8152838501888152606085018781526001608087018181525f60a08901818152888252601388528a82208f835288528a822099518a546001600160a01b0319166001600160a01b03909116178a559551898401559351600289015591516003880155905160049096018054935161ffff1990941696151561ff00191696909617610100931515939093029290921790945591835260129052918120805493945091926116a9908490612f31565b909155506116b990503388612343565b8660115f8282546116ca9190612f31565b909155505060408051888152602081018490529081018290526060810184905233907f89ad62c709031f6892a90b222612bc408f6b5e86c21c30c12d010ba59f21db269060800160405180910390a25050506117266001600955565b50505050565b5f61146885116117905760405162461bcd60e51b815260206004820152602960248201527f4d757374206265206c6172676572207468616e206d696e696d756d207374616b604482015268329030b6b7bab73a1760b91b606482015260840161088b565b61179b838584610d80565b6117a3575f80fd5b6305f5e1006117b28387612fae565b610d779190612fc5565b6117c4611f3c565b6040516370a0823160e01b815230600482015281905f906001600160a01b038316906370a0823190602401602060405180830381865afa15801561180a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061182e9190613020565b90505f811161186d5760405162461bcd60e51b815260206004820152600b60248201526a3737903130b630b731b29760a91b604482015260640161088b565b6010546040516370a0823160e01b81526001600160a01b0391821660048201819052915f91908516906370a0823190602401602060405180830381865afa1580156118ba573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118de9190613020565b6010549091506118fb906001600160a01b038681169116856125b8565b5f611904610dfb565b6040516370a0823160e01b81526001600160a01b0385811660048301529192505f918491908816906370a0823190602401602060405180830381865afa158015611950573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119749190613020565b61197e9190612f44565b90505f61198c836001612f31565b6001600160a01b0389165f9081526015602090815260408083208484529091528120805492935084929091906119c3908490612f31565b90915550506001600160a01b0388165f8181526015602090815260408083208584528252918290205482519384529083018590529082015283907f64ad25ad7ba7ca43c3f48a15dccd75a7981b14982aa6300dfe9f437a37a9d1e09060600160405180910390a2505050505050506109f26001600955565b5f611a44610dfb565b821115611a935760405162461bcd60e51b815260206004820152601b60248201527f506572696f6420486173204e6f742048617070656e6564205965740000000000604482015260640161088b565b611a9c8261145a565b611aae90670de0b6b3a7640000612fae565b611ab88584610d29565b6001600160a01b0385165f908152601560209081526040808320878452909152902054611aed90670de0b6b3a7640000612fae565b611af79190612fae565b61113b9190612fc5565b600c546001600160a01b03163314611b17575f80fd5b600e54604051636187a52d60e11b81526001600160a01b039091169063c30f4a5a90611b47908490600401612afe565b5f604051808303815f87803b158015611b5e575f80fd5b505af1158015611b70573d5f803e3d5ffd5b5050505050565b611b7f611f3c565b5f601782604051611b909190612f93565b908152604051908190036020019020600581015490915060ff161515600114611c065760405162461bcd60e51b815260206004820152602260248201527f41756374696f6e206d757374206861766520616c726561647920737461727465604482015261321760f11b606482015260840161088b565b80600201544211611c595760405162461bcd60e51b815260206004820152601c60248201527f41756374696f6e206d757374206265206f76657220746f20656e642e00000000604482015260640161088b565b6005810154610100900460ff1615611cb35760405162461bcd60e51b815260206004820152601f60248201527f41756374696f6e2068617320616c7265616479206265656e20656e6465642e00604482015260640161088b565b60058101805461ff00191661010017905560038101545f90611cde906001600160a01b0316846121be565b600383015460048401546040519293506001600160a01b039091169133917f9378576c306cb4d9bb218b037bbcb6249fe379ce5807b1cb91907c9d5f22372691611d29918891612f72565b60405180910390a3336001600160a01b03167fa53c02935736fbd1872c0fcd3656afcab41dab13824356904b8d86916356e40b8483604051610b5e929190612f72565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b604080516001600160a01b03841660208201529081018290525f90819060600160408051601f1981840301815282825280516020918201209083015201604051602081830303815290604052805190602001209050610d77857fc080050f7fa523e1ca454092bd721ecccc0252c67082bdfd3b7d6ab539a78d205f1b83612324565b6001600160a01b038316611e7a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161088b565b6001600160a01b038216611edb5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161088b565b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b600260095403611f8e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161088b565b6002600955565b6109f2338261247b565b5f611faa8484611d6c565b90505f19811461172657818110156120045760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161088b565b6117268484848403611e18565b6001600160a01b0383166120755760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161088b565b6001600160a01b0382166120d75760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161088b565b6120e283838361260a565b6001600160a01b0383165f90815260208190526040902054818110156121595760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161088b565b6001600160a01b038481165f81815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3611726565b600e54604051630192f8bb60e01b81525f9182916001600160a01b0390911690630192f8bb906121f49087908790600401613037565b6020604051808303815f875af1158015612210573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061113b9190613020565b5f805f841161227e5760405162461bcd60e51b815260206004820152601660248201527504552433230536e617073686f743a20696420697320360541b604482015260640161088b565b612286612339565b8411156122d55760405162461bcd60e51b815260206004820152601d60248201527f4552433230536e617073686f743a206e6f6e6578697374656e74206964000000604482015260640161088b565b5f6122e08486612615565b845490915081036122f7575f80925092505061231d565b600184600101828154811061230e5761230e61305a565b905f5260205f20015492509250505b9250929050565b5f8261233085846126b1565b14949350505050565b5f610e0460085490565b6001600160a01b0382166123a35760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161088b565b6123ae825f8361260a565b6001600160a01b0382165f90815260208190526040902054818110156124215760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161088b565b6001600160a01b0383165f818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101611f2f565b505050565b6001600160a01b0382166124d15760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161088b565b6124dc5f838361260a565b8060025f8282546124ed9190612f31565b90915550506001600160a01b0382165f81815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b5f62015180600a54426125569190612f44565b610e049190612fc5565b5f61256f600880546001019055565b5f612578612339565b90507f8030e83b04d87bef53480e26263266d6ca66863aa8506aca6f2559d18aa1cb67816040516125ab91815260200190565b60405180910390a1919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526124769084906126f3565b6124768383836127c4565b81545f90810361262657505f610816565b82545f905b8082101561266e575f61263e838361280c565b90508461264b8783612826565b54111561265a57809150612668565b612665816001612f31565b92505b5061262b565b5f8211801561269057508361268d86612688600186612f44565b612826565b54145b156126a9576126a0600183612f44565b92505050610816565b509050610816565b5f81815b84518110156126eb576126e1828683815181106126d4576126d461305a565b6020026020010151612836565b91506001016126b5565b509392505050565b5f612747826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166128629092919063ffffffff16565b8051909150156124765780806020019051810190612765919061306e565b6124765760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161088b565b6001600160a01b0383166127e3576127db82612870565b6124766128a1565b6001600160a01b0382166127fa576127db83612870565b61280383612870565b61247682612870565b5f61281a6002848418612fc5565b61147990848416612f31565b5f8281526020812082018061113b565b5f818310612850575f828152602084905260409020611479565b5f838152602083905260409020611479565b606061113b84845f856128af565b6001600160a01b0381165f90815260056020908152604080832091839052909120546109f29190612986565b612986565b611101600661289c60025490565b6060824710156129105760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161088b565b5f80866001600160a01b0316858760405161292b9190612f93565b5f6040518083038185875af1925050503d805f8114612965576040519150601f19603f3d011682016040523d82523d5f602084013e61296a565b606091505b509150915061297b878383876129ce565b979650505050505050565b5f61298f612339565b90508061299b84612a46565b1015612476578254600180820185555f858152602080822090930193909355938401805494850181558252902090910155565b60608315612a3c5782515f03612a35576001600160a01b0385163b612a355760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161088b565b508161113b565b61113b8383612a87565b80545f908103612a5757505f919050565b81548290612a6790600190612f44565b81548110612a7757612a7761305a565b905f5260205f2001549050919050565b815115612a975781518083602001fd5b8060405162461bcd60e51b815260040161088b9190612afe565b5f5b83811015612acb578181015183820152602001612ab3565b50505f910152565b5f8151808452612aea816020860160208601612ab1565b601f01601f19169290920160200192915050565b602081525f6114796020830184612ad3565b6001600160a01b03811681146109f2575f80fd5b5f8060408385031215612b35575f80fd5b8235612b4081612b10565b946020939093013593505050565b5f60208284031215612b5e575f80fd5b5035919050565b5f805f60608486031215612b77575f80fd5b8335612b8281612b10565b92506020840135612b9281612b10565b929592945050506040919091013590565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612be057612be0612ba3565b604052919050565b5f82601f830112612bf7575f80fd5b813567ffffffffffffffff811115612c1157612c11612ba3565b612c24601f8201601f1916602001612bb7565b818152846020838601011115612c38575f80fd5b816020850160208301375f918101602001919091529392505050565b5f60208284031215612c64575f80fd5b813567ffffffffffffffff811115612c7a575f80fd5b61113b84828501612be8565b5f82601f830112612c95575f80fd5b8135602067ffffffffffffffff821115612cb157612cb1612ba3565b8160051b612cc0828201612bb7565b9283528481018201928281019087851115612cd9575f80fd5b83870192505b8483101561297b57823582529183019190830190612cdf565b5f8060408385031215612d09575f80fd5b823567ffffffffffffffff811115612d1f575f80fd5b612d2b85828601612c86565b95602094909401359450505050565b5f805f60608486031215612d4c575f80fd5b833567ffffffffffffffff811115612d62575f80fd5b612d6e86828701612c86565b9660208601359650604090950135949350505050565b5f8060408385031215612d95575f80fd5b823567ffffffffffffffff811115612dab575f80fd5b612d2b85828601612be8565b5f60208284031215612dc7575f80fd5b813561147981612b10565b5f805f8060808587031215612de5575f80fd5b8435612df081612b10565b93506020850135612e0081612b10565b93969395505050506040820135916060013590565b5f805f8060808587031215612e28575f80fd5b8435935060208501359250604085013567ffffffffffffffff811115612e4c575f80fd5b612e5887828801612c86565b949793965093946060013593505050565b5f8060408385031215612e7a575f80fd5b8235612e8581612b10565b91506020830135612e9581612b10565b809150509250929050565b5f805f60608486031215612eb2575f80fd5b833567ffffffffffffffff811115612ec8575f80fd5b612ed486828701612c86565b9350506020840135612b9281612b10565b600181811c90821680612ef957607f821691505b602082108103612f1757634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561081657610816612f1d565b8181038181111561081657610816612f1d565b5f60208284031215612f67575f80fd5b815161147981612b10565b604081525f612f846040830185612ad3565b90508260208301529392505050565b5f8251612fa4818460208701612ab1565b9190910192915050565b808202811582820484141761081657610816612f1d565b5f82612fdf57634e487b7160e01b5f52601260045260245ffd5b500490565b606081525f612ff66060830186612ad3565b60208301949094525060400152919050565b5f6001820161301957613019612f1d565b5060010190565b5f60208284031215613030575f80fd5b5051919050565b6001600160a01b03831681526040602082018190525f9061113b90830184612ad3565b634e487b7160e01b5f52603260045260245ffd5b5f6020828403121561307e575f80fd5b81518015158114611479575f80fdfea2646970667358221220feb93cd5bb16e65b2eea3625d8a96ac29b90dc9b4275a7133905a91bfc42faa864736f6c63430008180033608060405234801561000f575f80fd5b50604051610b62380380610b6283398101604081905261002e9161007e565b60015f81905580546001600160a01b039384166001600160a01b031991821617909155600280549290931691161790556100af565b80516001600160a01b0381168114610079575f80fd5b919050565b5f806040838503121561008f575f80fd5b61009883610063565b91506100a660208401610063565b90509250929050565b610aa6806100bc5f395ff3fe608060405234801561000f575f80fd5b5060043610610060575f3560e01c8063050bed38146100645780630d65ad9b1461007f5780637b1d25b4146100aa5780637ca35209146100ed578063bfeaf3be14610102578063f95136e614610115575b5f80fd5b61006c602181565b6040519081526020015b60405180910390f35b600154610092906001600160a01b031681565b6040516001600160a01b039091168152602001610076565b6100dd6100b83660046108d7565b600360209081525f938452604080852082529284528284209052825290205460ff1681565b6040519015158152602001610076565b6101006100fb366004610910565b610128565b005b600254610092906001600160a01b031681565b610100610123366004610940565b6102eb565b6101306105cf565b60015460405163798c48a760e01b81523360048201526001600160a01b0385811660248301526044820185905260648201849052909116905f90829063798c48a790608401602060405180830381865afa158015610190573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101b4919061097f565b9050835b83811161027857335f9081526003602090815260408083206001600160a01b038a168452825280832084845290915290205460ff16156102315760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818db185a5b5959608a1b60448201526064015b60405180910390fd5b335f9081526003602090815260408083206001600160a01b038a16845282528083208484529091529020805460ff1916600117905580610270816109aa565b9150506101b8565b5061028d6001600160a01b0386163383610626565b60408051828152602081018690529081018490526001600160a01b0386169033907f94a8e1916a31bb1e2864bac78a6c85e5de33a2f0fc066dfd3cda6d69f5d3d5289060600160405180910390a350506102e660015f55565b505050565b6102f36105cf565b6002546001600160a01b0316331461035c5760405162461bcd60e51b815260206004820152602660248201527f4f6e6c7920746865206c69666567756172642063616e20636c65616e20746865604482015265103837b7b61760d11b6064820152608401610228565b60015460405163798c48a760e01b81526001600160a01b03868116600483015285811660248301526044820185905260648201849052909116905f90829063798c48a790608401602060405180830381865afa1580156103be573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103e2919061097f565b9050835b83811161055d576103f88160216109c2565b836001600160a01b0316635439ad866040518163ffffffff1660e01b8152600401602060405180830381865afa158015610434573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610458919061097f565b116104a55760405162461bcd60e51b815260206004820152601c60248201527f5265776172647320617265206e6f742065787069726564207965742e000000006044820152606401610228565b6001600160a01b038088165f908152600360209081526040808320938a1683529281528282208483529052205460ff16156105145760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818db185a5b5959608a1b6044820152606401610228565b6001600160a01b038088165f908152600360209081526040808320938a168352928152828220848352905220805460ff1916600117905580610555816109aa565b9150506103e6565b506105726001600160a01b0386163383610626565b60408051828152602081018690529081018490526001600160a01b038716907fd5acad549c6b5da0f35307ec2a0815c4084572a0972d3aee9215593ac44e10a09060600160405180910390a250506105c960015f55565b50505050565b60025f54036106205760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610228565b60025f55565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092018352602080830180516001600160e01b031663a9059cbb60e01b17905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908401526102e6928692915f916106b5918516908490610732565b8051909150156102e657808060200190518101906106d391906109db565b6102e65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610228565b606061074084845f85610748565b949350505050565b6060824710156107a95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610228565b5f80866001600160a01b031685876040516107c49190610a23565b5f6040518083038185875af1925050503d805f81146107fe576040519150601f19603f3d011682016040523d82523d5f602084013e610803565b606091505b50915091506108148783838761081f565b979650505050505050565b6060831561088d5782515f03610886576001600160a01b0385163b6108865760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610228565b5081610740565b61074083838151156108a25781518083602001fd5b8060405162461bcd60e51b81526004016102289190610a3e565b80356001600160a01b03811681146108d2575f80fd5b919050565b5f805f606084860312156108e9575f80fd5b6108f2846108bc565b9250610900602085016108bc565b9150604084013590509250925092565b5f805f60608486031215610922575f80fd5b61092b846108bc565b95602085013595506040909401359392505050565b5f805f8060808587031215610953575f80fd5b61095c856108bc565b935061096a602086016108bc565b93969395505050506040820135916060013590565b5f6020828403121561098f575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b5f600182016109bb576109bb610996565b5060010190565b808201808211156109d5576109d5610996565b92915050565b5f602082840312156109eb575f80fd5b815180151581146109fa575f80fd5b9392505050565b5f5b83811015610a1b578181015183820152602001610a03565b50505f910152565b5f8251610a34818460208701610a01565b9190910192915050565b602081525f8251806020840152610a5c816040850160208701610a01565b601f01601f1916919091016040019291505056fea264697066735822122037243de1ec0f56581cb4e1a8ff0d03f2e28627e1dfbde8c52ff8d412b2aa912e64736f6c6343000818003360e0604052602e6080818152906200202a60a03960109062000022908262000212565b503480156200002f575f80fd5b5060405162002058380380620020588339810160408190526200005291620002de565b6040518060400160405280601381526020017f506f6f6c205061727479204e616d657461677300000000000000000000000000815250604051806040016040528060088152602001674e616d657461677360c01b815250815f9081620000b9919062000212565b506001620000c8828262000212565b505050620000e5620000df6200011f60201b60201c565b62000123565b6001600b55620000f9600c80546001019055565b600f80546001600160a01b0319166001600160a01b03929092169190911790556200030d565b3390565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b634e487b7160e01b5f52604160045260245ffd5b600181811c908216806200019d57607f821691505b602082108103620001bc57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f8211156200020d57805f5260205f20601f840160051c81016020851015620001e95750805b601f840160051c820191505b818110156200020a575f8155600101620001f5565b50505b505050565b81516001600160401b038111156200022e576200022e62000174565b62000246816200023f845462000188565b84620001c2565b602080601f8311600181146200027c575f8415620002645750858301515b5f19600386901b1c1916600185901b178555620002d6565b5f85815260208120601f198616915b82811015620002ac578886015182559484019460019091019084016200028b565b5085821015620002ca57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b5f60208284031215620002ef575f80fd5b81516001600160a01b038116811462000306575f80fd5b9392505050565b611d0f806200031b5f395ff3fe608060405234801561000f575f80fd5b506004361061016c575f3560e01c80634f6ccce7116100d95780639d599eea11610093578063c30f4a5a1161006e578063c30f4a5a14610328578063c87b56dd1461033b578063e985e9c51461034e578063f2fde38b14610389575f80fd5b80639d599eea146102d7578063a22cb46514610302578063b88d4fde14610315575f80fd5b80634f6ccce71461027d5780636352211e1461029057806370a08231146102a3578063715018a6146102b65780638da5cb5b146102be57806395d89b41146102cf575f80fd5b80631141d7de1161012a5780631141d7de1461022157806318160ddd1461022957806323b872dd146102315780632f745c591461024457806336ebfe2b1461025757806342842e0e1461026a575f80fd5b80626b8ef5146101705780630192f8bb146101a057806301ffc9a7146101c157806306fdde03146101e4578063081812fc146101f9578063095ea7b31461020c575b5f80fd5b600f54610183906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101b36101ae366004611754565b61039c565b604051908152602001610197565b6101d46101cf3660046117b4565b610489565b6040519015158152602001610197565b6101ec610493565b604051610197919061181c565b61018361020736600461182e565b610522565b61021f61021a366004611845565b610547565b005b6101ec61065b565b6008546101b3565b61021f61023f36600461186d565b6106e7565b6101b3610252366004611845565b610718565b6101ec61026536600461182e565b6107ac565b61021f61027836600461186d565b6107c4565b6101b361028b36600461182e565b6107de565b61018361029e36600461182e565b61086e565b6101b36102b13660046118a6565b6108cd565b61021f610951565b600a546001600160a01b0316610183565b6101ec610964565b6101b36102e53660046118bf565b8051602081830181018051600e8252928201919093012091525481565b61021f6103103660046118f1565b610973565b61021f61032336600461192a565b610982565b61021f6103363660046118bf565b6109ba565b6101ec61034936600461182e565b6109ce565b6101d461035c3660046119a1565b6001600160a01b039182165f90815260056020908152604080832093909416825291909152205460ff1690565b61021f6103973660046118a6565b610a32565b5f6103a5610aab565b600e826040516103b591906119d2565b9081526020016040518091039020545f146104235760405162461bcd60e51b8152602060048201526024808201527f4d757374206e6f742068617665206265656e2061737369676e656420616c726560448201526330b23c9760e11b60648201526084015b60405180910390fd5b5f61042d600c5490565b905061043d600c80546001019055565b6104478482610b05565b5f818152600d6020526040902061045e8482611a69565b5080600e8460405161047091906119d2565b9081526040519081900360200190205590505b92915050565b5f61048382610b1e565b60605f80546104a1906119ed565b80601f01602080910402602001604051908101604052809291908181526020018280546104cd906119ed565b80156105185780601f106104ef57610100808354040283529160200191610518565b820191905f5260205f20905b8154815290600101906020018083116104fb57829003601f168201915b5050505050905090565b5f61052c82610b42565b505f908152600460205260409020546001600160a01b031690565b5f6105518261086e565b9050806001600160a01b0316836001600160a01b0316036105be5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161041a565b336001600160a01b03821614806105da57506105da813361035c565b61064c5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000606482015260840161041a565b6106568383610ba0565b505050565b60108054610668906119ed565b80601f0160208091040260200160405190810160405280929190818152602001828054610694906119ed565b80156106df5780601f106106b6576101008083540402835291602001916106df565b820191905f5260205f20905b8154815290600101906020018083116106c257829003601f168201915b505050505081565b6106f13382610c0d565b61070d5760405162461bcd60e51b815260040161041a90611b29565b610656838383610c8a565b5f610722836108cd565b82106107845760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161041a565b506001600160a01b03919091165f908152600660209081526040808320938352929052205490565b600d6020525f908152604090208054610668906119ed565b61065683838360405180602001604052805f815250610982565b5f6107e860085490565b821061084b5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161041a565b6008828154811061085e5761085e611b76565b905f5260205f2001549050919050565b5f818152600260205260408120546001600160a01b0316806104835760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604482015260640161041a565b5f6001600160a01b0382166109365760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b606482015260840161041a565b506001600160a01b03165f9081526003602052604090205490565b610959610aab565b6109625f610df9565b565b6060600180546104a1906119ed565b61097e338383610e4a565b5050565b61098c3383610c0d565b6109a85760405162461bcd60e51b815260040161041a90611b29565b6109b484848484610f17565b50505050565b6109c2610aab565b601061097e8282611a69565b60606109d982610b42565b5f6109e2610f4a565b90505f815111610a005760405180602001604052805f815250610a2b565b80610a0a84610f59565b604051602001610a1b929190611b8a565b6040516020818303038152906040525b9392505050565b610a3a610aab565b6001600160a01b038116610a9f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161041a565b610aa881610df9565b50565b600a546001600160a01b031633146109625760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161041a565b61097e828260405180602001604052805f815250610fe9565b5f6001600160e01b0319821663780e9d6360e01b148061048357506104838261101b565b5f818152600260205260409020546001600160a01b0316610aa85760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604482015260640161041a565b5f81815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610bd48261086e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b5f80610c188361086e565b9050806001600160a01b0316846001600160a01b03161480610c5e57506001600160a01b038082165f9081526005602090815260408083209388168352929052205460ff165b80610c825750836001600160a01b0316610c7784610522565b6001600160a01b0316145b949350505050565b826001600160a01b0316610c9d8261086e565b6001600160a01b031614610cc35760405162461bcd60e51b815260040161041a90611bb8565b6001600160a01b038216610d255760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161041a565b610d32838383600161106a565b826001600160a01b0316610d458261086e565b6001600160a01b031614610d6b5760405162461bcd60e51b815260040161041a90611bb8565b5f81815260046020908152604080832080546001600160a01b03199081169091556001600160a01b038781168086526003855283862080545f1901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b816001600160a01b0316836001600160a01b031603610eab5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161041a565b6001600160a01b038381165f81815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b610f22848484610c8a565b610f2e84848484611076565b6109b45760405162461bcd60e51b815260040161041a90611bfd565b6060601080546104a1906119ed565b60605f610f6583611173565b60010190505f8167ffffffffffffffff811115610f8457610f846116af565b6040519080825280601f01601f191660200182016040528015610fae576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610fb857509392505050565b610ff3838361124a565b610fff5f848484611076565b6106565760405162461bcd60e51b815260040161041a90611bfd565b5f6001600160e01b031982166380ac58cd60e01b148061104b57506001600160e01b03198216635b5e139f60e01b145b8061048357506301ffc9a760e01b6001600160e01b0319831614610483565b6109b4848484846113df565b5f6001600160a01b0384163b1561116857604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906110b9903390899088908890600401611c4f565b6020604051808303815f875af19250505080156110f3575060408051601f3d908101601f191682019092526110f091810190611c8b565b60015b61114e573d808015611120576040519150601f19603f3d011682016040523d82523d5f602084013e611125565b606091505b5080515f036111465760405162461bcd60e51b815260040161041a90611bfd565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610c82565b506001949350505050565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106111b15772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106111dd576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106111fb57662386f26fc10000830492506010015b6305f5e1008310611213576305f5e100830492506008015b612710831061122757612710830492506004015b60648310611239576064830492506002015b600a83106104835760010192915050565b6001600160a01b0382166112a05760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161041a565b5f818152600260205260409020546001600160a01b0316156113045760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161041a565b6113115f8383600161106a565b5f818152600260205260409020546001600160a01b0316156113755760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161041a565b6001600160a01b0382165f81815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600181111561144e5760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b606482015260840161041a565b816001600160a01b0385166114a9576114a481600880545f838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6114cc565b836001600160a01b0316856001600160a01b0316146114cc576114cc8582611512565b6001600160a01b0384166114e8576114e3816115ab565b61150b565b846001600160a01b0316846001600160a01b03161461150b5761150b8482611652565b5050505050565b5f600161151e846108cd565b6115289190611ca6565b5f83815260076020526040902054909150808214611579576001600160a01b0384165f9081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b505f9182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008545f906115bc90600190611ca6565b5f83815260096020526040812054600880549394509092849081106115e3576115e3611b76565b905f5260205f2001549050806008838154811061160257611602611b76565b5f91825260208083209091019290925582815260099091526040808220849055858252812055600880548061163957611639611cc5565b600190038181905f5260205f20015f9055905550505050565b5f61165c836108cd565b6001600160a01b039093165f908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b80356001600160a01b03811681146116aa575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f67ffffffffffffffff808411156116dd576116dd6116af565b604051601f8501601f19908116603f01168101908282118183101715611705576117056116af565b8160405280935085815286868601111561171d575f80fd5b858560208301375f602087830101525050509392505050565b5f82601f830112611745575f80fd5b610a2b838335602085016116c3565b5f8060408385031215611765575f80fd5b61176e83611694565b9150602083013567ffffffffffffffff811115611789575f80fd5b61179585828601611736565b9150509250929050565b6001600160e01b031981168114610aa8575f80fd5b5f602082840312156117c4575f80fd5b8135610a2b8161179f565b5f5b838110156117e95781810151838201526020016117d1565b50505f910152565b5f81518084526118088160208601602086016117cf565b601f01601f19169290920160200192915050565b602081525f610a2b60208301846117f1565b5f6020828403121561183e575f80fd5b5035919050565b5f8060408385031215611856575f80fd5b61185f83611694565b946020939093013593505050565b5f805f6060848603121561187f575f80fd5b61188884611694565b925061189660208501611694565b9150604084013590509250925092565b5f602082840312156118b6575f80fd5b610a2b82611694565b5f602082840312156118cf575f80fd5b813567ffffffffffffffff8111156118e5575f80fd5b610c8284828501611736565b5f8060408385031215611902575f80fd5b61190b83611694565b91506020830135801515811461191f575f80fd5b809150509250929050565b5f805f806080858703121561193d575f80fd5b61194685611694565b935061195460208601611694565b925060408501359150606085013567ffffffffffffffff811115611976575f80fd5b8501601f81018713611986575f80fd5b611995878235602084016116c3565b91505092959194509250565b5f80604083850312156119b2575f80fd5b6119bb83611694565b91506119c960208401611694565b90509250929050565b5f82516119e38184602087016117cf565b9190910192915050565b600181811c90821680611a0157607f821691505b602082108103611a1f57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561065657805f5260205f20601f840160051c81016020851015611a4a5750805b601f840160051c820191505b8181101561150b575f8155600101611a56565b815167ffffffffffffffff811115611a8357611a836116af565b611a9781611a9184546119ed565b84611a25565b602080601f831160018114611aca575f8415611ab35750858301515b5f19600386901b1c1916600185901b178555611b21565b5f85815260208120601f198616915b82811015611af857888601518255948401946001909101908401611ad9565b5085821015611b1557878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b5f52603260045260245ffd5b5f8351611b9b8184602088016117cf565b835190830190611baf8183602088016117cf565b01949350505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b03858116825284166020820152604081018390526080606082018190525f90611c81908301846117f1565b9695505050505050565b5f60208284031215611c9b575f80fd5b8151610a2b8161179f565b8181038181111561048357634e487b7160e01b5f52601160045260245ffd5b634e487b7160e01b5f52603160045260245ffdfea2646970667358221220e5b22e4a3aaeeb43e6b53049e8cceb9475020f8ce72621973377c558dcd36a7d64736f6c6343000818003368747470733a2f2f706f6f6c70617274796e66742e616e76696c2e6170702f5f2f6170692f6d657461646174612f000000000000000000000000c70868f9e3bc5828827d190f5fac8a4bbbd5abee
Deployed Bytecode
0x608060405234801561000f575f80fd5b506004361061028c575f3560e01c80637b76ac9111610161578063ae660895116100ca578063d41ce4b111610084578063d41ce4b114610679578063dd62ed3e14610682578063e823e55f14610695578063eaf2caaa146106a8578063f2dd96e0146106bb578063fb9e6a2a14610760575f80fd5b8063ae660895146105f3578063b45540f41461061a578063b9de1f9c1461062d578063c27051c314610640578063c30f4a5a14610653578063ce2ba9bf14610666575f80fd5b8063a457c2d71161011b578063a457c2d714610580578063a9059cbb14610593578063aa3330b6146105a6578063aae00fbe146105c5578063aca0b6ce146105cd578063acefe02e146105e0575f80fd5b80637b76ac911461052e578063862882e51461053657806386495b041461054957806395d89b411461055c578063981b24d0146105645780639f9eba3514610577575f80fd5b80633595be6d116102035780635439ad86116101bd5780635439ad86146104ae5780635f483313146104b65780635fbacb2d146104c95780636b023bc8146104eb57806370a08231146104f3578063798c48a71461051b575f80fd5b80633595be6d14610423578063395093511461044e5780633bb09178146104615780634eb21696146104745780634ee2cd7e14610488578063519bf24e1461049b575f80fd5b80631633f1cb116102545780631633f1cb14610324578063174f8c34146103bc57806318160ddd146103e657806323b872dd146103ee5780632bd34b7d14610401578063313ce56714610414575f80fd5b806306fdde0314610290578063095ea7b3146102ae5780630cbe28d6146102d15780630d7c223f146102e65780631403829f146102fd575b5f80fd5b610298610773565b6040516102a59190612afe565b60405180910390f35b6102c16102bc366004612b24565b610803565b60405190151581526020016102a5565b6102e46102df366004612b4e565b61081c565b005b6102ef60165481565b6040519081526020016102a5565b6102ef7ffe1001d98a99b01293dcc713f45e6b3122511f8a6f8de820e04e660508d747b381565b610381610332366004612b24565b601360209081525f9283526040808420909152908252902080546001820154600283015460038401546004909401546001600160a01b0390931693919290919060ff8082169161010090041686565b604080516001600160a01b039097168752602087019590955293850192909252606084015215156080830152151560a082015260c0016102a5565b6102ef6103ca366004612b24565b601560209081525f928352604080842090915290825290205481565b6002546102ef565b6102c16103fc366004612b65565b6109f5565b6102e461040f366004612c54565b610a18565b604051601281526020016102a5565b600f54610436906001600160a01b031681565b6040516001600160a01b0390911681526020016102a5565b6102c161045c366004612b24565b610b72565b6102e461046f366004612cf8565b610b93565b600c546102c190600160a01b900460ff1681565b6102ef610496366004612b24565b610d29565b6102c16104a9366004612d3a565b610d80565b6102ef610dfb565b6102e46104c4366004612d84565b610e09565b6102c16104d7366004612db7565b600d6020525f908152604090205460ff1681565b6102e4611091565b6102ef610501366004612db7565b6001600160a01b03165f9081526020819052604090205490565b6102ef610529366004612dd2565b611103565b6102ef611143565b6102e4610544366004612d84565b61114c565b6102e4610557366004612b4e565b61138b565b61029861144b565b6102ef610572366004612b4e565b61145a565b6102ef60145481565b6102c161058e366004612b24565b611480565b6102c16105a1366004612b24565b6114fa565b6102ef6105b4366004612db7565b60126020525f908152604090205481565b6102e4611507565b6102e46105db366004612e15565b6115a4565b601054610436906001600160a01b031681565b6102ef7fc080050f7fa523e1ca454092bd721ecccc0252c67082bdfd3b7d6ab539a78d2081565b6102ef610628366004612e15565b61172c565b6102e461063b366004612db7565b6117bc565b6102ef61064e366004612b65565b611a3b565b6102e4610661366004612c54565b611b01565b6102e4610674366004612c54565b611b77565b6102ef60115481565b6102ef610690366004612e69565b611d6c565b6102c16106a3366004612ea0565b611d96565b600b54610436906001600160a01b031681565b61071f6106c9366004612c54565b80516020818301810180516017825292820191909301209152805460018201546002830154600384015460048501546005909501549394929391926001600160a01b039091169160ff8082169161010090041687565b604080519788526020880196909652948601939093526001600160a01b0390911660608501526080840152151560a0830152151560c082015260e0016102a5565b600c54610436906001600160a01b031681565b60606003805461078290612ee5565b80601f01602080910402602001604051908101604052809291908181526020018280546107ae90612ee5565b80156107f95780601f106107d0576101008083540402835291602001916107f9565b820191905f5260205f20905b8154815290600101906020018083116107dc57829003601f168201915b5050505050905090565b5f33610810818585611e18565b60019150505b92915050565b610824611f3c565b335f9081526013602090815260408083208484529091529020600481015460ff1615156001146108945760405162461bcd60e51b81526020600482015260166024820152752a3434b99039ba30b5b29036bab9ba1032bc34b9ba1760511b60448201526064015b60405180910390fd5b80600201546108a1611143565b116108ee5760405162461bcd60e51b815260206004820152601f60248201527f54686973207374616b65206973206e6f7420636f6d706c657465207965742e00604482015260640161088b565b6004810154610100900460ff16156109485760405162461bcd60e51b815260206004820152601d60248201527f54686973207374616b652077617320616c726561647920656e6465642e000000604482015260640161088b565b6109648160030154826001015461095f9190612f31565b611f95565b806001015460115f8282546109799190612f44565b909155505060048101805461ff001916610100179055600181015460028201546003830154604080519384526020840192909252908201526060810183905233907f1deb31f039e2645a4e97af07659090228d39e7f992bfaf37af3838ad9665e23a9060800160405180910390a2506109f26001600955565b50565b5f33610a02858285611f9f565b610a0d858585612011565b506001949350505050565b610a20611f3c565b60405163353791d960e11b8152738b39b9b6fee1854a585321fbd3b2bab49cfb23599033908290636a6f23b290610a5b908690600401612afe565b602060405180830381865afa158015610a76573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a9a9190612f57565b6001600160a01b031614610b165760405162461bcd60e51b815260206004820152603960248201527f53656e646572206d75737420626520746865206f776e6572206f66207468652060448201527f7469636b6572206e616d6520696e204e616d65436c61696d2e00000000000000606482015260840161088b565b5f610b2133846121be565b9050336001600160a01b03167fa53c02935736fbd1872c0fcd3656afcab41dab13824356904b8d86916356e40b8483604051610b5e929190612f72565b60405180910390a250506109f26001600955565b5f33610810818585610b848383611d6c565b610b8e9190612f31565b611e18565b610b9b611f3c565b600c54600160a01b900460ff16610c055760405162461bcd60e51b815260206004820152602860248201527f476976652074696d6520666f72206c69717569646974792066756e6420746f20604482015267062652073657475760c41b606482015260840161088b565b610c10823383611d96565b610c6e5760405162461bcd60e51b815260206004820152602960248201527f4d75737420626520656c696769626c65206164647265737320616e6420616d6f6044820152683ab73a103830b4b91760b91b606482015260840161088b565b335f908152600d602052604090205460ff1615610cbf5760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818db185a5b5959608a1b604482015260640161088b565b610cc881611f95565b335f818152600d602052604090819020805460ff19166001179055517f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688590610d139084815260200190565b60405180910390a2610d256001600955565b5050565b6001600160a01b0382165f90815260056020526040812081908190610d4f908590612234565b9150915081610d75576001600160a01b0385165f90815260208190526040902054610d77565b805b95945050505050565b5f808383604051602001610d9e929190918252602082015260400190565b60408051808303601f1901815282825280516020918201208184015281518084038201815292820190915281519101209050610d77857ffe1001d98a99b01293dcc713f45e6b3122511f8a6f8de820e04e660508d747b383612324565b5f610e04612339565b905090565b610e11611f3c565b5f601783604051610e229190612f93565b908152604051908190036020019020600581015490915060ff161515600114610ea15760405162461bcd60e51b815260206004820152602b60248201527f546869732061756374696f6e206d7573742068617665206265656e207374617260448201526a74656420616c726561647960a81b606482015260840161088b565b6005810154610100900460ff1615610f0b5760405162461bcd60e51b815260206004820152602760248201527f546869732061756374696f6e206d757374206e6f742068617665206265656e2060448201526632b73232b2171760c91b606482015260840161088b565b62989680816004015462a037a0610f229190612fae565b610f2c9190612fc5565b821015610f895760405162461bcd60e51b815260206004820152602560248201527f426964206d757374206265203525206c6172676572207468616e207072696f72604482015264103134b21760d91b606482015260840161088b565b8060020154421115610fcf5760405162461bcd60e51b815260206004820152600f60248201526e20bab1ba34b7b71034b99037bb32b960891b604482015260640161088b565b610168428260020154610fe29190612f44565b101561100357610168816002015f828254610ffd9190612f31565b90915550505b61100d3383612343565b6003810154600482015461102a916001600160a01b03169061247b565b600481018290556003810180546001600160a01b03191633908117909155428083556040517f4155205ee6ae19e622283dcaa46bc29ed1b902788b4ab7919a3150cb98c95e479161107e9187918791612fe4565b60405180910390a250610d256001600955565b611099611f3c565b600c546001600160a01b031633146110e45760405162461bcd60e51b815260206004820152600e60248201526d13db9b1e481b1a599959dd585c9960921b604482015260640161088b565b600c805460ff60a01b1916600160a01b1790556111016001600955565b565b5f80835b83811161113757611119878783611a3b565b6111239083612f31565b91508061112f81613008565b915050611107565b5090505b949350505050565b5f610e04612543565b611154611f3c565b60405163353791d960e11b81525f90738b39b9b6fee1854a585321fbd3b2bab49cfb235990636a6f23b29061118d908690600401612afe565b602060405180830381865afa1580156111a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111cc9190612f57565b6001600160a01b0316146112225760405162461bcd60e51b815260206004820152601a60248201527f4e616d65206d757374206e6f742062652072657365727665642e000000000000604482015260640161088b565b5f6017836040516112339190612f93565b908152604051908190036020019020600581015490915060ff161561129a5760405162461bcd60e51b815260206004820181905260248201527f546869732061756374696f6e2068617320616c72656164792073746172746564604482015260640161088b565b6016548210156113025760405162461bcd60e51b815260206004820152602d60248201527f4d757374206265206c6172676572207468616e20746865206d696e696d756d2060448201526c39ba30b93a34b733903134b21760991b606482015260840161088b565b61130c3383612343565b60058101805460ff19166001908117909155600482018390556003820180546001600160a01b03191633179055429082018190558082556113509062015180612f31565b600282015560405133907f188ca2341cb9d0cffff3f6ae500f2640ca09feeb2f47ce508ac07c9564f9bb589061107e90869086904290612fe4565b600c546001600160a01b031633146113e55760405162461bcd60e51b815260206004820181905260248201527f4f6e6c7920746865206c6966656775617264206d61792072756e20746869732e604482015260640161088b565b60165481106114465760405162461bcd60e51b815260206004820152602760248201527f4d696e696d756d207374617274696e67206269642063616e206f6e6c7920646560448201526631b932b0b9b29760c91b606482015260840161088b565b601655565b60606004805461078290612ee5565b5f805f611468846006612234565b91509150816114795760025461113b565b9392505050565b5f338161148d8286611d6c565b9050838110156114ed5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161088b565b610a0d8286868403611e18565b5f33610810818585612011565b61150f611f3c565b5f611518611143565b9050601454600e6115299190612f31565b811161158e5760405162461bcd60e51b815260206004820152602e60248201527f536e617073686f742063616e206f6e6c792062652074616b656e206f6e63652060448201526d32bb32b93c9019103bb2b2b5b99760911b606482015260840161088b565b611596612560565b506014556111016001600955565b6115ac611f3c565b335f90815260126020526040812054906115c4611143565b6115ce9086612f31565b6115d9906001612f31565b90505f6115e88787878761172c565b6040805160c0810182523380825260208083018c8152838501888152606085018781526001608087018181525f60a08901818152888252601388528a82208f835288528a822099518a546001600160a01b0319166001600160a01b03909116178a559551898401559351600289015591516003880155905160049096018054935161ffff1990941696151561ff00191696909617610100931515939093029290921790945591835260129052918120805493945091926116a9908490612f31565b909155506116b990503388612343565b8660115f8282546116ca9190612f31565b909155505060408051888152602081018490529081018290526060810184905233907f89ad62c709031f6892a90b222612bc408f6b5e86c21c30c12d010ba59f21db269060800160405180910390a25050506117266001600955565b50505050565b5f61146885116117905760405162461bcd60e51b815260206004820152602960248201527f4d757374206265206c6172676572207468616e206d696e696d756d207374616b604482015268329030b6b7bab73a1760b91b606482015260840161088b565b61179b838584610d80565b6117a3575f80fd5b6305f5e1006117b28387612fae565b610d779190612fc5565b6117c4611f3c565b6040516370a0823160e01b815230600482015281905f906001600160a01b038316906370a0823190602401602060405180830381865afa15801561180a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061182e9190613020565b90505f811161186d5760405162461bcd60e51b815260206004820152600b60248201526a3737903130b630b731b29760a91b604482015260640161088b565b6010546040516370a0823160e01b81526001600160a01b0391821660048201819052915f91908516906370a0823190602401602060405180830381865afa1580156118ba573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118de9190613020565b6010549091506118fb906001600160a01b038681169116856125b8565b5f611904610dfb565b6040516370a0823160e01b81526001600160a01b0385811660048301529192505f918491908816906370a0823190602401602060405180830381865afa158015611950573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119749190613020565b61197e9190612f44565b90505f61198c836001612f31565b6001600160a01b0389165f9081526015602090815260408083208484529091528120805492935084929091906119c3908490612f31565b90915550506001600160a01b0388165f8181526015602090815260408083208584528252918290205482519384529083018590529082015283907f64ad25ad7ba7ca43c3f48a15dccd75a7981b14982aa6300dfe9f437a37a9d1e09060600160405180910390a2505050505050506109f26001600955565b5f611a44610dfb565b821115611a935760405162461bcd60e51b815260206004820152601b60248201527f506572696f6420486173204e6f742048617070656e6564205965740000000000604482015260640161088b565b611a9c8261145a565b611aae90670de0b6b3a7640000612fae565b611ab88584610d29565b6001600160a01b0385165f908152601560209081526040808320878452909152902054611aed90670de0b6b3a7640000612fae565b611af79190612fae565b61113b9190612fc5565b600c546001600160a01b03163314611b17575f80fd5b600e54604051636187a52d60e11b81526001600160a01b039091169063c30f4a5a90611b47908490600401612afe565b5f604051808303815f87803b158015611b5e575f80fd5b505af1158015611b70573d5f803e3d5ffd5b5050505050565b611b7f611f3c565b5f601782604051611b909190612f93565b908152604051908190036020019020600581015490915060ff161515600114611c065760405162461bcd60e51b815260206004820152602260248201527f41756374696f6e206d757374206861766520616c726561647920737461727465604482015261321760f11b606482015260840161088b565b80600201544211611c595760405162461bcd60e51b815260206004820152601c60248201527f41756374696f6e206d757374206265206f76657220746f20656e642e00000000604482015260640161088b565b6005810154610100900460ff1615611cb35760405162461bcd60e51b815260206004820152601f60248201527f41756374696f6e2068617320616c7265616479206265656e20656e6465642e00604482015260640161088b565b60058101805461ff00191661010017905560038101545f90611cde906001600160a01b0316846121be565b600383015460048401546040519293506001600160a01b039091169133917f9378576c306cb4d9bb218b037bbcb6249fe379ce5807b1cb91907c9d5f22372691611d29918891612f72565b60405180910390a3336001600160a01b03167fa53c02935736fbd1872c0fcd3656afcab41dab13824356904b8d86916356e40b8483604051610b5e929190612f72565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b604080516001600160a01b03841660208201529081018290525f90819060600160408051601f1981840301815282825280516020918201209083015201604051602081830303815290604052805190602001209050610d77857fc080050f7fa523e1ca454092bd721ecccc0252c67082bdfd3b7d6ab539a78d205f1b83612324565b6001600160a01b038316611e7a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161088b565b6001600160a01b038216611edb5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161088b565b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b600260095403611f8e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161088b565b6002600955565b6109f2338261247b565b5f611faa8484611d6c565b90505f19811461172657818110156120045760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161088b565b6117268484848403611e18565b6001600160a01b0383166120755760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161088b565b6001600160a01b0382166120d75760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161088b565b6120e283838361260a565b6001600160a01b0383165f90815260208190526040902054818110156121595760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161088b565b6001600160a01b038481165f81815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3611726565b600e54604051630192f8bb60e01b81525f9182916001600160a01b0390911690630192f8bb906121f49087908790600401613037565b6020604051808303815f875af1158015612210573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061113b9190613020565b5f805f841161227e5760405162461bcd60e51b815260206004820152601660248201527504552433230536e617073686f743a20696420697320360541b604482015260640161088b565b612286612339565b8411156122d55760405162461bcd60e51b815260206004820152601d60248201527f4552433230536e617073686f743a206e6f6e6578697374656e74206964000000604482015260640161088b565b5f6122e08486612615565b845490915081036122f7575f80925092505061231d565b600184600101828154811061230e5761230e61305a565b905f5260205f20015492509250505b9250929050565b5f8261233085846126b1565b14949350505050565b5f610e0460085490565b6001600160a01b0382166123a35760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161088b565b6123ae825f8361260a565b6001600160a01b0382165f90815260208190526040902054818110156124215760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161088b565b6001600160a01b0383165f818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101611f2f565b505050565b6001600160a01b0382166124d15760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161088b565b6124dc5f838361260a565b8060025f8282546124ed9190612f31565b90915550506001600160a01b0382165f81815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b5f62015180600a54426125569190612f44565b610e049190612fc5565b5f61256f600880546001019055565b5f612578612339565b90507f8030e83b04d87bef53480e26263266d6ca66863aa8506aca6f2559d18aa1cb67816040516125ab91815260200190565b60405180910390a1919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526124769084906126f3565b6124768383836127c4565b81545f90810361262657505f610816565b82545f905b8082101561266e575f61263e838361280c565b90508461264b8783612826565b54111561265a57809150612668565b612665816001612f31565b92505b5061262b565b5f8211801561269057508361268d86612688600186612f44565b612826565b54145b156126a9576126a0600183612f44565b92505050610816565b509050610816565b5f81815b84518110156126eb576126e1828683815181106126d4576126d461305a565b6020026020010151612836565b91506001016126b5565b509392505050565b5f612747826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166128629092919063ffffffff16565b8051909150156124765780806020019051810190612765919061306e565b6124765760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161088b565b6001600160a01b0383166127e3576127db82612870565b6124766128a1565b6001600160a01b0382166127fa576127db83612870565b61280383612870565b61247682612870565b5f61281a6002848418612fc5565b61147990848416612f31565b5f8281526020812082018061113b565b5f818310612850575f828152602084905260409020611479565b5f838152602083905260409020611479565b606061113b84845f856128af565b6001600160a01b0381165f90815260056020908152604080832091839052909120546109f29190612986565b612986565b611101600661289c60025490565b6060824710156129105760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161088b565b5f80866001600160a01b0316858760405161292b9190612f93565b5f6040518083038185875af1925050503d805f8114612965576040519150601f19603f3d011682016040523d82523d5f602084013e61296a565b606091505b509150915061297b878383876129ce565b979650505050505050565b5f61298f612339565b90508061299b84612a46565b1015612476578254600180820185555f858152602080822090930193909355938401805494850181558252902090910155565b60608315612a3c5782515f03612a35576001600160a01b0385163b612a355760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161088b565b508161113b565b61113b8383612a87565b80545f908103612a5757505f919050565b81548290612a6790600190612f44565b81548110612a7757612a7761305a565b905f5260205f2001549050919050565b815115612a975781518083602001fd5b8060405162461bcd60e51b815260040161088b9190612afe565b5f5b83811015612acb578181015183820152602001612ab3565b50505f910152565b5f8151808452612aea816020860160208601612ab1565b601f01601f19169290920160200192915050565b602081525f6114796020830184612ad3565b6001600160a01b03811681146109f2575f80fd5b5f8060408385031215612b35575f80fd5b8235612b4081612b10565b946020939093013593505050565b5f60208284031215612b5e575f80fd5b5035919050565b5f805f60608486031215612b77575f80fd5b8335612b8281612b10565b92506020840135612b9281612b10565b929592945050506040919091013590565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612be057612be0612ba3565b604052919050565b5f82601f830112612bf7575f80fd5b813567ffffffffffffffff811115612c1157612c11612ba3565b612c24601f8201601f1916602001612bb7565b818152846020838601011115612c38575f80fd5b816020850160208301375f918101602001919091529392505050565b5f60208284031215612c64575f80fd5b813567ffffffffffffffff811115612c7a575f80fd5b61113b84828501612be8565b5f82601f830112612c95575f80fd5b8135602067ffffffffffffffff821115612cb157612cb1612ba3565b8160051b612cc0828201612bb7565b9283528481018201928281019087851115612cd9575f80fd5b83870192505b8483101561297b57823582529183019190830190612cdf565b5f8060408385031215612d09575f80fd5b823567ffffffffffffffff811115612d1f575f80fd5b612d2b85828601612c86565b95602094909401359450505050565b5f805f60608486031215612d4c575f80fd5b833567ffffffffffffffff811115612d62575f80fd5b612d6e86828701612c86565b9660208601359650604090950135949350505050565b5f8060408385031215612d95575f80fd5b823567ffffffffffffffff811115612dab575f80fd5b612d2b85828601612be8565b5f60208284031215612dc7575f80fd5b813561147981612b10565b5f805f8060808587031215612de5575f80fd5b8435612df081612b10565b93506020850135612e0081612b10565b93969395505050506040820135916060013590565b5f805f8060808587031215612e28575f80fd5b8435935060208501359250604085013567ffffffffffffffff811115612e4c575f80fd5b612e5887828801612c86565b949793965093946060013593505050565b5f8060408385031215612e7a575f80fd5b8235612e8581612b10565b91506020830135612e9581612b10565b809150509250929050565b5f805f60608486031215612eb2575f80fd5b833567ffffffffffffffff811115612ec8575f80fd5b612ed486828701612c86565b9350506020840135612b9281612b10565b600181811c90821680612ef957607f821691505b602082108103612f1757634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561081657610816612f1d565b8181038181111561081657610816612f1d565b5f60208284031215612f67575f80fd5b815161147981612b10565b604081525f612f846040830185612ad3565b90508260208301529392505050565b5f8251612fa4818460208701612ab1565b9190910192915050565b808202811582820484141761081657610816612f1d565b5f82612fdf57634e487b7160e01b5f52601260045260245ffd5b500490565b606081525f612ff66060830186612ad3565b60208301949094525060400152919050565b5f6001820161301957613019612f1d565b5060010190565b5f60208284031215613030575f80fd5b5051919050565b6001600160a01b03831681526040602082018190525f9061113b90830184612ad3565b634e487b7160e01b5f52603260045260245ffd5b5f6020828403121561307e575f80fd5b81518015158114611479575f80fdfea2646970667358221220feb93cd5bb16e65b2eea3625d8a96ac29b90dc9b4275a7133905a91bfc42faa864736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c70868f9e3bc5828827d190f5fac8a4bbbd5abee
-----Decoded View---------------
Arg [0] : liquidity_fund_address (address): 0xc70868F9E3BC5828827D190F5fAC8a4bBbd5abEE
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000c70868f9e3bc5828827d190f5fac8a4bbbd5abee
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.