Contract Overview
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Latest 1 internal transaction
Parent Txn Hash | Block | From | To | Value | |||
---|---|---|---|---|---|---|---|
0xcc2101aace2ea6893fb23a6b0b33eaa328f5f9385e8c3358ab5619db10ceaf52 | 8483264 | 13 days 6 hrs ago | 0x09339714ebd314d0a7c8db4f657d7f7351a39226 | Contract Creation | 0 CRO |
[ Download CSV Export ]
Contract Name:
CandyPartnerFarm
Compiler Version
v0.8.11+commit.d7f03943
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >=0.8.11; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "./BaseFarmAttributes.sol"; contract CandyPartnerFarm is BaseFarmAttributes, ReentrancyGuard, IERC721Receiver { using UniversalERC20 for IERC20; using EnumerableSet for EnumerableSet.UintSet; struct UserInfo { uint256 amount; // How many staked tokens the user has provided uint256 rewardDebt; // Reward debt EnumerableSet.UintSet nfts; } /// @notice The address of the smart chef factory address public immutable FACTORY_CONTRACT; /// @notice User info mapping(address => UserInfo) private _userInfo; /** * @notice Constructor */ constructor() { FACTORY_CONTRACT = msg.sender; } /// @notice Initialize the contract /// @dev Only factory contract can call this function /// @param addresses_ abi encoded value of following addresses /// admin account /// staking token /// reward token /// boosting nft /// treasury account /// @param uint256Datas_ abi encoded value of following uint256 datas /// reward per block /// start block /// end block /// max token per user /// @param uint16Datas_ abi encoded value of following uint16 datas /// deposit fee /// max nft per user /// boosting rate function initialize( bytes calldata addresses_, bytes calldata uint256Datas_, bytes calldata uint16Datas_ ) external { require(!isInitialized, "Already initialized"); require(msg.sender == FACTORY_CONTRACT, "Not factory"); // Make this contract initialized isInitialized = true; _initializeUint256Datas(uint256Datas_); _initializeUint16Datas(uint16Datas_); _initializeAddresses(addresses_); } /// @notice Deposit tokens and nfts /// @dev If there are available rewards, it is transferred to the account function stake( uint256 tokenAmount_, uint256[] calldata nftIds_ ) external nonReentrant { updatePool(); UserInfo storage user = _userInfo[_msgSender()]; uint256 userTokenAmount = user.amount; uint256 userNftAmount = user.nfts.length(); uint256 userBoostedShare = _boostedShare( userTokenAmount, userNftAmount ); if (userBoostedShare > 0) { uint256 pending = (userBoostedShare * accTokenPerShare) / PRECISION_FACTOR - user.rewardDebt; IERC20(rewardToken).universalTransfer(_msgSender(), pending); emit Harvested(_msgSender(), pending); } uint256 nftAmountToStake = nftIds_.length; if (tokenAmount_ > 0 || nftAmountToStake > 0) { uint256 totalBoostedShare_ = totalBoostedShare; // gas-saving code totalBoostedShare_ -= userBoostedShare; if (tokenAmount_ > 0) { tokenAmount_ = IERC20(stakingToken) .universalTransferFromSenderToThis(tokenAmount_); uint256 feeAmount = (tokenAmount_ * depositFee) / FEE_UNIT; if (feeAmount > 0) { IERC20(stakingToken).universalTransfer(treasury, feeAmount); tokenAmount_ -= feeAmount; } userTokenAmount += tokenAmount_; require( tokenLimitPerUser == 0 || userTokenAmount <= tokenLimitPerUser, "Over token staking limit" ); user.amount = userTokenAmount; totalStakedToken += tokenAmount_; } if (nftAmountToStake > 0) { userNftAmount += nftAmountToStake; require( nftLimitPerUser == 0 || userNftAmount <= nftLimitPerUser, "Over nft staking limit" ); uint256 index; for (; index < nftAmountToStake; index++) { IERC721(boosterNft).safeTransferFrom( _msgSender(), address(this), nftIds_[index] ); user.nfts.add(nftIds_[index]); } totalStakedNft += nftAmountToStake; } userBoostedShare = _boostedShare(userTokenAmount, userNftAmount); totalBoostedShare_ += userBoostedShare; totalBoostedShare = totalBoostedShare_; } user.rewardDebt = (userBoostedShare * accTokenPerShare) / PRECISION_FACTOR; emit Staked(_msgSender(), uint16(nftAmountToStake), tokenAmount_); } /// @notice Withdraw staked tokens and collect reward tokens function withdraw( uint256 tokenAmount_, uint256[] calldata nftIds_ ) external nonReentrant { updatePool(); UserInfo storage user = _userInfo[msg.sender]; uint256 userTokenAmount = user.amount; uint256 userNftAmount = user.nfts.length(); uint256 userBoostedShare = _boostedShare( userTokenAmount, userNftAmount ); if (userBoostedShare > 0) { uint256 pending = (userBoostedShare * accTokenPerShare) / PRECISION_FACTOR - user.rewardDebt; IERC20(rewardToken).universalTransfer(_msgSender(), pending); emit Harvested(_msgSender(), pending); } uint256 nftAmountToWithdraw = nftIds_.length; if (tokenAmount_ > 0 || nftAmountToWithdraw > 0) { uint256 totalBoostedShare_ = totalBoostedShare; // gas-saving code totalBoostedShare_ -= userBoostedShare; if (tokenAmount_ > 0) { IERC20(stakingToken).universalTransfer( _msgSender(), tokenAmount_ ); userTokenAmount -= tokenAmount_; user.amount = userTokenAmount; totalStakedToken -= tokenAmount_; } if (nftAmountToWithdraw > 0) { uint256 index; for (; index < nftAmountToWithdraw; index++) { require(user.nfts.remove(nftIds_[index]), "Not owned nft"); IERC721(boosterNft).safeTransferFrom( address(this), _msgSender(), nftIds_[index] ); } userNftAmount -= nftAmountToWithdraw; totalStakedNft -= nftAmountToWithdraw; } userBoostedShare = _boostedShare(userTokenAmount, userNftAmount); totalBoostedShare_ += userBoostedShare; totalBoostedShare = totalBoostedShare_; } user.rewardDebt = (userBoostedShare * accTokenPerShare) / PRECISION_FACTOR; emit Withdrawn(_msgSender(), uint16(nftAmountToWithdraw), tokenAmount_); } /// @notice Withdraw staked tokens and boosting nfts without harvesting rewards /// @dev Needs to be for emergency. function emergencyWithdraw() external nonReentrant { UserInfo storage user = _userInfo[msg.sender]; uint256 userTokenAmount = user.amount; uint256 userNftAmount = user.nfts.length(); uint256 userBoostedShare = _boostedShare( userTokenAmount, userNftAmount ); totalBoostedShare -= userBoostedShare; if (userTokenAmount > 0) { IERC20(stakingToken).universalTransfer( _msgSender(), userTokenAmount ); user.amount = 0; totalStakedToken -= userTokenAmount; } if (userNftAmount > 0) { uint256 index; uint256[] memory userNfts = user.nfts.values(); for (; index < userNftAmount; index++) { IERC721(boosterNft).safeTransferFrom( address(this), _msgSender(), userNfts[index] ); user.nfts.remove(userNfts[index]); } totalStakedNft -= userNftAmount; } user.rewardDebt = 0; emit EmergencyWithdrawn( _msgSender(), uint16(userNftAmount), userTokenAmount ); } /// @notice Calculate boosted share from the token amount and nft amount function _boostedShare( uint256 tokenAmount_, uint256 nftAmount_ ) internal view returns (uint256) { return (tokenAmount_ * (FEE_UNIT + nftAmount_ * boostRate)) / FEE_UNIT; } /// @notice View current user info /// @return tokenAmount User staked token amount /// @return nftAmount User staked boosting nft amount /// @return boostedShare Boosted share calculated from user's staked token and nfts function viewUserInfo( address account_ ) external view returns (uint256 tokenAmount, uint256 nftAmount, uint256 boostedShare) { UserInfo storage user = _userInfo[account_]; tokenAmount = user.amount; nftAmount = user.nfts.length(); boostedShare = _boostedShare(tokenAmount, nftAmount); } /// @notice View user staked nft ids /// @dev This function is paginated because staked nft amount might be too big to fetch at once function viewUserNfts( address account_, uint16 offset_, uint16 count_ ) external view returns (uint256[] memory nfts) { UserInfo storage user = _userInfo[account_]; uint16 nftAmount = uint16(user.nfts.length()); uint256[] memory userNfts = user.nfts.values(); if (offset_ > nftAmount) offset_ = nftAmount; if (offset_ + count_ > nftAmount) count_ = nftAmount - offset_; nfts = new uint256[](count_); uint16 i; for (; i < count_; i++) nfts[i] = userNfts[offset_ + i]; } /// @notice Get current pending reward of given `account_` function pendingReward(address account_) external view returns (uint256) { UserInfo storage user = _userInfo[account_]; uint256 adjustedTokenPerShare = accTokenPerShare; uint256 userTokenAmount = user.amount; uint256 userNftAmount = user.nfts.length(); uint256 userBoostedShare = _boostedShare( userTokenAmount, userNftAmount ); if (block.number > lastRewardBlock && totalBoostedShare != 0) { uint256 multiplier = _getMultiplier(lastRewardBlock, block.number); uint256 rewardAmount = multiplier * rewardPerBlock; adjustedTokenPerShare += (rewardAmount * PRECISION_FACTOR) / totalBoostedShare; } return (userBoostedShare * adjustedTokenPerShare) / PRECISION_FACTOR - user.rewardDebt; } /// @notice Update reward variables of the given pool to be up-to-date function updatePool() public { uint256 lastRewardBlock_ = lastRewardBlock; // Gas-saving code if (block.number <= lastRewardBlock_) return; uint256 totalBoostedShare_ = totalBoostedShare; // Gas-saving code if (totalBoostedShare_ == 0) { lastRewardBlock = block.number; return; } uint256 multiplier = _getMultiplier(lastRewardBlock_, block.number); uint256 rewardAmount = multiplier * rewardPerBlock; accTokenPerShare += (rewardAmount * PRECISION_FACTOR) / totalBoostedShare_; lastRewardBlock = block.number; } /// @notice Return reward multiplier over the given from_ - to_ block. /// @param from_: block to start /// @param to_: block to finish function _getMultiplier( uint256 from_, uint256 to_ ) internal view returns (uint256) { if (to_ <= endBlock) return to_ - from_; if (from_ >= endBlock) return 0; return endBlock - from_; } /// @notice Emergency reward withdraw from the contract /// @dev Only owner is allowed to call this function function emergencyRewardWithdraw(uint256 amount_) external onlyOwner { IERC20(rewardToken).universalTransfer(_msgSender(), amount_); } /// @notice Allows the owner to recover tokens sent to the contract by mistake /// @param token_: token address /// @dev Callable by owner function recoverToken(address token_) external onlyOwner { require( token_ != stakingToken && token_ != rewardToken, "Unpermitted token address" ); uint256 balance = IERC20(token_).universalBalanceOf(address(this)); IERC20(token_).universalTransfer(_msgSender(), balance); } /// @notice To recieve ETH receive() external payable {} function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.11; import "@openzeppelin/contracts/access/Ownable.sol"; import "../libs/UniversalERC20.sol"; contract BaseFarmAttributes is Ownable { using UniversalERC20 for IERC20; uint16 public constant MAX_DEPOSIT_FEE = 2000; uint16 public constant FEE_UNIT = 10000; /// @notice The reward token address public rewardToken; /// @notice The staking token address public stakingToken; /// @notice The boosting nft address public boosterNft; /// @notice Treasury account which deposit fee is sent to address public treasury; /// @notice Whether it is initialized bool public isInitialized; /// @notice Deposit fee uint16 public depositFee; /// @notice Nft boosting percentage uint16 public boostRate; /// @notice Max boostable nft amount per user uint16 public nftLimitPerUser; /// @notice The pool limit (0 if none) uint256 public tokenLimitPerUser; /// @notice Reward distributed per block uint256 public rewardPerBlock; /// @notice Accrued token per share uint256 public accTokenPerShare; /// @notice The block number when reward distribution ends uint256 public endBlock; /// @notice The block number when reward distribution starts uint256 public startBlock; /// @notice The block number of the last pool update uint256 public lastRewardBlock; /// @notice Total staked token amount uint256 public totalStakedToken; /// @notice Total staked nft amount uint256 public totalStakedNft; /// @notice The total amount of boosted user shares uint256 public totalBoostedShare; /// @notice The precision factor uint256 public PRECISION_FACTOR; event Harvested(address account, uint256 amount); event Staked(address account, uint16 nftAmount, uint256 tokenAmount); event Withdrawn(address account, uint16 nftAmount, uint256 tokenAmount); event EmergencyWithdrawn( address account, uint16 nftAmount, uint256 tokenAmount ); event EndBlockUpdated(uint256 blockNumber); event StartBlockUpdated(uint256 blockNumber); event EmissionRateUpdated(uint256 emission); event TreasuryAccountUpdated(address account); event DepositFeeUpdated(uint16 fee); event BoostRateUpdated(uint16 rate); event NftLimitPerUserUpdated(uint16 limit); event TokenLimitPerUserUpdated(uint256 limit); /// @notice Initialize uint256 variables function _initializeUint256Datas(bytes memory uint256Datas_) internal { ( uint256 emission_, uint256 startBlock_, uint256 endBlock_, uint256 tokenLimitPerUser_ ) = abi.decode(uint256Datas_, (uint256, uint256, uint256, uint256)); require(emission_ > 0, "Invalid emission"); require( startBlock_ < endBlock_, "Start block must be before end block" ); require(startBlock_ > block.number, "Unable to set past block"); rewardPerBlock = emission_; startBlock = startBlock_; endBlock = endBlock_; tokenLimitPerUser = tokenLimitPerUser_; // Set the lastRewardBlock as the startBlock lastRewardBlock = startBlock_; } /// @notice Initialize uint16 variables function _initializeUint16Datas(bytes memory uint16Datas_) internal { (uint16 depositFee_, uint16 nftLimitPerUser_, uint16 boostRate_) = abi .decode(uint16Datas_, (uint16, uint16, uint16)); require(depositFee_ <= MAX_DEPOSIT_FEE, "Too much deposit fee"); depositFee = depositFee_; nftLimitPerUser = nftLimitPerUser_; boostRate = boostRate_; } /// @notice Initialize address variables function _initializeAddresses(bytes memory addresses_) internal { ( address admin_, address stakingToken_, address rewardToken_, address boosterNft_, address treasury_ ) = abi.decode( addresses_, (address, address, address, address, address) ); require(treasury_ != address(0), "Invalid treasury"); stakingToken = stakingToken_; rewardToken = rewardToken_; boosterNft = boosterNft_; treasury = treasury_; uint256 decimalsRewardToken = IERC20(rewardToken_).universalDecimals(); PRECISION_FACTOR = uint256(10 ** (30 - decimalsRewardToken)); // Transfer ownership to the admin address who becomes owner of the contract transferOwnership(admin_); } /// @notice Update treasury address /// @dev Only owner is allowed to call this function function updateTreasury(address treasury_) external onlyOwner { require(treasury_ != address(0), "Invalid address"); require(treasury != treasury_, "Nothing changed"); treasury = treasury_; emit TreasuryAccountUpdated(treasury_); } /// @notice Update deposit fee /// @dev Only owner is allowed to call this function function updateDepositFee(uint16 fee_) external onlyOwner { require(fee_ <= MAX_DEPOSIT_FEE, "Too much fee"); require(depositFee != fee_, "Nothing changed"); depositFee = fee_; emit DepositFeeUpdated(fee_); } /// @notice Update nft boosting percentage /// @dev Only owner is allowed to call this function function updateBoostRate(uint16 rate_) external onlyOwner { require(boostRate != rate_, "Nothing changed"); boostRate = rate_; emit BoostRateUpdated(rate_); } /// @notice Update booster nft staking limit per user /// @dev Only owner is allowed to call this function function updateNftLimitPerUser(uint16 limit_) external onlyOwner { require(nftLimitPerUser != limit_, "Nothing changed"); nftLimitPerUser = limit_; emit NftLimitPerUserUpdated(limit_); } /// @notice Update token staking limit per user /// @dev Only owner is allowed to call this function function updateTokenLimitPerUser(uint256 limit_) external onlyOwner { require(tokenLimitPerUser != limit_, "Nothing changed"); tokenLimitPerUser = limit_; emit TokenLimitPerUserUpdated(limit_); } /// @notice Update reward per block /// @dev Only callable by owner. /// @param emission_: the reward per block function updateRewardPerBlock(uint256 emission_) external onlyOwner { require(emission_ > 0, "Invalid emission"); require(rewardPerBlock != emission_, "Nothing changed"); rewardPerBlock = emission_; emit EmissionRateUpdated(emission_); } /// @notice Update start block number /// @dev Only owner is allowed to call this function function updateStartBlock(uint256 block_) external onlyOwner { require(startBlock > block.number, "Already started"); require(block_ > block.number, "Unable to set past block"); require(block_ < endBlock, "Must be before end block"); require(startBlock != block_, "Nothing changed"); startBlock = block_; // Set the lastRewardBlock as the startBlock lastRewardBlock = block_; emit StartBlockUpdated(block_); } /// @notice Update end block number /// @dev Only owner is allowed to call this function function updateEndBlock(uint256 block_) external onlyOwner { require(block_ > block.number, "Unable to set past block"); require(block_ > startBlock, "Must be after start block"); require(endBlock != block_, "Nothing changed"); endBlock = block_; emit EndBlockUpdated(block_); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev 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 (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.7.0) (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; // File: contracts/UniversalERC20.sol import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; library UniversalERC20 { using SafeERC20 for IERC20; using Address for address payable; IERC20 private constant ZERO_ADDRESS = IERC20(0x0000000000000000000000000000000000000000); IERC20 private constant ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); function universalTransfer( IERC20 token, address to, uint256 amount ) internal returns (uint256) { if (amount == 0) { return 0; } if (isETH(token)) { payable(address(uint160(to))).sendValue(amount); return amount; } else { uint256 balanceBefore = token.balanceOf(to); token.safeTransfer(to, amount); uint256 balanceAfter = token.balanceOf(to); return balanceAfter - balanceBefore; } } function universalTransferFrom( IERC20 token, address from, address to, uint256 amount ) internal returns (uint256) { if (amount == 0) { return 0; } if (isETH(token)) { require( from == msg.sender && msg.value >= amount, "Wrong usage of ETH.universalTransferFrom" ); if (to != address(this)) { payable(address(uint160(to))).sendValue(amount); } if (msg.value > amount) { // refund redundant amount payable(msg.sender).sendValue(msg.value - amount); } return amount; } else { uint256 balanceBefore = token.balanceOf(to); token.safeTransferFrom(from, to, amount); uint256 balanceAfter = token.balanceOf(to); return balanceAfter - balanceBefore; } } function universalTransferFromSenderToThis(IERC20 token, uint256 amount) internal returns (uint256) { if (amount == 0) { return 0; } if (isETH(token)) { require( msg.value >= amount, "Wrong usage of ETH.universalTransferFromSenderToThis" ); if (msg.value > amount) { // Return remainder if exist payable(msg.sender).sendValue(msg.value - amount); } return amount; } else { uint256 balanceBefore = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), amount); uint256 balanceAfter = token.balanceOf(address(this)); return balanceAfter - balanceBefore; } } function universalApprove( IERC20 token, address to, uint256 amount ) internal { if (!isETH(token)) { if (amount > 0 && token.allowance(address(this), to) > 0) { token.safeApprove(to, 0); } token.safeApprove(to, amount); } } function universalBalanceOf(IERC20 token, address who) internal view returns (uint256) { if (isETH(token)) { return who.balance; } else { return token.balanceOf(who); } } function universalDecimals(IERC20 token) internal view returns (uint256) { if (isETH(token)) { return 18; } (bool success, bytes memory data) = address(token).staticcall{ gas: 10000 }(abi.encodeWithSignature("decimals()")); if (!success || data.length == 0) { (success, data) = address(token).staticcall{gas: 10000}( abi.encodeWithSignature("DECIMALS()") ); } return (success && data.length > 0) ? abi.decode(data, (uint256)) : 18; } function isETH(IERC20 token) internal pure returns (bool) { return (address(token) == address(ZERO_ADDRESS) || address(token) == address(ETH_ADDRESS)); } }
// 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.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @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 (last updated v4.7.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.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 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 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 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); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "solmate/=lib/solmate/src/" ], "libraries": {} }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"rate","type":"uint16"}],"name":"BoostRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"fee","type":"uint16"}],"name":"DepositFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint16","name":"nftAmount","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"EmergencyWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"emission","type":"uint256"}],"name":"EmissionRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"EndBlockUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Harvested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"limit","type":"uint16"}],"name":"NftLimitPerUserUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint16","name":"nftAmount","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"StartBlockUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"limit","type":"uint256"}],"name":"TokenLimitPerUserUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"TreasuryAccountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint16","name":"nftAmount","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"FACTORY_CONTRACT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_UNIT","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_DEPOSIT_FEE","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION_FACTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accTokenPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boostRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boosterNft","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"emergencyRewardWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"addresses_","type":"bytes"},{"internalType":"bytes","name":"uint256Datas_","type":"bytes"},{"internalType":"bytes","name":"uint16Datas_","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastRewardBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftLimitPerUser","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"pendingReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"}],"name":"recoverToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount_","type":"uint256"},{"internalType":"uint256[]","name":"nftIds_","type":"uint256[]"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenLimitPerUser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBoostedShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStakedNft","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStakedToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"rate_","type":"uint16"}],"name":"updateBoostRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"fee_","type":"uint16"}],"name":"updateDepositFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"block_","type":"uint256"}],"name":"updateEndBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"limit_","type":"uint16"}],"name":"updateNftLimitPerUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"emission_","type":"uint256"}],"name":"updateRewardPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"block_","type":"uint256"}],"name":"updateStartBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"limit_","type":"uint256"}],"name":"updateTokenLimitPerUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"treasury_","type":"address"}],"name":"updateTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"viewUserInfo","outputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"uint256","name":"nftAmount","type":"uint256"},{"internalType":"uint256","name":"boostedShare","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint16","name":"offset_","type":"uint16"},{"internalType":"uint16","name":"count_","type":"uint16"}],"name":"viewUserNfts","outputs":[{"internalType":"uint256[]","name":"nfts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount_","type":"uint256"},{"internalType":"uint256[]","name":"nftIds_","type":"uint256[]"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60a060405234801561001057600080fd5b5061001a33610028565b6001600f5533608052610078565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60805161326b6200009b600039600081816105d40152610de8015261326b6000f3fe60806040526004361061025f5760003560e01c80638f66291511610144578063ccd34cd5116100b6578063e3161ddd1161007a578063e3161ddd1461073c578063f1441a5414610751578063f2fde38b14610767578063f40f0f5214610787578063f7c618c1146107a7578063fac2b9ba146107c757600080fd5b8063ccd34cd5146106bb578063d1016eab146106d1578063da9f0a5c146106f1578063db2e21bc14610707578063dffae28c1461071c57600080fd5b8063afa63b1e11610108578063afa63b1e1461060c578063b993cf8e14610639578063c1acea2f14610659578063c6d87dd514610679578063cb6d8ee61461068f578063cbfa319d146106a557600080fd5b80638f662915146105515780639be65a6014610567578063a37d985014610587578063a9aefee7146105c2578063a9f8d181146105f657600080fd5b806348cd4cb1116101dd578063715018a6116101a1578063715018a6146104a857806372f702f3146104bd5780637f51bb1f146104dd5780638aab7d1c146104fd5780638ae39cac1461051d5780638da5cb5b1461053357600080fd5b806348cd4cb1146103f85780635411b2091461040e5780635915d8061461042e57806361d027b31461044e57806367a527931461048657600080fd5b806316f605571161022457806316f60557146103305780632e9564e4146103505780633279beab14610385578063336c2981146103a5578063392e53cd146103c757600080fd5b80626f02311461026b57806301f8a9761461028d578063083c6323146102ad5780630d3b23bb146102d6578063150b7a02146102ec57600080fd5b3661026657005b600080fd5b34801561027757600080fd5b5061028b610286366004612a50565b6107e7565b005b34801561029957600080fd5b5061028b6102a8366004612a50565b6108c6565b3480156102b957600080fd5b506102c360085481565b6040519081526020015b60405180910390f35b3480156102e257600080fd5b506102c3600d5481565b3480156102f857600080fd5b50610317610307366004612a94565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020016102cd565b34801561033c57600080fd5b5061028b61034b366004612b74565b610968565b34801561035c57600080fd5b5060045461037290600160b81b900461ffff1681565b60405161ffff90911681526020016102cd565b34801561039157600080fd5b5061028b6103a0366004612a50565b610d78565b3480156103b157600080fd5b5060045461037290600160c81b900461ffff1681565b3480156103d357600080fd5b506004546103e890600160a01b900460ff1681565b60405190151581526020016102cd565b34801561040457600080fd5b506102c360095481565b34801561041a57600080fd5b5061028b610429366004612c3c565b610d8d565b34801561043a57600080fd5b5061028b610449366004612b74565b610f19565b34801561045a57600080fd5b5060045461046e906001600160a01b031681565b6040516001600160a01b0390911681526020016102cd565b34801561049257600080fd5b5060045461037290600160a81b900461ffff1681565b3480156104b457600080fd5b5061028b6111f6565b3480156104c957600080fd5b5060025461046e906001600160a01b031681565b3480156104e957600080fd5b5061028b6104f8366004612cd6565b61120a565b34801561050957600080fd5b5061028b610518366004612d03565b6112d6565b34801561052957600080fd5b506102c360065481565b34801561053f57600080fd5b506000546001600160a01b031661046e565b34801561055d57600080fd5b506102c360075481565b34801561057357600080fd5b5061028b610582366004612cd6565b6113a3565b34801561059357600080fd5b506105a76105a2366004612cd6565b611453565b604080519384526020840192909252908201526060016102cd565b3480156105ce57600080fd5b5061046e7f000000000000000000000000000000000000000000000000000000000000000081565b34801561060257600080fd5b506102c3600a5481565b34801561061857600080fd5b5061062c610627366004612d20565b611492565b6040516102cd9190612d6b565b34801561064557600080fd5b5061028b610654366004612a50565b6115c6565b34801561066557600080fd5b5060035461046e906001600160a01b031681565b34801561068557600080fd5b506103726107d081565b34801561069b57600080fd5b506102c3600b5481565b3480156106b157600080fd5b506102c360055481565b3480156106c757600080fd5b506102c3600e5481565b3480156106dd57600080fd5b5061028b6106ec366004612d03565b611625565b3480156106fd57600080fd5b5061037261271081565b34801561071357600080fd5b5061028b6116ad565b34801561072857600080fd5b5061028b610737366004612d03565b6118a8565b34801561074857600080fd5b5061028b611930565b34801561075d57600080fd5b506102c3600c5481565b34801561077357600080fd5b5061028b610782366004612cd6565b6119a6565b34801561079357600080fd5b506102c36107a2366004612cd6565b611a1f565b3480156107b357600080fd5b5060015461046e906001600160a01b031681565b3480156107d357600080fd5b5061028b6107e2366004612a50565b611aed565b6107ef611c04565b4381116108175760405162461bcd60e51b815260040161080e90612daf565b60405180910390fd5b60095481116108685760405162461bcd60e51b815260206004820152601960248201527f4d75737420626520616674657220737461727420626c6f636b00000000000000604482015260640161080e565b80600854141561088a5760405162461bcd60e51b815260040161080e90612de6565b60088190556040518181527f0972575658363b3e7c472ab3a6a918726742c853b732f6a4a2763e2e3a94c977906020015b60405180910390a150565b6108ce611c04565b600081116109115760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b21032b6b4b9b9b4b7b760811b604482015260640161080e565b8060065414156109335760405162461bcd60e51b815260040161080e90612de6565b60068190556040518181527fffcc630bf88a67ba7c8b27440787c31777ae923aee1e9bbd0127feea56da2cd0906020016108bb565b6002600f54141561098b5760405162461bcd60e51b815260040161080e90612e0f565b6002600f55610998611930565b336000908152601060205260408120805490916109b760028401611c5e565b905060006109c58383611c6e565b90508015610a595760008460010154600e54600754846109e59190612e5c565b6109ef9190612e7b565b6109f99190612e9d565b9050610a13335b6001546001600160a01b03169083611cb4565b507f121c5042302bae5fc561fbc64368f297ca60a880878e1e3a7f7e9380377260bf33604080516001600160a01b039092168252602082018490520160405180910390a1505b8487151580610a685750600081115b15610cfc57600d54610a7a8382612e9d565b90508815610b8157600254610a98906001600160a01b03168a611df3565b60045490995060009061271090610aba90600160a81b900461ffff168c612e5c565b610ac49190612e7b565b90508015610af757600454600254610ae9916001600160a01b03918216911683611cb4565b50610af4818b612e9d565b99505b610b018a87612eb4565b955060055460001480610b1657506005548611155b610b625760405162461bcd60e51b815260206004820152601860248201527f4f76657220746f6b656e207374616b696e67206c696d69740000000000000000604482015260640161080e565b858755600b80548b9190600090610b7a908490612eb4565b9091555050505b8115610ce157610b918285612eb4565b600454909450600160c81b900461ffff161580610bbb5750600454600160c81b900461ffff168411155b610c005760405162461bcd60e51b815260206004820152601660248201527513dd995c881b999d081cdd185ada5b99c81b1a5b5a5d60521b604482015260640161080e565b60005b82811015610cc8576003546001600160a01b03166342842e0e33308c8c86818110610c3057610c30612ecc565b905060200201356040518463ffffffff1660e01b8152600401610c5593929190612ee2565b600060405180830381600087803b158015610c6f57600080fd5b505af1158015610c83573d6000803e3d6000fd5b50505050610cb5898983818110610c9c57610c9c612ecc565b9050602002013588600201611fa290919063ffffffff16565b5080610cc081612f06565b915050610c03565b82600c6000828254610cda9190612eb4565b9091555050505b610ceb8585611c6e565b9250610cf78382612eb4565b600d55505b600e54600754610d0c9084612e5c565b610d169190612e7b565b60018601557f074be96cbda9766dbe0c925ac833fc192f07104c123e767598a5c06096e6e03d335b604080516001600160a01b03909216825261ffff8416602083015281018a905260600160405180910390a150506001600f55505050505050565b610d80611c04565b610d8933610a00565b5050565b600454600160a01b900460ff1615610ddd5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604482015260640161080e565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610e435760405162461bcd60e51b815260206004820152600b60248201526a4e6f7420666163746f727960a81b604482015260640161080e565b6004805460ff60a01b1916600160a01b179055604080516020601f8601819004810282018101909252848152610e93918690869081908401838280828437600092019190915250611fae92505050565b610ed282828080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120a792505050565b610f1186868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061216492505050565b505050505050565b6002600f541415610f3c5760405162461bcd60e51b815260040161080e90612e0f565b6002600f55610f49611930565b33600090815260106020526040812080549091610f6860028401611c5e565b90506000610f768383611c6e565b90508015610ffb5760008460010154600e5460075484610f969190612e5c565b610fa09190612e7b565b610faa9190612e9d565b9050610fb533610a00565b507f121c5042302bae5fc561fbc64368f297ca60a880878e1e3a7f7e9380377260bf33604080516001600160a01b039092168252602082018490520160405180910390a1505b848715158061100a5750600081115b156111b057600d5461101c8382612e9d565b905088156110665761103b336002546001600160a01b0316908b611cb4565b506110468986612e9d565b808755600b80549196508a91600090611060908490612e9d565b90915550505b81156111955760005b82811015611170576110a589898381811061108c5761108c612ecc565b905060200201358860020161225a90919063ffffffff16565b6110e15760405162461bcd60e51b815260206004820152600d60248201526c139bdd081bdddb9959081b999d609a1b604482015260640161080e565b6003546001600160a01b03166342842e0e30338c8c8681811061110657611106612ecc565b905060200201356040518463ffffffff1660e01b815260040161112b93929190612ee2565b600060405180830381600087803b15801561114557600080fd5b505af1158015611159573d6000803e3d6000fd5b50505050808061116890612f06565b91505061106f565b61117a8386612e9d565b945082600c600082825461118e9190612e9d565b9091555050505b61119f8585611c6e565b92506111ab8382612eb4565b600d55505b600e546007546111c09084612e5c565b6111ca9190612e7b565b60018601557fe96bafbc150b64987f56de0d71ac8b317088ed71fa7a2b1d466d0d9474494a1933610d3e565b6111fe611c04565b6112086000612266565b565b611212611c04565b6001600160a01b03811661125a5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015260640161080e565b6004546001600160a01b03828116911614156112885760405162461bcd60e51b815260040161080e90612de6565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527f29136396b324aa7f7a8d1b8f00da39b8d88642bc714a9747c151b20e3d2af233906020016108bb565b6112de611c04565b6107d061ffff821611156113235760405162461bcd60e51b815260206004820152600c60248201526b546f6f206d7563682066656560a01b604482015260640161080e565b60045461ffff828116600160a81b9092041614156113535760405162461bcd60e51b815260040161080e90612de6565b6004805461ffff60a81b1916600160a81b61ffff8416908102919091179091556040519081527f92054bc497ec573babf5e634a5dc5173926f395ae55840950300efa8cc9f3ff1906020016108bb565b6113ab611c04565b6002546001600160a01b038281169116148015906113d757506001546001600160a01b03828116911614155b6114235760405162461bcd60e51b815260206004820152601960248201527f556e7065726d697474656420746f6b656e206164647265737300000000000000604482015260640161080e565b60006114386001600160a01b038316306122b6565b905061144e6001600160a01b0383163383611cb4565b505050565b6001600160a01b038116600090815260106020526040812080549190819061147d60028201611c5e565b92506114898484611c6e565b93959294505050565b6001600160a01b03831660009081526010602052604081206060916114b960028301611c5e565b905060006114c983600201612348565b90508161ffff168661ffff1611156114df578195505b61ffff82166114ee8688612f21565b61ffff161115611505576115028683612f47565b94505b8461ffff1667ffffffffffffffff81111561152257611522612a7e565b60405190808252806020026020018201604052801561154b578160200160208202803683370190505b50935060005b8561ffff168161ffff1610156115bb578161156c8289612f21565b61ffff168151811061158057611580612ecc565b6020026020010151858261ffff168151811061159e5761159e612ecc565b6020908102919091010152806115b381612f6a565b915050611551565b505050509392505050565b6115ce611c04565b8060055414156115f05760405162461bcd60e51b815260040161080e90612de6565b60058190556040518181527fef3a47d813b9d4809179eaa647a960e1ca881d54cae2acd6cb8af4956081abce906020016108bb565b61162d611c04565b60045461ffff828116600160b81b90920416141561165d5760405162461bcd60e51b815260040161080e90612de6565b6004805461ffff60b81b1916600160b81b61ffff8416908102919091179091556040519081527f1153ce3eabea864c4c4346b80491fa91f7600d2329628e5edf43c0ac4535e22f906020016108bb565b6002600f5414156116d05760405162461bcd60e51b815260040161080e90612e0f565b6002600f819055336000908152601060205260408120805490929091906116f8908401611c5e565b905060006117068383611c6e565b905080600d600082825461171a9190612e9d565b9091555050821561175a5761173c336002546001600160a01b03169085611cb4565b506000808555600b8054859290611754908490612e9d565b90915550505b81156118535760008061176f86600201612348565b90505b83821015611839576003546001600160a01b03166342842e0e303384868151811061179f5761179f612ecc565b60200260200101516040518463ffffffff1660e01b81526004016117c593929190612ee2565b600060405180830381600087803b1580156117df57600080fd5b505af11580156117f3573d6000803e3d6000fd5b5050505061182681838151811061180c5761180c612ecc565b60200260200101518760020161225a90919063ffffffff16565b508161183181612f06565b925050611772565b83600c600082825461184b9190612e9d565b909155505050505b600060018501556040805133815261ffff8416602082015280820185905290517f0829ea81627dd1d708e25f99f78e74159287c081e84c7f56c8b73727dcf0db4a9181900360600190a150506001600f555050565b6118b0611c04565b60045461ffff828116600160c81b9092041614156118e05760405162461bcd60e51b815260040161080e90612de6565b6004805461ffff60c81b1916600160c81b61ffff8416908102919091179091556040519081527fd2e2ca6bd52466936bd4e303f88d0453cf4993564a740055f443396d5852c635906020016108bb565b600a5443811061193d5750565b600d548061194d57505043600a55565b60006119598343612355565b905060006006548261196b9190612e5c565b905082600e548261197c9190612e5c565b6119869190612e7b565b600760008282546119979190612eb4565b909155505043600a5550505050565b6119ae611c04565b6001600160a01b038116611a135760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161080e565b611a1c81612266565b50565b6001600160a01b0381166000908152601060205260408120600754815483611a4960028501611c5e565b90506000611a578383611c6e565b9050600a5443118015611a6b5750600d5415155b15611abc576000611a7e600a5443612355565b9050600060065482611a909190612e5c565b9050600d54600e5482611aa39190612e5c565b611aad9190612e7b565b611ab79087612eb4565b955050505b6001850154600e54611ace8684612e5c565b611ad89190612e7b565b611ae29190612e9d565b979650505050505050565b611af5611c04565b4360095411611b385760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e481cdd185c9d1959608a1b604482015260640161080e565b438111611b575760405162461bcd60e51b815260040161080e90612daf565b6008548110611ba85760405162461bcd60e51b815260206004820152601860248201527f4d757374206265206265666f726520656e6420626c6f636b0000000000000000604482015260640161080e565b806009541415611bca5760405162461bcd60e51b815260040161080e90612de6565b6009819055600a8190556040518181527f4bb9dd09b6a66721c98f875ba3f3533d0bd985533957120aee36f4e1599068b5906020016108bb565b6000546001600160a01b031633146112085760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161080e565b6000611c68825490565b92915050565b60045460009061271090611c8d90600160b81b900461ffff1684612e5c565b611c9990612710612eb4565b611ca39085612e5c565b611cad9190612e7b565b9392505050565b600081611cc357506000611cad565b611ccc84612389565b15611ceb57611ce46001600160a01b038416836123c2565b5080611cad565b6040516370a0823160e01b81526001600160a01b038481166004830152600091908616906370a0823190602401602060405180830381865afa158015611d35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d599190612f8c565b9050611d6f6001600160a01b03861685856124db565b6040516370a0823160e01b81526001600160a01b038581166004830152600091908716906370a0823190602401602060405180830381865afa158015611db9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ddd9190612f8c565b9050611de98282612e9d565b9695505050505050565b600081611e0257506000611c68565b611e0b83612389565b15611ea05781341015611e7d5760405162461bcd60e51b815260206004820152603460248201527f57726f6e67207573616765206f66204554482e756e6976657273616c5472616e6044820152737366657246726f6d53656e646572546f5468697360601b606482015260840161080e565b81341115611e9957611e99611e928334612e9d565b33906123c2565b5080611c68565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015611ee7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0b9190612f8c565b9050611f226001600160a01b03851633308661253e565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015611f69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8d9190612f8c565b9050611f998282612e9d565b92505050611c68565b6000611cad8383612565565b60008060008084806020019051810190611fc89190612fa5565b9350935093509350600084116120135760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b21032b6b4b9b9b4b7b760811b604482015260640161080e565b81831061206e5760405162461bcd60e51b8152602060048201526024808201527f537461727420626c6f636b206d757374206265206265666f726520656e6420626044820152636c6f636b60e01b606482015260840161080e565b43831161208d5760405162461bcd60e51b815260040161080e90612daf565b6006939093556009829055600855600591909155600a5550565b6000806000838060200190518101906120c09190612fdb565b919450925090506107d061ffff841611156121145760405162461bcd60e51b8152602060048201526014602482015273546f6f206d756368206465706f7369742066656560601b604482015260640161080e565b6004805465ffff0000ffff60a81b1916600160a81b61ffff9586160261ffff60c81b191617600160c81b938516939093029290921761ffff60b81b1916600160b81b919093160291909117905550565b600080600080600085806020019051810190612180919061301d565b9398509196509450925090506001600160a01b0381166121d55760405162461bcd60e51b815260206004820152601060248201526f496e76616c696420747265617375727960801b604482015260640161080e565b600280546001600160a01b038087166001600160a01b03199283161790925560018054868416908316811790915560038054868516908416179055600480549385169390921692909217905560009061222d906125b4565b905061223a81601e612e9d565b61224590600a613176565b600e55612251866119a6565b50505050505050565b6000611cad838361272b565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006122c183612389565b156122d757506001600160a01b03811631611c68565b6040516370a0823160e01b81526001600160a01b0383811660048301528416906370a0823190602401602060405180830381865afa15801561231d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123419190612f8c565b9050611c68565b60606000611cad8361281e565b6000600854821161236a576123418383612e9d565b600854831061237b57506000611c68565b82600854611cad9190612e9d565b60006001600160a01b0382161580611c6857506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b804710156124125760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161080e565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461245f576040519150601f19603f3d011682016040523d82523d6000602084013e612464565b606091505b505090508061144e5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161080e565b6040516001600160a01b03831660248201526044810182905261144e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261287a565b61255f846323b872dd60e01b85858560405160240161250793929190612ee2565b50505050565b60008181526001830160205260408120546125ac57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611c68565b506000611c68565b60006125bf82612389565b156125cc57506012919050565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b179052905160009182916001600160a01b038616916127109161261491906131ae565b6000604051808303818686fa925050503d8060008114612650576040519150601f19603f3d011682016040523d82523d6000602084013e612655565b606091505b509150915081158061266657508051155b156126f65760408051600481526024810182526020810180516001600160e01b0316632e0f262560e01b17905290516001600160a01b03861691612710916126ae91906131ae565b6000604051808303818686fa925050503d80600081146126ea576040519150601f19603f3d011682016040523d82523d6000602084013e6126ef565b606091505b5090925090505b818015612704575060008151115b61270f576012612723565b808060200190518101906127239190612f8c565b949350505050565b6000818152600183016020526040812054801561281457600061274f600183612e9d565b855490915060009061276390600190612e9d565b90508181146127c857600086600001828154811061278357612783612ecc565b90600052602060002001549050808760000184815481106127a6576127a6612ecc565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806127d9576127d96131ca565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611c68565b6000915050611c68565b60608160000180548060200260200160405190810160405280929190818152602001828054801561286e57602002820191906000526020600020905b81548152602001906001019080831161285a575b50505050509050919050565b60006128cf826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661294c9092919063ffffffff16565b80519091501561144e57808060200190518101906128ed91906131e0565b61144e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161080e565b60606127238484600085856001600160a01b0385163b6129ae5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161080e565b600080866001600160a01b031685876040516129ca91906131ae565b60006040518083038185875af1925050503d8060008114612a07576040519150601f19603f3d011682016040523d82523d6000602084013e612a0c565b606091505b5091509150611ae282828660608315612a26575081611cad565b825115612a365782518084602001fd5b8160405162461bcd60e51b815260040161080e9190613202565b600060208284031215612a6257600080fd5b5035919050565b6001600160a01b0381168114611a1c57600080fd5b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215612aaa57600080fd5b8435612ab581612a69565b93506020850135612ac581612a69565b925060408501359150606085013567ffffffffffffffff80821115612ae957600080fd5b818701915087601f830112612afd57600080fd5b813581811115612b0f57612b0f612a7e565b604051601f8201601f19908116603f01168101908382118183101715612b3757612b37612a7e565b816040528281528a6020848701011115612b5057600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b600080600060408486031215612b8957600080fd5b83359250602084013567ffffffffffffffff80821115612ba857600080fd5b818601915086601f830112612bbc57600080fd5b813581811115612bcb57600080fd5b8760208260051b8501011115612be057600080fd5b6020830194508093505050509250925092565b60008083601f840112612c0557600080fd5b50813567ffffffffffffffff811115612c1d57600080fd5b602083019150836020828501011115612c3557600080fd5b9250929050565b60008060008060008060608789031215612c5557600080fd5b863567ffffffffffffffff80821115612c6d57600080fd5b612c798a838b01612bf3565b90985096506020890135915080821115612c9257600080fd5b612c9e8a838b01612bf3565b90965094506040890135915080821115612cb757600080fd5b50612cc489828a01612bf3565b979a9699509497509295939492505050565b600060208284031215612ce857600080fd5b8135611cad81612a69565b61ffff81168114611a1c57600080fd5b600060208284031215612d1557600080fd5b8135611cad81612cf3565b600080600060608486031215612d3557600080fd5b8335612d4081612a69565b92506020840135612d5081612cf3565b91506040840135612d6081612cf3565b809150509250925092565b6020808252825182820181905260009190848201906040850190845b81811015612da357835183529284019291840191600101612d87565b50909695505050505050565b60208082526018908201527f556e61626c6520746f20736574207061737420626c6f636b0000000000000000604082015260600190565b6020808252600f908201526e139bdd1a1a5b99c818da185b99d959608a1b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612e7657612e76612e46565b500290565b600082612e9857634e487b7160e01b600052601260045260246000fd5b500490565b600082821015612eaf57612eaf612e46565b500390565b60008219821115612ec757612ec7612e46565b500190565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b039384168152919092166020820152604081019190915260600190565b6000600019821415612f1a57612f1a612e46565b5060010190565b600061ffff808316818516808303821115612f3e57612f3e612e46565b01949350505050565b600061ffff83811690831681811015612f6257612f62612e46565b039392505050565b600061ffff80831681811415612f8257612f82612e46565b6001019392505050565b600060208284031215612f9e57600080fd5b5051919050565b60008060008060808587031215612fbb57600080fd5b505082516020840151604085015160609095015191969095509092509050565b600080600060608486031215612ff057600080fd5b8351612ffb81612cf3565b602085015190935061300c81612cf3565b6040850151909250612d6081612cf3565b600080600080600060a0868803121561303557600080fd5b855161304081612a69565b602087015190955061305181612a69565b604087015190945061306281612a69565b606087015190935061307381612a69565b608087015190925061308481612a69565b809150509295509295909350565b600181815b808511156130cd5781600019048211156130b3576130b3612e46565b808516156130c057918102915b93841c9390800290613097565b509250929050565b6000826130e457506001611c68565b816130f157506000611c68565b816001811461310757600281146131115761312d565b6001915050611c68565b60ff84111561312257613122612e46565b50506001821b611c68565b5060208310610133831016604e8410600b8410161715613150575081810a611c68565b61315a8383613092565b806000190482111561316e5761316e612e46565b029392505050565b6000611cad83836130d5565b60005b8381101561319d578181015183820152602001613185565b8381111561255f5750506000910152565b600082516131c0818460208701613182565b9190910192915050565b634e487b7160e01b600052603160045260246000fd5b6000602082840312156131f257600080fd5b81518015158114611cad57600080fd5b6020815260008251806020840152613221816040850160208701613182565b601f01601f1916919091016040019291505056fea2646970667358221220d664ba4380217b24472de8acb20c50bf64d1fd2a1861edc6ecae4c730dc3f99164736f6c634300080b0033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.