Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
RewardEscrowV2
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; // Inheritance import {IRewardEscrowV2} from "./interfaces/IRewardEscrowV2.sol"; import {ERC721EnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; // Internal references import {IKwenta} from "./interfaces/IKwenta.sol"; import {IStakingRewardsV2} from "./interfaces/IStakingRewardsV2.sol"; import {IEscrowMigrator} from "./interfaces/IEscrowMigrator.sol"; /// @title KWENTA Reward Escrow V2 /// @author Originally inspired by SYNTHETIX RewardEscrow /// @author Kwenta's RewardEscrow V1 by JaredBorders ([email protected]), JChiaramonte7 ([email protected]) /// @author RewardEscrowV2 by tommyrharper ([email protected]) /// @notice Updated version of Synthetix's RewardEscrow with new features specific to Kwenta contract RewardEscrowV2 is IRewardEscrowV2, ERC721EnumerableUpgradeable, Ownable2StepUpgradeable, PausableUpgradeable, UUPSUpgradeable { /*/////////////////////////////////////////////////////////////// CONSTANTS/IMMUTABLES ///////////////////////////////////////////////////////////////*/ /// @notice Max escrow duration /// @dev WARNING: updating this value to less than 2 years will allow this check to be bypassed /// via the escrow migrator contract, by creating V1 escrow entries and migrating them to V2 uint256 public constant MAX_DURATION = 4 * 52 weeks; // Default max 4 years duration /// @notice Min escrow duration uint256 public constant DEFAULT_DURATION = 52 weeks; // Default 1 year duration /// @notice Default early vesting fee - used for new vesting entries from staking rewards uint256 public constant DEFAULT_EARLY_VESTING_FEE = 90; // Default 90 percent /// @notice Maximum early vesting fee - cannot be higher than 100% /// @dev WARNING: Updating this value to below 90 will be able to be bypassed via importEscrowEntry /// through the EscrowMigrator contract uint256 public constant MAXIMUM_EARLY_VESTING_FEE = 100; /// @inheritdoc IRewardEscrowV2 /// @dev WARNING: see warning in IRewardEscrowV2 if planning on changing this value uint256 public constant MINIMUM_EARLY_VESTING_FEE = 50; /// @notice Contract for KWENTA ERC20 token /// @custom:oz-upgrades-unsafe-allow state-variable-immutable IKwenta public immutable kwenta; /// @notice RewardsNotifier address /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address public immutable rewardsNotifier; /*/////////////////////////////////////////////////////////////// STATE ///////////////////////////////////////////////////////////////*/ /// @notice Contract for StakingRewardsV2 IStakingRewardsV2 public stakingRewards; /// @notice Contract for EscrowMigrator IEscrowMigrator public escrowMigrator; /// @notice treasury address - this may change address public treasuryDAO; ///@notice mapping of entryIDs to vesting entries mapping(uint256 => VestingEntryPacked) public vestingSchedules; /// @notice Counter for new vesting entry ids uint256 public nextEntryId; /// @notice An account's total escrowed KWENTA balance to save recomputing this for fee extraction purposes mapping(address => uint256) public totalEscrowedAccountBalance; /// @notice An account's total vested reward KWENTA mapping(address => uint256) public totalVestedAccountBalance; /// @notice The total remaining escrowed balance, for verifying the actual KWENTA balance of this contract against uint256 public totalEscrowedBalance; /*/////////////////////////////////////////////////////////////// AUTH ///////////////////////////////////////////////////////////////*/ /// @notice Restrict function to only the staking rewards contract modifier onlyStakingRewards() { _onlyStakingRewards(); _; } function _onlyStakingRewards() internal view { if (msg.sender != address(stakingRewards)) revert OnlyStakingRewards(); } /// @notice Restrict function to only the escrow migrator contract modifier onlyEscrowMigrator() { if (msg.sender != address(escrowMigrator)) revert OnlyEscrowMigrator(); _; } /*/////////////////////////////////////////////////////////////// CONSTRUCTOR / INITIALIZER ///////////////////////////////////////////////////////////////*/ /// @dev disable default constructor for disable implementation contract /// Actual contract construction will take place in the initialize function via proxy /// @custom:oz-upgrades-unsafe-allow constructor /// @param _kwenta The address for the KWENTA ERC20 token /// @param _rewardsNotifier The address for the StakingRewardsNotifier contract constructor(address _kwenta, address _rewardsNotifier) { if (_kwenta == address(0) || _rewardsNotifier == address(0)) revert ZeroAddress(); kwenta = IKwenta(_kwenta); rewardsNotifier = _rewardsNotifier; _disableInitializers(); } /// @inheritdoc IRewardEscrowV2 function initialize(address _contractOwner) external initializer { if (_contractOwner == address(0)) revert ZeroAddress(); // Initialize inherited contracts __ERC721_init("Kwenta Reward Escrow", "KRE"); __Ownable2Step_init(); __Pausable_init(); __UUPSUpgradeable_init(); // transfer ownership _transferOwnership(_contractOwner); // define variables nextEntryId = 1; } /*/////////////////////////////////////////////////////////////// SETTERS ///////////////////////////////////////////////////////////////*/ /// @inheritdoc IRewardEscrowV2 function setStakingRewards(address _stakingRewards) external onlyOwner { if (_stakingRewards == address(0)) revert ZeroAddress(); if (address(stakingRewards) != address(0)) revert StakingRewardsAlreadySet(); stakingRewards = IStakingRewardsV2(_stakingRewards); emit StakingRewardsSet(_stakingRewards); } /// @inheritdoc IRewardEscrowV2 function setEscrowMigrator(address _escrowMigrator) external onlyOwner { if (_escrowMigrator == address(0)) revert ZeroAddress(); escrowMigrator = IEscrowMigrator(_escrowMigrator); emit EscrowMigratorSet(_escrowMigrator); } /// @inheritdoc IRewardEscrowV2 function setTreasuryDAO(address _treasuryDAO) external onlyOwner { if (_treasuryDAO == address(0)) revert ZeroAddress(); treasuryDAO = _treasuryDAO; emit TreasuryDAOSet(treasuryDAO); } /*/////////////////////////////////////////////////////////////// VIEWS ///////////////////////////////////////////////////////////////*/ /// @inheritdoc IRewardEscrowV2 function getKwentaAddress() external view returns (address) { return address(kwenta); } /// @inheritdoc IRewardEscrowV2 function escrowedBalanceOf(address _account) external view returns (uint256) { return totalEscrowedAccountBalance[_account]; } /// @inheritdoc IRewardEscrowV2 function unstakedEscrowedBalanceOf(address _account) public view returns (uint256) { return totalEscrowedAccountBalance[_account] - stakingRewards.escrowedBalanceOf(_account); } /// @inheritdoc IRewardEscrowV2 function getVestingEntry(uint256 _entryID) external view returns (uint256 endTime, uint256 escrowAmount, uint256 duration, uint256 earlyVestingFee) { VestingEntryPacked storage entry = vestingSchedules[_entryID]; endTime = entry.endTime; escrowAmount = entry.escrowAmount; duration = entry.duration; earlyVestingFee = entry.earlyVestingFee; } /// @inheritdoc IRewardEscrowV2 function getVestingSchedules(address _account, uint256 _index, uint256 _pageSize) external view returns (VestingEntryWithID[] memory) { if (_pageSize == 0) { return new VestingEntryWithID[](0); } uint256 endIndex = _index + _pageSize; // If the page extends past the end of the list, truncate it. uint256 numEntries = balanceOf(_account); if (endIndex > numEntries) { endIndex = numEntries; } if (endIndex < _index) return new VestingEntryWithID[](0); uint256 n; unchecked { n = endIndex - _index; } VestingEntryWithID[] memory vestingEntries = new VestingEntryWithID[]( n ); for (uint256 i; i < n;) { uint256 entryID; unchecked { entryID = tokenOfOwnerByIndex(_account, i + _index); } VestingEntryPacked storage entry = vestingSchedules[entryID]; vestingEntries[i] = VestingEntryWithID({ endTime: entry.endTime, escrowAmount: entry.escrowAmount, entryID: entryID }); unchecked { ++i; } } return vestingEntries; } /// @inheritdoc IRewardEscrowV2 function getAccountVestingEntryIDs(address _account, uint256 _index, uint256 _pageSize) external view returns (uint256[] memory) { uint256 endIndex = _index + _pageSize; // If the page extends past the end of the list, truncate it. uint256 numEntries = balanceOf(_account); if (endIndex > numEntries) { endIndex = numEntries; } if (endIndex <= _index) { return new uint256[](0); } uint256 n = endIndex - _index; uint256[] memory page = new uint256[](n); for (uint256 i; i < n;) { unchecked { page[i] = tokenOfOwnerByIndex(_account, i + _index); } unchecked { ++i; } } return page; } /// @inheritdoc IRewardEscrowV2 function getVestingQuantity(uint256[] calldata _entryIDs) external view returns (uint256 total, uint256 totalFee) { uint256 entryIDsLength = _entryIDs.length; for (uint256 i = 0; i < entryIDsLength;) { VestingEntry memory entry = _unpackVestingEntryStruct(_entryIDs[i]); (uint256 quantity, uint256 fee) = _claimableAmount(entry); // add quantity to total total += quantity; totalFee += fee; unchecked { ++i; } } } /// @inheritdoc IRewardEscrowV2 function getVestingEntryClaimable(uint256 _entryID) external view returns (uint256 quantity, uint256 fee) { VestingEntry memory entry = _unpackVestingEntryStruct(_entryID); (quantity, fee) = _claimableAmount(entry); } function _claimableAmount(VestingEntry memory _entry) internal view returns (uint256 quantity, uint256 fee) { uint256 escrowAmount = _entry.escrowAmount; // Full escrow amounts claimable if block.timestamp equal to or after entry endTime if (block.timestamp >= _entry.endTime) { quantity = escrowAmount; } else { fee = _earlyVestFee(_entry); quantity = escrowAmount - fee; } } function _earlyVestFee(VestingEntry memory _entry) internal view returns (uint256 earlyVestFee) { uint256 timeUntilVest = _entry.endTime - block.timestamp; // Fee starts by default at 90% (but could be any percentage) and falls linearly earlyVestFee = (_entry.escrowAmount * _entry.earlyVestingFee * timeUntilVest) / (100 * _entry.duration); } /*/////////////////////////////////////////////////////////////// MUTATIVE FUNCTIONS ///////////////////////////////////////////////////////////////*/ /// @inheritdoc IRewardEscrowV2 function vest(uint256[] calldata _entryIDs) external whenNotPaused { uint256 total; uint256 totalFee; uint256 entryIDsLength = _entryIDs.length; for (uint256 i = 0; i < entryIDsLength; ++i) { uint256 entryID = _entryIDs[i]; if (_ownerOf(entryID) != msg.sender) { continue; } (uint256 quantity, uint256 fee) = _claimableAmount(_unpackVestingEntryStruct(entryID)); // update entry to remove escrowAmount vestingSchedules[entryID].escrowAmount = 0; _burn(entryID); // add quantity to total total += quantity; totalFee += fee; } // Transfer vested tokens uint256 totalWithFee = total + totalFee; if (totalWithFee != 0) { // Unstake staked escrowed kwenta if needed for reward/fee uint256 unstakedEscrow = unstakedEscrowedBalanceOf(msg.sender); if (totalWithFee > unstakedEscrow) { uint256 amountToUnstake; unchecked { amountToUnstake = totalWithFee - unstakedEscrow; } stakingRewards.unstakeEscrowSkipCooldown(msg.sender, amountToUnstake); } // update balances totalEscrowedBalance -= totalWithFee; totalEscrowedAccountBalance[msg.sender] -= totalWithFee; totalVestedAccountBalance[msg.sender] += total; // Send 50% any fee to Treasury and // 50% to RewardsNotifier // UNLESS Distributor isn't set // then send all funds to Treasury if (totalFee != 0) { /// @dev this will revert if the kwenta token transfer fails uint256 amountToTreasury = totalFee / 2; uint256 amountToNotifier = totalFee - amountToTreasury; kwenta.transfer(treasuryDAO, amountToTreasury); kwenta.transfer(rewardsNotifier, amountToNotifier); emit EarlyVestFeeSent(amountToTreasury, amountToNotifier); } if (total != 0) { // Transfer kwenta /// @dev this will revert if the kwenta token transfer fails kwenta.transfer(msg.sender, total); } // trigger event emit Vested(msg.sender, total); } } /// @inheritdoc IRewardEscrowV2 function importEscrowEntry(address _account, VestingEntry memory _entry) external onlyEscrowMigrator { _mint( _account, _entry.endTime, _entry.escrowAmount, _entry.duration, _entry.earlyVestingFee ); } /// @inheritdoc IRewardEscrowV2 function createEscrowEntry( address _beneficiary, uint256 _deposit, uint256 _duration, uint256 _earlyVestingFee ) external { if (_beneficiary == address(0)) revert ZeroAddress(); if (_earlyVestingFee > MAXIMUM_EARLY_VESTING_FEE) revert EarlyVestingFeeTooHigh(); if (_earlyVestingFee < MINIMUM_EARLY_VESTING_FEE) revert EarlyVestingFeeTooLow(); if (_deposit == 0) revert ZeroAmount(); uint256 minimumDuration = stakingRewards.cooldownPeriod(); if (_duration < minimumDuration || _duration > MAX_DURATION) revert InvalidDuration(); /// @dev this will revert if the kwenta token transfer fails kwenta.transferFrom(msg.sender, address(this), _deposit); // Escrow the tokens for duration. uint256 endTime = block.timestamp + _duration; // Append vesting entry for the beneficiary address _mint(_beneficiary, endTime, _deposit, _duration, _earlyVestingFee); } /// @inheritdoc IRewardEscrowV2 function appendVestingEntry(address _account, uint256 _quantity) external onlyStakingRewards { // Escrow the tokens for duration. uint256 endTime = block.timestamp + DEFAULT_DURATION; _mint(_account, endTime, _quantity, DEFAULT_DURATION, DEFAULT_EARLY_VESTING_FEE); } /// @inheritdoc IRewardEscrowV2 function bulkTransferFrom(address _from, address _to, uint256[] calldata _entryIDs) external whenNotPaused { if (_from == _to) revert CannotTransferToSelf(); uint256 totalEscrowTransferred; uint256 entryIDsLength = _entryIDs.length; for (uint256 i = 0; i < entryIDsLength;) { uint256 entryID = _entryIDs[i]; // sum totalEscrowTransferred so that _applyTransferBalanceUpdates can be applied only once to save gas totalEscrowTransferred += uint256(vestingSchedules[entryID].escrowAmount); _checkApproved(entryID); // use super._transfer to avoid double updating of balances super._transfer(_from, _to, entryID); unchecked { ++i; } } // update balances all at once _applyTransferBalanceUpdates(_from, _to, totalEscrowTransferred); } /*/////////////////////////////////////////////////////////////// INTERNALS ///////////////////////////////////////////////////////////////*/ /// @dev override the internal _transfer function to ensure vestingSchedules and account balances are updated /// and that there is sufficient unstaked escrow for a transfer when transferFrom and safeTransferFrom are called function _transfer(address _from, address _to, uint256 _entryID) internal override whenNotPaused { uint256 escrowAmount = vestingSchedules[_entryID].escrowAmount; _applyTransferBalanceUpdates(_from, _to, escrowAmount); super._transfer(_from, _to, _entryID); } function _applyTransferBalanceUpdates(address _from, address _to, uint256 _escrowAmount) internal { uint256 unstakedEscrow = unstakedEscrowedBalanceOf(_from); if (unstakedEscrow < _escrowAmount) { revert InsufficientUnstakedBalance(_escrowAmount, unstakedEscrow); } unchecked { totalEscrowedAccountBalance[_from] -= _escrowAmount; } totalEscrowedAccountBalance[_to] += _escrowAmount; } function _checkApproved(uint256 _entryID) internal view { /// @dev not using a custom error to keep consistency with OpenZeppelin errors require( _isApprovedOrOwner(_msgSender(), _entryID), "ERC721: caller is not token owner or approved" ); } function _mint( address _account, uint256 _endTime, uint256 _quantity, uint256 _duration, uint256 _earlyVestingFee ) internal whenNotPaused { // There must be enough balance in the contract to provide for the vesting entry. totalEscrowedBalance += _quantity; assert(kwenta.balanceOf(address(this)) >= totalEscrowedBalance); // Add quantity to account's escrowed balance totalEscrowedAccountBalance[_account] += _quantity; uint256 entryID = nextEntryId; vestingSchedules[entryID] = VestingEntryPacked({ endTime: uint64(_endTime), escrowAmount: uint144(_quantity), duration: uint40(_duration), earlyVestingFee: uint8(_earlyVestingFee) }); // Increment the next entry id. unchecked { ++nextEntryId; } emit VestingEntryCreated(_account, _quantity, _duration, entryID, _earlyVestingFee); super._mint(_account, entryID); } function _unpackVestingEntryStruct(uint256 _entryID) internal view returns (VestingEntry memory vestingEntry) { VestingEntryPacked storage entry = vestingSchedules[_entryID]; vestingEntry = VestingEntry({ endTime: entry.endTime, escrowAmount: entry.escrowAmount, duration: entry.duration, earlyVestingFee: entry.earlyVestingFee }); } function _authorizeUpgrade(address _newImplementation) internal override onlyOwner {} /*/////////////////////////////////////////////////////////////// PAUSABLE ///////////////////////////////////////////////////////////////*/ /// @inheritdoc IRewardEscrowV2 function pauseRewardEscrow() external onlyOwner { _pause(); } /// @inheritdoc IRewardEscrowV2 function unpauseRewardEscrow() external onlyOwner { _unpause(); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; interface IRewardEscrowV2 { /*////////////////////////////////////////////////////////////// STRUCTS //////////////////////////////////////////////////////////////*/ /// @notice A vesting entry contains the data for each escrow NFT struct VestingEntry { // The amount of KWENTA stored in this vesting entry uint256 escrowAmount; // The length of time until the entry is fully matured uint256 duration; // The time at which the entry will be fully matured uint256 endTime; // The percentage fee for vesting immediately // The actual penalty decreases linearly with time until it reaches 0 at block.timestamp=endTime uint256 earlyVestingFee; } /// @notice The same as VestingEntry but packed to fit in a single slot struct VestingEntryPacked { uint144 escrowAmount; uint40 duration; uint64 endTime; uint8 earlyVestingFee; } /// @notice Helper struct for getVestingSchedules view struct VestingEntryWithID { // The amount of KWENTA stored in this vesting entry uint256 escrowAmount; // The unique ID of this escrow entry NFT uint256 entryID; // The time at which the entry will be fully matured uint256 endTime; } /*/////////////////////////////////////////////////////////////// INITIALIZER ///////////////////////////////////////////////////////////////*/ /// @notice Initializes the contract /// @param _owner The address of the owner of this contract /// @dev this function should be called via proxy, not via direct contract interaction function initialize(address _owner) external; /*/////////////////////////////////////////////////////////////// SETTERS ///////////////////////////////////////////////////////////////*/ /// @notice Function used to define the StakingRewardsV2 contract address to use /// @param _stakingRewards The address of the StakingRewardsV2 contract /// @dev This function can only be called once function setStakingRewards(address _stakingRewards) external; /// @notice Function used to define the EscrowMigrator contract address to use /// @param _escrowMigrator The address of the EscrowMigrator contract function setEscrowMigrator(address _escrowMigrator) external; /// @notice Function used to define the TreasuryDAO address to use /// @param _treasuryDAO The address of the TreasuryDAO /// @dev This function can only be called multiple times function setTreasuryDAO(address _treasuryDAO) external; /*/////////////////////////////////////////////////////////////// VIEWS ///////////////////////////////////////////////////////////////*/ /// @notice Minimum early vesting fee /// @dev this must be high enought to prevent governance attacks where the user /// can set the early vesting fee to a very low number, stake, vote, then withdraw /// via vesting which avoids the unstaking cooldown function MINIMUM_EARLY_VESTING_FEE() external view returns (uint256); /// @notice Default early vesting fee /// @dev This is the default fee applied for early vesting function DEFAULT_EARLY_VESTING_FEE() external view returns (uint256); /// @notice Default escrow duration /// @dev This is the default duration for escrow function DEFAULT_DURATION() external view returns (uint256); /// @notice helper function to return kwenta address function getKwentaAddress() external view returns (address); /// @notice A simple alias to totalEscrowedAccountBalance function escrowedBalanceOf(address _account) external view returns (uint256); /// @notice Get the amount of escrowed kwenta that is not staked for a given account function unstakedEscrowedBalanceOf(address _account) external view returns (uint256); /// @notice Get the details of a given vesting entry /// @param _entryID The id of the vesting entry. /// @return endTime the vesting entry object /// @return escrowAmount rate per second emission. /// @return duration the duration of the vesting entry. /// @return earlyVestingFee the early vesting fee of the vesting entry. function getVestingEntry(uint256 _entryID) external view returns (uint256, uint256, uint256, uint256); /// @notice Get the vesting entries for a given account /// @param _account The account to get the vesting entries for /// @param _index The index of the first vesting entry to get /// @param _pageSize The number of vesting entries to get /// @return vestingEntries the list of vesting entries with ids function getVestingSchedules(address _account, uint256 _index, uint256 _pageSize) external view returns (VestingEntryWithID[] memory); /// @notice Get the vesting entries for a given account /// @param _account The account to get the vesting entries for /// @param _index The index of the first vesting entry to get /// @param _pageSize The number of vesting entries to get /// @return vestingEntries the list of vesting entry ids function getAccountVestingEntryIDs(address _account, uint256 _index, uint256 _pageSize) external view returns (uint256[] memory); /// @notice Get the amount that can be vested now for a set of vesting entries /// @param _entryIDs The ids of the vesting entries to get the quantity for /// @return total The total amount that can be vested for these entries /// @return totalFee The total amount of fees that will be paid for these vesting entries function getVestingQuantity(uint256[] calldata _entryIDs) external view returns (uint256, uint256); /// @notice Get the amount that can be vested now for a given vesting entry /// @param _entryID The id of the vesting entry to get the quantity for /// @return quantity The total amount that can be vested for this entry /// @return totalFee The total amount of fees that will be paid for this vesting entry function getVestingEntryClaimable(uint256 _entryID) external view returns (uint256, uint256); /*/////////////////////////////////////////////////////////////// MUTATIVE FUNCTIONS ///////////////////////////////////////////////////////////////*/ /// @notice Vest escrowed amounts that are claimable - allows users to vest their vesting entries based on msg.sender /// @param _entryIDs The ids of the vesting entries to vest function vest(uint256[] calldata _entryIDs) external; /// @notice Utilized by the escrow migrator contract to transfer V1 escrow /// @param _account The account to import the escrow entry to /// @param entryToImport The vesting entry to import function importEscrowEntry(address _account, VestingEntry memory entryToImport) external; /// @notice Create an escrow entry to lock KWENTA for a given duration in seconds /// @param _beneficiary The account that will be able to withdraw the escrowed amount /// @param _deposit The amount of KWENTA to escrow /// @param _duration The duration in seconds to lock the KWENTA for /// @param _earlyVestingFee The fee to apply if the escrowed amount is withdrawn before the end of the vesting period /// @dev the early vesting fee decreases linearly over the vesting period /// @dev This call expects that the depositor (msg.sender) has already approved the Reward escrow contract /// to spend the the amount being escrowed. function createEscrowEntry( address _beneficiary, uint256 _deposit, uint256 _duration, uint256 _earlyVestingFee ) external; /// @notice Add a new vesting entry at a given time and quantity to an account's schedule. /// @dev A call to this should accompany a previous successful call to kwenta.transfer(rewardEscrow, amount), /// to ensure that when the funds are withdrawn, there is enough balance. /// This is only callable by the staking rewards contract /// The duration defaults to 1 year, and the early vesting fee to 90% /// @param _account The account to append a new vesting entry to. /// @param _quantity The quantity of KWENTA that will be escrowed. function appendVestingEntry(address _account, uint256 _quantity) external; /// @notice Transfer multiple entries from one account to another /// Sufficient escrowed KWENTA must be unstaked for the transfer to succeed /// @param _from The account to transfer the entries from /// @param _to The account to transfer the entries to /// @param _entryIDs a list of the ids of the entries to transfer function bulkTransferFrom(address _from, address _to, uint256[] calldata _entryIDs) external; /// @dev Triggers stopped state function pauseRewardEscrow() external; /// @dev Returns to normal state. function unpauseRewardEscrow() external; /*/////////////////////////////////////////////////////////////// EVENTS ///////////////////////////////////////////////////////////////*/ /// @notice emitted when an escrow entry is vested /// @param beneficiary The account that was vested to /// @param value The amount of KWENTA that was vested event Vested(address indexed beneficiary, uint256 value); /// @notice emitted when an escrow entry is created /// @param beneficiary The account that gets the entry /// @param value The amount of KWENTA that was escrowed /// @param duration The duration in seconds of the vesting entry /// @param entryID The id of the vesting entry /// @param earlyVestingFee The early vesting fee of the vesting entry event VestingEntryCreated( address indexed beneficiary, uint256 value, uint256 duration, uint256 entryID, uint256 earlyVestingFee ); /// @notice emitted when the staking rewards contract is set /// @param stakingRewards The address of the staking rewards contract event StakingRewardsSet(address stakingRewards); /// @notice emitted when the escrow migrator contract is set /// @param escrowMigrator The address of the escrow migrator contract event EscrowMigratorSet(address escrowMigrator); /// @notice emitted when the treasury DAO is set /// @param treasuryDAO The address of the treasury DAO event TreasuryDAOSet(address treasuryDAO); /// @notice emitted when the early vest fee is sent to the treasury and notifier /// @param amountToTreasury The amount of KWENTA sent to the treasury /// @param amountToNotifier The amount of KWENTA sent to the notifier event EarlyVestFeeSent(uint256 amountToTreasury, uint256 amountToNotifier); /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ /// @notice Thrown when attempting to bulk transfer from and to the same address error CannotTransferToSelf(); /// @notice Insufficient unstaked escrow to facilitate transfer /// @param escrowAmount the amount of escrow attempted to transfer /// @param unstakedBalance the amount of unstaked escrow available error InsufficientUnstakedBalance(uint256 escrowAmount, uint256 unstakedBalance); /// @notice Attempted to set entry early vesting fee beyond 100% error EarlyVestingFeeTooHigh(); /// @notice cannot mint entries with early vesting fee below the minimum error EarlyVestingFeeTooLow(); /// @notice error someone other than staking rewards calls an onlyStakingRewards function error OnlyStakingRewards(); /// @notice error someone other than escrow migrator calls an onlyEscrowMigrator function error OnlyEscrowMigrator(); /// @notice staking rewards is only allowed to be set once error StakingRewardsAlreadySet(); /// @notice cannot set this value to the zero address error ZeroAddress(); /// @notice cannot mint entries with zero escrow error ZeroAmount(); /// @notice Cannot escrow with 0 duration OR above max_duration error InvalidDuration(); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable { function __ERC721Enumerable_init() internal onlyInitializing { } function __ERC721Enumerable_init_unchained() internal onlyInitializing { } // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC721Upgradeable) returns (bool) { return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev See {ERC721-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual override { super._beforeTokenTransfer(from, to, firstTokenId, batchSize); if (batchSize > 1) { // Will only trigger during construction. Batch transferring (minting) is not available afterwards. revert("ERC721Enumerable: consecutive transfers not supported"); } uint256 tokenId = firstTokenId; if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721Upgradeable.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[46] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol) pragma solidity ^0.8.0; import "./OwnableUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides 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} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable { function __Ownable2Step_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable2Step_init_unchained() internal onlyInitializing { } address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() external { address sender = _msgSender(); require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner"); _transferOwnership(sender); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; interface IKwenta is IERC20 { function mint(address account, uint amount) external; function burn(uint amount) external; function setSupplySchedule(address _supplySchedule) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; interface IStakingRewardsV2 { /*////////////////////////////////////////////////////////////// STRUCTS //////////////////////////////////////////////////////////////*/ /// @notice A checkpoint for tracking values at a given timestamp struct Checkpoint { // The timestamp when the value was generated uint64 ts; // The block number when the value was generated uint64 blk; // The value of the checkpoint /// @dev will not overflow unless it value reaches 340 quintillion /// This number should be impossible to reach with the total supply of $KWENTA uint128 value; } /*/////////////////////////////////////////////////////////////// INITIALIZER ///////////////////////////////////////////////////////////////*/ /// @notice Initializes the contract /// @param _owner: owner of this contract /// @dev this function should be called via proxy, not via direct contract interaction function initialize(address _owner) external; /*////////////////////////////////////////////////////////////// Views //////////////////////////////////////////////////////////////*/ // token state /// @dev returns staked tokens which will likely not be equal to total tokens /// in the contract since reward and staking tokens are the same /// @return total amount of tokens that are being staked function totalSupply() external view returns (uint256); // staking state /// @notice Returns the total number of staked tokens for a user /// the sum of all escrowed and non-escrowed tokens /// @param _account: address of potential staker /// @return amount of tokens staked by account function balanceOf(address _account) external view returns (uint256); /// @notice Getter function for number of staked escrow tokens /// @param _account address to check the escrowed tokens staked /// @return amount of escrowed tokens staked function escrowedBalanceOf(address _account) external view returns (uint256); /// @notice Getter function for number of staked non-escrow tokens /// @param _account address to check the non-escrowed tokens staked /// @return amount of non-escrowed tokens staked function nonEscrowedBalanceOf(address _account) external view returns (uint256); /// @notice Getter function for the total number of escrowed tokens that are not not staked /// @param _account: address to check /// @return amount of tokens escrowed but not staked function unstakedEscrowedBalanceOf(address _account) external view returns (uint256); /// @notice the period of time a user has to wait after staking to unstake function cooldownPeriod() external view returns (uint256); // rewards /// @notice calculate the total rewards for one duration based on the current rate /// @return rewards for the duration specified by rewardsDuration function getRewardForDuration() external view returns (uint256); /// @notice calculate running sum of reward per total tokens staked /// at this specific time /// @return running sum of reward per total tokens staked function rewardPerToken() external view returns (uint256); /// @notice calculate running sum of USDC reward per total tokens staked /// at this specific time /// @return running sum of USDC reward per total tokens staked function rewardPerTokenUSDC() external view returns (uint256); /// @notice get the last time a reward is applicable for a given user /// @return timestamp of the last time rewards are applicable function lastTimeRewardApplicable() external view returns (uint256); /// @notice determine how much reward token an account has earned thus far /// @param _account: address of account earned amount is being calculated for function earned(address _account) external view returns (uint256); /// @notice determine how much USDC reward an account has earned thus far /// @param _account: address of account earned amount is being calculated for function earnedUSDC(address _account) external view returns (uint256); // checkpointing /// @notice get the number of balances checkpoints for an account /// @param _account: address of account to check /// @return number of balances checkpoints function balancesCheckpointsLength(address _account) external view returns (uint256); /// @notice get the number of escrowed balance checkpoints for an account /// @param _account: address of account to check /// @return number of escrowed balance checkpoints function escrowedBalancesCheckpointsLength(address _account) external view returns (uint256); /// @notice get the number of total supply checkpoints /// @return number of total supply checkpoints function totalSupplyCheckpointsLength() external view returns (uint256); /// @notice get a users balance at a given timestamp /// @param _account: address of account to check /// @param _timestamp: timestamp to check /// @return balance at given timestamp /// @dev if called with a timestamp that equals the current block timestamp, then the function might return inconsistent /// values as further transactions changing the balances can still occur within the same block. function balanceAtTime(address _account, uint256 _timestamp) external view returns (uint256); /// @notice get a users escrowed balance at a given timestamp /// @param _account: address of account to check /// @param _timestamp: timestamp to check /// @return escrowed balance at given timestamp /// @dev if called with a timestamp that equals the current block timestamp, then the function might return inconsistent /// values as further transactions changing the balances can still occur within the same block. function escrowedBalanceAtTime(address _account, uint256 _timestamp) external view returns (uint256); /// @notice get the total supply at a given timestamp /// @param _timestamp: timestamp to check /// @return total supply at given timestamp /// @dev if called with a timestamp that equals the current block timestamp, then the function might return inconsistent /// values as further transactions changing the balances can still occur within the same block. function totalSupplyAtTime(uint256 _timestamp) external view returns (uint256); /*////////////////////////////////////////////////////////////// Mutative //////////////////////////////////////////////////////////////*/ // Staking/Unstaking /// @notice stake token /// @param _amount: amount to stake /// @dev updateReward() called prior to function logic function stake(uint256 _amount) external; /// @notice unstake token /// @param _amount: amount to unstake /// @dev updateReward() called prior to function logic function unstake(uint256 _amount) external; /// @notice stake escrowed token /// @param _amount: amount to stake /// @dev updateReward() called prior to function logic function stakeEscrow(uint256 _amount) external; /// @notice unstake escrowed token /// @param _amount: amount to unstake /// @dev updateReward() called prior to function logic function unstakeEscrow(uint256 _amount) external; /// @notice unstake escrowed token skipping the cooldown wait period /// @param _account: address of account to unstake from /// @param _amount: amount to unstake /// @dev this function is used to allow tokens to be vested at any time by RewardEscrowV2 function unstakeEscrowSkipCooldown(address _account, uint256 _amount) external; /// @notice unstake all available staked non-escrowed tokens and /// claim any rewards function exit() external; // claim rewards /// @notice caller claims any rewards generated from staking /// @dev rewards are escrowed in RewardEscrow /// @dev updateReward() called prior to function logic function getReward() external; /// @notice claim rewards for an account and stake them function compound() external; // delegation /// @notice approve an operator to collect rewards and stake escrow on behalf of the sender /// @param operator: address of operator to approve /// @param approved: whether or not to approve the operator function approveOperator(address operator, bool approved) external; /// @notice stake escrowed token on behalf of another account /// @param _account: address of account to stake on behalf of /// @param _amount: amount to stake function stakeEscrowOnBehalf(address _account, uint256 _amount) external; /// @notice caller claims any rewards generated from staking on behalf of another account /// The rewards will be escrowed in RewardEscrow with the account as the beneficiary /// @param _account: address of account to claim rewards for function getRewardOnBehalf(address _account) external; /// @notice claim and stake rewards on behalf of another account /// @param _account: address of account to claim and stake rewards for function compoundOnBehalf(address _account) external; // settings /// @notice configure reward rate /// @param _reward: amount of token to be distributed over a period /// @param _reward: amount of usdc to be distributed over a period /// @dev updateReward() called prior to function logic (with zero address) function notifyRewardAmount(uint256 _reward, uint256 _rewardUsdc) external; /// @notice set rewards duration /// @param _rewardsDuration: denoted in seconds function setRewardsDuration(uint256 _rewardsDuration) external; /// @notice set unstaking cooldown period /// @param _cooldownPeriod: denoted in seconds function setCooldownPeriod(uint256 _cooldownPeriod) external; // pausable /// @dev Triggers stopped state function pauseStakingRewards() external; /// @dev Returns to normal state. function unpauseStakingRewards() external; // misc. /// @notice added to support recovering LP Rewards from other systems /// such as BAL to be distributed to holders /// @param tokenAddress: address of token to be recovered /// @param tokenAmount: amount of token to be recovered function recoverERC20(address tokenAddress, uint256 tokenAmount) external; /*/////////////////////////////////////////////////////////////// EVENTS ///////////////////////////////////////////////////////////////*/ /// @notice update reward rate /// @param reward: kwenta amount to be distributed over applicable rewards duration /// @param rewardUsdc: usdc amount to be distributed over applicable rewards duration event RewardAdded(uint256 reward, uint256 rewardUsdc); /// @notice emitted when user stakes tokens /// @param user: staker address /// @param amount: amount staked event Staked(address indexed user, uint256 amount); /// @notice emitted when user unstakes tokens /// @param user: address of user unstaking /// @param amount: amount unstaked event Unstaked(address indexed user, uint256 amount); /// @notice emitted when escrow staked /// @param user: owner of escrowed tokens address /// @param amount: amount staked event EscrowStaked(address indexed user, uint256 amount); /// @notice emitted when staked escrow tokens are unstaked /// @param user: owner of escrowed tokens address /// @param amount: amount unstaked event EscrowUnstaked(address user, uint256 amount); /// @notice emitted when user claims rewards /// @param user: address of user claiming rewards /// @param reward: amount of reward token claimed event RewardPaid(address indexed user, uint256 reward); /// @notice emitted when user claims USDC rewards /// @param user: address of user claiming rewards /// @param reward: amount of USDC token claimed event RewardPaidUSDC(address indexed user, uint256 reward); /// @notice emitted when rewards duration changes /// @param newDuration: denoted in seconds event RewardsDurationUpdated(uint256 newDuration); /// @notice emitted when tokens are recovered from this contract /// @param token: address of token recovered /// @param amount: amount of token recovered event Recovered(address token, uint256 amount); /// @notice emitted when the unstaking cooldown period is updated /// @param cooldownPeriod: the new unstaking cooldown period event CooldownPeriodUpdated(uint256 cooldownPeriod); /// @notice emitted when an operator is approved /// @param owner: owner of tokens /// @param operator: address of operator /// @param approved: whether or not operator is approved event OperatorApproved(address owner, address operator, bool approved); /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ /// @notice error someone other than reward escrow calls an onlyRewardEscrow function error OnlyRewardEscrow(); /// @notice error someone other than the rewards notifier calls an onlyRewardsNotifier function error OnlyRewardsNotifier(); /// @notice cannot set this value to the zero address error ZeroAddress(); /// @notice error when user tries to stake/unstake 0 tokens error AmountZero(); /// @notice the user does not have enough tokens to unstake that amount /// @param availableBalance: amount of tokens available to withdraw error InsufficientBalance(uint256 availableBalance); /// @notice error when trying to stakeEscrow more than the unstakedEscrow available /// @param unstakedEscrow amount of unstaked escrow error InsufficientUnstakedEscrow(uint256 unstakedEscrow); /// @notice previous rewards period must be complete before changing the duration for the new period error RewardsPeriodNotComplete(); /// @notice recovering the staking token is not allowed error CannotRecoverStakingToken(); /// @notice recovering the usdc reward token is not allowed error CannotRecoverRewardToken(); /// @notice error when user tries unstake during the cooldown period /// @param canUnstakeAt timestamp when user can unstake error MustWaitForUnlock(uint256 canUnstakeAt); /// @notice error when trying to set a rewards duration that is too short error RewardsDurationCannotBeZero(); /// @notice error when trying to set a cooldown period below the minimum /// @param minCooldownPeriod minimum cooldown period error CooldownPeriodTooLow(uint256 minCooldownPeriod); /// @notice error when trying to set a cooldown period above the maximum /// @param maxCooldownPeriod maximum cooldown period error CooldownPeriodTooHigh(uint256 maxCooldownPeriod); /// @notice the caller is not approved to take this action error NotApproved(); /// @notice attempted to approve self as an operator error CannotApproveSelf(); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; interface IEscrowMigrator { /*////////////////////////////////////////////////////////////// STRUCTS AND ENUMS //////////////////////////////////////////////////////////////*/ /// @notice A vesting entry contains the data for each escrow entry struct VestingEntry { // The amount of KWENTA stored in this vesting entry uint248 escrowAmount; // Whether the entry has been migrated to v2 bool migrated; } /// @notice A vesting entry contains the data for each escrow entry struct VestingEntryWithID { // The entryID associated with this vesting entry uint256 entryID; // The amount of KWENTA stored in this vesting entry uint256 escrowAmount; // Whether the entry has been migrated to v2 bool migrated; } /*/////////////////////////////////////////////////////////////// INITIALIZER ///////////////////////////////////////////////////////////////*/ /// @notice Initializes the contract /// @param _owner The address of the owner of this contract /// @param _treasuryDAO The address of the treasury DAO /// @dev this function should be called via proxy, not via direct contract interaction function initialize(address _owner, address _treasuryDAO) external; /*////////////////////////////////////////////////////////////// VIEWS //////////////////////////////////////////////////////////////*/ /// @notice The deadline for migration, set to 2 weeks from when a user initializes function MIGRATION_DEADLINE() external view returns (uint256); /// @notice Get the total number of registered vesting entries for a given account /// @param _account The address of the account to query /// @return The number of vesting entries for the given account function numberOfRegisteredEntries(address _account) external view returns (uint256); /// @notice Get the total number of migrated vesting entries for a given account /// @param _account The address of the account to query /// @return The number of vesting entries for the given account /// @dev WARNING: loop is potentially limitless - could revert with out of gas error if called on-chain function numberOfMigratedEntries(address _account) external view returns (uint256); /// @notice Get the total escrowed registerd for an account /// @param _account The address of the account to query /// @return total the total escrow registered for the given account /// @dev WARNING: loop is potentially limitless - could revert with out of gas error if called on-chain function totalEscrowRegistered(address _account) external view returns (uint256 total); /// @notice Get the total escrowed migrated for an account /// @param _account The address of the account to query /// @return total the total escrow migrated for the given account /// @dev WARNING: loop is potentially limitless - could revert with out of gas error if called on-chain function totalEscrowMigrated(address _account) external view returns (uint256 total); /// @notice Get the total escrow that has been registered but not migrated for a user /// @param _account The address of the account to query /// @return total the total registered but non-migrated escrow for the given account /// @dev WARNING: loop is potentially limitless - could revert with out of gas error if called on-chain function totalEscrowUnmigrated(address _account) external view returns (uint256 total); /// @notice the amount a given user needs to pay to migrate all currently vested /// registered entries. The user should approve the escrow migrator for at least /// this amount before beginning the migration step /// @param _account The address of the account to query /// @return toPay the amount the user needs to pay to migrate all currently vested function toPay(address _account) external view returns (uint256); /// @notice Get the vesting entry data for a given account and entry ID /// @param _account The address of the account to query /// @param _entryID The ID of the entry to query function getRegisteredVestingEntry(address _account, uint256 _entryID) external view returns (uint256 escrowAmount, bool migrated); /// @notice get a list of vesting entries for a given account /// @param _account The address of the account to query /// @param _index The _index of the first entry to query /// @param _pageSize The number of entries to query function getRegisteredVestingSchedules(address _account, uint256 _index, uint256 _pageSize) external view returns (VestingEntryWithID[] memory); /// @notice get a list of vesting entry IDs for a given account /// @param _account The address of the account to query /// @param _index The index of the first entry to query /// @param _pageSize The number of entries to query function getRegisteredVestingEntryIDs(address _account, uint256 _index, uint256 _pageSize) external view returns (uint256[] memory); /*////////////////////////////////////////////////////////////// STEP 0 //////////////////////////////////////////////////////////////*/ /// @notice claim any remaining StakingRewards V1 rewards /// This should be done before the migration process can begin /*////////////////////////////////////////////////////////////// STEP 1 //////////////////////////////////////////////////////////////*/ /// @notice Step 1 in the migration process - register any entries to be migrated /// @param _entryIDs: The entries to register for migration /// @dev WARNING: If the user vests non-registerd entries after this step, they will have to pay extra for the migration. /// The user should register all entries they want to migrate BEFORE vesting, otherwise it will not be possible to migrate them. /// @dev WARNING: To reiterate, if the user vests any entries that are not registered after initiating, they will have /// to pay extra for the migration. This is because the user will have to pay for the migration based on the total vested balance at the time of /// migration - but only registered entries will be created for them on V2 /// @param _entryIDs: The entries to register for migration function registerEntries(uint256[] calldata _entryIDs) external; /*////////////////////////////////////////////////////////////// STEP 2 //////////////////////////////////////////////////////////////*/ /// @notice Vest any registered entries and approve the EscrowMigrator contract /// to spend liquid at least the `toPay` amount of $KWENTA /// @notice WARNING: DO NOT VEST ANY NON-REGISTERED ENTRIES /*////////////////////////////////////////////////////////////// STEP 3 //////////////////////////////////////////////////////////////*/ /// @notice Step 3 in the migration process - migrate the registered entries /// @notice The user MUST vest any registered entries before they can be migrated /// @notice The user MUST NOT vest any non-registered entries before this step /// @param _to: The address to migrate the entries to /// @param _entryIDs: The entries to migrate function migrateEntries(address _to, uint256[] calldata _entryIDs) external; /*////////////////////////////////////////////////////////////// INTEGRATOR MIGRATION //////////////////////////////////////////////////////////////*/ /// @notice step 0 - claim any remaining StakingRewards V1 rewards /// @notice step 1 - initiate & register entries for migration /// @param _integrator: The address of the integrator to register entries for /// @param _entryIDs: The entries to register for migration /// @dev WARNING: If the integrator vests non-registerd entries after this step, they will have to pay extra for the migration. function registerIntegratorEntries(address _integrator, uint256[] calldata _entryIDs) external; /// @notice step 2 - vest all registered entries via the integartor, pulling the early vested KWENTA to the beneficiary's address. /// Then the beneficiary must approve the EscrowMigrator contract for at least the integrators `toPay` amount. /// @notice step 3 - migrate all registered & vested entries /// @param _integrator: The address of the integrator to migrate entries for /// @param _to: The address to migrate the entries to /// @param _entryIDs: The entries to migrate function migrateIntegratorEntries( address _integrator, address _to, uint256[] calldata _entryIDs ) external; /*////////////////////////////////////////////////////////////// FUND RECOVERY //////////////////////////////////////////////////////////////*/ /// @notice Allows the owner to change the treasury DAO address /// @param _newTreasuryDAO The address of the new treasury DAO function setTreasuryDAO(address _newTreasuryDAO) external; /// @notice Account for locked funds for a list of expired migrators /// @param _expiredMigrators The addresses of the expired migrators /// @dev warning - may fail due to unbounded loop for certain users function updateTotalLocked(address[] memory _expiredMigrators) external; /// @notice Account for locked funds for a single expired migrator /// @param _expiredMigrator The address of the expired migrator /// @dev warning - may fail due to unbounded loop for certain users function updateTotalLocked(address _expiredMigrator) external; /// @notice Withdraw excess funds from the contract to the treasury function recoverExcessFunds() external; /*/////////////////////////////////////////////////////////////// PAUSABLE //////////////////////////////////////////////////////////////*/ /// @notice Pause the reward escrow contract function pauseEscrowMigrator() external; /// @notice Unpause the reward escrow contract function unpauseEscrowMigrator() external; /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ /// @notice cannot set this value to the zero address error ZeroAddress(); /// @notice the caller is not approved to take this action error NotApproved(); /// @notice the user may not begin the migration process if they have nothing to migrate error NoEscrowBalanceToMigrate(); /// @notice step 2 canont be called until the user has initiated via step 1 error MustBeInitiated(); /// @notice a user must complete migrating within the specified time window after initiating error DeadlinePassed(); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.2) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721Upgradeable.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[44] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _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); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.3) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/IERC1967Upgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @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) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0 <0.9.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (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 IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.3) (interfaces/IERC1967.sol) pragma solidity ^0.8.0; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. * * _Available since v4.9._ */ interface IERC1967Upgradeable { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
// 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 IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "@openzeppelin/=node_modules/@openzeppelin/", "@ensdomains/=node_modules/@ensdomains/", "@eth-optimism/=node_modules/@eth-optimism/", "@openzeppelin/=node_modules/@openzeppelin/", "eth-gas-reporter/=node_modules/eth-gas-reporter/", "hardhat-deploy/=node_modules/hardhat-deploy/", "hardhat/=node_modules/hardhat/", "openzeppelin-solidity-2.3.0/=node_modules/openzeppelin-solidity-2.3.0/", "synthetix/=node_modules/synthetix/", "truffle/=node_modules/truffle/" ], "optimizer": { "enabled": true, "runs": 1000000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_kwenta","type":"address"},{"internalType":"address","name":"_rewardsNotifier","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CannotTransferToSelf","type":"error"},{"inputs":[],"name":"EarlyVestingFeeTooHigh","type":"error"},{"inputs":[],"name":"EarlyVestingFeeTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"escrowAmount","type":"uint256"},{"internalType":"uint256","name":"unstakedBalance","type":"uint256"}],"name":"InsufficientUnstakedBalance","type":"error"},{"inputs":[],"name":"InvalidDuration","type":"error"},{"inputs":[],"name":"OnlyEscrowMigrator","type":"error"},{"inputs":[],"name":"OnlyStakingRewards","type":"error"},{"inputs":[],"name":"StakingRewardsAlreadySet","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountToTreasury","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountToNotifier","type":"uint256"}],"name":"EarlyVestFeeSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"escrowMigrator","type":"address"}],"name":"EscrowMigratorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","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"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stakingRewards","type":"address"}],"name":"StakingRewardsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"treasuryDAO","type":"address"}],"name":"TreasuryDAOSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Vested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"entryID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"earlyVestingFee","type":"uint256"}],"name":"VestingEntryCreated","type":"event"},{"inputs":[],"name":"DEFAULT_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_EARLY_VESTING_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAXIMUM_EARLY_VESTING_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_EARLY_VESTING_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_quantity","type":"uint256"}],"name":"appendVestingEntry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256[]","name":"_entryIDs","type":"uint256[]"}],"name":"bulkTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_deposit","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"},{"internalType":"uint256","name":"_earlyVestingFee","type":"uint256"}],"name":"createEscrowEntry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"escrowMigrator","outputs":[{"internalType":"contract IEscrowMigrator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"escrowedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_pageSize","type":"uint256"}],"name":"getAccountVestingEntryIDs","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getKwentaAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_entryID","type":"uint256"}],"name":"getVestingEntry","outputs":[{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"escrowAmount","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"earlyVestingFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_entryID","type":"uint256"}],"name":"getVestingEntryClaimable","outputs":[{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_entryIDs","type":"uint256[]"}],"name":"getVestingQuantity","outputs":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"totalFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_pageSize","type":"uint256"}],"name":"getVestingSchedules","outputs":[{"components":[{"internalType":"uint256","name":"escrowAmount","type":"uint256"},{"internalType":"uint256","name":"entryID","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"}],"internalType":"struct IRewardEscrowV2.VestingEntryWithID[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"components":[{"internalType":"uint256","name":"escrowAmount","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"earlyVestingFee","type":"uint256"}],"internalType":"struct IRewardEscrowV2.VestingEntry","name":"_entry","type":"tuple"}],"name":"importEscrowEntry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contractOwner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"kwenta","outputs":[{"internalType":"contract IKwenta","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextEntryId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseRewardEscrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardsNotifier","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_escrowMigrator","type":"address"}],"name":"setEscrowMigrator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingRewards","type":"address"}],"name":"setStakingRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasuryDAO","type":"address"}],"name":"setTreasuryDAO","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingRewards","outputs":[{"internalType":"contract IStakingRewardsV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalEscrowedAccountBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalEscrowedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalVestedAccountBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryDAO","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpauseRewardEscrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"unstakedEscrowedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_entryIDs","type":"uint256[]"}],"name":"vest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"vestingSchedules","outputs":[{"internalType":"uint144","name":"escrowAmount","type":"uint144"},{"internalType":"uint40","name":"duration","type":"uint40"},{"internalType":"uint64","name":"endTime","type":"uint64"},{"internalType":"uint8","name":"earlyVestingFee","type":"uint8"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60e0604052306080523480156200001557600080fd5b5060405162005f1c38038062005f1c833981016040819052620000389162000179565b6001600160a01b03821615806200005657506001600160a01b038116155b15620000755760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b0380831660a052811660c052620000926200009a565b5050620001b1565b600054610100900460ff1615620001075760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811610156200015a576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b03811681146200017457600080fd5b919050565b600080604083850312156200018d57600080fd5b62000198836200015c565b9150620001a8602084016200015c565b90509250929050565b60805160a05160c051615cee6200022e60003960008181610c6201526117e601526000818161039f0152818161098c0152818161127b0152818161173b01528181611815015281816118fa01526131a60152600081816119d201528181611a8201528181611bf201528181611ca20152611ea90152615cee6000f3fe60806040526004361061038b5760003560e01c80636fb83a57116101dc578063ad18e97e11610102578063ca2c7f76116100a0578063e6b2cf6c1161006f578063e6b2cf6c14610c84578063e985e9c514610c9b578063eac6248914610cf1578063f2fde38b14610d1e57600080fd5b8063ca2c7f7614610be5578063daf3807314610c05578063e30c397814610c25578063e509584314610c5057600080fd5b8063b88d4fde116100dc578063b88d4fde14610b6d578063c297fa0f14610b8d578063c4d66de814610ba5578063c87b56dd14610bc557600080fd5b8063ad18e97e14610b07578063b1724b4614610b35578063b5ddb9c714610b4d57600080fd5b80638da5cb5b1161017a578063a22cb46511610149578063a22cb465146109e3578063a4116a7e14610a03578063a46eddcf14610ad2578063ac2fdb1a14610af257600080fd5b80638da5cb5b1461094f5780639034802b1461097a57806395d89b41146109ae57806398ab1e3d146109c357600080fd5b806371e780f3116101b657806371e780f3146108e1578063773ab39f146108f857806379ba5097146109255780637d5ff94d1461093a57600080fd5b80636fb83a571461088c57806370a08231146108ac578063715018a6146108cc57600080fd5b806334c7fec9116102c157806352d1902d1161025f5780635c975abb1161022e5780635c975abb1461072a5780636352211e1461074357806364b87a70146107635780636d3cbe211461079157600080fd5b806352d1902d146106c0578063534c0842146106d557806353a535d3146106ea5780635414408d1461070a57600080fd5b806342842e0e1161029b57806342842e0e1461063f57806348591dd71461065f5780634f1ef2861461068d5780634f6ccce7146106a057600080fd5b806334c7fec9146105ea5780633659cfe61461060a5780633e7f4c091461062a57600080fd5b806318160ddd1161032e57806323b872dd1161030857806323b872dd1461056757806324c0f5b5146105875780632f745c591461059c578063326a3cfb146105bc57600080fd5b806318160ddd1461050457806318c1cb5214610519578063227d517a1461053957600080fd5b8063057a601b1161036a578063057a601b1461044e57806306fdde03146104a0578063081812fc146104c2578063095ea7b3146104e257600080fd5b80624d37e21461039057806301ffc9a7146103e957806303df264014610419575b600080fd5b34801561039c57600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b3480156103f557600080fd5b50610409610404366004615282565b610d3e565b60405190151581526020016103e0565b34801561042557600080fd5b506104396104343660046152eb565b610d9a565b604080519283526020830191909152016103e0565b34801561045a57600080fd5b50610492610469366004615356565b73ffffffffffffffffffffffffffffffffffffffff1660009081526101c8602052604090205490565b6040519081526020016103e0565b3480156104ac57600080fd5b506104b5610e0d565b6040516103e091906153df565b3480156104ce57600080fd5b506103bf6104dd3660046153f2565b610e9f565b3480156104ee57600080fd5b506105026104fd36600461540b565b610ed3565b005b34801561051057600080fd5b50609954610492565b34801561052557600080fd5b50610502610534366004615435565b611064565b34801561054557600080fd5b50610492610554366004615356565b6101c96020526000908152604090205481565b34801561057357600080fd5b5061050261058236600461546e565b611321565b34801561059357600080fd5b50610492606481565b3480156105a857600080fd5b506104926105b736600461540b565b6113c3565b3480156105c857600080fd5b506104926105d7366004615356565b6101c86020526000908152604090205481565b3480156105f657600080fd5b506105026106053660046152eb565b611492565b34801561061657600080fd5b50610502610625366004615356565b6119bb565b34801561063657600080fd5b50610492603281565b34801561064b57600080fd5b5061050261065a36600461546e565b611bc0565b34801561066b57600080fd5b506101c4546103bf9073ffffffffffffffffffffffffffffffffffffffff1681565b61050261069b366004615584565b611bdb565b3480156106ac57600080fd5b506104926106bb3660046153f2565b611dd1565b3480156106cc57600080fd5b50610492611e8f565b3480156106e157600080fd5b50610502611f7b565b3480156106f657600080fd5b506105026107053660046155d2565b611f8d565b34801561071657600080fd5b50610502610725366004615356565b612084565b34801561073657600080fd5b5061012d5460ff16610409565b34801561074f57600080fd5b506103bf61075e3660046153f2565b612154565b34801561076f57600080fd5b506101c3546103bf9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561079d57600080fd5b5061083f6107ac3660046153f2565b6101c66020526000908152604090205471ffffffffffffffffffffffffffffffffffff8116907201000000000000000000000000000000000000810464ffffffffff169077010000000000000000000000000000000000000000000000810467ffffffffffffffff16907f0100000000000000000000000000000000000000000000000000000000000000900460ff1684565b6040805171ffffffffffffffffffffffffffffffffffff909516855264ffffffffff909316602085015267ffffffffffffffff9091169183019190915260ff1660608201526080016103e0565b34801561089857600080fd5b506105026108a7366004615356565b6121e0565b3480156108b857600080fd5b506104926108c7366004615356565b6122fa565b3480156108d857600080fd5b506105026123c8565b3480156108ed57600080fd5b506104926101ca5481565b34801561090457600080fd5b50610918610913366004615633565b6123da565b6040516103e09190615666565b34801561093157600080fd5b506105026125f1565b34801561094657600080fd5b50610492605a81565b34801561095b57600080fd5b5060c95473ffffffffffffffffffffffffffffffffffffffff166103bf565b34801561098657600080fd5b506103bf7f000000000000000000000000000000000000000000000000000000000000000081565b3480156109ba57600080fd5b506104b56126a3565b3480156109cf57600080fd5b506104396109de3660046153f2565b6126b2565b3480156109ef57600080fd5b506105026109fe3660046156cd565b6126d6565b348015610a0f57600080fd5b50610ab2610a1e3660046153f2565b60009081526101c6602052604090205477010000000000000000000000000000000000000000000000810467ffffffffffffffff169171ffffffffffffffffffffffffffffffffffff8216917201000000000000000000000000000000000000810464ffffffffff16917f010000000000000000000000000000000000000000000000000000000000000090910460ff1690565b6040805194855260208501939093529183015260608201526080016103e0565b348015610ade57600080fd5b50610502610aed366004615356565b6126e1565b348015610afe57600080fd5b506105026127aa565b348015610b1357600080fd5b506101c5546103bf9073ffffffffffffffffffffffffffffffffffffffff1681565b348015610b4157600080fd5b5061049263077f880081565b348015610b5957600080fd5b50610502610b6836600461540b565b6127ba565b348015610b7957600080fd5b50610502610b88366004615704565b6127e6565b348015610b9957600080fd5b506104926301dfe20081565b348015610bb157600080fd5b50610502610bc0366004615356565b61288e565b348015610bd157600080fd5b506104b5610be03660046153f2565b612b00565b348015610bf157600080fd5b50610502610c0036600461576c565b612b73565b348015610c1157600080fd5b50610492610c20366004615356565b612be2565b348015610c3157600080fd5b5060fb5473ffffffffffffffffffffffffffffffffffffffff166103bf565b348015610c5c57600080fd5b506103bf7f000000000000000000000000000000000000000000000000000000000000000081565b348015610c9057600080fd5b506104926101c75481565b348015610ca757600080fd5b50610409610cb6366004615814565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152606a6020908152604080832093909416825291909152205460ff1690565b348015610cfd57600080fd5b50610d11610d0c366004615633565b612ca9565b6040516103e09190615847565b348015610d2a57600080fd5b50610502610d39366004615356565b612d80565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d63000000000000000000000000000000000000000000000000000000001480610d945750610d9482612e30565b92915050565b60008082815b81811015610e04576000610dcb878784818110610dbf57610dbf61588b565b90506020020135612f13565b9050600080610dd983612ff1565b9092509050610de882886158e9565b9650610df481876158e9565b9550836001019350505050610da0565b50509250929050565b606060658054610e1c906158fc565b80601f0160208091040260200160405190810160405280929190818152602001828054610e48906158fc565b8015610e955780601f10610e6a57610100808354040283529160200191610e95565b820191906000526020600020905b815481529060010190602001808311610e7857829003601f168201915b5050505050905090565b6000610eaa82613029565b5060009081526069602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6000610ede82612154565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610fa0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff82161480610fc95750610fc98133610cb6565b611055576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610f97565b61105f83836130b4565b505050565b73ffffffffffffffffffffffffffffffffffffffff84166110b1576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60648111156110ec576040517f30aed3ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6032811015611127576040517f6eede11900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82600003611161576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c354604080517f04646a49000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff16916304646a499160048083019260209291908290030181865afa1580156111d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f6919061594f565b905080831080611209575063077f880083115b15611240576040517f7616640100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018590527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906323b872dd906064016020604051808303816000875af11580156112d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fd9190615968565b50600061130a84426158e9565b90506113198682878787613154565b505050505050565b61132c335b8261341d565b6113b8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610f97565b61105f8383836134dd565b60006113ce836122fa565b821061145c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610f97565b5073ffffffffffffffffffffffffffffffffffffffff919091166000908152609760209081526040808320938352929052205490565b61149a61351f565b60008082815b818110156115ac5760008686838181106114bc576114bc61588b565b9050602002013590503373ffffffffffffffffffffffffffffffffffffffff166115088260009081526067602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611529575061159c565b60008061153d61153884612f13565b612ff1565b60008581526101c66020526040902080547fffffffffffffffffffffffffffff00000000000000000000000000000000000016905590925090506115808361358d565b61158a82886158e9565b965061159681876158e9565b95505050505b6115a581615985565b90506114a0565b5060006115b983856158e9565b905080156113195760006115cc33612be2565b905080821115611665576101c3546040517f7f94e8ff000000000000000000000000000000000000000000000000000000008152336004820152828403602482018190529173ffffffffffffffffffffffffffffffffffffffff1690637f94e8ff90604401600060405180830381600087803b15801561164b57600080fd5b505af115801561165f573d6000803e3d6000fd5b50505050505b816101ca600082825461167891906159bd565b90915550503360009081526101c860205260408120805484929061169d9084906159bd565b90915550503360009081526101c96020526040812080548792906116c29084906158e9565b909155505083156118bf5760006116da6002866159d0565b905060006116e882876159bd565b6101c5546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018590529192507f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af1158015611784573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117a89190615968565b506040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af115801561185e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118829190615968565b5060408051838152602081018390527fadd2755028f410fd28d5b98415bb469e4a5f7824d30429ca1c0c8a54de1eb537910160405180910390a150505b841561197e576040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018690527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063a9059cbb906044016020604051808303816000875af1158015611958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061197c9190615968565b505b60405185815233907ed5958799b183a7b738d3ad5e711305293dd5076a37a4e3b7e6611dea6114f39060200160405180910390a250505050505050565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163003611a80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610f97565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16611af57f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611b98576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610f97565b611ba181613673565b60408051600080825260208201909252611bbd9183919061367b565b50565b61105f838383604051806020016040528060008152506127e6565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163003611ca0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610f97565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16611d157f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611db8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610f97565b611dc182613673565b611dcd8282600161367b565b5050565b6000611ddc60995490565b8210611e6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610f97565b60998281548110611e7d57611e7d61588b565b90600052602060002001549050919050565b60003073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614611f56576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610f97565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b611f8361387a565b611f8b6138fb565b565b611f9561351f565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611ffa576040517fdad89dca00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081815b8181101561207857600085858381811061201b5761201b61588b565b6020908102929092013560008181526101c69093526040909220549192506120599171ffffffffffffffffffffffffffffffffffff169050856158e9565b935061206481613979565b61206f888883613a0e565b50600101611fff565b50611319868684613d16565b61208c61387a565b73ffffffffffffffffffffffffffffffffffffffff81166120d9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c480547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f790bf62e04348d5f5d45f86cb3a270b9b281e2e4e11f54a24eca40cf4dea5703906020015b60405180910390a150565b60008181526067602052604081205473ffffffffffffffffffffffffffffffffffffffff1680610d94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610f97565b6121e861387a565b73ffffffffffffffffffffffffffffffffffffffff8116612235576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c35473ffffffffffffffffffffffffffffffffffffffff1615612286576040517fa32250de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fb63c81227c62f4cb3e2b1120e3afbf3a2ed5dd8b9d99b8bef7275b084e6a98cb90602001612149565b600073ffffffffffffffffffffffffffffffffffffffff821661239f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152608401610f97565b5073ffffffffffffffffffffffffffffffffffffffff1660009081526068602052604090205490565b6123d061387a565b611f8b6000613db9565b606081600003612439576040805160008082526020820190925290612431565b61241e60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816123fa5790505b5090506125ea565b600061244583856158e9565b90506000612452866122fa565b905080821115612460578091505b848210156124bf5760408051600080825260208201909252906124b5565b6124a260405180606001604052806000815260200160008152602001600081525090565b81526020019060019003908161247e5790505b50925050506125ea565b84820360008167ffffffffffffffff8111156124dd576124dd6154aa565b60405190808252806020026020018201604052801561253257816020015b61251f60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816124fb5790505b50905060005b828110156125e357600061254e8a8a84016113c3565b60008181526101c660209081526040918290208251606081018452815471ffffffffffffffffffffffffffffffffffff811682529281018590527701000000000000000000000000000000000000000000000090920467ffffffffffffffff1692820192909252855192935090918590859081106125ce576125ce61588b565b60209081029190910101525050600101612538565b5093505050505b9392505050565b60fb54339073ffffffffffffffffffffffffffffffffffffffff16811461269a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e657200000000000000000000000000000000000000000000006064820152608401610f97565b611bbd81613db9565b606060668054610e1c906158fc565b60008060006126c084612f13565b90506126cb81612ff1565b909590945092505050565b611dcd338383613dea565b6126e961387a565b73ffffffffffffffffffffffffffffffffffffffff8116612736576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fd780e06c55efd6b3157e8c26704d2fd7bd2750bd9d0e71d2e5f675572dfad7a290602001612149565b6127b261387a565b611f8b613f17565b6127c2613f73565b60006127d26301dfe200426158e9565b905061105f8382846301dfe200605a613154565b6127f0338361341d565b61287c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610f97565b61288884848484613fc5565b50505050565b600054610100900460ff16158080156128ae5750600054600160ff909116105b806128c85750303b1580156128c8575060005460ff166001145b612954576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610f97565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156129b257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff82166129ff576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612a736040518060400160405280601481526020017f4b77656e74612052657761726420457363726f770000000000000000000000008152506040518060400160405280600381526020017f4b52450000000000000000000000000000000000000000000000000000000000815250614068565b612a7b614109565b612a836141a8565b612a8b614247565b612a9482613db9565b60016101c7558015611dcd57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b6060612b0b82613029565b6000612b2260408051602081019091526000815290565b90506000815111612b4257604051806020016040528060008152506125ea565b80612b4c846142de565b604051602001612b5d929190615a0b565b6040516020818303038152906040529392505050565b6101c45473ffffffffffffffffffffffffffffffffffffffff163314612bc5576040517f8f8a680600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611dcd828260400151836000015184602001518560600151613154565b6101c3546040517f057a601b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152600092169063057a601b90602401602060405180830381865afa158015612c54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c78919061594f565b73ffffffffffffffffffffffffffffffffffffffff831660009081526101c86020526040902054610d9491906159bd565b60606000612cb783856158e9565b90506000612cc4866122fa565b905080821115612cd2578091505b848211612cef5760408051600080825260208201909252906124b5565b6000612cfb86846159bd565b905060008167ffffffffffffffff811115612d1857612d186154aa565b604051908082528060200260200182016040528015612d41578160200160208202803683370190505b50905060005b828110156125e357612d5b898983016113c3565b828281518110612d6d57612d6d61588b565b6020908102919091010152600101612d47565b612d8861387a565b60fb805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff00000000000000000000000000000000000000009091168117909155612deb60c95473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd000000000000000000000000000000000000000000000000000000001480612ec357507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b80610d9457507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610d94565b612f3e6040518060800160405280600081526020016000815260200160008152602001600081525090565b5060009081526101c660209081526040918290208251608081018452905471ffffffffffffffffffffffffffffffffffff811682527201000000000000000000000000000000000000810464ffffffffff169282019290925277010000000000000000000000000000000000000000000000820467ffffffffffffffff16928101929092527f0100000000000000000000000000000000000000000000000000000000000000900460ff16606082015290565b805160408201516000918291421061300b57809250613023565b6130148461439c565b915061302082826159bd565b92505b50915091565b60008181526067602052604090205473ffffffffffffffffffffffffffffffffffffffff16611bbd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610f97565b600081815260696020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8416908117909155819061310e82612154565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b61315c61351f565b826101ca600082825461316f91906158e9565b90915550506101ca546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015613202573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613226919061594f565b101561323457613234615a3a565b73ffffffffffffffffffffffffffffffffffffffff851660009081526101c860205260408120805485929061326a9084906158e9565b90915550506101c78054604080516080808201835271ffffffffffffffffffffffffffffffffffff888116835264ffffffffff888116602080860191825267ffffffffffffffff8d811687890190815260ff8c81166060808b0191825260008d81526101c687528c90209a518b549751945192519093167f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9290951677010000000000000000000000000000000000000000000000029190911676ffffffffffffffffffffffffffffffffffffffffffffff939097167201000000000000000000000000000000000000027fffffffffffffffffff000000000000000000000000000000000000000000000090961691909716179390931792909216929092171790935585546001019095558251888152918201879052918101839052928301849052909173ffffffffffffffffffffffffffffffffffffffff8816917f2cc016694185d38abbe28d9e9baea2e9d95a321ae43475e5ea7b643756840bc0910160405180910390a261131986826143e8565b60008061342983612154565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480613497575073ffffffffffffffffffffffffffffffffffffffff8082166000908152606a602090815260408083209388168352929052205460ff165b806134d557508373ffffffffffffffffffffffffffffffffffffffff166134bd84610e9f565b73ffffffffffffffffffffffffffffffffffffffff16145b949350505050565b6134e561351f565b60008181526101c6602052604090205471ffffffffffffffffffffffffffffffffffff16613514848483613d16565b612888848484613a0e565b61012d5460ff1615611f8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610f97565b600061359882612154565b90506135a881600084600161461b565b6135b182612154565b600083815260696020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff85168085526068845282852080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190558785526067909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b611bbd61387a565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156136ae5761105f836147bf565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613733575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526137309181019061594f565b60015b6137bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610f97565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc811461386e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610f97565b5061105f8383836148c9565b60c95473ffffffffffffffffffffffffffffffffffffffff163314611f8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f97565b6139036148ee565b61012d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b61398233611326565b611bbd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610f97565b8273ffffffffffffffffffffffffffffffffffffffff16613a2e82612154565b73ffffffffffffffffffffffffffffffffffffffff1614613ad1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610f97565b73ffffffffffffffffffffffffffffffffffffffff8216613b73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610f97565b613b80838383600161461b565b8273ffffffffffffffffffffffffffffffffffffffff16613ba082612154565b73ffffffffffffffffffffffffffffffffffffffff1614613c43576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610f97565b600081815260696020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff8781168086526068855283862080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01905590871680865283862080546001019055868652606790945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000613d2184612be2565b905081811015613d67576040517f89906d5e0000000000000000000000000000000000000000000000000000000081526004810183905260248101829052604401610f97565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526101c860205260408082208054869003905591851681529081208054849290613dae9084906158e9565b909155505050505050565b60fb80547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055611bbd8161495b565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603613e7f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610f97565b73ffffffffffffffffffffffffffffffffffffffff8381166000818152606a602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b613f1f61351f565b61012d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861394f3390565b6101c35473ffffffffffffffffffffffffffffffffffffffff163314611f8b576040517f18bc9fde00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613fd08484846134dd565b613fdc848484846149d2565b612888576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610f97565b600054610100900460ff166140ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b611dcd8282614bc5565b600054610100900460ff166141a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b611f8b614c75565b600054610100900460ff1661423f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b611f8b614d15565b600054610100900460ff16611f8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b606060006142eb83614dd7565b600101905060008167ffffffffffffffff81111561430b5761430b6154aa565b6040519080825280601f01601f191660200182016040528015614335576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461433f57509392505050565b6000804283604001516143af91906159bd565b9050826020015160646143c29190615a69565b6060840151845183916143d491615a69565b6143de9190615a69565b6125ea91906159d0565b73ffffffffffffffffffffffffffffffffffffffff8216614465576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610f97565b60008181526067602052604090205473ffffffffffffffffffffffffffffffffffffffff16156144f1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610f97565b6144ff60008383600161461b565b60008181526067602052604090205473ffffffffffffffffffffffffffffffffffffffff161561458b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610f97565b73ffffffffffffffffffffffffffffffffffffffff8216600081815260686020908152604080832080546001019055848352606790915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60018111156146ac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e736563757469766520747260448201527f616e7366657273206e6f7420737570706f7274656400000000000000000000006064820152608401610f97565b8173ffffffffffffffffffffffffffffffffffffffff85166147155761471081609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b614752565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614614752576147528582614eb9565b73ffffffffffffffffffffffffffffffffffffffff841661477b5761477681614f70565b6147b8565b8473ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16146147b8576147b8848261501f565b5050505050565b73ffffffffffffffffffffffffffffffffffffffff81163b614863576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610f97565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6148d283615070565b6000825111806148df5750805b1561105f5761288883836150bd565b61012d5460ff16611f8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610f97565b60c9805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600073ffffffffffffffffffffffffffffffffffffffff84163b15614bba576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a0290614a49903390899088908890600401615a80565b6020604051808303816000875af1925050508015614aa2575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252614a9f91810190615ac9565b60015b614b6f573d808015614ad0576040519150601f19603f3d011682016040523d82523d6000602084013e614ad5565b606091505b508051600003614b67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610f97565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001490506134d5565b506001949350505050565b600054610100900460ff16614c5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b6065614c688382615b2c565b50606661105f8282615b2c565b600054610100900460ff16614d0c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b611f8b33613db9565b600054610100900460ff16614dac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b61012d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310614e20577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310614e4c576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310614e6a57662386f26fc10000830492506010015b6305f5e1008310614e82576305f5e100830492506008015b6127108310614e9657612710830492506004015b60648310614ea8576064830492506002015b600a8310610d945760010192915050565b60006001614ec6846122fa565b614ed091906159bd565b600083815260986020526040902054909150808214614f305773ffffffffffffffffffffffffffffffffffffffff841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b50600091825260986020908152604080842084905573ffffffffffffffffffffffffffffffffffffffff9094168352609781528383209183525290812055565b609954600090614f82906001906159bd565b6000838152609a602052604081205460998054939450909284908110614faa57614faa61588b565b906000526020600020015490508060998381548110614fcb57614fcb61588b565b6000918252602080832090910192909255828152609a9091526040808220849055858252812055609980548061500357615003615c46565b6001900381819060005260206000200160009055905550505050565b600061502a836122fa565b73ffffffffffffffffffffffffffffffffffffffff9093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b615079816147bf565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606073ffffffffffffffffffffffffffffffffffffffff83163b615163576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401610f97565b6000808473ffffffffffffffffffffffffffffffffffffffff168460405161518b9190615c75565b600060405180830381855af49150503d80600081146151c6576040519150601f19603f3d011682016040523d82523d6000602084013e6151cb565b606091505b50915091506151f38282604051806060016040528060278152602001615c92602791396151fc565b95945050505050565b6060831561520b5750816125ea565b6125ea83838151156152205781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9791906153df565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114611bbd57600080fd5b60006020828403121561529457600080fd5b81356125ea81615254565b60008083601f8401126152b157600080fd5b50813567ffffffffffffffff8111156152c957600080fd5b6020830191508360208260051b85010111156152e457600080fd5b9250929050565b600080602083850312156152fe57600080fd5b823567ffffffffffffffff81111561531557600080fd5b6153218582860161529f565b90969095509350505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461535157600080fd5b919050565b60006020828403121561536857600080fd5b6125ea8261532d565b60005b8381101561538c578181015183820152602001615374565b50506000910152565b600081518084526153ad816020860160208601615371565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006125ea6020830184615395565b60006020828403121561540457600080fd5b5035919050565b6000806040838503121561541e57600080fd5b6154278361532d565b946020939093013593505050565b6000806000806080858703121561544b57600080fd5b6154548561532d565b966020860135965060408601359560600135945092505050565b60008060006060848603121561548357600080fd5b61548c8461532d565b925061549a6020850161532d565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f8301126154ea57600080fd5b813567ffffffffffffffff80821115615505576155056154aa565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561554b5761554b6154aa565b8160405283815286602085880101111561556457600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561559757600080fd5b6155a08361532d565b9150602083013567ffffffffffffffff8111156155bc57600080fd5b6155c8858286016154d9565b9150509250929050565b600080600080606085870312156155e857600080fd5b6155f18561532d565b93506155ff6020860161532d565b9250604085013567ffffffffffffffff81111561561b57600080fd5b6156278782880161529f565b95989497509550505050565b60008060006060848603121561564857600080fd5b6156518461532d565b95602085013595506040909401359392505050565b602080825282518282018190526000919060409081850190868401855b828110156156b25781518051855286810151878601528501518585015260609093019290850190600101615683565b5091979650505050505050565b8015158114611bbd57600080fd5b600080604083850312156156e057600080fd5b6156e98361532d565b915060208301356156f9816156bf565b809150509250929050565b6000806000806080858703121561571a57600080fd5b6157238561532d565b93506157316020860161532d565b925060408501359150606085013567ffffffffffffffff81111561575457600080fd5b615760878288016154d9565b91505092959194509250565b60008082840360a081121561578057600080fd5b6157898461532d565b925060807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0820112156157bb57600080fd5b506040516080810181811067ffffffffffffffff821117156157df576157df6154aa565b806040525060208401358152604084013560208201526060840135604082015260808401356060820152809150509250929050565b6000806040838503121561582757600080fd5b6158308361532d565b915061583e6020840161532d565b90509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561587f57835183529284019291840191600101615863565b50909695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610d9457610d946158ba565b600181811c9082168061591057607f821691505b602082108103615949577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60006020828403121561596157600080fd5b5051919050565b60006020828403121561597a57600080fd5b81516125ea816156bf565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036159b6576159b66158ba565b5060010190565b81810381811115610d9457610d946158ba565b600082615a06577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008351615a1d818460208801615371565b835190830190615a31818360208801615371565b01949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b8082028115828204841417610d9457610d946158ba565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015260806060830152615abf6080830184615395565b9695505050505050565b600060208284031215615adb57600080fd5b81516125ea81615254565b601f82111561105f57600081815260208120601f850160051c81016020861015615b0d5750805b601f850160051c820191505b8181101561131957828155600101615b19565b815167ffffffffffffffff811115615b4657615b466154aa565b615b5a81615b5484546158fc565b84615ae6565b602080601f831160018114615bad5760008415615b775750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555611319565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015615bfa57888601518255948401946001909101908401615bdb565b5085821015615c3657878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60008251615c87818460208701615371565b919091019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207d47b5b8b003956bd605d161e66e5a5ddf96b1b53c8b5c833cc032c61903dac364736f6c63430008130033000000000000000000000000920cf626a271321c151d027030d5d08af699456b000000000000000000000000b176dad2916db0905cd2d65ed54fdc3a878affe4
Deployed Bytecode
0x60806040526004361061038b5760003560e01c80636fb83a57116101dc578063ad18e97e11610102578063ca2c7f76116100a0578063e6b2cf6c1161006f578063e6b2cf6c14610c84578063e985e9c514610c9b578063eac6248914610cf1578063f2fde38b14610d1e57600080fd5b8063ca2c7f7614610be5578063daf3807314610c05578063e30c397814610c25578063e509584314610c5057600080fd5b8063b88d4fde116100dc578063b88d4fde14610b6d578063c297fa0f14610b8d578063c4d66de814610ba5578063c87b56dd14610bc557600080fd5b8063ad18e97e14610b07578063b1724b4614610b35578063b5ddb9c714610b4d57600080fd5b80638da5cb5b1161017a578063a22cb46511610149578063a22cb465146109e3578063a4116a7e14610a03578063a46eddcf14610ad2578063ac2fdb1a14610af257600080fd5b80638da5cb5b1461094f5780639034802b1461097a57806395d89b41146109ae57806398ab1e3d146109c357600080fd5b806371e780f3116101b657806371e780f3146108e1578063773ab39f146108f857806379ba5097146109255780637d5ff94d1461093a57600080fd5b80636fb83a571461088c57806370a08231146108ac578063715018a6146108cc57600080fd5b806334c7fec9116102c157806352d1902d1161025f5780635c975abb1161022e5780635c975abb1461072a5780636352211e1461074357806364b87a70146107635780636d3cbe211461079157600080fd5b806352d1902d146106c0578063534c0842146106d557806353a535d3146106ea5780635414408d1461070a57600080fd5b806342842e0e1161029b57806342842e0e1461063f57806348591dd71461065f5780634f1ef2861461068d5780634f6ccce7146106a057600080fd5b806334c7fec9146105ea5780633659cfe61461060a5780633e7f4c091461062a57600080fd5b806318160ddd1161032e57806323b872dd1161030857806323b872dd1461056757806324c0f5b5146105875780632f745c591461059c578063326a3cfb146105bc57600080fd5b806318160ddd1461050457806318c1cb5214610519578063227d517a1461053957600080fd5b8063057a601b1161036a578063057a601b1461044e57806306fdde03146104a0578063081812fc146104c2578063095ea7b3146104e257600080fd5b80624d37e21461039057806301ffc9a7146103e957806303df264014610419575b600080fd5b34801561039c57600080fd5b507f000000000000000000000000920cf626a271321c151d027030d5d08af699456b5b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b3480156103f557600080fd5b50610409610404366004615282565b610d3e565b60405190151581526020016103e0565b34801561042557600080fd5b506104396104343660046152eb565b610d9a565b604080519283526020830191909152016103e0565b34801561045a57600080fd5b50610492610469366004615356565b73ffffffffffffffffffffffffffffffffffffffff1660009081526101c8602052604090205490565b6040519081526020016103e0565b3480156104ac57600080fd5b506104b5610e0d565b6040516103e091906153df565b3480156104ce57600080fd5b506103bf6104dd3660046153f2565b610e9f565b3480156104ee57600080fd5b506105026104fd36600461540b565b610ed3565b005b34801561051057600080fd5b50609954610492565b34801561052557600080fd5b50610502610534366004615435565b611064565b34801561054557600080fd5b50610492610554366004615356565b6101c96020526000908152604090205481565b34801561057357600080fd5b5061050261058236600461546e565b611321565b34801561059357600080fd5b50610492606481565b3480156105a857600080fd5b506104926105b736600461540b565b6113c3565b3480156105c857600080fd5b506104926105d7366004615356565b6101c86020526000908152604090205481565b3480156105f657600080fd5b506105026106053660046152eb565b611492565b34801561061657600080fd5b50610502610625366004615356565b6119bb565b34801561063657600080fd5b50610492603281565b34801561064b57600080fd5b5061050261065a36600461546e565b611bc0565b34801561066b57600080fd5b506101c4546103bf9073ffffffffffffffffffffffffffffffffffffffff1681565b61050261069b366004615584565b611bdb565b3480156106ac57600080fd5b506104926106bb3660046153f2565b611dd1565b3480156106cc57600080fd5b50610492611e8f565b3480156106e157600080fd5b50610502611f7b565b3480156106f657600080fd5b506105026107053660046155d2565b611f8d565b34801561071657600080fd5b50610502610725366004615356565b612084565b34801561073657600080fd5b5061012d5460ff16610409565b34801561074f57600080fd5b506103bf61075e3660046153f2565b612154565b34801561076f57600080fd5b506101c3546103bf9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561079d57600080fd5b5061083f6107ac3660046153f2565b6101c66020526000908152604090205471ffffffffffffffffffffffffffffffffffff8116907201000000000000000000000000000000000000810464ffffffffff169077010000000000000000000000000000000000000000000000810467ffffffffffffffff16907f0100000000000000000000000000000000000000000000000000000000000000900460ff1684565b6040805171ffffffffffffffffffffffffffffffffffff909516855264ffffffffff909316602085015267ffffffffffffffff9091169183019190915260ff1660608201526080016103e0565b34801561089857600080fd5b506105026108a7366004615356565b6121e0565b3480156108b857600080fd5b506104926108c7366004615356565b6122fa565b3480156108d857600080fd5b506105026123c8565b3480156108ed57600080fd5b506104926101ca5481565b34801561090457600080fd5b50610918610913366004615633565b6123da565b6040516103e09190615666565b34801561093157600080fd5b506105026125f1565b34801561094657600080fd5b50610492605a81565b34801561095b57600080fd5b5060c95473ffffffffffffffffffffffffffffffffffffffff166103bf565b34801561098657600080fd5b506103bf7f000000000000000000000000920cf626a271321c151d027030d5d08af699456b81565b3480156109ba57600080fd5b506104b56126a3565b3480156109cf57600080fd5b506104396109de3660046153f2565b6126b2565b3480156109ef57600080fd5b506105026109fe3660046156cd565b6126d6565b348015610a0f57600080fd5b50610ab2610a1e3660046153f2565b60009081526101c6602052604090205477010000000000000000000000000000000000000000000000810467ffffffffffffffff169171ffffffffffffffffffffffffffffffffffff8216917201000000000000000000000000000000000000810464ffffffffff16917f010000000000000000000000000000000000000000000000000000000000000090910460ff1690565b6040805194855260208501939093529183015260608201526080016103e0565b348015610ade57600080fd5b50610502610aed366004615356565b6126e1565b348015610afe57600080fd5b506105026127aa565b348015610b1357600080fd5b506101c5546103bf9073ffffffffffffffffffffffffffffffffffffffff1681565b348015610b4157600080fd5b5061049263077f880081565b348015610b5957600080fd5b50610502610b6836600461540b565b6127ba565b348015610b7957600080fd5b50610502610b88366004615704565b6127e6565b348015610b9957600080fd5b506104926301dfe20081565b348015610bb157600080fd5b50610502610bc0366004615356565b61288e565b348015610bd157600080fd5b506104b5610be03660046153f2565b612b00565b348015610bf157600080fd5b50610502610c0036600461576c565b612b73565b348015610c1157600080fd5b50610492610c20366004615356565b612be2565b348015610c3157600080fd5b5060fb5473ffffffffffffffffffffffffffffffffffffffff166103bf565b348015610c5c57600080fd5b506103bf7f000000000000000000000000b176dad2916db0905cd2d65ed54fdc3a878affe481565b348015610c9057600080fd5b506104926101c75481565b348015610ca757600080fd5b50610409610cb6366004615814565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152606a6020908152604080832093909416825291909152205460ff1690565b348015610cfd57600080fd5b50610d11610d0c366004615633565b612ca9565b6040516103e09190615847565b348015610d2a57600080fd5b50610502610d39366004615356565b612d80565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d63000000000000000000000000000000000000000000000000000000001480610d945750610d9482612e30565b92915050565b60008082815b81811015610e04576000610dcb878784818110610dbf57610dbf61588b565b90506020020135612f13565b9050600080610dd983612ff1565b9092509050610de882886158e9565b9650610df481876158e9565b9550836001019350505050610da0565b50509250929050565b606060658054610e1c906158fc565b80601f0160208091040260200160405190810160405280929190818152602001828054610e48906158fc565b8015610e955780601f10610e6a57610100808354040283529160200191610e95565b820191906000526020600020905b815481529060010190602001808311610e7857829003601f168201915b5050505050905090565b6000610eaa82613029565b5060009081526069602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6000610ede82612154565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610fa0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff82161480610fc95750610fc98133610cb6565b611055576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610f97565b61105f83836130b4565b505050565b73ffffffffffffffffffffffffffffffffffffffff84166110b1576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60648111156110ec576040517f30aed3ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6032811015611127576040517f6eede11900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82600003611161576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c354604080517f04646a49000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff16916304646a499160048083019260209291908290030181865afa1580156111d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f6919061594f565b905080831080611209575063077f880083115b15611240576040517f7616640100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018590527f000000000000000000000000920cf626a271321c151d027030d5d08af699456b73ffffffffffffffffffffffffffffffffffffffff16906323b872dd906064016020604051808303816000875af11580156112d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fd9190615968565b50600061130a84426158e9565b90506113198682878787613154565b505050505050565b61132c335b8261341d565b6113b8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610f97565b61105f8383836134dd565b60006113ce836122fa565b821061145c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610f97565b5073ffffffffffffffffffffffffffffffffffffffff919091166000908152609760209081526040808320938352929052205490565b61149a61351f565b60008082815b818110156115ac5760008686838181106114bc576114bc61588b565b9050602002013590503373ffffffffffffffffffffffffffffffffffffffff166115088260009081526067602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611529575061159c565b60008061153d61153884612f13565b612ff1565b60008581526101c66020526040902080547fffffffffffffffffffffffffffff00000000000000000000000000000000000016905590925090506115808361358d565b61158a82886158e9565b965061159681876158e9565b95505050505b6115a581615985565b90506114a0565b5060006115b983856158e9565b905080156113195760006115cc33612be2565b905080821115611665576101c3546040517f7f94e8ff000000000000000000000000000000000000000000000000000000008152336004820152828403602482018190529173ffffffffffffffffffffffffffffffffffffffff1690637f94e8ff90604401600060405180830381600087803b15801561164b57600080fd5b505af115801561165f573d6000803e3d6000fd5b50505050505b816101ca600082825461167891906159bd565b90915550503360009081526101c860205260408120805484929061169d9084906159bd565b90915550503360009081526101c96020526040812080548792906116c29084906158e9565b909155505083156118bf5760006116da6002866159d0565b905060006116e882876159bd565b6101c5546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018590529192507f000000000000000000000000920cf626a271321c151d027030d5d08af699456b169063a9059cbb906044016020604051808303816000875af1158015611784573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117a89190615968565b506040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b176dad2916db0905cd2d65ed54fdc3a878affe481166004830152602482018390527f000000000000000000000000920cf626a271321c151d027030d5d08af699456b169063a9059cbb906044016020604051808303816000875af115801561185e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118829190615968565b5060408051838152602081018390527fadd2755028f410fd28d5b98415bb469e4a5f7824d30429ca1c0c8a54de1eb537910160405180910390a150505b841561197e576040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018690527f000000000000000000000000920cf626a271321c151d027030d5d08af699456b73ffffffffffffffffffffffffffffffffffffffff169063a9059cbb906044016020604051808303816000875af1158015611958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061197c9190615968565b505b60405185815233907ed5958799b183a7b738d3ad5e711305293dd5076a37a4e3b7e6611dea6114f39060200160405180910390a250505050505050565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000fbf7d647e94780f2787f8d80da59dce74d40c5cc163003611a80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610f97565b7f000000000000000000000000fbf7d647e94780f2787f8d80da59dce74d40c5cc73ffffffffffffffffffffffffffffffffffffffff16611af57f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611b98576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610f97565b611ba181613673565b60408051600080825260208201909252611bbd9183919061367b565b50565b61105f838383604051806020016040528060008152506127e6565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000fbf7d647e94780f2787f8d80da59dce74d40c5cc163003611ca0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610f97565b7f000000000000000000000000fbf7d647e94780f2787f8d80da59dce74d40c5cc73ffffffffffffffffffffffffffffffffffffffff16611d157f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611db8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610f97565b611dc182613673565b611dcd8282600161367b565b5050565b6000611ddc60995490565b8210611e6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610f97565b60998281548110611e7d57611e7d61588b565b90600052602060002001549050919050565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000fbf7d647e94780f2787f8d80da59dce74d40c5cc1614611f56576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610f97565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b611f8361387a565b611f8b6138fb565b565b611f9561351f565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611ffa576040517fdad89dca00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081815b8181101561207857600085858381811061201b5761201b61588b565b6020908102929092013560008181526101c69093526040909220549192506120599171ffffffffffffffffffffffffffffffffffff169050856158e9565b935061206481613979565b61206f888883613a0e565b50600101611fff565b50611319868684613d16565b61208c61387a565b73ffffffffffffffffffffffffffffffffffffffff81166120d9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c480547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f790bf62e04348d5f5d45f86cb3a270b9b281e2e4e11f54a24eca40cf4dea5703906020015b60405180910390a150565b60008181526067602052604081205473ffffffffffffffffffffffffffffffffffffffff1680610d94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610f97565b6121e861387a565b73ffffffffffffffffffffffffffffffffffffffff8116612235576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c35473ffffffffffffffffffffffffffffffffffffffff1615612286576040517fa32250de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fb63c81227c62f4cb3e2b1120e3afbf3a2ed5dd8b9d99b8bef7275b084e6a98cb90602001612149565b600073ffffffffffffffffffffffffffffffffffffffff821661239f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152608401610f97565b5073ffffffffffffffffffffffffffffffffffffffff1660009081526068602052604090205490565b6123d061387a565b611f8b6000613db9565b606081600003612439576040805160008082526020820190925290612431565b61241e60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816123fa5790505b5090506125ea565b600061244583856158e9565b90506000612452866122fa565b905080821115612460578091505b848210156124bf5760408051600080825260208201909252906124b5565b6124a260405180606001604052806000815260200160008152602001600081525090565b81526020019060019003908161247e5790505b50925050506125ea565b84820360008167ffffffffffffffff8111156124dd576124dd6154aa565b60405190808252806020026020018201604052801561253257816020015b61251f60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816124fb5790505b50905060005b828110156125e357600061254e8a8a84016113c3565b60008181526101c660209081526040918290208251606081018452815471ffffffffffffffffffffffffffffffffffff811682529281018590527701000000000000000000000000000000000000000000000090920467ffffffffffffffff1692820192909252855192935090918590859081106125ce576125ce61588b565b60209081029190910101525050600101612538565b5093505050505b9392505050565b60fb54339073ffffffffffffffffffffffffffffffffffffffff16811461269a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e657200000000000000000000000000000000000000000000006064820152608401610f97565b611bbd81613db9565b606060668054610e1c906158fc565b60008060006126c084612f13565b90506126cb81612ff1565b909590945092505050565b611dcd338383613dea565b6126e961387a565b73ffffffffffffffffffffffffffffffffffffffff8116612736576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fd780e06c55efd6b3157e8c26704d2fd7bd2750bd9d0e71d2e5f675572dfad7a290602001612149565b6127b261387a565b611f8b613f17565b6127c2613f73565b60006127d26301dfe200426158e9565b905061105f8382846301dfe200605a613154565b6127f0338361341d565b61287c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610f97565b61288884848484613fc5565b50505050565b600054610100900460ff16158080156128ae5750600054600160ff909116105b806128c85750303b1580156128c8575060005460ff166001145b612954576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610f97565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156129b257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff82166129ff576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612a736040518060400160405280601481526020017f4b77656e74612052657761726420457363726f770000000000000000000000008152506040518060400160405280600381526020017f4b52450000000000000000000000000000000000000000000000000000000000815250614068565b612a7b614109565b612a836141a8565b612a8b614247565b612a9482613db9565b60016101c7558015611dcd57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b6060612b0b82613029565b6000612b2260408051602081019091526000815290565b90506000815111612b4257604051806020016040528060008152506125ea565b80612b4c846142de565b604051602001612b5d929190615a0b565b6040516020818303038152906040529392505050565b6101c45473ffffffffffffffffffffffffffffffffffffffff163314612bc5576040517f8f8a680600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611dcd828260400151836000015184602001518560600151613154565b6101c3546040517f057a601b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152600092169063057a601b90602401602060405180830381865afa158015612c54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c78919061594f565b73ffffffffffffffffffffffffffffffffffffffff831660009081526101c86020526040902054610d9491906159bd565b60606000612cb783856158e9565b90506000612cc4866122fa565b905080821115612cd2578091505b848211612cef5760408051600080825260208201909252906124b5565b6000612cfb86846159bd565b905060008167ffffffffffffffff811115612d1857612d186154aa565b604051908082528060200260200182016040528015612d41578160200160208202803683370190505b50905060005b828110156125e357612d5b898983016113c3565b828281518110612d6d57612d6d61588b565b6020908102919091010152600101612d47565b612d8861387a565b60fb805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff00000000000000000000000000000000000000009091168117909155612deb60c95473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd000000000000000000000000000000000000000000000000000000001480612ec357507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b80610d9457507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610d94565b612f3e6040518060800160405280600081526020016000815260200160008152602001600081525090565b5060009081526101c660209081526040918290208251608081018452905471ffffffffffffffffffffffffffffffffffff811682527201000000000000000000000000000000000000810464ffffffffff169282019290925277010000000000000000000000000000000000000000000000820467ffffffffffffffff16928101929092527f0100000000000000000000000000000000000000000000000000000000000000900460ff16606082015290565b805160408201516000918291421061300b57809250613023565b6130148461439c565b915061302082826159bd565b92505b50915091565b60008181526067602052604090205473ffffffffffffffffffffffffffffffffffffffff16611bbd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610f97565b600081815260696020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8416908117909155819061310e82612154565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b61315c61351f565b826101ca600082825461316f91906158e9565b90915550506101ca546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201527f000000000000000000000000920cf626a271321c151d027030d5d08af699456b73ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015613202573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613226919061594f565b101561323457613234615a3a565b73ffffffffffffffffffffffffffffffffffffffff851660009081526101c860205260408120805485929061326a9084906158e9565b90915550506101c78054604080516080808201835271ffffffffffffffffffffffffffffffffffff888116835264ffffffffff888116602080860191825267ffffffffffffffff8d811687890190815260ff8c81166060808b0191825260008d81526101c687528c90209a518b549751945192519093167f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9290951677010000000000000000000000000000000000000000000000029190911676ffffffffffffffffffffffffffffffffffffffffffffff939097167201000000000000000000000000000000000000027fffffffffffffffffff000000000000000000000000000000000000000000000090961691909716179390931792909216929092171790935585546001019095558251888152918201879052918101839052928301849052909173ffffffffffffffffffffffffffffffffffffffff8816917f2cc016694185d38abbe28d9e9baea2e9d95a321ae43475e5ea7b643756840bc0910160405180910390a261131986826143e8565b60008061342983612154565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480613497575073ffffffffffffffffffffffffffffffffffffffff8082166000908152606a602090815260408083209388168352929052205460ff165b806134d557508373ffffffffffffffffffffffffffffffffffffffff166134bd84610e9f565b73ffffffffffffffffffffffffffffffffffffffff16145b949350505050565b6134e561351f565b60008181526101c6602052604090205471ffffffffffffffffffffffffffffffffffff16613514848483613d16565b612888848484613a0e565b61012d5460ff1615611f8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610f97565b600061359882612154565b90506135a881600084600161461b565b6135b182612154565b600083815260696020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff85168085526068845282852080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190558785526067909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b611bbd61387a565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156136ae5761105f836147bf565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613733575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526137309181019061594f565b60015b6137bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610f97565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc811461386e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610f97565b5061105f8383836148c9565b60c95473ffffffffffffffffffffffffffffffffffffffff163314611f8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f97565b6139036148ee565b61012d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b61398233611326565b611bbd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610f97565b8273ffffffffffffffffffffffffffffffffffffffff16613a2e82612154565b73ffffffffffffffffffffffffffffffffffffffff1614613ad1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610f97565b73ffffffffffffffffffffffffffffffffffffffff8216613b73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610f97565b613b80838383600161461b565b8273ffffffffffffffffffffffffffffffffffffffff16613ba082612154565b73ffffffffffffffffffffffffffffffffffffffff1614613c43576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610f97565b600081815260696020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff8781168086526068855283862080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01905590871680865283862080546001019055868652606790945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000613d2184612be2565b905081811015613d67576040517f89906d5e0000000000000000000000000000000000000000000000000000000081526004810183905260248101829052604401610f97565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526101c860205260408082208054869003905591851681529081208054849290613dae9084906158e9565b909155505050505050565b60fb80547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055611bbd8161495b565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603613e7f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610f97565b73ffffffffffffffffffffffffffffffffffffffff8381166000818152606a602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b613f1f61351f565b61012d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861394f3390565b6101c35473ffffffffffffffffffffffffffffffffffffffff163314611f8b576040517f18bc9fde00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613fd08484846134dd565b613fdc848484846149d2565b612888576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610f97565b600054610100900460ff166140ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b611dcd8282614bc5565b600054610100900460ff166141a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b611f8b614c75565b600054610100900460ff1661423f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b611f8b614d15565b600054610100900460ff16611f8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b606060006142eb83614dd7565b600101905060008167ffffffffffffffff81111561430b5761430b6154aa565b6040519080825280601f01601f191660200182016040528015614335576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461433f57509392505050565b6000804283604001516143af91906159bd565b9050826020015160646143c29190615a69565b6060840151845183916143d491615a69565b6143de9190615a69565b6125ea91906159d0565b73ffffffffffffffffffffffffffffffffffffffff8216614465576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610f97565b60008181526067602052604090205473ffffffffffffffffffffffffffffffffffffffff16156144f1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610f97565b6144ff60008383600161461b565b60008181526067602052604090205473ffffffffffffffffffffffffffffffffffffffff161561458b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610f97565b73ffffffffffffffffffffffffffffffffffffffff8216600081815260686020908152604080832080546001019055848352606790915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60018111156146ac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e736563757469766520747260448201527f616e7366657273206e6f7420737570706f7274656400000000000000000000006064820152608401610f97565b8173ffffffffffffffffffffffffffffffffffffffff85166147155761471081609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b614752565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614614752576147528582614eb9565b73ffffffffffffffffffffffffffffffffffffffff841661477b5761477681614f70565b6147b8565b8473ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16146147b8576147b8848261501f565b5050505050565b73ffffffffffffffffffffffffffffffffffffffff81163b614863576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610f97565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6148d283615070565b6000825111806148df5750805b1561105f5761288883836150bd565b61012d5460ff16611f8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610f97565b60c9805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600073ffffffffffffffffffffffffffffffffffffffff84163b15614bba576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a0290614a49903390899088908890600401615a80565b6020604051808303816000875af1925050508015614aa2575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252614a9f91810190615ac9565b60015b614b6f573d808015614ad0576040519150601f19603f3d011682016040523d82523d6000602084013e614ad5565b606091505b508051600003614b67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610f97565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001490506134d5565b506001949350505050565b600054610100900460ff16614c5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b6065614c688382615b2c565b50606661105f8282615b2c565b600054610100900460ff16614d0c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b611f8b33613db9565b600054610100900460ff16614dac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f97565b61012d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310614e20577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310614e4c576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310614e6a57662386f26fc10000830492506010015b6305f5e1008310614e82576305f5e100830492506008015b6127108310614e9657612710830492506004015b60648310614ea8576064830492506002015b600a8310610d945760010192915050565b60006001614ec6846122fa565b614ed091906159bd565b600083815260986020526040902054909150808214614f305773ffffffffffffffffffffffffffffffffffffffff841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b50600091825260986020908152604080842084905573ffffffffffffffffffffffffffffffffffffffff9094168352609781528383209183525290812055565b609954600090614f82906001906159bd565b6000838152609a602052604081205460998054939450909284908110614faa57614faa61588b565b906000526020600020015490508060998381548110614fcb57614fcb61588b565b6000918252602080832090910192909255828152609a9091526040808220849055858252812055609980548061500357615003615c46565b6001900381819060005260206000200160009055905550505050565b600061502a836122fa565b73ffffffffffffffffffffffffffffffffffffffff9093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b615079816147bf565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606073ffffffffffffffffffffffffffffffffffffffff83163b615163576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401610f97565b6000808473ffffffffffffffffffffffffffffffffffffffff168460405161518b9190615c75565b600060405180830381855af49150503d80600081146151c6576040519150601f19603f3d011682016040523d82523d6000602084013e6151cb565b606091505b50915091506151f38282604051806060016040528060278152602001615c92602791396151fc565b95945050505050565b6060831561520b5750816125ea565b6125ea83838151156152205781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9791906153df565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114611bbd57600080fd5b60006020828403121561529457600080fd5b81356125ea81615254565b60008083601f8401126152b157600080fd5b50813567ffffffffffffffff8111156152c957600080fd5b6020830191508360208260051b85010111156152e457600080fd5b9250929050565b600080602083850312156152fe57600080fd5b823567ffffffffffffffff81111561531557600080fd5b6153218582860161529f565b90969095509350505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461535157600080fd5b919050565b60006020828403121561536857600080fd5b6125ea8261532d565b60005b8381101561538c578181015183820152602001615374565b50506000910152565b600081518084526153ad816020860160208601615371565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006125ea6020830184615395565b60006020828403121561540457600080fd5b5035919050565b6000806040838503121561541e57600080fd5b6154278361532d565b946020939093013593505050565b6000806000806080858703121561544b57600080fd5b6154548561532d565b966020860135965060408601359560600135945092505050565b60008060006060848603121561548357600080fd5b61548c8461532d565b925061549a6020850161532d565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f8301126154ea57600080fd5b813567ffffffffffffffff80821115615505576155056154aa565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561554b5761554b6154aa565b8160405283815286602085880101111561556457600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561559757600080fd5b6155a08361532d565b9150602083013567ffffffffffffffff8111156155bc57600080fd5b6155c8858286016154d9565b9150509250929050565b600080600080606085870312156155e857600080fd5b6155f18561532d565b93506155ff6020860161532d565b9250604085013567ffffffffffffffff81111561561b57600080fd5b6156278782880161529f565b95989497509550505050565b60008060006060848603121561564857600080fd5b6156518461532d565b95602085013595506040909401359392505050565b602080825282518282018190526000919060409081850190868401855b828110156156b25781518051855286810151878601528501518585015260609093019290850190600101615683565b5091979650505050505050565b8015158114611bbd57600080fd5b600080604083850312156156e057600080fd5b6156e98361532d565b915060208301356156f9816156bf565b809150509250929050565b6000806000806080858703121561571a57600080fd5b6157238561532d565b93506157316020860161532d565b925060408501359150606085013567ffffffffffffffff81111561575457600080fd5b615760878288016154d9565b91505092959194509250565b60008082840360a081121561578057600080fd5b6157898461532d565b925060807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0820112156157bb57600080fd5b506040516080810181811067ffffffffffffffff821117156157df576157df6154aa565b806040525060208401358152604084013560208201526060840135604082015260808401356060820152809150509250929050565b6000806040838503121561582757600080fd5b6158308361532d565b915061583e6020840161532d565b90509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561587f57835183529284019291840191600101615863565b50909695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610d9457610d946158ba565b600181811c9082168061591057607f821691505b602082108103615949577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60006020828403121561596157600080fd5b5051919050565b60006020828403121561597a57600080fd5b81516125ea816156bf565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036159b6576159b66158ba565b5060010190565b81810381811115610d9457610d946158ba565b600082615a06577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008351615a1d818460208801615371565b835190830190615a31818360208801615371565b01949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b8082028115828204841417610d9457610d946158ba565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015260806060830152615abf6080830184615395565b9695505050505050565b600060208284031215615adb57600080fd5b81516125ea81615254565b601f82111561105f57600081815260208120601f850160051c81016020861015615b0d5750805b601f850160051c820191505b8181101561131957828155600101615b19565b815167ffffffffffffffff811115615b4657615b466154aa565b615b5a81615b5484546158fc565b84615ae6565b602080601f831160018114615bad5760008415615b775750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555611319565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015615bfa57888601518255948401946001909101908401615bdb565b5085821015615c3657878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60008251615c87818460208701615371565b919091019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207d47b5b8b003956bd605d161e66e5a5ddf96b1b53c8b5c833cc032c61903dac364736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000920cf626a271321c151d027030d5d08af699456b000000000000000000000000b176dad2916db0905cd2d65ed54fdc3a878affe4
-----Decoded View---------------
Arg [0] : _kwenta (address): 0x920Cf626a271321C151D027030D5d08aF699456b
Arg [1] : _rewardsNotifier (address): 0xb176DaD2916db0905cd2D65ed54FDC3a878aFFe4
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000920cf626a271321c151d027030d5d08af699456b
Arg [1] : 000000000000000000000000b176dad2916db0905cd2d65ed54fdc3a878affe4
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.