Address Details
contract
0x8ea91a982d93836415CE3abbaf12d59fb8cE3Ff8
- Contract Name
- Staking
- Creator
- 0x3c16c7–9f1d7b at 0x7a27a3–428f03
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 31,078 Transactions
- Transfers
- 8,057 Transfers
- Gas Used
- 7,129,138,077
- Last Balance Update
- 13800811
Transactions
Token Transfers
Tokens
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Write Contract
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- Staking
- Optimization enabled
- true
- Compiler version
- v0.8.7+commit.e28d00a7
- Optimization runs
- 1000
- EVM Version
- london
- Verified at
- 2022-07-14T18:26:40.913741Z
contracts/Staking.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC1363Receiver} from "@openzeppelin/contracts/interfaces/IERC1363Receiver.sol"; import {IAccessControl, AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import "hardhat/console.sol"; import {StableThenToken} from "./staking/StableThenToken.sol"; import {IRewardParameters, RewardCalculator} from "./staking/RewardCalculator.sol"; import {ITalentToken} from "./TalentToken.sol"; import {ITalentFactory} from "./TalentFactory.sol"; /// Staking contract /// /// @notice During phase 1, accepts USDT, which is automatically converted into an equivalent TAL amount. /// Once phase 2 starts (after a TAL address has been set), only TAL deposits are accepted /// /// @notice Staking: /// Each stake results in minting a set supply of the corresponding talent token /// Talent tokens are immediately transfered to the staker, and TAL is locked into the stake /// If the amount of TAL sent corresponds to an amount of Talent Token greater than /// /// @notice Checkpoints: /// Any action on a stake triggers a checkpoint. Checkpoints accumulate /// all rewards since the last checkpoint until now. A new stake amount is /// calculated, and reward calculation starts again from the checkpoint's /// timestamp. /// /// @notice Unstaking: /// By sending back an amount of talent token, you can recover an amount of /// TAL previously staked (or earned through staking rewards), in proportion to /// your stake and amount of talent tokens. e.g.: if you have a stake of 110 TAL /// and have minted 2 Talent Tokens, sending 1 Talent Token gets you 55 TAL back. /// This process also burns the sent Talent Token /// /// @notice Re-stake: /// Stakers can at any moment strengthen their position by sending in more TAL to an existing stake. /// This will cause a checkpoint, accumulate rewards in the stake, and mint new Talent Token /// /// @notice Claim rewards: /// Stakers can, at any moment, claim whatever rewards are pending from their stake. /// Rewards are only calculated from the moment of their last checkpoint. /// Claiming rewards adds the calculated amount of TAL to the existing stake, /// and mints the equivalent amount of Talent Token. /// /// @notice Withdraw rewards: /// Stakers can, at any moment, claim whatever rewards are pending from their stake. /// Rewards are only calculated from the moment of their last checkpoint. /// Withdrawing rewards sends the calculated amount of TAL to the staker's wallet. /// No Talent Token is minted in this scenario /// /// @notice Rewards: /// given based on the logic from `RewardCalculator`, which /// relies on a continuous `totalAdjustedShares` being updated on every /// stake/withdraw. Seel `RewardCalculator` for more details /// /// @notice Disabling staking: /// The team reserves the ability to halt staking & reward accumulation, /// to use if the tokenomics model or contracts don't work as expected, and need to be rethough. /// In this event, any pending rewards must still be valid and redeemable by stakers. /// New stakes must not be allowed, and existing stakes will not accumulate new rewards past the disabling block /// /// @notice Withdrawing remaining rewards: /// If staking is disabled, or if the end timestamp has been reached, the team can then /// intervene on stakes to accumulate their rewards on their behalf, in order to reach an `activeStakes` count of 0. /// Once 0 is reached, since no more claims will ever be made, /// the remaining TAL from the reward pool can be safely withdrawn back to the team contract Staking is AccessControl, StableThenToken, RewardCalculator, IERC1363Receiver { // // Begin: Declarations // /// Details of each individual stake struct StakeData { /// Amount currently staked uint256 tokenAmount; /// Talent tokens minted as part of this stake uint256 talentAmount; /// Latest checkpoint for this stake. Staking rewards should only be /// calculated from this moment forward. Anything past it should already /// be accounted for in `tokenAmount` uint256 lastCheckpointAt; uint256 S; bool finishedAccumulating; } /// Possible actions when a checkpoint is being triggered enum RewardAction { WITHDRAW, RESTAKE } // // Begin: Constants // bytes4 constant ERC1363_RECEIVER_RET = bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)")); // // Begin: State // /// List of all stakes (investor => talent => Stake) mapping(address => mapping(address => StakeData)) public stakes; // How many stakes are there in total uint256 public activeStakes; // How many stakes have finished accumulating rewards uint256 finishedAccumulatingStakeCount; /// Talent's share of rewards, to be redeemable by each individual talent mapping(address => uint256) public talentRedeemableRewards; /// Max S for a given talent, to halt rewards after minting is over mapping(address => uint256) public maxSForTalent; // Ability for admins to disable further stakes and rewards bool public disabled; /// The Talent Token Factory contract (ITalentFactory) address public factory; /// The price (in USD cents) of a single TAL token uint256 public tokenPrice; /// The price (in TAL tokens) of a single Talent Token uint256 public talentPrice; /// How much stablecoin was staked, but without yet depositing the expected TAL equivalent /// /// @notice After TAL is deployed, `swapStableForToken(uint256)` needs to be /// called by an admin, to withdraw any stable coin stored in the contract, /// and replace it with the TAL equivalent uint256 public totalStableStored; // How much TAL is currently staked (not including rewards) uint256 public totalTokensStaked; // How many has been withdrawn by the admin at the end of staking uint256 rewardsAdminWithdrawn; /// Sum of sqrt(tokenAmount) for each stake /// Used to compute adjusted reward values uint256 public override(IRewardParameters) totalAdjustedShares; // How much TAL is to be given in rewards uint256 public immutable override(IRewardParameters) rewardsMax; // How much TAL has already been given/reserved in rewards uint256 public override(IRewardParameters) rewardsGiven; /// Start date for staking period uint256 public immutable override(IRewardParameters) start; /// End date for staking period uint256 public immutable override(IRewardParameters) end; // Continuously growing value used to compute reward distributions uint256 public S; // Timestamp at which S was last updated uint256 public SAt; /// re-entrancy guard for `updatesAdjustedShares` bool private isAlreadyUpdatingAdjustedShares; // // Begin: Events // // emitted when a new stake is created event Stake(address indexed owner, address indexed talentToken, uint256 talAmount, bool stable); // emitte when stake rewards are reinvested into the stake event RewardClaim(address indexed owner, address indexed talentToken, uint256 stakerReward, uint256 talentReward); // emitted when stake rewards are withdrawn event RewardWithdrawal( address indexed owner, address indexed talentToken, uint256 stakerReward, uint256 talentReward ); // emitted when a talent withdraws his share of rewards event TalentRewardWithdrawal(address indexed talentToken, address indexed talentTokenWallet, uint256 reward); // emitted when a withdrawal is made from an existing stake event Unstake(address indexed owner, address indexed talentToken, uint256 talAmount); // // Begin: Implementation // /// @param _start Timestamp at which staking begins /// @param _end Timestamp at which staking ends /// @param _rewardsMax Total amount of TAL to be given in rewards /// @param _stableCoin The USD-pegged stable-coin contract to use /// @param _factory ITalentFactory instance /// @param _tokenPrice The price of a tal token in the give stable-coin (50 means 1 TAL = 0.50USD) /// @param _talentPrice The price of a talent token in TAL (50 means 1 Talent Token = 50 TAL) constructor( uint256 _start, uint256 _end, uint256 _rewardsMax, address _stableCoin, address _factory, uint256 _tokenPrice, uint256 _talentPrice ) StableThenToken(_stableCoin) { require(_tokenPrice > 0, "_tokenPrice cannot be 0"); require(_talentPrice > 0, "_talentPrice cannot be 0"); start = _start; end = _end; rewardsMax = _rewardsMax; factory = _factory; tokenPrice = _tokenPrice; talentPrice = _talentPrice; SAt = _start; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /// Creates a new stake from an amount of stable coin. /// The USD amount will be converted to the equivalent amount in TAL, according to the pre-determined rate /// /// @param _amount The amount of stable coin to stake /// @return true if operation succeeds /// /// @notice The contract must be previously approved to spend _amount on behalf of `msg.sender` function stakeStable(address _talent, uint256 _amount) public onlyWhileStakingEnabled stablePhaseOnly updatesAdjustedShares(msg.sender, _talent) returns (bool) { require(_amount > 0, "amount cannot be zero"); require(!disabled, "staking has been disabled"); uint256 tokenAmount = convertUsdToToken(_amount); totalStableStored += _amount; _checkpointAndStake(msg.sender, _talent, tokenAmount); IERC20(stableCoin).transferFrom(msg.sender, address(this), _amount); emit Stake(msg.sender, _talent, tokenAmount, true); return true; } /// Redeems rewards since last checkpoint, and reinvests them in the stake /// /// @param _talent talent token of the stake to process /// @return true if operation succeeds function claimRewards(address _talent) public returns (bool) { claimRewardsOnBehalf(msg.sender, _talent); return true; } /// Redeems rewards for a given staker, and reinvests them in the stake /// /// @param _owner owner of the stake to process /// @param _talent talent token of the stake to process /// @return true if operation succeeds function claimRewardsOnBehalf(address _owner, address _talent) public updatesAdjustedShares(_owner, _talent) returns (bool) { _checkpoint(_owner, _talent, RewardAction.RESTAKE); return true; } /// Redeems rewards since last checkpoint, and withdraws them to the owner's wallet /// /// @param _talent talent token of the stake to process /// @return true if operation succeeds function withdrawRewards(address _talent) public tokenPhaseOnly updatesAdjustedShares(msg.sender, _talent) returns (bool) { _checkpoint(msg.sender, _talent, RewardAction.WITHDRAW); return true; } /// Redeems a talent's share of the staking rewards /// /// @notice When stakers claim rewards, a share of those is reserved for /// the talent to redeem for himself through this function /// /// @param _talent The talent token from which rewards are to be claimed /// @return true if operation succeeds function withdrawTalentRewards(address _talent) public tokenPhaseOnly returns (bool) { // only the talent himself can redeem their own rewards require(msg.sender == ITalentToken(_talent).talent(), "only the talent can withdraw their own shares"); uint256 amount = talentRedeemableRewards[_talent]; IERC20(token).transfer(msg.sender, amount); talentRedeemableRewards[_talent] = 0; return true; } /// Calculates stable coin balance of the contract /// /// @return the stable coin balance function stableCoinBalance() public view returns (uint256) { return IERC20(stableCoin).balanceOf(address(this)); } /// Calculates TAL token balance of the contract /// /// @return the amount of TAL tokens function tokenBalance() public view returns (uint256) { return IERC20(token).balanceOf(address(this)); } /// Queries how much TAL can currently be staked on a given talent token /// /// @notice The limit of this value is enforced by the tokens' `mintingAvailability()` /// (see `TalentToken` contract) /// /// @notice Stakes that exceed this amount will be rejected /// /// @param _talent Talent token to query /// @return How much TAL can be staked on the given talent token, before depleting minting supply function stakeAvailability(address _talent) public view returns (uint256) { require(_isTalentToken(_talent), "not a valid talent token"); uint256 talentAmount = ITalentToken(_talent).mintingAvailability(); return convertTalentToToken(talentAmount); } /// Deposits TAL in exchange for the equivalent amount of stable coin stored in the contract /// /// @notice Meant to be used by the contract owner to retrieve stable coin /// from phase 1, and provide the equivalent TAL amount expected from stakers /// /// @param _stableAmount amount of stable coin to be retrieved. /// /// @notice Corresponding TAL amount will be enforced based on the set price function swapStableForToken(uint256 _stableAmount) public onlyRole(DEFAULT_ADMIN_ROLE) tokenPhaseOnly { require(_stableAmount <= totalStableStored, "not enough stable coin left in the contract"); uint256 tokenAmount = convertUsdToToken(_stableAmount); totalStableStored -= _stableAmount; IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(stableCoin).transfer(msg.sender, _stableAmount); } // // Begin: IERC1363Receiver // function onTransferReceived( address, // _operator address _sender, uint256 _amount, bytes calldata data ) external override(IERC1363Receiver) onlyWhileStakingEnabled returns (bytes4) { if (_isToken(msg.sender)) { require(!disabled, "staking has been disabled"); // if input is TAL, this is a stake since TAL deposits are enabled when // `setToken` is called, no additional check for `tokenPhaseOnly` is // necessary here address talent = bytesToAddress(data); _checkpointAndStake(_sender, talent, _amount); emit Stake(_sender, talent, _amount, false); return ERC1363_RECEIVER_RET; } else if (_isTalentToken(msg.sender)) { require(_isTokenSet(), "TAL token not yet set. Refund not possible"); // if it's a registered Talent Token, this is a refund address talent = msg.sender; uint256 tokenAmount = _checkpointAndUnstake(_sender, talent, _amount); emit Unstake(_sender, talent, tokenAmount); return ERC1363_RECEIVER_RET; } else { revert("Unrecognized ERC1363 token received"); } } function _isToken(address _address) internal view returns (bool) { return _address == token; } function _isTalentToken(address _address) internal view returns (bool) { return ITalentFactory(factory).isTalentToken(_address); } // // End: IERC1363Receivber // // // Begin: IRewardParameters // function totalShares() public view override(IRewardParameters) returns (uint256) { return totalTokensStaked; } function rewardsLeft() public view override(IRewardParameters) returns (uint256) { return rewardsMax - rewardsGiven - rewardsAdminWithdrawn; } /// Panic button, if we decide to halt the staking process for some reason /// /// @notice This feature should halt further accumulation of rewards, and prevent new stakes from occuring /// Existing stakes will still be able to perform all usual operations on existing stakes. /// They just won't accumulate new TAL rewards (i.e.: they can still restake rewards and mint new talent tokens) function disable() public onlyRole(DEFAULT_ADMIN_ROLE) { require(!disabled, "already disabled"); _updateS(); disabled = true; } /// Allows the admin to withdraw whatever is left of the reward pool function adminWithdraw() public onlyRole(DEFAULT_ADMIN_ROLE) { require(disabled || block.timestamp < end, "not disabled, and not end of staking either"); require(activeStakes == 0, "there are still stakes accumulating rewards. Call `claimRewardsOnBehalf` on them"); uint256 amount = rewardsLeft(); require(amount > 0, "nothing left to withdraw"); IERC20(token).transfer(msg.sender, amount); rewardsAdminWithdrawn += amount; } // // End: IRewardParameters // // // Private Interface // /// Creates a checkpoint, and then stakes adds the given TAL amount to the stake, /// minting Talent token in the process /// /// @dev This function assumes tokens have been previously transfered by /// the caller function or via `ERC1363Receiver` or `stableStake` /// /// @param _owner Owner of the stake /// @param _talent Talent token to stake on /// @param _tokenAmount TAL amount to stake function _checkpointAndStake( address _owner, address _talent, uint256 _tokenAmount ) private updatesAdjustedShares(_owner, _talent) { require(_isTalentToken(_talent), "not a valid talent token"); require(_tokenAmount > 0, "amount cannot be zero"); _checkpoint(_owner, _talent, RewardAction.RESTAKE); _stake(_owner, _talent, _tokenAmount); } /// Creates a checkpoint, and then unstakes the given TAL amount, /// burning Talent token in the process /// /// @dev This function assumes tokens have been previously transfered by /// the caller function or via `ERC1363Receiver` or `stableStake` /// /// @param _owner Owner of the stake /// @param _talent Talent token to uliasnstake from /// @param _talentAmount Talent token amount to unstake function _checkpointAndUnstake( address _owner, address _talent, uint256 _talentAmount ) private updatesAdjustedShares(_owner, _talent) returns (uint256) { require(_isTalentToken(_talent), "not a valid talent token"); _checkpoint(_owner, _talent, RewardAction.RESTAKE); StakeData storage stake = stakes[_owner][_talent]; require(stake.lastCheckpointAt > 0, "stake does not exist"); require(stake.talentAmount >= _talentAmount); // calculate TAL amount proportional to how many talent tokens are // being deposited if stake has 100 deposited TAL + 1 TAL earned from // rewards, then returning 1 Talent Token should result in 50.5 TAL // being returned, instead of the 50 that would be given under the set // exchange rate uint256 proportion = (_talentAmount * MUL) / stake.talentAmount; uint256 tokenAmount = (stake.tokenAmount * proportion) / MUL; require(IERC20(token).balanceOf(address(this)) >= tokenAmount, "not enough TAL to fulfill request"); stake.talentAmount -= _talentAmount; stake.tokenAmount -= tokenAmount; totalTokensStaked -= tokenAmount; // if stake is over, it has finished accumulating if (stake.tokenAmount == 0 && !stake.finishedAccumulating) { stake.finishedAccumulating = true; // also decrease the counter activeStakes -= 1; } _burnTalent(_talent, _talentAmount); _withdrawToken(_owner, tokenAmount); return tokenAmount; } /// Adds the given TAL amount to the stake, minting Talent token in the process /// /// @dev This function assumes tokens have been previously transfered by /// the caller function or via `ERC1363Receiver` or `stableStake` /// /// @param _owner Owner of the stake /// @param _talent Talent token to stake on /// @param _tokenAmount TAL amount to stake function _stake( address _owner, address _talent, uint256 _tokenAmount ) private { uint256 talentAmount = convertTokenToTalent(_tokenAmount); StakeData storage stake = stakes[_owner][_talent]; // if it's a new stake, increase stake count if (stake.tokenAmount == 0) { activeStakes += 1; } stake.tokenAmount += _tokenAmount; stake.talentAmount += talentAmount; totalTokensStaked += _tokenAmount; _mintTalent(_owner, _talent, talentAmount); } /// Performs a new checkpoint for a given stake /// /// Calculates all pending rewards since the last checkpoint, and accumulates them /// @param _owner Owner of the stake /// @param _talent Talent token staked /// @param _action Whether to withdraw or restake rewards function _checkpoint( address _owner, address _talent, RewardAction _action ) private updatesAdjustedShares(_owner, _talent) { StakeData storage stake = stakes[_owner][_talent]; _updateS(); // calculate rewards since last checkpoint address talentAddress = ITalentToken(_talent).talent(); // if the talent token has been fully minted, rewards can only be // considered up until that timestamp (or S, according to the math) // so end date of reward is // truncated in that case // // this will enforce that rewards past this checkpoint will always be // 0, effectively ending the stake uint256 maxS = (maxSForTalent[_talent] > 0) ? maxSForTalent[_talent] : S; (uint256 stakerRewards, uint256 talentRewards) = calculateReward( stake.tokenAmount, stake.S, maxS, stake.talentAmount, IERC20(_talent).balanceOf(talentAddress) ); rewardsGiven += stakerRewards + talentRewards; stake.S = maxS; stake.lastCheckpointAt = block.timestamp; talentRedeemableRewards[_talent] += talentRewards; // if staking is disabled, set token to finishedAccumulating, and decrease activeStakes // this forces admins to finish accumulation of all stakes, via `claimRewardsOnBehalf` // before withdrawing any remaining TAL from the reward pool if (disabled && !stake.finishedAccumulating) { stake.finishedAccumulating = true; activeStakes -= 1; } // no need to proceed if there's no rewards yet if (stakerRewards == 0) { return; } if (_action == RewardAction.WITHDRAW) { IERC20(token).transfer(_owner, stakerRewards); emit RewardWithdrawal(_owner, _talent, stakerRewards, talentRewards); } else if (_action == RewardAction.RESTAKE) { // truncate rewards to stake to the maximum stake availability uint256 availability = stakeAvailability(_talent); uint256 rewardsToStake = (availability > stakerRewards) ? stakerRewards : availability; uint256 rewardsToWithdraw = stakerRewards - rewardsToStake; _stake(_owner, _talent, rewardsToStake); emit RewardClaim(_owner, _talent, rewardsToStake, talentRewards); // TODO test // TODO the !!token part as well if (rewardsToWithdraw > 0 && token != address(0x0)) { IERC20(token).transfer(_owner, rewardsToWithdraw); emit RewardWithdrawal(_owner, _talent, rewardsToWithdraw, 0); } } else { revert("Unrecognized checkpoint action"); } } function _updateS() private { if (disabled) { return; } if (totalTokensStaked == 0) { return; } S = S + (calculateGlobalReward(SAt, block.timestamp)) / totalAdjustedShares; SAt = block.timestamp; } function calculateEstimatedReturns( address _owner, address _talent, uint256 _currentTime ) public view returns (uint256 stakerRewards, uint256 talentRewards) { StakeData storage stake = stakes[_owner][_talent]; uint256 newS; if (maxSForTalent[_talent] > 0) { newS = maxSForTalent[_talent]; } else { newS = S + (calculateGlobalReward(SAt, _currentTime)) / totalAdjustedShares; } address talentAddress = ITalentToken(_talent).talent(); uint256 talentBalance = IERC20(_talent).balanceOf(talentAddress); (uint256 sRewards, uint256 tRewards) = calculateReward( stake.tokenAmount, stake.S, newS, stake.talentAmount, talentBalance ); return (sRewards, tRewards); } // function disable() { // _updateS(); // disable = true; // totalSharesWhenDisable = totalTokensStaked; // reservedTAL = (sqrt(totalSharesWhenDisable) * (S - 0)) / MUL; // availableTAL = rewardsMax() - reservedTAL; // } /// mints a given amount of a given talent token /// to be used within a staking update (re-stake or new deposit) /// /// @notice The staking update itself is assumed to happen on the caller function _mintTalent( address _owner, address _talent, uint256 _amount ) private { ITalentToken(_talent).mint(_owner, _amount); if (maxSForTalent[_talent] == 0 && ITalentToken(_talent).mintingFinishedAt() > 0) { maxSForTalent[_talent] = S; } } /// burns a given amount of a given talent token /// to be used within a staking update (withdrawal or refund) /// /// @notice The staking update itself is assumed to happen on the caller /// /// @notice Since withdrawal functions work via ERC1363 and receive the /// Talent token prior to calling `onTransferReceived`, / by this point, /// the contract is the owner of the tokens to be burnt, not the owner function _burnTalent(address _talent, uint256 _amount) private { ITalentToken(_talent).burn(address(this), _amount); } /// returns a given amount of TAL to an owner function _withdrawToken(address _owner, uint256 _amount) private { IERC20(token).transfer(_owner, _amount); } modifier updatesAdjustedShares(address _owner, address _talent) { if (isAlreadyUpdatingAdjustedShares) { // works like a re-entrancy guard, to prevent sqrt calculations // from happening twice _; } else { isAlreadyUpdatingAdjustedShares = true; // calculate current adjusted shares for this stake // we don't deduct it directly because other computations wrapped by this modifier depend on the original value // (e.g. reward calculation) // therefore, we just keep track of it, and do a final update to the stored value at the end; // temporarily deduct from adjusted shares uint256 toDeduct = sqrt(stakes[_owner][_talent].tokenAmount); _; // calculated adjusted shares again, now with rewards included, and // excluding the previously computed amount to be deducted // (replaced by the new one) totalAdjustedShares = totalAdjustedShares + sqrt(stakes[_owner][_talent].tokenAmount) - toDeduct; isAlreadyUpdatingAdjustedShares = false; } } modifier onlyWhileStakingEnabled() { require(block.timestamp >= start, "staking period not yet started"); require(block.timestamp <= end, "staking period already finished"); _; } /// Converts a given USD amount to TAL /// /// @param _usd The amount of USD, in cents, to convert /// @return The converted TAL amount function convertUsdToToken(uint256 _usd) public view returns (uint256) { return (_usd / tokenPrice) * 1 ether; } /// Converts a given TAL amount to a Talent Token amount /// /// @param _tal The amount of TAL to convert /// @return The converted Talent Token amount function convertTokenToTalent(uint256 _tal) public view returns (uint256) { return (_tal / talentPrice) * 1 ether; } /// Converts a given Talent Token amount to TAL /// /// @param _talent The amount of Talent Tokens to convert /// @return The converted TAL amount function convertTalentToToken(uint256 _talent) public view returns (uint256) { return (_talent * talentPrice) / 1 ether; } /// Converts a given USD amount to Talent token /// /// @param _usd The amount of USD, in cents, to convert /// @return The converted Talent token amount function convertUsdToTalent(uint256 _usd) public view returns (uint256) { return convertTokenToTalent(convertUsdToToken(_usd)); } /// Converts a byte sequence to address /// /// @dev This function requires the byte sequence to have 20 bytes of length /// /// @dev I didn't understand why using `calldata` instead of `memory` doesn't work, /// or what would be the correct assembly to work with it. function bytesToAddress(bytes memory bs) private pure returns (address addr) { require(bs.length == 20, "invalid data length for address"); assembly { addr := mload(add(bs, 20)) } } }
/_openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../token/ERC20/IERC20Upgradeable.sol";
/_openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/introspection/IERC165Upgradeable.sol";
/_openzeppelin/contracts-upgradeable/interfaces/IERC1363Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./IERC165Upgradeable.sol"; interface IERC1363Upgradeable is IERC165Upgradeable, IERC20Upgradeable { /* * Note: the ERC-165 identifier for this interface is 0x4bbee2df. * 0x4bbee2df === * bytes4(keccak256('transferAndCall(address,uint256)')) ^ * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) */ /* * Note: the ERC-165 identifier for this interface is 0xfb9ec8ce. * 0xfb9ec8ce === * bytes4(keccak256('approveAndCall(address,uint256)')) ^ * bytes4(keccak256('approveAndCall(address,uint256,bytes)')) */ /** * @dev Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver * @param to address The address which you want to transfer to * @param value uint256 The amount of tokens to be transferred * @return true unless throwing */ function transferAndCall(address to, uint256 value) external returns (bool); /** * @dev Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver * @param to address The address which you want to transfer to * @param value uint256 The amount of tokens to be transferred * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ function transferAndCall( address to, uint256 value, bytes memory data ) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver * @param from address The address which you want to send tokens from * @param to address The address which you want to transfer to * @param value uint256 The amount of tokens to be transferred * @return true unless throwing */ function transferFromAndCall( address from, address to, uint256 value ) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver * @param from address The address which you want to send tokens from * @param to address The address which you want to transfer to * @param value uint256 The amount of tokens to be transferred * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ function transferFromAndCall( address from, address to, uint256 value, bytes memory data ) external returns (bool); /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender * and then call `onApprovalReceived` on spender. * @param spender address The address which will spend the funds * @param value uint256 The amount of tokens to be spent */ function approveAndCall(address spender, uint256 value) external returns (bool); /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender * and then call `onApprovalReceived` on spender. * @param spender address The address which will spend the funds * @param value uint256 The amount of tokens to be spent * @param data bytes Additional data with no specified format, sent in call to `spender` */ function approveAndCall( address spender, uint256 value, bytes memory data ) external returns (bool); }
/hardhat/console.sol
// SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } }
/contracts/tokens/ERC1363Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/interfaces/IERC1363Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/interfaces/IERC1363ReceiverUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/interfaces/IERC1363SpenderUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; /** * @title ERC1363 * @author Vittorio Minacori (https://github.com/vittominacori) * @dev Implementation of an ERC1363 interface */ abstract contract ERC1363Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, ERC20Upgradeable, IERC1363Upgradeable { using AddressUpgradeable for address; function __ERC1363_init(string memory _name, string memory _symbol) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC20_init_unchained(_name, _symbol); } function __ERC1363_init_unchained(string memory _name, string memory _symbol) internal initializer {} /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC1363Upgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Transfer tokens to a specified address and then execute a callback on recipient. * @param recipient The address to transfer to. * @param amount The amount to be transferred. * @return A boolean that indicates if the operation was successful. */ function transferAndCall(address recipient, uint256 amount) public virtual override returns (bool) { return transferAndCall(recipient, amount, ""); } /** * @dev Transfer tokens to a specified address and then execute a callback on recipient. * @param recipient The address to transfer to * @param amount The amount to be transferred * @param data Additional data with no specified format * @return A boolean that indicates if the operation was successful. */ function transferAndCall( address recipient, uint256 amount, bytes memory data ) public virtual override returns (bool) { transfer(recipient, amount); require(_checkAndCallTransfer(_msgSender(), recipient, amount, data), "ERC1363: _checkAndCallTransfer reverts"); return true; } /** * @dev Transfer tokens from one address to another and then execute a callback on recipient. * @param sender The address which you want to send tokens from * @param recipient The address which you want to transfer to * @param amount The amount of tokens to be transferred * @return A boolean that indicates if the operation was successful. */ function transferFromAndCall( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { return transferFromAndCall(sender, recipient, amount, ""); } /** * @dev Transfer tokens from one address to another and then execute a callback on recipient. * @param sender The address which you want to send tokens from * @param recipient The address which you want to transfer to * @param amount The amount of tokens to be transferred * @param data Additional data with no specified format * @return A boolean that indicates if the operation was successful. */ function transferFromAndCall( address sender, address recipient, uint256 amount, bytes memory data ) public virtual override returns (bool) { transferFrom(sender, recipient, amount); require(_checkAndCallTransfer(sender, recipient, amount, data), "ERC1363: _checkAndCallTransfer reverts"); return true; } /** * @dev Approve spender to transfer tokens and then execute a callback on recipient. * @param spender The address allowed to transfer to * @param amount The amount allowed to be transferred * @return A boolean that indicates if the operation was successful. */ function approveAndCall(address spender, uint256 amount) public virtual override returns (bool) { return approveAndCall(spender, amount, ""); } /** * @dev Approve spender to transfer tokens and then execute a callback on recipient. * @param spender The address allowed to transfer to. * @param amount The amount allowed to be transferred. * @param data Additional daa with no specified format. * @return A boolean that indicates if the operation was successful. */ function approveAndCall( address spender, uint256 amount, bytes memory data ) public virtual override returns (bool) { approve(spender, amount); require(_checkAndCallApprove(spender, amount, data), "ERC1363: _checkAndCallApprove reverts"); return true; } /** * @dev Internal function to invoke `onTransferReceived` on a target address * The call is not executed if the target address is not a contract * @param sender address Representing the previous owner of the given token value * @param recipient address Target address that will receive the tokens * @param amount uint256 The amount mount of tokens to be transferred * @param data bytes Optional data to send along with the call * @return whether the call correctly returned the expected magic value */ function _checkAndCallTransfer( address sender, address recipient, uint256 amount, bytes memory data ) internal virtual returns (bool) { if (!recipient.isContract()) { return false; } bytes4 retval = IERC1363ReceiverUpgradeable(recipient).onTransferReceived(_msgSender(), sender, amount, data); return (retval == IERC1363ReceiverUpgradeable(recipient).onTransferReceived.selector); } /** * @dev Internal function to invoke `onApprovalReceived` on a target address * The call is not executed if the target address is not a contract * @param spender address The address which will spend the funds * @param amount uint256 The amount of tokens to be spent * @param data bytes Optional data to send along with the call * @return whether the call correctly returned the expected magic value */ function _checkAndCallApprove( address spender, uint256 amount, bytes memory data ) internal virtual returns (bool) { if (!spender.isContract()) { return false; } bytes4 retval = IERC1363SpenderUpgradeable(spender).onApprovalReceived(_msgSender(), amount, data); return (retval == IERC1363SpenderUpgradeable(spender).onApprovalReceived.selector); } }
/contracts/staking/StableThenToken.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import {ERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; /// @title A two-phase contract, starting with a stable coin and proceeding to // a alternative token once possible. /// /// @notice Since the first phase of staking will be done in a USD-pegged /// stable-coin, we need a mechanism to later / switch to the TAL token, while /// also converting any initial USD stakes to TAL, given a pre-determined rate abstract contract StableThenToken { using ERC165Checker for address; /// stable coin to use address public immutable stableCoin; /// the token to stake address public token; /// @param _stableCoin The USD-pegged stable-coin contract to use constructor(address _stableCoin) { // USDT does not implement ERC165, so we can't do much more than this require(_stableCoin != address(0), "stable-coin address must be valid"); stableCoin = _stableCoin; } /// Sets the TAL token address /// /// @param _token ERC20 address of the TAL token. Must be a valid ERC20 token with the symbol "TAL"; function setToken(address _token) public stablePhaseOnly { require(_token != address(0x0), "Address must be set"); require(_token.supportsInterface(type(IERC20).interfaceId), "not a valid ERC20 token"); // require(ERC165(_token).supportsInterface(type(IERC20).interfaceId), "not a valid ERC20 token"); ERC20 erc20 = ERC20(_token); require(strcmp(erc20.symbol(), "TAL"), "token name is not TAL"); token = _token; } /// Allows execution only while in stable phase modifier stablePhaseOnly() { require(!_isTokenSet(), "Stable coin disabled"); _; } /// Allows execution only while in token phase modifier tokenPhaseOnly() { require(_isTokenSet(), "TAL token not yet set"); _; } function _isTokenSet() internal view returns (bool) { return token != address(0x0); } /// Checks equality of two strings function strcmp(string memory a, string memory b) private pure returns (bool) { return memcmp(bytes(a), bytes(b)); } /// Checks equality of two byte sequences, both in length and in content function memcmp(bytes memory a, bytes memory b) private pure returns (bool) { return (a.length == b.length) && (keccak256(a) == keccak256(b)); } }
/contracts/staking/RewardCalculator.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "hardhat/console.sol"; interface IRewardParameters { /// Start of the staking period function start() external view returns (uint256); /// End of the staking period function end() external view returns (uint256); // Total amount of shares currently staked function totalShares() external view returns (uint256); /// Maximum amount of rewards to be distributed function rewardsMax() external view returns (uint256); // Total amount of rewards already given function rewardsGiven() external view returns (uint256); // Amount of rewards still left to earn function rewardsLeft() external view returns (uint256); /// Sum of sqrt(tokenAmount) for each stake /// Used to compute adjusted reward values function totalAdjustedShares() external view returns (uint256); } /// @title Mathematical model that calculates staking rewards /// /// @notice Rewards are calculated with a few variables in mind: /// 1. A downward polynomial curve that rewards early stakers more than later ones /// 2. The relative weight of a stake at the beginning of the given period /// 3. The relative weight of a stake at the end of the given period /// 4. The duration of the period /// /// @notice Percentage-based calculation: /// Most calculations in this contract are made in percentages (0% to 100% /// ranges) to decouple the mathematical model from the actual values defined by /// the team. /// /// @notice Multiplier: /// All equations were adjusted to consider a multiplier, in order to work /// with high-enough numbers and avoid loss of precision due to lack of /// floating-point numbers. /// i.e.: instead of `0.1` we consider `0.1 * Multiplier` /// The inverse operation (divide by the multipler) is thus needed at the end, /// to retrieve the originally inteded result /// /// @notice Adjusted weights: /// Weights are adjusted through their square root, to decrease differences between high and low stakes /// e.g.: if two stakes exist, Alice with 1 TAL, and Bob with 2 TAL, adjusted weights are: /// Alice: sqrt(1) / (sqrt(1) + sqrt(2)) ~= 41.42% /// Bob: sqrt(2) / (sqrt(1) + sqrt(2)) ~= 58.57% abstract contract RewardCalculator is IRewardParameters { /// Multiplier used to offset small percentage values to fit within a uint256 /// e.g. 5% is internally represented as (0.05 * mul). The final result /// after calculations is divided by mul again to retrieve a real value uint256 internal constant MUL = 1e10; /// Calculates how many shares should be rewarded to a stake, /// based on how many shares are staked, and a beginning timestamp /// /// This will take into account the current weight of the stake in /// comparison to `totalShares()`, and the duration of the stake /// /// @notice Rewards are split between staker and talent, according to the adjusted weights, /// given for each of them, which should correspond to their own Talent token balance /// /// @param _shares How many shares to be considered /// @param _stakerS S value at last checkpoint made by staker /// @param _currentS current S value /// @param _stakerWeight The non-adjusted weight of the staker when splitting the reward /// @param _talentWeight The non-adjusted weight of the talent when splitting the reward /// @return stakerShare the staker's share of the reward /// @return talentShare the talent's share of the reward function calculateReward( uint256 _shares, uint256 _stakerS, uint256 _currentS, uint256 _stakerWeight, uint256 _talentWeight ) internal pure returns (uint256, uint256) { uint256 total = (sqrt(_shares) * (_currentS - _stakerS)) / MUL; uint256 talentShare = _calculateTalentShare(total, _stakerWeight, _talentWeight); return (total - talentShare, talentShare); } function calculateGlobalReward(uint256 _start, uint256 _end) internal view returns (uint256) { (uint256 start, uint256 end) = _truncatePeriod(_start, _end); (uint256 startPercent, uint256 endPercent) = _periodToPercents(start, end); uint256 percentage = _curvePercentage(startPercent, endPercent); return ((percentage * this.rewardsMax())); } function _calculateTalentShare( uint256 _rewards, uint256 _stakerWeight, uint256 _talentWeight ) internal pure returns (uint256) { uint256 stakeAdjustedWeight = sqrt(_stakerWeight * MUL); uint256 talentAdjustedWeight = sqrt(_talentWeight * MUL); uint256 talentWeight = (talentAdjustedWeight * MUL) / ((stakeAdjustedWeight + talentAdjustedWeight)); uint256 talentRewards = (_rewards * talentWeight) / MUL; uint256 minTalentRewards = _rewards / 100; if (talentRewards < minTalentRewards) { talentRewards = minTalentRewards; } return talentRewards; } /// Truncates a period to fit within the start and end date of the staking period function _truncatePeriod(uint256 _start, uint256 _end) internal view returns (uint256, uint256) { if (_end <= this.start() || _start >= this.end()) { return (this.start(), this.start()); } uint256 periodStart = _start < this.start() ? this.start() : _start; uint256 periodEnd = _end > this.end() ? this.end() : _end; return (periodStart, periodEnd); } /// converts a period to percentages where 0 is the beginning and 100 is /// the end of the staking period function _periodToPercents(uint256 _start, uint256 _end) internal view returns (uint256, uint256) { uint256 totalDuration = this.end() - this.start(); if (totalDuration == 0) { return (0, 1); } uint256 startPercent = ((_start - this.start()) * MUL) / totalDuration; uint256 endPercent = ((_end - this.start()) * MUL) / totalDuration; return (startPercent, endPercent); } function _curvePercentage(uint256 _start, uint256 _end) internal pure returns (uint256) { int256 maxArea = _integralAt(MUL) - _integralAt(0); int256 actualArea = _integralAt(_end) - _integralAt(_start); uint256 ratio = uint256((actualArea * int256(MUL)) / maxArea); return ratio; } // Original equation: (1-x)^2 (ranging from 0 to 1 in both axis) // We actualy need to go from 0 to MUL, to keep outside of floating point territory: // Equation with multiplier: (MUL-x)^2/MUL // // We want the integral equation of that: // Integrate[(MUL-x)^2/MUL] // => Integrate[(MUL-x)^2] / MUL // => (x^3/3 - MUL * x^2 + M^2 * x) / MUL // // This last part, `x^3/3 - MUL * x^2 + M^2 * x`, is what we want to calculate here // The final division by `MUL` is missing, but this is expected to be done // outside, once the final reward calculation is made, since it would // result in too much loss of precision at this stage. function _integralAt(uint256 _x) internal pure returns (int256) { int256 x = int256(_x); int256 m = int256(MUL); return (x**3) / 3 - m * x**2 + m**2 * x; } /// copied from https://github.com/ethereum/dapp-bin/pull/50/files function sqrt(uint256 x) internal pure returns (uint256 y) { if (x == 0) return 0; else if (x <= 3) return 1; uint256 z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
/contracts/TalentToken.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import {IERC165Upgradeable} from "@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol"; import {IERC1363Upgradeable} from "@openzeppelin/contracts-upgradeable/interfaces/IERC1363Upgradeable.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {ERC165Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol"; import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; // import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; import {ERC1363Upgradeable} from "./tokens/ERC1363Upgradeable.sol"; interface ITalentToken is IERC20Upgradeable { // mints new talent tokens function mint(address _owner, uint256 _amount) external; // burns existing talent tokens function burn(address _owner, uint256 _amount) external; // talent's wallet function talent() external view returns (address); // timestamp at which MAX_SUPPLY was reached (or 0 if never reached) function mintingFinishedAt() external view returns (uint256); // how much is available to be minted function mintingAvailability() external view returns (uint256); } /// @title The base contract for Talent Tokens /// /// @notice a standard ERC20 contract, upgraded with ERC1363 functionality, and /// upgradeability and AccessControl functions from OpenZeppelin /// /// @notice Minting: /// A TalentToken has a fixed MAX_SUPPLY, after which no more minting can occur /// Minting & burning is only allowed by a specific role, assigned on initialization /// /// @notice Burning: /// If tokens are burnt before MAX_SUPPLY is ever reached, they are added /// back into the `mintingAvailability` pool / If MAX_SUPPLY has already been /// reached at some point, then future burns can no longer be minted back, /// effectively making the burn permanent contract TalentToken is Initializable, ContextUpgradeable, ERC165Upgradeable, AccessControlUpgradeable, ERC1363Upgradeable, UUPSUpgradeable, ITalentToken { /// Talent role bytes32 public constant ROLE_TALENT = keccak256("TALENT"); /// Minter role bytes32 public constant ROLE_MINTER = keccak256("MINTER"); uint256 public constant MAX_SUPPLY = 1000000 ether; // amount available to be minted uint256 public override(ITalentToken) mintingAvailability; // timestamp at which minting reached MAX_SUPPLY uint256 public override(ITalentToken) mintingFinishedAt; // talent's wallet address public override(ITalentToken) talent; function initialize( string memory _name, string memory _symbol, uint256 _initialSupply, address _talent, address _minter, address _admin ) public initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC20_init_unchained(_name, _symbol); __AccessControl_init_unchained(); talent = _talent; _setupRole(DEFAULT_ADMIN_ROLE, _admin); _setupRole(ROLE_TALENT, _talent); _setupRole(ROLE_MINTER, _minter); _setRoleAdmin(ROLE_TALENT, ROLE_TALENT); _mint(_talent, _initialSupply); mintingAvailability = MAX_SUPPLY - _initialSupply; } function _authorizeUpgrade(address newImplementation) internal override(UUPSUpgradeable) onlyRole(DEFAULT_ADMIN_ROLE) {} /// Mints new supply /// /// @notice Only accessible to the role MINTER /// /// @param _to Recipient of the new tokens /// @param _amount Amount to mint function mint(address _to, uint256 _amount) public override(ITalentToken) onlyRole(ROLE_MINTER) { require(mintingAvailability >= _amount, "_amount exceeds minting availability"); mintingAvailability -= _amount; if (mintingAvailability == 0) { mintingFinishedAt = block.timestamp; } _mint(_to, _amount); } /// Burns existing supply /// /// @notice Only accessible to the role MINTER /// /// @param _from Owner of the tokens to burn /// @param _amount Amount to mint function burn(address _from, uint256 _amount) public override(ITalentToken) onlyRole(ROLE_MINTER) { // if we have already reached MAX_SUPPLY, we don't ever want to allow // minting, even if a burn has occured afterwards if (mintingAvailability > 0) { mintingAvailability += _amount; } _burn(_from, _amount); } /// Changes the talent's wallet /// /// @notice Callable by the talent to chance his own ownership address /// /// @notice onlyRole() is not needed here, since the equivalent check is /// already done by `grantRole`, which only allows the role's admin, which /// is the TALENT role itself, to grant the role. /// /// @param _newTalent address for the new talent's wallet function transferTalentWallet(address _newTalent) public { talent = _newTalent; grantRole(ROLE_TALENT, _newTalent); revokeRole(ROLE_TALENT, msg.sender); } // // Begin: ERC165 // /// @inheritdoc ERC165Upgradeable function supportsInterface(bytes4 interfaceId) public view override(ERC165Upgradeable, AccessControlUpgradeable, ERC1363Upgradeable) returns (bool) { return interfaceId == type(IERC20Upgradeable).interfaceId || interfaceId == type(IERC1363Upgradeable).interfaceId || super.supportsInterface(interfaceId); } // // End: ERC165 // }
/contracts/TalentFactory.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import {ERC165Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol"; import {IAccessControlEnumerableUpgradeable, AccessControlEnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; import {TalentToken} from "./TalentToken.sol"; interface ITalentFactory { /// Returns true is a given address corresponds to a registered Talent Token /// /// @param addr address of the token to find /// @return true if the address corresponds to a talent token function isTalentToken(address addr) external view returns (bool); /// Returns true is a given symbol corresponds to a registered Talent Token /// /// @param symbol Symbol of the token to find /// @return true if the symbol corresponds to an existing talent token function isSymbol(string memory symbol) external view returns (bool); } /// @title Factory in charge of deploying Talent Token contracts /// /// @notice This contract relies on ERC1167 proxies to cheaply deploy talent tokens /// /// @notice Roles: /// A minter role defines who is allowed to deploy talent tokens. Deploying /// a talent token grants you the right to mint that talent token, meaning the /// same deployer will be granted that role /// /// @notice beacon: /// TalentTokens are implemented with BeaconProxies, allowing an update of /// the underlying beacon, to target all existing talent tokens. contract TalentFactory is Initializable, ContextUpgradeable, ERC165Upgradeable, AccessControlEnumerableUpgradeable, ITalentFactory { /// creator role bytes32 public constant ROLE_MINTER = keccak256("MINTER"); /// initial supply of each new token minted uint256 public constant INITIAL_SUPPLY = 2000 ether; /// maps each talent's address to their talent token mapping(address => address) public talentsToTokens; /// maps each talent tokens' address to their talent mapping(address => address) public tokensToTalents; /// maps each token's symbol to the token address mapping(string => address) public symbolsToTokens; /// minter for new tokens address public minter; /// implementation template to clone address public implementationBeacon; event TalentCreated(address indexed talent, address indexed token); function initialize() public virtual initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControlEnumerable_init_unchained(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); UpgradeableBeacon _beacon = new UpgradeableBeacon(address(new TalentToken())); _beacon.transferOwnership(msg.sender); implementationBeacon = address(_beacon); } function setMinter(address _minter) public onlyRole(DEFAULT_ADMIN_ROLE) { require(minter == address(0x0), "minter already set"); minter = _minter; _setupRole(ROLE_MINTER, _minter); } /// Creates a new talent token /// /// @param _talent The talent's address /// @param _name The new token's name /// @param _symbol The new token's symbol function createTalent( address _talent, string memory _name, string memory _symbol ) public returns (address) { require(!isSymbol(_symbol), "talent token with this symbol already exists"); require(_isMinterSet(), "minter not yet set"); BeaconProxy proxy = new BeaconProxy( implementationBeacon, abi.encodeWithSelector( TalentToken(address(0x0)).initialize.selector, _name, _symbol, INITIAL_SUPPLY, _talent, minter, getRoleMember(DEFAULT_ADMIN_ROLE, 0) ) ); // address token = ClonesUpgradeable.clone(implementation); // TalentToken(token).initialize( // _name, // _symbol, // INITIAL_SUPPLY, // _talent, // minter, // getRoleMember(DEFAULT_ADMIN_ROLE, 0) // ); address token = address(proxy); symbolsToTokens[_symbol] = token; tokensToTalents[token] = _talent; emit TalentCreated(_talent, token); return token; } // // Begin: ERC165 // /// @inheritdoc ERC165Upgradeable function supportsInterface(bytes4 interfaceId) public view override(ERC165Upgradeable, AccessControlEnumerableUpgradeable) returns (bool) { return AccessControlEnumerableUpgradeable.supportsInterface(interfaceId); } // // End: ERC165 // // // Begin: ITalentFactory // function isTalentToken(address addr) public view override(ITalentFactory) returns (bool) { return tokensToTalents[addr] != address(0x0); } function isSymbol(string memory _symbol) public view override(ITalentFactory) returns (bool) { return symbolsToTokens[_symbol] != address(0x0); } // // End: ITalentFactory // function _isMinterSet() private view returns (bool) { return minter != address(0x0); } }
/_openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } }
/_openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface 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); }
/_openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT 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 initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
/_openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT 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 initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
/_openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/_openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
/_openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @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); }
/_openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} uint256[45] private __gap; }
/_openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {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. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } }
/_openzeppelin/contracts-upgradeable/interfaces/IERC1363SpenderUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC1363SpenderUpgradeable { /* * Note: the ERC-165 identifier for this interface is 0x7b04a2d0. * 0x7b04a2d0 === bytes4(keccak256("onApprovalReceived(address,uint256,bytes)")) */ /** * @notice Handle the approval of ERC1363 tokens * @dev Any ERC1363 smart contract calls this function on the recipient * after an `approve`. This function MAY throw to revert and reject the * approval. Return of other than the magic value MUST result in the * transaction being reverted. * Note: the token contract address is always the message sender. * @param owner address The address which called `approveAndCall` function * @param value uint256 The amount of tokens to be spent * @param data bytes Additional data with no specified format * @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` * unless throwing */ function onApprovalReceived( address owner, uint256 value, bytes memory data ) external returns (bytes4); }
/_openzeppelin/contracts-upgradeable/interfaces/IERC1363ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC1363ReceiverUpgradeable { /* * Note: the ERC-165 identifier for this interface is 0x88a7ca5c. * 0x88a7ca5c === bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)")) */ /** * @notice Handle the receipt of ERC1363 tokens * @dev Any ERC1363 smart contract calls this function on the recipient * after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the * transfer. Return of other than the magic value MUST result in the * transaction being reverted. * Note: the token contract address is always the message sender. * @param operator address The address which called `transferAndCall` or `transferFromAndCall` function * @param from address The address which are token transferred from * @param value uint256 The amount of tokens transferred * @param data bytes Additional data with no specified format * @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` * unless throwing */ function onTransferReceived( address operator, address from, uint256 value, bytes memory data ) external returns (bytes4); }
/_openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
/_openzeppelin/contracts-upgradeable/access/IAccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
/_openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; }
/_openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable { function __AccessControlEnumerable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); __AccessControlEnumerable_init_unchained(); } function __AccessControlEnumerable_init_unchained() internal initializer { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } uint256[49] private __gap; }
/_openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
/_openzeppelin/contracts/utils/introspection/ERC165Checker.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /** * @dev Returns true if `account` supports the {IERC165} interface, */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return _supportsERC165Interface(account, type(IERC165).interfaceId) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. * * _Available since v3.4._ */ function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in _interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!_supportsERC165Interface(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * Interface identification is specified in ERC-165. */ function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId); (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams); if (result.length < 32) return false; return success && abi.decode(result, (bool)); } }
/_openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
/_openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
/_openzeppelin/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
/_openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
/_openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/_openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
/_openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/_openzeppelin/contracts/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/_openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967Upgrade.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 ERC1967Upgrade { /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, bytes(""), 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 { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(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; }
/_openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IBeacon.sol"; import "../../access/Ownable.sol"; import "../../utils/Address.sol"; /** * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their * implementation contract, which is where they will delegate all function calls. * * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon. */ contract UpgradeableBeacon is IBeacon, Ownable { address private _implementation; /** * @dev Emitted when the implementation returned by the beacon is changed. */ event Upgraded(address indexed implementation); /** * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the * beacon. */ constructor(address implementation_) { _setImplementation(implementation_); } /** * @dev Returns the current implementation address. */ function implementation() public view virtual override returns (address) { return _implementation; } /** * @dev Upgrades the beacon to a new implementation. * * Emits an {Upgraded} event. * * Requirements: * * - msg.sender must be the owner of the contract. * - `newImplementation` must be a contract. */ function upgradeTo(address newImplementation) public virtual onlyOwner { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation contract address for this beacon * * Requirements: * * - `newImplementation` must be a contract. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "UpgradeableBeacon: implementation is not a contract"); _implementation = newImplementation; } }
/_openzeppelin/contracts/proxy/beacon/IBeacon.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @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); }
/_openzeppelin/contracts/proxy/beacon/BeaconProxy.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IBeacon.sol"; import "../Proxy.sol"; import "../ERC1967/ERC1967Upgrade.sol"; /** * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}. * * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't * conflict with the storage layout of the implementation behind the proxy. * * _Available since v3.4._ */ contract BeaconProxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the proxy with `beacon`. * * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity * constructor. * * Requirements: * * - `beacon` must be a contract with the interface {IBeacon}. */ constructor(address beacon, bytes memory data) payable { assert(_BEACON_SLOT == bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1)); _upgradeBeaconToAndCall(beacon, data, false); } /** * @dev Returns the current beacon address. */ function _beacon() internal view virtual returns (address) { return _getBeacon(); } /** * @dev Returns the current implementation address of the associated beacon. */ function _implementation() internal view virtual override returns (address) { return IBeacon(_getBeacon()).implementation(); } /** * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}. * * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. * * Requirements: * * - `beacon` must be a contract. * - The implementation returned by `beacon` must be a contract. */ function _setBeacon(address beacon, bytes memory data) internal virtual { _upgradeBeaconToAndCall(beacon, data, false); } }
/_openzeppelin/contracts/proxy/Proxy.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} }
/_openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.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 ERC1967Upgrade { // 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 Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.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) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @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 Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.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"); StorageSlot.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 Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.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) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
/_openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../Proxy.sol"; import "./ERC1967Upgrade.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _upgradeToAndCall(_logic, _data, false); } /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { return ERC1967Upgrade._getImplementation(); } }
/_openzeppelin/contracts/interfaces/IERC1363Receiver.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC1363Receiver { /* * Note: the ERC-165 identifier for this interface is 0x88a7ca5c. * 0x88a7ca5c === bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)")) */ /** * @notice Handle the receipt of ERC1363 tokens * @dev Any ERC1363 smart contract calls this function on the recipient * after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the * transfer. Return of other than the magic value MUST result in the * transaction being reverted. * Note: the token contract address is always the message sender. * @param operator address The address which called `transferAndCall` or `transferFromAndCall` function * @param from address The address which are token transferred from * @param value uint256 The amount of tokens transferred * @param data bytes Additional data with no specified format * @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` * unless throwing */ function onTransferReceived( address operator, address from, uint256 value, bytes memory data ) external returns (bytes4); }
/_openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
/_openzeppelin/contracts/access/IAccessControl.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
/_openzeppelin/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"uint256","name":"_start","internalType":"uint256"},{"type":"uint256","name":"_end","internalType":"uint256"},{"type":"uint256","name":"_rewardsMax","internalType":"uint256"},{"type":"address","name":"_stableCoin","internalType":"address"},{"type":"address","name":"_factory","internalType":"address"},{"type":"uint256","name":"_tokenPrice","internalType":"uint256"},{"type":"uint256","name":"_talentPrice","internalType":"uint256"}]},{"type":"event","name":"RewardClaim","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"talentToken","internalType":"address","indexed":true},{"type":"uint256","name":"stakerReward","internalType":"uint256","indexed":false},{"type":"uint256","name":"talentReward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardWithdrawal","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"talentToken","internalType":"address","indexed":true},{"type":"uint256","name":"stakerReward","internalType":"uint256","indexed":false},{"type":"uint256","name":"talentReward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Stake","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"talentToken","internalType":"address","indexed":true},{"type":"uint256","name":"talAmount","internalType":"uint256","indexed":false},{"type":"bool","name":"stable","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"TalentRewardWithdrawal","inputs":[{"type":"address","name":"talentToken","internalType":"address","indexed":true},{"type":"address","name":"talentTokenWallet","internalType":"address","indexed":true},{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Unstake","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"talentToken","internalType":"address","indexed":true},{"type":"uint256","name":"talAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"S","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"SAt","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"activeStakes","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"adminWithdraw","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"stakerRewards","internalType":"uint256"},{"type":"uint256","name":"talentRewards","internalType":"uint256"}],"name":"calculateEstimatedReturns","inputs":[{"type":"address","name":"_owner","internalType":"address"},{"type":"address","name":"_talent","internalType":"address"},{"type":"uint256","name":"_currentTime","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"claimRewards","inputs":[{"type":"address","name":"_talent","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"claimRewardsOnBehalf","inputs":[{"type":"address","name":"_owner","internalType":"address"},{"type":"address","name":"_talent","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"convertTalentToToken","inputs":[{"type":"uint256","name":"_talent","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"convertTokenToTalent","inputs":[{"type":"uint256","name":"_tal","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"convertUsdToTalent","inputs":[{"type":"uint256","name":"_usd","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"convertUsdToToken","inputs":[{"type":"uint256","name":"_usd","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"disable","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"disabled","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"end","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"factory","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxSForTalent","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onTransferReceived","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"_sender","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardsGiven","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardsLeft","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardsMax","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setToken","inputs":[{"type":"address","name":"_token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"stableCoin","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stableCoinBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stakeAvailability","inputs":[{"type":"address","name":"_talent","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"stakeStable","inputs":[{"type":"address","name":"_talent","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"tokenAmount","internalType":"uint256"},{"type":"uint256","name":"talentAmount","internalType":"uint256"},{"type":"uint256","name":"lastCheckpointAt","internalType":"uint256"},{"type":"uint256","name":"S","internalType":"uint256"},{"type":"bool","name":"finishedAccumulating","internalType":"bool"}],"name":"stakes","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"start","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"swapStableForToken","inputs":[{"type":"uint256","name":"_stableAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"talentPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"talentRedeemableRewards","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"token","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalAdjustedShares","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalShares","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalStableStored","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalTokensStaked","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"withdrawRewards","inputs":[{"type":"address","name":"_talent","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"withdrawTalentRewards","inputs":[{"type":"address","name":"_talent","internalType":"address"}]}]
Contract Creation Code
0x6101006040523480156200001257600080fd5b506040516200500a3803806200500a833981016040819052620000359162000272565b836001600160a01b0381166200009c5760405162461bcd60e51b815260206004820152602160248201527f737461626c652d636f696e2061646472657373206d7573742062652076616c696044820152601960fa1b60648201526084015b60405180910390fd5b60601b6001600160601b03191660805281620000fb5760405162461bcd60e51b815260206004820152601760248201527f5f746f6b656e50726963652063616e6e6f742062652030000000000000000000604482015260640162000093565b600081116200014d5760405162461bcd60e51b815260206004820152601860248201527f5f74616c656e7450726963652063616e6e6f7420626520300000000000000000604482015260640162000093565b60c087905260e086905260a085905260078054610100600160a81b0319166101006001600160a01b0386160217905560088290556009819055601087905562000198600033620001a5565b50505050505050620002da565b620001b18282620001b5565b5050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16620001b1576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620002113390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b80516001600160a01b03811681146200026d57600080fd5b919050565b600080600080600080600060e0888a0312156200028e57600080fd5b875196506020880151955060408801519450620002ae6060890162000255565b9350620002be6080890162000255565b925060a0880151915060c0880151905092959891949750929550565b60805160601c60a05160c05160e051614cad6200035d600039600081816106fc015281816112230152818161168b0152611e8c015260008181610647015281816111b3015261161b0152600081816106860152611bdd015260008181610532015281816111150152818161184e01528181611a500152611ddd0152614cad6000f3fe608060405234801561001057600080fd5b506004361061030a5760003560e01c8063904846731161019c578063b435842c116100ee578063ed2f236911610097578063efbe1c1c11610071578063efbe1c1c146106f7578063f18d20be1461071e578063fc0c546a1461072657600080fd5b8063ed2f2369146106ce578063ee070805146106d7578063ef5cfb8c146106e457600080fd5b8063d1990538116100c8578063d199053814610681578063d4ce5789146106a8578063d547741f146106bb57600080fd5b8063b435842c1461063a578063be9a655514610642578063c45a01551461066957600080fd5b8063a217fddf11610150578063aa0b01791161012a578063aa0b0179146105f6578063aef2200d1461061e578063b0e31b2d1461063157600080fd5b8063a217fddf14610574578063a4e47b661461057c578063a8bc58f2146105ee57600080fd5b8063977bee8e11610181578063977bee8e1461051a578063992642e51461052d5780639e1a4d191461056c57600080fd5b806390484673146104da57806391d14854146104e357600080fd5b80633dbf35631161026057806371f19f94116102095780637ff9b596116101e35780637ff9b5961461049257806388a7ca5c1461049b5780638ba2855d146104c757600080fd5b806371f19f941461044c5780637773a92b1461045f5780637eefc5251461047f57600080fd5b806343f49d891161023a57806343f49d89146104275780634be1c7961461043a5780636a0675cf1461044357600080fd5b80633dbf3563146103e157806342c0e5ef1461040157806342d866931461041457600080fd5b806325b58c87116102c257806336568abe1161029c57806336568abe146103b35780633a98ef39146103c65780633b039b9e146103ce57600080fd5b806325b58c871461038f5780632f2770db146103985780632f2ff15d146103a057600080fd5b80631ea18fc5116102f35780631ea18fc51461034c57806322b3a6a114610363578063248a9ca31461036c57600080fd5b806301ffc9a71461030f578063144fa6d714610337575b600080fd5b61032261031d366004614722565b610739565b60405190151581526020015b60405180910390f35b61034a610345366004614543565b610789565b005b61035560095481565b60405190815260200161032e565b610355600d5481565b61035561037a3660046146e4565b60009081526020819052604090206001015490565b610355600a5481565b61034a6109fb565b61034a6103ae3660046146fd565b610a72565b61034a6103c13660046146fd565b610a9d565b600b54610355565b6103226103dc366004614543565b610b29565b6103556103ef366004614543565b60056020526000908152604090205481565b61035561040f3660046146e4565b610d3c565b610322610422366004614543565b610d5e565b610355610435366004614543565b610e92565b610355600f5481565b610355600e5481565b61034a61045a3660046146e4565b610f6e565b61035561046d366004614543565b60066020526000908152604090205481565b61035561048d3660046146e4565b61119f565b61035560085481565b6104ae6104a93660046145f7565b6111af565b6040516001600160e01b0319909116815260200161032e565b6103226104d536600461457d565b611541565b61035560105481565b6103226104f13660046146fd565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610322610528366004614696565b611617565b6105547f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161032e565b610355611b51565b610355600081565b6105c461058a36600461457d565b6002602081815260009384526040808520909152918352912080546001820154928201546003830154600490930154919392909160ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161032e565b610355611bd3565b6106096106043660046145b6565b611c10565b6040805192835260208301919091520161032e565b61035561062c3660046146e4565b611db7565b610355600b5481565b610355611dc5565b6103557f000000000000000000000000000000000000000000000000000000000000000081565b6007546105549061010090046001600160a01b031681565b6103557f000000000000000000000000000000000000000000000000000000000000000081565b6103556106b63660046146e4565b611e14565b61034a6106c93660046146fd565b611e37565b61035560035481565b6007546103229060ff1681565b6103226106f2366004614543565b611e5d565b6103557f000000000000000000000000000000000000000000000000000000000000000081565b61034a611e72565b600154610554906001600160a01b031681565b60006001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061078357506301ffc9a760e01b6001600160e01b03198316145b92915050565b6001546001600160a01b0316156107e75760405162461bcd60e51b815260206004820152601460248201527f537461626c6520636f696e2064697361626c656400000000000000000000000060448201526064015b60405180910390fd5b6001600160a01b03811661083d5760405162461bcd60e51b815260206004820152601360248201527f41646472657373206d757374206265207365740000000000000000000000000060448201526064016107de565b6108706001600160a01b0382167f36372b07000000000000000000000000000000000000000000000000000000006120b8565b6108bc5760405162461bcd60e51b815260206004820152601760248201527f6e6f7420612076616c696420455243323020746f6b656e00000000000000000060448201526064016107de565b6000819050610974816001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156108fd57600080fd5b505afa158015610911573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610939919081019061474c565b6040518060400160405280600381526020017f54414c00000000000000000000000000000000000000000000000000000000008152506120d4565b6109c05760405162461bcd60e51b815260206004820152601560248201527f746f6b656e206e616d65206973206e6f742054414c000000000000000000000060448201526064016107de565b50600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6000610a0781336120e0565b60075460ff1615610a5a5760405162461bcd60e51b815260206004820152601060248201527f616c72656164792064697361626c65640000000000000000000000000000000060448201526064016107de565b610a6261215e565b506007805460ff19166001179055565b600082815260208190526040902060010154610a8e81336120e0565b610a9883836121a3565b505050565b6001600160a01b0381163314610b1b5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016107de565b610b258282612241565b5050565b6000610b3f6001546001600160a01b0316151590565b610b8b5760405162461bcd60e51b815260206004820152601560248201527f54414c20746f6b656e206e6f742079657420736574000000000000000000000060448201526064016107de565b816001600160a01b031663c4daa5936040518163ffffffff1660e01b815260040160206040518083038186803b158015610bc457600080fd5b505afa158015610bd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfc9190614560565b6001600160a01b0316336001600160a01b031614610c825760405162461bcd60e51b815260206004820152602d60248201527f6f6e6c79207468652074616c656e742063616e2077697468647261772074686560448201527f6972206f776e207368617265730000000000000000000000000000000000000060648201526084016107de565b6001600160a01b038281166000908152600560205260409081902054600154915163a9059cbb60e01b8152336004820152602481018290529092919091169063a9059cbb90604401602060405180830381600087803b158015610ce457600080fd5b505af1158015610cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1c91906146c2565b5050506001600160a01b0316600090815260056020526040812055600190565b600060095482610d4c9190614967565b61078390670de0b6b3a7640000614b39565b6000610d746001546001600160a01b0316151590565b610dc05760405162461bcd60e51b815260206004820152601560248201527f54414c20746f6b656e206e6f742079657420736574000000000000000000000060448201526064016107de565b6011543390839060ff1615610de457610ddb338560006122c0565b60019250610e8b565b6011805460ff191660011790556001600160a01b038083166000908152600260209081526040808320938516835292905290812054610e2290612d59565b9050610e30338660006122c0565b600193506001600160a01b038084166000908152600260209081526040808320938616835292905220548190610e6590612d59565b600d54610e729190614921565b610e7c9190614b97565b600d55506011805460ff191690555b5050919050565b6000610e9d82612dd0565b610ee95760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b6000826001600160a01b031663aafa93716040518163ffffffff1660e01b815260040160206040518083038186803b158015610f2457600080fd5b505afa158015610f38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5c91906147f9565b9050610f6781611e14565b9392505050565b6000610f7a81336120e0565b6001546001600160a01b0316610fd25760405162461bcd60e51b815260206004820152601560248201527f54414c20746f6b656e206e6f742079657420736574000000000000000000000060448201526064016107de565b600a5482111561104a5760405162461bcd60e51b815260206004820152602b60248201527f6e6f7420656e6f75676820737461626c6520636f696e206c65667420696e207460448201527f686520636f6e747261637400000000000000000000000000000000000000000060648201526084016107de565b60006110558361119f565b905082600a60008282546110699190614b97565b90915550506001546040516323b872dd60e01b8152336004820152306024820152604481018390526001600160a01b03909116906323b872dd90606401602060405180830381600087803b1580156110c057600080fd5b505af11580156110d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f891906146c2565b5060405163a9059cbb60e01b8152336004820152602481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb90604401602060405180830381600087803b15801561116157600080fd5b505af1158015611175573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119991906146c2565b50505050565b600060085482610d4c9190614967565b60007f00000000000000000000000000000000000000000000000000000000000000004210156112215760405162461bcd60e51b815260206004820152601e60248201527f7374616b696e6720706572696f64206e6f74207965742073746172746564000060448201526064016107de565b7f00000000000000000000000000000000000000000000000000000000000000004211156112915760405162461bcd60e51b815260206004820152601f60248201527f7374616b696e6720706572696f6420616c72656164792066696e69736865640060448201526064016107de565b6001546001600160a01b03163314156113b75760075460ff16156112f75760405162461bcd60e51b815260206004820152601960248201527f7374616b696e6720686173206265656e2064697361626c65640000000000000060448201526064016107de565b600061133884848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612e6c92505050565b9050611345868287612ec7565b60408051868152600060208201526001600160a01b0380841692908916917f929ad80cfbf532d1e879107de0553ee80942d13c8043f2b2615f9b15b87d10da910160405180910390a37f88a7ca5c75456956db1e96e88ee87aca8bdad85895835c2dc76fcc96396569cf915050611538565b6113c033612dd0565b156114ca576001546001600160a01b03166114435760405162461bcd60e51b815260206004820152602a60248201527f54414c20746f6b656e206e6f7420796574207365742e20526566756e64206e6f60448201527f7420706f737369626c650000000000000000000000000000000000000000000060648201526084016107de565b336000611451878388613083565b9050816001600160a01b0316876001600160a01b03167f390b1276974b9463e5d66ab10df69b6f3d7b930eb066a0e66df327edd2cc811c8360405161149891815260200190565b60405180910390a37f88a7ca5c75456956db1e96e88ee87aca8bdad85895835c2dc76fcc96396569cf92505050611538565b60405162461bcd60e51b815260206004820152602360248201527f556e7265636f676e697a6564204552433133363320746f6b656e20726563656960448201527f766564000000000000000000000000000000000000000000000000000000000060648201526084016107de565b95945050505050565b6011546000908390839060ff16156115685761155f858560016122c0565b6001925061160f565b6011805460ff191660011790556001600160a01b0380831660009081526002602090815260408083209385168352929052908120546115a690612d59565b90506115b4868660016122c0565b600193506001600160a01b0380841660009081526002602090815260408083209386168352929052205481906115e990612d59565b600d546115f69190614921565b6116009190614b97565b600d55506011805460ff191690555b505092915050565b60007f00000000000000000000000000000000000000000000000000000000000000004210156116895760405162461bcd60e51b815260206004820152601e60248201527f7374616b696e6720706572696f64206e6f74207965742073746172746564000060448201526064016107de565b7f00000000000000000000000000000000000000000000000000000000000000004211156116f95760405162461bcd60e51b815260206004820152601f60248201527f7374616b696e6720706572696f6420616c72656164792066696e69736865640060448201526064016107de565b6001546001600160a01b0316156117525760405162461bcd60e51b815260206004820152601460248201527f537461626c6520636f696e2064697361626c656400000000000000000000000060448201526064016107de565b6011543390849060ff161561192357600084116117a95760405162461bcd60e51b8152602060048201526015602482015274616d6f756e742063616e6e6f74206265207a65726f60581b60448201526064016107de565b60075460ff16156117fc5760405162461bcd60e51b815260206004820152601960248201527f7374616b696e6720686173206265656e2064697361626c65640000000000000060448201526064016107de565b60006118078561119f565b905084600a600082825461181b9190614921565b9091555061182c9050338783612ec7565b6040516323b872dd60e01b8152336004820152306024820152604481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906323b872dd90606401602060405180830381600087803b15801561189a57600080fd5b505af11580156118ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d291906146c2565b5060408051828152600160208201526001600160a01b0388169133917f929ad80cfbf532d1e879107de0553ee80942d13c8043f2b2615f9b15b87d10da910160405180910390a3600193505061160f565b6011805460ff191660011790556001600160a01b03808316600090815260026020908152604080832093851683529290529081205461196190612d59565b9050600085116119ab5760405162461bcd60e51b8152602060048201526015602482015274616d6f756e742063616e6e6f74206265207a65726f60581b60448201526064016107de565b60075460ff16156119fe5760405162461bcd60e51b815260206004820152601960248201527f7374616b696e6720686173206265656e2064697361626c65640000000000000060448201526064016107de565b6000611a098661119f565b905085600a6000828254611a1d9190614921565b90915550611a2e9050338883612ec7565b6040516323b872dd60e01b8152336004820152306024820152604481018790527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906323b872dd90606401602060405180830381600087803b158015611a9c57600080fd5b505af1158015611ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad491906146c2565b5060408051828152600160208201526001600160a01b0389169133917f929ad80cfbf532d1e879107de0553ee80942d13c8043f2b2615f9b15b87d10da910160405180910390a360019450506001600160a01b0380841660009081526002602090815260408083209386168352929052205481906115e990612d59565b6001546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a08231906024015b60206040518083038186803b158015611b9657600080fd5b505afa158015611baa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bce91906147f9565b905090565b6000600c54600e547f0000000000000000000000000000000000000000000000000000000000000000611c069190614b97565b611bce9190614b97565b6001600160a01b038084166000908152600260209081526040808320938616835292815282822060069091529181205490918291829015611c6a57506001600160a01b038516600090815260066020526040902054611c93565b600d54611c7960105487613693565b611c839190614967565b600f54611c909190614921565b90505b6000866001600160a01b031663c4daa5936040518163ffffffff1660e01b815260040160206040518083038186803b158015611cce57600080fd5b505afa158015611ce2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d069190614560565b6040516370a0823160e01b81526001600160a01b0380831660048301529192506000918916906370a082319060240160206040518083038186803b158015611d4d57600080fd5b505afa158015611d61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8591906147f9565b9050600080611da3866000015487600301548789600101548761374c565b90985096505050505050505b935093915050565b600061078361040f8361119f565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401611b7e565b6000670de0b6b3a764000060095483611e2d9190614b39565b6107839190614967565b600082815260208190526040902060010154611e5381336120e0565b610a988383612241565b6000611e693383611541565b50600192915050565b6000611e7e81336120e0565b60075460ff1680611eae57507f000000000000000000000000000000000000000000000000000000000000000042105b611f205760405162461bcd60e51b815260206004820152602b60248201527f6e6f742064697361626c65642c20616e64206e6f7420656e64206f662073746160448201527f6b696e672065697468657200000000000000000000000000000000000000000060648201526084016107de565b60035415611fbc5760405162461bcd60e51b815260206004820152605060248201527f746865726520617265207374696c6c207374616b657320616363756d756c617460448201527f696e6720726577617264732e2043616c6c2060636c61696d526577617264734f60648201527f6e426568616c6660206f6e207468656d00000000000000000000000000000000608482015260a4016107de565b6000611fc6611bd3565b9050600081116120185760405162461bcd60e51b815260206004820152601860248201527f6e6f7468696e67206c65667420746f207769746864726177000000000000000060448201526064016107de565b60015460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b15801561206457600080fd5b505af1158015612078573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061209c91906146c2565b5080600c60008282546120af9190614921565b90915550505050565b60006120c3836137a6565b8015610f675750610f6783836137d9565b6000610f6783836138d7565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610b255761211c816001600160a01b031660146138fc565b6121278360206138fc565b60405160200161213892919061482e565b60408051601f198184030181529082905262461bcd60e51b82526107de916004016148af565b60075460ff161561216b57565b600b5461217457565b600d5461218360105442613693565b61218d9190614967565b600f5461219a9190614921565b600f5542601055565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610b25576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556121fd3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1615610b25576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6011548390839060ff1615612800576001600160a01b0380861660009081526002602090815260408083209388168352929052206122fc61215e565b6000856001600160a01b031663c4daa5936040518163ffffffff1660e01b815260040160206040518083038186803b15801561233757600080fd5b505afa15801561234b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236f9190614560565b6001600160a01b0387166000908152600660205260408120549192509061239857600f546123b2565b6001600160a01b0387166000908152600660205260409020545b8354600385015460018601546040516370a0823160e01b81526001600160a01b038781166004830152949550600094859461244f949093909288928f16906370a08231906024015b60206040518083038186803b15801561241257600080fd5b505afa158015612426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061244a91906147f9565b61374c565b909250905061245e8183614921565b600e600082825461246f9190614921565b9091555050600385018390554260028601556001600160a01b038916600090815260056020526040812080548392906124a9908490614921565b909155505060075460ff1680156124c55750600485015460ff16155b156124f45760048501805460ff19166001908117909155600380546000906124ee908490614b97565b90915550505b81612503575050505050612d52565b600088600181111561251757612517614c1d565b14156125ff5760015460405163a9059cbb60e01b81526001600160a01b038c81166004830152602482018590529091169063a9059cbb90604401602060405180830381600087803b15801561256b57600080fd5b505af115801561257f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a391906146c2565b50886001600160a01b03168a6001600160a01b03167f013ceff621e16e2f96e454db0b811d5e35d3be38beab8a6bf4be6a3dc8cd23f384846040516125f2929190918252602082015260400190565b60405180910390a36127f6565b600188600181111561261357612613614c1d565b14156127ae5760006126248a610e92565b905060008382116126355781612637565b835b905060006126458286614b97565b90506126528d8d84613add565b8b6001600160a01b03168d6001600160a01b03167f661cda9d247039eabdcc72b8fed0de4ce46c907660a504c7e40889080fbd559084876040516126a0929190918252602082015260400190565b60405180910390a36000811180156126c257506001546001600160a01b031615155b156127a65760015460405163a9059cbb60e01b81526001600160a01b038f81166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b15801561271557600080fd5b505af1158015612729573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061274d91906146c2565b508b6001600160a01b03168d6001600160a01b03167f013ceff621e16e2f96e454db0b811d5e35d3be38beab8a6bf4be6a3dc8cd23f383600060405161279d929190918252602082015260400190565b60405180910390a35b5050506127f6565b60405162461bcd60e51b815260206004820152601e60248201527f556e7265636f676e697a656420636865636b706f696e7420616374696f6e000060448201526064016107de565b5050505050612d52565b6011805460ff191660011790556001600160a01b03808316600090815260026020908152604080832093851683529290529081205461283e90612d59565b6001600160a01b038088166000908152600260209081526040808320938a1683529290522090915061286e61215e565b6000866001600160a01b031663c4daa5936040518163ffffffff1660e01b815260040160206040518083038186803b1580156128a957600080fd5b505afa1580156128bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e19190614560565b6001600160a01b0388166000908152600660205260408120549192509061290a57600f54612924565b6001600160a01b0388166000908152600660205260409020545b9050600080612977856000015486600301548588600101548e6001600160a01b03166370a082318a6040518263ffffffff1660e01b81526004016123fa91906001600160a01b0391909116815260200190565b90925090506129868183614921565b600e60008282546129979190614921565b9091555050600385018390554260028601556001600160a01b038a16600090815260056020526040812080548392906129d1908490614921565b909155505060075460ff1680156129ed5750600485015460ff16155b15612a1c5760048501805460ff1916600190811790915560038054600090612a16908490614b97565b90915550505b81612a2b575050505050612cfb565b6000896001811115612a3f57612a3f614c1d565b1415612b275760015460405163a9059cbb60e01b81526001600160a01b038d81166004830152602482018590529091169063a9059cbb90604401602060405180830381600087803b158015612a9357600080fd5b505af1158015612aa7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612acb91906146c2565b50896001600160a01b03168b6001600160a01b03167f013ceff621e16e2f96e454db0b811d5e35d3be38beab8a6bf4be6a3dc8cd23f38484604051612b1a929190918252602082015260400190565b60405180910390a3612cf5565b6001896001811115612b3b57612b3b614c1d565b14156127ae576000612b4c8b610e92565b90506000838211612b5d5781612b5f565b835b90506000612b6d8286614b97565b9050612b7a8e8e84613add565b8c6001600160a01b03168e6001600160a01b03167f661cda9d247039eabdcc72b8fed0de4ce46c907660a504c7e40889080fbd55908487604051612bc8929190918252602082015260400190565b60405180910390a3600081118015612bea57506001546001600160a01b031615155b15612cf157600160009054906101000a90046001600160a01b03166001600160a01b031663a9059cbb8f836040518363ffffffff1660e01b8152600401612c469291906001600160a01b03929092168252602082015260400190565b602060405180830381600087803b158015612c6057600080fd5b505af1158015612c74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9891906146c2565b508c6001600160a01b03168e6001600160a01b03167f013ceff621e16e2f96e454db0b811d5e35d3be38beab8a6bf4be6a3dc8cd23f3836000604051612ce8929190918252602082015260400190565b60405180910390a35b5050505b50505050505b6001600160a01b038084166000908152600260209081526040808320938616835292905220548190612d2c90612d59565b600d54612d399190614921565b612d439190614b97565b600d55506011805460ff191690555b5050505050565b600081612d6857506000919050565b60038211612d7857506001919050565b60006002612d87846001614921565b612d919190614967565b90508291505b81811015612dca57905080600281612daf8186614967565b612db99190614921565b612dc39190614967565b9050612d97565b50919050565b6007546040517f099aba560000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301526000926101009004169063099aba569060240160206040518083038186803b158015612e3457600080fd5b505afa158015612e48573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078391906146c2565b60008151601414612ebf5760405162461bcd60e51b815260206004820152601f60248201527f696e76616c69642064617461206c656e67746820666f7220616464726573730060448201526064016107de565b506014015190565b6011548390839060ff1615612f8f57612edf84612dd0565b612f2b5760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b60008311612f735760405162461bcd60e51b8152602060048201526015602482015274616d6f756e742063616e6e6f74206265207a65726f60581b60448201526064016107de565b612f7f858560016122c0565b612f8a858585613add565b612d52565b6011805460ff191660011790556001600160a01b038083166000908152600260209081526040808320938516835292905290812054612fcd90612d59565b9050612fd885612dd0565b6130245760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b6000841161306c5760405162461bcd60e51b8152602060048201526015602482015274616d6f756e742063616e6e6f74206265207a65726f60581b60448201526064016107de565b613078868660016122c0565b612cfb868686613add565b6011546000908490849060ff16156133475761309e85612dd0565b6130ea5760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b6130f6868660016122c0565b6001600160a01b038087166000908152600260208181526040808420948a1684529390529190209081015461316d5760405162461bcd60e51b815260206004820152601460248201527f7374616b6520646f6573206e6f7420657869737400000000000000000000000060448201526064016107de565b848160010154101561317e57600080fd5b60018101546000906131956402540be40088614b39565b61319f9190614967565b905060006402540be4008284600001546131b99190614b39565b6131c39190614967565b6001546040516370a0823160e01b815230600482015291925082916001600160a01b03909116906370a082319060240160206040518083038186803b15801561320b57600080fd5b505afa15801561321f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061324391906147f9565b101561329b5760405162461bcd60e51b815260206004820152602160248201527f6e6f7420656e6f7567682054414c20746f2066756c66696c6c207265717565736044820152601d60fa1b60648201526084016107de565b868360010160008282546132af9190614b97565b90915550508254819084906000906132c8908490614b97565b9250508190555080600b60008282546132e19190614b97565b909155505082541580156132fa5750600483015460ff16155b156133295760048301805460ff1916600190811790915560038054600090613323908490614b97565b90915550505b6133338888613b89565b61333d8982613c06565b945061368a915050565b6011805460ff191660011790556001600160a01b03808316600090815260026020908152604080832093851683529290529081205461338590612d59565b905061339086612dd0565b6133dc5760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b6133e8878760016122c0565b6001600160a01b038088166000908152600260208181526040808420948b1684529390529190209081015461345f5760405162461bcd60e51b815260206004820152601460248201527f7374616b6520646f6573206e6f7420657869737400000000000000000000000060448201526064016107de565b858160010154101561347057600080fd5b60018101546000906134876402540be40089614b39565b6134919190614967565b905060006402540be4008284600001546134ab9190614b39565b6134b59190614967565b6001546040516370a0823160e01b815230600482015291925082916001600160a01b03909116906370a082319060240160206040518083038186803b1580156134fd57600080fd5b505afa158015613511573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061353591906147f9565b101561358d5760405162461bcd60e51b815260206004820152602160248201527f6e6f7420656e6f7567682054414c20746f2066756c66696c6c207265717565736044820152601d60fa1b60648201526084016107de565b878360010160008282546135a19190614b97565b90915550508254819084906000906135ba908490614b97565b9250508190555080600b60008282546135d39190614b97565b909155505082541580156135ec5750600483015460ff16155b1561361b5760048301805460ff1916600190811790915560038054600090613615908490614b97565b90915550505b6136258989613b89565b61362f8a82613c06565b955050506001600160a01b03808416600090815260026020908152604080832093861683529290522054819061366490612d59565b600d546136719190614921565b61367b9190614b97565b600d55506011805460ff191690555b50509392505050565b60008060006136a28585613c8c565b915091506000806136b3848461405f565b9150915060006136c383836142a5565b9050306001600160a01b031663d19905386040518163ffffffff1660e01b815260040160206040518083038186803b1580156136fe57600080fd5b505afa158015613712573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061373691906147f9565b6137409082614b39565b98975050505050505050565b600080806402540be4006137608888614b97565b6137698a612d59565b6137739190614b39565b61377d9190614967565b9050600061378c828787614308565b90506137988183614b97565b999098509650505050505050565b60006137b9826301ffc9a760e01b6137d9565b801561078357506137d2826001600160e01b03196137d9565b1592915050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166301ffc9a760e01b179052905160009190829081906001600160a01b0387169061753090613855908690614812565b6000604051808303818686fa925050503d8060008114613891576040519150601f19603f3d011682016040523d82523d6000602084013e613896565b606091505b50915091506020815110156138b15760009350505050610783565b8180156138cd5750808060200190518101906138cd91906146c2565b9695505050505050565b600081518351148015610f675750508051602091820120825192909101919091201490565b6060600061390b836002614b39565b613916906002614921565b67ffffffffffffffff81111561392e5761392e614c49565b6040519080825280601f01601f191660200182016040528015613958576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061398f5761398f614c33565b60200101906001600160f81b031916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106139da576139da614c33565b60200101906001600160f81b031916908160001a90535060006139fe846002614b39565b613a09906001614921565b90505b6001811115613a8e577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613a4a57613a4a614c33565b1a60f81b828281518110613a6057613a60614c33565b60200101906001600160f81b031916908160001a90535060049490941c93613a8781614bda565b9050613a0c565b508315610f675760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107de565b6000613ae882610d3c565b6001600160a01b038086166000908152600260209081526040808320938816835292905220805491925090613b3057600160036000828254613b2a9190614921565b90915550505b82816000016000828254613b449190614921565b9250508190555081816001016000828254613b5f9190614921565b9250508190555082600b6000828254613b789190614921565b90915550612d5290508585846143a6565b6040517f9dc29fac000000000000000000000000000000000000000000000000000000008152306004820152602481018290526001600160a01b03831690639dc29fac90604401600060405180830381600087803b158015613bea57600080fd5b505af1158015613bfe573d6000803e3d6000fd5b505050505050565b60015460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b158015613c5457600080fd5b505af1158015613c68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9891906146c2565b600080306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613cc857600080fd5b505afa158015613cdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d0091906147f9565b83111580613d7e5750306001600160a01b031663efbe1c1c6040518163ffffffff1660e01b815260040160206040518083038186803b158015613d4257600080fd5b505afa158015613d56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d7a91906147f9565b8410155b15613e6e57306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613dbc57600080fd5b505afa158015613dd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613df491906147f9565b306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613e2d57600080fd5b505afa158015613e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e6591906147f9565b91509150614058565b6000306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613ea957600080fd5b505afa158015613ebd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ee191906147f9565b8510613eed5784613f5e565b306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613f2657600080fd5b505afa158015613f3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f5e91906147f9565b90506000306001600160a01b031663efbe1c1c6040518163ffffffff1660e01b815260040160206040518083038186803b158015613f9b57600080fd5b505afa158015613faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fd391906147f9565b8511613fdf5784614050565b306001600160a01b031663efbe1c1c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561401857600080fd5b505afa15801561402c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061405091906147f9565b919350909150505b9250929050565b6000806000306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b15801561409d57600080fd5b505afa1580156140b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140d591906147f9565b306001600160a01b031663efbe1c1c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561410e57600080fd5b505afa158015614122573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061414691906147f9565b6141509190614b97565b90508061416557600060019250925050614058565b6000816402540be400306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b1580156141a757600080fd5b505afa1580156141bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141df91906147f9565b6141e99089614b97565b6141f39190614b39565b6141fd9190614967565b90506000826402540be400306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b15801561424157600080fd5b505afa158015614255573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061427991906147f9565b6142839089614b97565b61428d9190614b39565b6142979190614967565b919791965090945050505050565b6000806142b260006144dd565b6142c06402540be4006144dd565b6142ca9190614b58565b905060006142d7856144dd565b6142e0856144dd565b6142ea9190614b58565b90506000826142fe6402540be40084614ab2565b6138cd9190614939565b60008061432261431d6402540be40086614b39565b612d59565b9050600061433861431d6402540be40086614b39565b905060006143468284614921565b6143556402540be40084614b39565b61435f9190614967565b905060006402540be400614373838a614b39565b61437d9190614967565b9050600061438c60648a614967565b90508082101561439a578091505b50979650505050505050565b6040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152602482018390528316906340c10f1990604401600060405180830381600087803b15801561440957600080fd5b505af115801561441d573d6000803e3d6000fd5b505050506001600160a01b0382166000908152600660205260409020541580156144b757506000826001600160a01b0316633e0075a16040518163ffffffff1660e01b815260040160206040518083038186803b15801561447d57600080fd5b505afa158015614491573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144b591906147f9565b115b15610a9857600f546001600160a01b038316600090815260066020526040902055505050565b6000816402540be400816144f2600283614aa3565b6144fc9190614ab2565b614507600284614aa3565b6145119083614ab2565b600361451d8186614aa3565b6145279190614939565b6145319190614b58565b61453b91906148e2565b949350505050565b60006020828403121561455557600080fd5b8135610f6781614c5f565b60006020828403121561457257600080fd5b8151610f6781614c5f565b6000806040838503121561459057600080fd5b823561459b81614c5f565b915060208301356145ab81614c5f565b809150509250929050565b6000806000606084860312156145cb57600080fd5b83356145d681614c5f565b925060208401356145e681614c5f565b929592945050506040919091013590565b60008060008060006080868803121561460f57600080fd5b853561461a81614c5f565b9450602086013561462a81614c5f565b935060408601359250606086013567ffffffffffffffff8082111561464e57600080fd5b818801915088601f83011261466257600080fd5b81358181111561467157600080fd5b89602082850101111561468357600080fd5b9699959850939650602001949392505050565b600080604083850312156146a957600080fd5b82356146b481614c5f565b946020939093013593505050565b6000602082840312156146d457600080fd5b81518015158114610f6757600080fd5b6000602082840312156146f657600080fd5b5035919050565b6000806040838503121561471057600080fd5b8235915060208301356145ab81614c5f565b60006020828403121561473457600080fd5b81356001600160e01b031981168114610f6757600080fd5b60006020828403121561475e57600080fd5b815167ffffffffffffffff8082111561477657600080fd5b818401915084601f83011261478a57600080fd5b81518181111561479c5761479c614c49565b604051601f8201601f19908116603f011681019083821181831017156147c4576147c4614c49565b816040528281528760208487010111156147dd57600080fd5b6147ee836020830160208801614bae565b979650505050505050565b60006020828403121561480b57600080fd5b5051919050565b60008251614824818460208701614bae565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351614866816017850160208801614bae565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516148a3816028840160208801614bae565b01602801949350505050565b60208152600082518060208401526148ce816040850160208701614bae565b601f01601f19169190910160400192915050565b6000808212826001600160ff1b030384138115161561490357614903614bf1565b82600160ff1b03841281161561491b5761491b614bf1565b50500190565b6000821982111561493457614934614bf1565b500190565b60008261494857614948614c07565b600160ff1b82146000198414161561496257614962614bf1565b500590565b60008261497657614976614c07565b500490565b80825b600180861161498d5750611daf565b816001600160ff1b03048211156149a6576149a6614bf1565b808616156149b357918102915b9490941c93800261497e565b60008280156149d557600181146149df576149e8565b6001915050610783565b82915050610783565b50816149f657506000610783565b50600160008213808214614a0f578015614a2d57614a46565b826001600160ff1b0304831115614a2857614a28614bf1565b614a46565b826001600160ff1b0305831215614a4657614a46614bf1565b5080831615614a525750805b614a628360011c8384028361497b565b806001600160ff1b03048211600083131615614a8057614a80614bf1565b80600160ff1b058212600083121615614a9b57614a9b614bf1565b029392505050565b6000610f6760ff8416836149bf565b60006001600160ff1b03600084136000841385830485118282161615614ada57614ada614bf1565b600160ff1b6000871286820588128184161615614af957614af9614bf1565b60008712925087820587128484161615614b1557614b15614bf1565b87850587128184161615614b2b57614b2b614bf1565b505050929093029392505050565b6000816000190483118215151615614b5357614b53614bf1565b500290565b600080831283600160ff1b01831281151615614b7657614b76614bf1565b836001600160ff1b03018313811615614b9157614b91614bf1565b50500390565b600082821015614ba957614ba9614bf1565b500390565b60005b83811015614bc9578181015183820152602001614bb1565b838111156111995750506000910152565b600081614be957614be9614bf1565b506000190190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114614c7457600080fd5b5056fea264697066735822122002015437701f48972f2156ddcd7690e0a243d574897c2267a3b7cd027f73295764736f6c6343000807003300000000000000000000000000000000000000000000000000000000617178b100000000000000000000000000000000000000000000000000000000acaeb1590000000000000000000000000000000000000000014adf4b7320334b90000000000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a000000000000000000000000a902da7a40a671b84ba3dd0bdba6fd9d2d88824600000000000000000000000000000000000000000000000000470de4df8200000000000000000000000000000000000000000000000000004563918244f40000
Deployed ByteCode
0x608060405234801561001057600080fd5b506004361061030a5760003560e01c8063904846731161019c578063b435842c116100ee578063ed2f236911610097578063efbe1c1c11610071578063efbe1c1c146106f7578063f18d20be1461071e578063fc0c546a1461072657600080fd5b8063ed2f2369146106ce578063ee070805146106d7578063ef5cfb8c146106e457600080fd5b8063d1990538116100c8578063d199053814610681578063d4ce5789146106a8578063d547741f146106bb57600080fd5b8063b435842c1461063a578063be9a655514610642578063c45a01551461066957600080fd5b8063a217fddf11610150578063aa0b01791161012a578063aa0b0179146105f6578063aef2200d1461061e578063b0e31b2d1461063157600080fd5b8063a217fddf14610574578063a4e47b661461057c578063a8bc58f2146105ee57600080fd5b8063977bee8e11610181578063977bee8e1461051a578063992642e51461052d5780639e1a4d191461056c57600080fd5b806390484673146104da57806391d14854146104e357600080fd5b80633dbf35631161026057806371f19f94116102095780637ff9b596116101e35780637ff9b5961461049257806388a7ca5c1461049b5780638ba2855d146104c757600080fd5b806371f19f941461044c5780637773a92b1461045f5780637eefc5251461047f57600080fd5b806343f49d891161023a57806343f49d89146104275780634be1c7961461043a5780636a0675cf1461044357600080fd5b80633dbf3563146103e157806342c0e5ef1461040157806342d866931461041457600080fd5b806325b58c87116102c257806336568abe1161029c57806336568abe146103b35780633a98ef39146103c65780633b039b9e146103ce57600080fd5b806325b58c871461038f5780632f2770db146103985780632f2ff15d146103a057600080fd5b80631ea18fc5116102f35780631ea18fc51461034c57806322b3a6a114610363578063248a9ca31461036c57600080fd5b806301ffc9a71461030f578063144fa6d714610337575b600080fd5b61032261031d366004614722565b610739565b60405190151581526020015b60405180910390f35b61034a610345366004614543565b610789565b005b61035560095481565b60405190815260200161032e565b610355600d5481565b61035561037a3660046146e4565b60009081526020819052604090206001015490565b610355600a5481565b61034a6109fb565b61034a6103ae3660046146fd565b610a72565b61034a6103c13660046146fd565b610a9d565b600b54610355565b6103226103dc366004614543565b610b29565b6103556103ef366004614543565b60056020526000908152604090205481565b61035561040f3660046146e4565b610d3c565b610322610422366004614543565b610d5e565b610355610435366004614543565b610e92565b610355600f5481565b610355600e5481565b61034a61045a3660046146e4565b610f6e565b61035561046d366004614543565b60066020526000908152604090205481565b61035561048d3660046146e4565b61119f565b61035560085481565b6104ae6104a93660046145f7565b6111af565b6040516001600160e01b0319909116815260200161032e565b6103226104d536600461457d565b611541565b61035560105481565b6103226104f13660046146fd565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610322610528366004614696565b611617565b6105547f000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a81565b6040516001600160a01b03909116815260200161032e565b610355611b51565b610355600081565b6105c461058a36600461457d565b6002602081815260009384526040808520909152918352912080546001820154928201546003830154600490930154919392909160ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161032e565b610355611bd3565b6106096106043660046145b6565b611c10565b6040805192835260208301919091520161032e565b61035561062c3660046146e4565b611db7565b610355600b5481565b610355611dc5565b6103557f00000000000000000000000000000000000000000000000000000000617178b181565b6007546105549061010090046001600160a01b031681565b6103557f0000000000000000000000000000000000000000014adf4b7320334b9000000081565b6103556106b63660046146e4565b611e14565b61034a6106c93660046146fd565b611e37565b61035560035481565b6007546103229060ff1681565b6103226106f2366004614543565b611e5d565b6103557f00000000000000000000000000000000000000000000000000000000acaeb15981565b61034a611e72565b600154610554906001600160a01b031681565b60006001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061078357506301ffc9a760e01b6001600160e01b03198316145b92915050565b6001546001600160a01b0316156107e75760405162461bcd60e51b815260206004820152601460248201527f537461626c6520636f696e2064697361626c656400000000000000000000000060448201526064015b60405180910390fd5b6001600160a01b03811661083d5760405162461bcd60e51b815260206004820152601360248201527f41646472657373206d757374206265207365740000000000000000000000000060448201526064016107de565b6108706001600160a01b0382167f36372b07000000000000000000000000000000000000000000000000000000006120b8565b6108bc5760405162461bcd60e51b815260206004820152601760248201527f6e6f7420612076616c696420455243323020746f6b656e00000000000000000060448201526064016107de565b6000819050610974816001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156108fd57600080fd5b505afa158015610911573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610939919081019061474c565b6040518060400160405280600381526020017f54414c00000000000000000000000000000000000000000000000000000000008152506120d4565b6109c05760405162461bcd60e51b815260206004820152601560248201527f746f6b656e206e616d65206973206e6f742054414c000000000000000000000060448201526064016107de565b50600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6000610a0781336120e0565b60075460ff1615610a5a5760405162461bcd60e51b815260206004820152601060248201527f616c72656164792064697361626c65640000000000000000000000000000000060448201526064016107de565b610a6261215e565b506007805460ff19166001179055565b600082815260208190526040902060010154610a8e81336120e0565b610a9883836121a3565b505050565b6001600160a01b0381163314610b1b5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016107de565b610b258282612241565b5050565b6000610b3f6001546001600160a01b0316151590565b610b8b5760405162461bcd60e51b815260206004820152601560248201527f54414c20746f6b656e206e6f742079657420736574000000000000000000000060448201526064016107de565b816001600160a01b031663c4daa5936040518163ffffffff1660e01b815260040160206040518083038186803b158015610bc457600080fd5b505afa158015610bd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfc9190614560565b6001600160a01b0316336001600160a01b031614610c825760405162461bcd60e51b815260206004820152602d60248201527f6f6e6c79207468652074616c656e742063616e2077697468647261772074686560448201527f6972206f776e207368617265730000000000000000000000000000000000000060648201526084016107de565b6001600160a01b038281166000908152600560205260409081902054600154915163a9059cbb60e01b8152336004820152602481018290529092919091169063a9059cbb90604401602060405180830381600087803b158015610ce457600080fd5b505af1158015610cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1c91906146c2565b5050506001600160a01b0316600090815260056020526040812055600190565b600060095482610d4c9190614967565b61078390670de0b6b3a7640000614b39565b6000610d746001546001600160a01b0316151590565b610dc05760405162461bcd60e51b815260206004820152601560248201527f54414c20746f6b656e206e6f742079657420736574000000000000000000000060448201526064016107de565b6011543390839060ff1615610de457610ddb338560006122c0565b60019250610e8b565b6011805460ff191660011790556001600160a01b038083166000908152600260209081526040808320938516835292905290812054610e2290612d59565b9050610e30338660006122c0565b600193506001600160a01b038084166000908152600260209081526040808320938616835292905220548190610e6590612d59565b600d54610e729190614921565b610e7c9190614b97565b600d55506011805460ff191690555b5050919050565b6000610e9d82612dd0565b610ee95760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b6000826001600160a01b031663aafa93716040518163ffffffff1660e01b815260040160206040518083038186803b158015610f2457600080fd5b505afa158015610f38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5c91906147f9565b9050610f6781611e14565b9392505050565b6000610f7a81336120e0565b6001546001600160a01b0316610fd25760405162461bcd60e51b815260206004820152601560248201527f54414c20746f6b656e206e6f742079657420736574000000000000000000000060448201526064016107de565b600a5482111561104a5760405162461bcd60e51b815260206004820152602b60248201527f6e6f7420656e6f75676820737461626c6520636f696e206c65667420696e207460448201527f686520636f6e747261637400000000000000000000000000000000000000000060648201526084016107de565b60006110558361119f565b905082600a60008282546110699190614b97565b90915550506001546040516323b872dd60e01b8152336004820152306024820152604481018390526001600160a01b03909116906323b872dd90606401602060405180830381600087803b1580156110c057600080fd5b505af11580156110d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f891906146c2565b5060405163a9059cbb60e01b8152336004820152602481018490527f000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a6001600160a01b03169063a9059cbb90604401602060405180830381600087803b15801561116157600080fd5b505af1158015611175573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119991906146c2565b50505050565b600060085482610d4c9190614967565b60007f00000000000000000000000000000000000000000000000000000000617178b14210156112215760405162461bcd60e51b815260206004820152601e60248201527f7374616b696e6720706572696f64206e6f74207965742073746172746564000060448201526064016107de565b7f00000000000000000000000000000000000000000000000000000000acaeb1594211156112915760405162461bcd60e51b815260206004820152601f60248201527f7374616b696e6720706572696f6420616c72656164792066696e69736865640060448201526064016107de565b6001546001600160a01b03163314156113b75760075460ff16156112f75760405162461bcd60e51b815260206004820152601960248201527f7374616b696e6720686173206265656e2064697361626c65640000000000000060448201526064016107de565b600061133884848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612e6c92505050565b9050611345868287612ec7565b60408051868152600060208201526001600160a01b0380841692908916917f929ad80cfbf532d1e879107de0553ee80942d13c8043f2b2615f9b15b87d10da910160405180910390a37f88a7ca5c75456956db1e96e88ee87aca8bdad85895835c2dc76fcc96396569cf915050611538565b6113c033612dd0565b156114ca576001546001600160a01b03166114435760405162461bcd60e51b815260206004820152602a60248201527f54414c20746f6b656e206e6f7420796574207365742e20526566756e64206e6f60448201527f7420706f737369626c650000000000000000000000000000000000000000000060648201526084016107de565b336000611451878388613083565b9050816001600160a01b0316876001600160a01b03167f390b1276974b9463e5d66ab10df69b6f3d7b930eb066a0e66df327edd2cc811c8360405161149891815260200190565b60405180910390a37f88a7ca5c75456956db1e96e88ee87aca8bdad85895835c2dc76fcc96396569cf92505050611538565b60405162461bcd60e51b815260206004820152602360248201527f556e7265636f676e697a6564204552433133363320746f6b656e20726563656960448201527f766564000000000000000000000000000000000000000000000000000000000060648201526084016107de565b95945050505050565b6011546000908390839060ff16156115685761155f858560016122c0565b6001925061160f565b6011805460ff191660011790556001600160a01b0380831660009081526002602090815260408083209385168352929052908120546115a690612d59565b90506115b4868660016122c0565b600193506001600160a01b0380841660009081526002602090815260408083209386168352929052205481906115e990612d59565b600d546115f69190614921565b6116009190614b97565b600d55506011805460ff191690555b505092915050565b60007f00000000000000000000000000000000000000000000000000000000617178b14210156116895760405162461bcd60e51b815260206004820152601e60248201527f7374616b696e6720706572696f64206e6f74207965742073746172746564000060448201526064016107de565b7f00000000000000000000000000000000000000000000000000000000acaeb1594211156116f95760405162461bcd60e51b815260206004820152601f60248201527f7374616b696e6720706572696f6420616c72656164792066696e69736865640060448201526064016107de565b6001546001600160a01b0316156117525760405162461bcd60e51b815260206004820152601460248201527f537461626c6520636f696e2064697361626c656400000000000000000000000060448201526064016107de565b6011543390849060ff161561192357600084116117a95760405162461bcd60e51b8152602060048201526015602482015274616d6f756e742063616e6e6f74206265207a65726f60581b60448201526064016107de565b60075460ff16156117fc5760405162461bcd60e51b815260206004820152601960248201527f7374616b696e6720686173206265656e2064697361626c65640000000000000060448201526064016107de565b60006118078561119f565b905084600a600082825461181b9190614921565b9091555061182c9050338783612ec7565b6040516323b872dd60e01b8152336004820152306024820152604481018690527f000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a6001600160a01b0316906323b872dd90606401602060405180830381600087803b15801561189a57600080fd5b505af11580156118ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d291906146c2565b5060408051828152600160208201526001600160a01b0388169133917f929ad80cfbf532d1e879107de0553ee80942d13c8043f2b2615f9b15b87d10da910160405180910390a3600193505061160f565b6011805460ff191660011790556001600160a01b03808316600090815260026020908152604080832093851683529290529081205461196190612d59565b9050600085116119ab5760405162461bcd60e51b8152602060048201526015602482015274616d6f756e742063616e6e6f74206265207a65726f60581b60448201526064016107de565b60075460ff16156119fe5760405162461bcd60e51b815260206004820152601960248201527f7374616b696e6720686173206265656e2064697361626c65640000000000000060448201526064016107de565b6000611a098661119f565b905085600a6000828254611a1d9190614921565b90915550611a2e9050338883612ec7565b6040516323b872dd60e01b8152336004820152306024820152604481018790527f000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a6001600160a01b0316906323b872dd90606401602060405180830381600087803b158015611a9c57600080fd5b505af1158015611ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad491906146c2565b5060408051828152600160208201526001600160a01b0389169133917f929ad80cfbf532d1e879107de0553ee80942d13c8043f2b2615f9b15b87d10da910160405180910390a360019450506001600160a01b0380841660009081526002602090815260408083209386168352929052205481906115e990612d59565b6001546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a08231906024015b60206040518083038186803b158015611b9657600080fd5b505afa158015611baa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bce91906147f9565b905090565b6000600c54600e547f0000000000000000000000000000000000000000014adf4b7320334b90000000611c069190614b97565b611bce9190614b97565b6001600160a01b038084166000908152600260209081526040808320938616835292815282822060069091529181205490918291829015611c6a57506001600160a01b038516600090815260066020526040902054611c93565b600d54611c7960105487613693565b611c839190614967565b600f54611c909190614921565b90505b6000866001600160a01b031663c4daa5936040518163ffffffff1660e01b815260040160206040518083038186803b158015611cce57600080fd5b505afa158015611ce2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d069190614560565b6040516370a0823160e01b81526001600160a01b0380831660048301529192506000918916906370a082319060240160206040518083038186803b158015611d4d57600080fd5b505afa158015611d61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8591906147f9565b9050600080611da3866000015487600301548789600101548761374c565b90985096505050505050505b935093915050565b600061078361040f8361119f565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a6001600160a01b0316906370a0823190602401611b7e565b6000670de0b6b3a764000060095483611e2d9190614b39565b6107839190614967565b600082815260208190526040902060010154611e5381336120e0565b610a988383612241565b6000611e693383611541565b50600192915050565b6000611e7e81336120e0565b60075460ff1680611eae57507f00000000000000000000000000000000000000000000000000000000acaeb15942105b611f205760405162461bcd60e51b815260206004820152602b60248201527f6e6f742064697361626c65642c20616e64206e6f7420656e64206f662073746160448201527f6b696e672065697468657200000000000000000000000000000000000000000060648201526084016107de565b60035415611fbc5760405162461bcd60e51b815260206004820152605060248201527f746865726520617265207374696c6c207374616b657320616363756d756c617460448201527f696e6720726577617264732e2043616c6c2060636c61696d526577617264734f60648201527f6e426568616c6660206f6e207468656d00000000000000000000000000000000608482015260a4016107de565b6000611fc6611bd3565b9050600081116120185760405162461bcd60e51b815260206004820152601860248201527f6e6f7468696e67206c65667420746f207769746864726177000000000000000060448201526064016107de565b60015460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b15801561206457600080fd5b505af1158015612078573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061209c91906146c2565b5080600c60008282546120af9190614921565b90915550505050565b60006120c3836137a6565b8015610f675750610f6783836137d9565b6000610f6783836138d7565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610b255761211c816001600160a01b031660146138fc565b6121278360206138fc565b60405160200161213892919061482e565b60408051601f198184030181529082905262461bcd60e51b82526107de916004016148af565b60075460ff161561216b57565b600b5461217457565b600d5461218360105442613693565b61218d9190614967565b600f5461219a9190614921565b600f5542601055565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610b25576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556121fd3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1615610b25576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6011548390839060ff1615612800576001600160a01b0380861660009081526002602090815260408083209388168352929052206122fc61215e565b6000856001600160a01b031663c4daa5936040518163ffffffff1660e01b815260040160206040518083038186803b15801561233757600080fd5b505afa15801561234b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236f9190614560565b6001600160a01b0387166000908152600660205260408120549192509061239857600f546123b2565b6001600160a01b0387166000908152600660205260409020545b8354600385015460018601546040516370a0823160e01b81526001600160a01b038781166004830152949550600094859461244f949093909288928f16906370a08231906024015b60206040518083038186803b15801561241257600080fd5b505afa158015612426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061244a91906147f9565b61374c565b909250905061245e8183614921565b600e600082825461246f9190614921565b9091555050600385018390554260028601556001600160a01b038916600090815260056020526040812080548392906124a9908490614921565b909155505060075460ff1680156124c55750600485015460ff16155b156124f45760048501805460ff19166001908117909155600380546000906124ee908490614b97565b90915550505b81612503575050505050612d52565b600088600181111561251757612517614c1d565b14156125ff5760015460405163a9059cbb60e01b81526001600160a01b038c81166004830152602482018590529091169063a9059cbb90604401602060405180830381600087803b15801561256b57600080fd5b505af115801561257f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a391906146c2565b50886001600160a01b03168a6001600160a01b03167f013ceff621e16e2f96e454db0b811d5e35d3be38beab8a6bf4be6a3dc8cd23f384846040516125f2929190918252602082015260400190565b60405180910390a36127f6565b600188600181111561261357612613614c1d565b14156127ae5760006126248a610e92565b905060008382116126355781612637565b835b905060006126458286614b97565b90506126528d8d84613add565b8b6001600160a01b03168d6001600160a01b03167f661cda9d247039eabdcc72b8fed0de4ce46c907660a504c7e40889080fbd559084876040516126a0929190918252602082015260400190565b60405180910390a36000811180156126c257506001546001600160a01b031615155b156127a65760015460405163a9059cbb60e01b81526001600160a01b038f81166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b15801561271557600080fd5b505af1158015612729573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061274d91906146c2565b508b6001600160a01b03168d6001600160a01b03167f013ceff621e16e2f96e454db0b811d5e35d3be38beab8a6bf4be6a3dc8cd23f383600060405161279d929190918252602082015260400190565b60405180910390a35b5050506127f6565b60405162461bcd60e51b815260206004820152601e60248201527f556e7265636f676e697a656420636865636b706f696e7420616374696f6e000060448201526064016107de565b5050505050612d52565b6011805460ff191660011790556001600160a01b03808316600090815260026020908152604080832093851683529290529081205461283e90612d59565b6001600160a01b038088166000908152600260209081526040808320938a1683529290522090915061286e61215e565b6000866001600160a01b031663c4daa5936040518163ffffffff1660e01b815260040160206040518083038186803b1580156128a957600080fd5b505afa1580156128bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e19190614560565b6001600160a01b0388166000908152600660205260408120549192509061290a57600f54612924565b6001600160a01b0388166000908152600660205260409020545b9050600080612977856000015486600301548588600101548e6001600160a01b03166370a082318a6040518263ffffffff1660e01b81526004016123fa91906001600160a01b0391909116815260200190565b90925090506129868183614921565b600e60008282546129979190614921565b9091555050600385018390554260028601556001600160a01b038a16600090815260056020526040812080548392906129d1908490614921565b909155505060075460ff1680156129ed5750600485015460ff16155b15612a1c5760048501805460ff1916600190811790915560038054600090612a16908490614b97565b90915550505b81612a2b575050505050612cfb565b6000896001811115612a3f57612a3f614c1d565b1415612b275760015460405163a9059cbb60e01b81526001600160a01b038d81166004830152602482018590529091169063a9059cbb90604401602060405180830381600087803b158015612a9357600080fd5b505af1158015612aa7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612acb91906146c2565b50896001600160a01b03168b6001600160a01b03167f013ceff621e16e2f96e454db0b811d5e35d3be38beab8a6bf4be6a3dc8cd23f38484604051612b1a929190918252602082015260400190565b60405180910390a3612cf5565b6001896001811115612b3b57612b3b614c1d565b14156127ae576000612b4c8b610e92565b90506000838211612b5d5781612b5f565b835b90506000612b6d8286614b97565b9050612b7a8e8e84613add565b8c6001600160a01b03168e6001600160a01b03167f661cda9d247039eabdcc72b8fed0de4ce46c907660a504c7e40889080fbd55908487604051612bc8929190918252602082015260400190565b60405180910390a3600081118015612bea57506001546001600160a01b031615155b15612cf157600160009054906101000a90046001600160a01b03166001600160a01b031663a9059cbb8f836040518363ffffffff1660e01b8152600401612c469291906001600160a01b03929092168252602082015260400190565b602060405180830381600087803b158015612c6057600080fd5b505af1158015612c74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9891906146c2565b508c6001600160a01b03168e6001600160a01b03167f013ceff621e16e2f96e454db0b811d5e35d3be38beab8a6bf4be6a3dc8cd23f3836000604051612ce8929190918252602082015260400190565b60405180910390a35b5050505b50505050505b6001600160a01b038084166000908152600260209081526040808320938616835292905220548190612d2c90612d59565b600d54612d399190614921565b612d439190614b97565b600d55506011805460ff191690555b5050505050565b600081612d6857506000919050565b60038211612d7857506001919050565b60006002612d87846001614921565b612d919190614967565b90508291505b81811015612dca57905080600281612daf8186614967565b612db99190614921565b612dc39190614967565b9050612d97565b50919050565b6007546040517f099aba560000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301526000926101009004169063099aba569060240160206040518083038186803b158015612e3457600080fd5b505afa158015612e48573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078391906146c2565b60008151601414612ebf5760405162461bcd60e51b815260206004820152601f60248201527f696e76616c69642064617461206c656e67746820666f7220616464726573730060448201526064016107de565b506014015190565b6011548390839060ff1615612f8f57612edf84612dd0565b612f2b5760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b60008311612f735760405162461bcd60e51b8152602060048201526015602482015274616d6f756e742063616e6e6f74206265207a65726f60581b60448201526064016107de565b612f7f858560016122c0565b612f8a858585613add565b612d52565b6011805460ff191660011790556001600160a01b038083166000908152600260209081526040808320938516835292905290812054612fcd90612d59565b9050612fd885612dd0565b6130245760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b6000841161306c5760405162461bcd60e51b8152602060048201526015602482015274616d6f756e742063616e6e6f74206265207a65726f60581b60448201526064016107de565b613078868660016122c0565b612cfb868686613add565b6011546000908490849060ff16156133475761309e85612dd0565b6130ea5760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b6130f6868660016122c0565b6001600160a01b038087166000908152600260208181526040808420948a1684529390529190209081015461316d5760405162461bcd60e51b815260206004820152601460248201527f7374616b6520646f6573206e6f7420657869737400000000000000000000000060448201526064016107de565b848160010154101561317e57600080fd5b60018101546000906131956402540be40088614b39565b61319f9190614967565b905060006402540be4008284600001546131b99190614b39565b6131c39190614967565b6001546040516370a0823160e01b815230600482015291925082916001600160a01b03909116906370a082319060240160206040518083038186803b15801561320b57600080fd5b505afa15801561321f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061324391906147f9565b101561329b5760405162461bcd60e51b815260206004820152602160248201527f6e6f7420656e6f7567682054414c20746f2066756c66696c6c207265717565736044820152601d60fa1b60648201526084016107de565b868360010160008282546132af9190614b97565b90915550508254819084906000906132c8908490614b97565b9250508190555080600b60008282546132e19190614b97565b909155505082541580156132fa5750600483015460ff16155b156133295760048301805460ff1916600190811790915560038054600090613323908490614b97565b90915550505b6133338888613b89565b61333d8982613c06565b945061368a915050565b6011805460ff191660011790556001600160a01b03808316600090815260026020908152604080832093851683529290529081205461338590612d59565b905061339086612dd0565b6133dc5760405162461bcd60e51b815260206004820152601860248201527f6e6f7420612076616c69642074616c656e7420746f6b656e000000000000000060448201526064016107de565b6133e8878760016122c0565b6001600160a01b038088166000908152600260208181526040808420948b1684529390529190209081015461345f5760405162461bcd60e51b815260206004820152601460248201527f7374616b6520646f6573206e6f7420657869737400000000000000000000000060448201526064016107de565b858160010154101561347057600080fd5b60018101546000906134876402540be40089614b39565b6134919190614967565b905060006402540be4008284600001546134ab9190614b39565b6134b59190614967565b6001546040516370a0823160e01b815230600482015291925082916001600160a01b03909116906370a082319060240160206040518083038186803b1580156134fd57600080fd5b505afa158015613511573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061353591906147f9565b101561358d5760405162461bcd60e51b815260206004820152602160248201527f6e6f7420656e6f7567682054414c20746f2066756c66696c6c207265717565736044820152601d60fa1b60648201526084016107de565b878360010160008282546135a19190614b97565b90915550508254819084906000906135ba908490614b97565b9250508190555080600b60008282546135d39190614b97565b909155505082541580156135ec5750600483015460ff16155b1561361b5760048301805460ff1916600190811790915560038054600090613615908490614b97565b90915550505b6136258989613b89565b61362f8a82613c06565b955050506001600160a01b03808416600090815260026020908152604080832093861683529290522054819061366490612d59565b600d546136719190614921565b61367b9190614b97565b600d55506011805460ff191690555b50509392505050565b60008060006136a28585613c8c565b915091506000806136b3848461405f565b9150915060006136c383836142a5565b9050306001600160a01b031663d19905386040518163ffffffff1660e01b815260040160206040518083038186803b1580156136fe57600080fd5b505afa158015613712573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061373691906147f9565b6137409082614b39565b98975050505050505050565b600080806402540be4006137608888614b97565b6137698a612d59565b6137739190614b39565b61377d9190614967565b9050600061378c828787614308565b90506137988183614b97565b999098509650505050505050565b60006137b9826301ffc9a760e01b6137d9565b801561078357506137d2826001600160e01b03196137d9565b1592915050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166301ffc9a760e01b179052905160009190829081906001600160a01b0387169061753090613855908690614812565b6000604051808303818686fa925050503d8060008114613891576040519150601f19603f3d011682016040523d82523d6000602084013e613896565b606091505b50915091506020815110156138b15760009350505050610783565b8180156138cd5750808060200190518101906138cd91906146c2565b9695505050505050565b600081518351148015610f675750508051602091820120825192909101919091201490565b6060600061390b836002614b39565b613916906002614921565b67ffffffffffffffff81111561392e5761392e614c49565b6040519080825280601f01601f191660200182016040528015613958576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061398f5761398f614c33565b60200101906001600160f81b031916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106139da576139da614c33565b60200101906001600160f81b031916908160001a90535060006139fe846002614b39565b613a09906001614921565b90505b6001811115613a8e577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613a4a57613a4a614c33565b1a60f81b828281518110613a6057613a60614c33565b60200101906001600160f81b031916908160001a90535060049490941c93613a8781614bda565b9050613a0c565b508315610f675760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107de565b6000613ae882610d3c565b6001600160a01b038086166000908152600260209081526040808320938816835292905220805491925090613b3057600160036000828254613b2a9190614921565b90915550505b82816000016000828254613b449190614921565b9250508190555081816001016000828254613b5f9190614921565b9250508190555082600b6000828254613b789190614921565b90915550612d5290508585846143a6565b6040517f9dc29fac000000000000000000000000000000000000000000000000000000008152306004820152602481018290526001600160a01b03831690639dc29fac90604401600060405180830381600087803b158015613bea57600080fd5b505af1158015613bfe573d6000803e3d6000fd5b505050505050565b60015460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b158015613c5457600080fd5b505af1158015613c68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9891906146c2565b600080306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613cc857600080fd5b505afa158015613cdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d0091906147f9565b83111580613d7e5750306001600160a01b031663efbe1c1c6040518163ffffffff1660e01b815260040160206040518083038186803b158015613d4257600080fd5b505afa158015613d56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d7a91906147f9565b8410155b15613e6e57306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613dbc57600080fd5b505afa158015613dd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613df491906147f9565b306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613e2d57600080fd5b505afa158015613e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e6591906147f9565b91509150614058565b6000306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613ea957600080fd5b505afa158015613ebd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ee191906147f9565b8510613eed5784613f5e565b306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b158015613f2657600080fd5b505afa158015613f3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f5e91906147f9565b90506000306001600160a01b031663efbe1c1c6040518163ffffffff1660e01b815260040160206040518083038186803b158015613f9b57600080fd5b505afa158015613faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fd391906147f9565b8511613fdf5784614050565b306001600160a01b031663efbe1c1c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561401857600080fd5b505afa15801561402c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061405091906147f9565b919350909150505b9250929050565b6000806000306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b15801561409d57600080fd5b505afa1580156140b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140d591906147f9565b306001600160a01b031663efbe1c1c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561410e57600080fd5b505afa158015614122573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061414691906147f9565b6141509190614b97565b90508061416557600060019250925050614058565b6000816402540be400306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b1580156141a757600080fd5b505afa1580156141bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141df91906147f9565b6141e99089614b97565b6141f39190614b39565b6141fd9190614967565b90506000826402540be400306001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b15801561424157600080fd5b505afa158015614255573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061427991906147f9565b6142839089614b97565b61428d9190614b39565b6142979190614967565b919791965090945050505050565b6000806142b260006144dd565b6142c06402540be4006144dd565b6142ca9190614b58565b905060006142d7856144dd565b6142e0856144dd565b6142ea9190614b58565b90506000826142fe6402540be40084614ab2565b6138cd9190614939565b60008061432261431d6402540be40086614b39565b612d59565b9050600061433861431d6402540be40086614b39565b905060006143468284614921565b6143556402540be40084614b39565b61435f9190614967565b905060006402540be400614373838a614b39565b61437d9190614967565b9050600061438c60648a614967565b90508082101561439a578091505b50979650505050505050565b6040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152602482018390528316906340c10f1990604401600060405180830381600087803b15801561440957600080fd5b505af115801561441d573d6000803e3d6000fd5b505050506001600160a01b0382166000908152600660205260409020541580156144b757506000826001600160a01b0316633e0075a16040518163ffffffff1660e01b815260040160206040518083038186803b15801561447d57600080fd5b505afa158015614491573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144b591906147f9565b115b15610a9857600f546001600160a01b038316600090815260066020526040902055505050565b6000816402540be400816144f2600283614aa3565b6144fc9190614ab2565b614507600284614aa3565b6145119083614ab2565b600361451d8186614aa3565b6145279190614939565b6145319190614b58565b61453b91906148e2565b949350505050565b60006020828403121561455557600080fd5b8135610f6781614c5f565b60006020828403121561457257600080fd5b8151610f6781614c5f565b6000806040838503121561459057600080fd5b823561459b81614c5f565b915060208301356145ab81614c5f565b809150509250929050565b6000806000606084860312156145cb57600080fd5b83356145d681614c5f565b925060208401356145e681614c5f565b929592945050506040919091013590565b60008060008060006080868803121561460f57600080fd5b853561461a81614c5f565b9450602086013561462a81614c5f565b935060408601359250606086013567ffffffffffffffff8082111561464e57600080fd5b818801915088601f83011261466257600080fd5b81358181111561467157600080fd5b89602082850101111561468357600080fd5b9699959850939650602001949392505050565b600080604083850312156146a957600080fd5b82356146b481614c5f565b946020939093013593505050565b6000602082840312156146d457600080fd5b81518015158114610f6757600080fd5b6000602082840312156146f657600080fd5b5035919050565b6000806040838503121561471057600080fd5b8235915060208301356145ab81614c5f565b60006020828403121561473457600080fd5b81356001600160e01b031981168114610f6757600080fd5b60006020828403121561475e57600080fd5b815167ffffffffffffffff8082111561477657600080fd5b818401915084601f83011261478a57600080fd5b81518181111561479c5761479c614c49565b604051601f8201601f19908116603f011681019083821181831017156147c4576147c4614c49565b816040528281528760208487010111156147dd57600080fd5b6147ee836020830160208801614bae565b979650505050505050565b60006020828403121561480b57600080fd5b5051919050565b60008251614824818460208701614bae565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351614866816017850160208801614bae565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516148a3816028840160208801614bae565b01602801949350505050565b60208152600082518060208401526148ce816040850160208701614bae565b601f01601f19169190910160400192915050565b6000808212826001600160ff1b030384138115161561490357614903614bf1565b82600160ff1b03841281161561491b5761491b614bf1565b50500190565b6000821982111561493457614934614bf1565b500190565b60008261494857614948614c07565b600160ff1b82146000198414161561496257614962614bf1565b500590565b60008261497657614976614c07565b500490565b80825b600180861161498d5750611daf565b816001600160ff1b03048211156149a6576149a6614bf1565b808616156149b357918102915b9490941c93800261497e565b60008280156149d557600181146149df576149e8565b6001915050610783565b82915050610783565b50816149f657506000610783565b50600160008213808214614a0f578015614a2d57614a46565b826001600160ff1b0304831115614a2857614a28614bf1565b614a46565b826001600160ff1b0305831215614a4657614a46614bf1565b5080831615614a525750805b614a628360011c8384028361497b565b806001600160ff1b03048211600083131615614a8057614a80614bf1565b80600160ff1b058212600083121615614a9b57614a9b614bf1565b029392505050565b6000610f6760ff8416836149bf565b60006001600160ff1b03600084136000841385830485118282161615614ada57614ada614bf1565b600160ff1b6000871286820588128184161615614af957614af9614bf1565b60008712925087820587128484161615614b1557614b15614bf1565b87850587128184161615614b2b57614b2b614bf1565b505050929093029392505050565b6000816000190483118215151615614b5357614b53614bf1565b500290565b600080831283600160ff1b01831281151615614b7657614b76614bf1565b836001600160ff1b03018313811615614b9157614b91614bf1565b50500390565b600082821015614ba957614ba9614bf1565b500390565b60005b83811015614bc9578181015183820152602001614bb1565b838111156111995750506000910152565b600081614be957614be9614bf1565b506000190190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114614c7457600080fd5b5056fea264697066735822122002015437701f48972f2156ddcd7690e0a243d574897c2267a3b7cd027f73295764736f6c63430008070033